def package_exists(package_name: str) -> bool: return package_name in build_apt_package_list()
def parse_args(argv):
parser = argparse.ArgumentParser(
description="Install Chromium build dependencies.")
parser.add_argument("--syms",
action="store_true",
help="Enable installation of debugging symbols")
parser.add_argument( "--no-syms",
action="store_false",
dest="syms",
help="Disable installation of debugging symbols",
)
parser.add_argument( "--lib32",
action="store_true",
help="Enable installation of 32-bit libraries, e.g. for V8 snapshot",
)
parser.add_argument( "--android",
action="store_true", # Deprecated flag retained as functional for backward compatibility: # Enable installation of android dependencies
help=argparse.SUPPRESS)
parser.add_argument( "--no-android",
action="store_false",
dest="android", # Deprecated flag retained as functional for backward compatibility: # Enable installation of android dependencies
help=argparse.SUPPRESS)
parser.add_argument("--arm",
action="store_true",
help="Enable installation of arm cross toolchain")
parser.add_argument( "--no-arm",
action="store_false",
dest="arm",
help="Disable installation of arm cross toolchain",
)
parser.add_argument( "--chromeos-fonts",
action="store_true",
help="Enable installation of Chrome OS fonts",
)
parser.add_argument( "--no-chromeos-fonts",
action="store_false",
dest="chromeos_fonts",
help="Disable installation of Chrome OS fonts",
)
parser.add_argument( "--nacl",
action="store_true",
help="Enable installation of prerequisites for building NaCl",
)
parser.add_argument( "--no-nacl",
action="store_false",
dest="nacl",
help="Disable installation of prerequisites for building NaCl",
)
parser.add_argument( "--backwards-compatible",
action="store_true",
help= "Enable installation of packages that are no longer currently needed and"
+ "have been removed from this script. Useful for bisection.",
)
parser.add_argument( "--no-backwards-compatible",
action="store_false",
dest="backwards_compatible",
help= "Disable installation of packages that are no longer currently needed and"
+ "have been removed from this script.",
)
parser.add_argument("--no-prompt",
action="store_true",
help="Automatic yes to prompts")
parser.add_argument( "--quick-check",
action="store_true",
help="Quickly try to determine if dependencies are installed",
)
parser.add_argument( "--unsupported",
action="store_true",
help="Attempt installation even on unsupported systems",
)
options = parser.parse_args(argv)
if options.arm or options.android:
options.lib32 = True
return options
def check_lsb_release(): ifnot shutil.which("lsb_release"):
print("ERROR: lsb_release not found in $PATH", file=sys.stderr)
print("try: sudo apt-get install lsb-release", file=sys.stderr)
sys.exit(1)
if (distro_codename() notin supported_codenames and distro_id notin supported_ids):
print( "WARNING: The following distributions are supported,", "but distributions not in the list below can also try to install", "dependencies by passing the `--unsupported` parameter.", "EoS refers to end of standard support and does not include", "extended security support.", "\tUbuntu 20.04 LTS (focal with EoS April 2025)", "\tUbuntu 22.04 LTS (jammy with EoS June 2027)", "\tUbuntu 24.04 LTS (noble with EoS June 2029)", "\tDebian 11 (bullseye) or later",
sep="\n",
file=sys.stderr,
)
sys.exit(1)
def check_architecture():
architecture = subprocess.check_output(["uname", "-m"]).decode().strip() if architecture notin ["i686", "x86_64", 'aarch64']:
print("Only x86 and ARM64 architectures are currently supported",
file=sys.stderr)
sys.exit(1)
def check_root(): if os.geteuid() != 0:
print("Running as non-root user.", file=sys.stderr)
print("You might have to enter your password one or more times for 'sudo'.",
file=sys.stderr)
print(file=sys.stderr)
def apt_update(options): if options.lib32 or options.nacl:
subprocess.check_call(["sudo", "dpkg", "--add-architecture", "i386"])
subprocess.check_call(["sudo", "apt-get", "update"])
if package_exists("libav-tools"):
packages.append("libav-tools")
if package_exists("libvulkan-dev"):
packages.append("libvulkan-dev")
if package_exists("libinput-dev"):
packages.append("libinput-dev")
# So accessibility APIs work, needed for AX fuzzer if package_exists("at-spi2-core"):
packages.append("at-spi2-core")
# Cross-toolchain strip is needed for building the sysroots. if package_exists("binutils-arm-linux-gnueabihf"):
packages.append("binutils-arm-linux-gnueabihf") if package_exists("binutils-aarch64-linux-gnu"):
packages.append("binutils-aarch64-linux-gnu") if package_exists("binutils-mipsel-linux-gnu"):
packages.append("binutils-mipsel-linux-gnu") if package_exists("binutils-mips64el-linux-gnuabi64"):
packages.append("binutils-mips64el-linux-gnuabi64")
# 64-bit systems need a minimum set of 32-bit compat packages for the # pre-built NaCl binaries. if"ELF 64-bit"in subprocess.check_output(["file", "-L", "/sbin/init"]).decode(): # ARM64 may not support these. if package_exists("libc6-i386"):
packages.append("libc6-i386") if package_exists("lib32stdc++6"):
packages.append("lib32stdc++6")
# lib32gcc-s1 used to be called lib32gcc1 in older distros. if package_exists("lib32gcc-s1"):
packages.append("lib32gcc-s1") elif package_exists("lib32gcc1"):
packages.append("lib32gcc1")
# Run-time libraries required by chromeos only
packages += [ "libpulse0", "libbz2-1.0",
]
# May not exist (e.g. ARM64) if package_exists("lib32z1"):
packages.append("lib32z1")
if package_exists("libffi8"):
packages.append("libffi8") elif package_exists("libffi7"):
packages.append("libffi7") elif package_exists("libffi6"):
packages.append("libffi6")
if package_exists("libpng16-16t64"):
packages.append("libpng16-16t64") elif package_exists("libpng16-16"):
packages.append("libpng16-16") else:
packages.append("libpng12-0")
if package_exists("libnspr4"):
packages.extend(["libnspr4", "libnss3"]) else:
packages.extend(["libnspr4-0d", "libnss3-1d"])
if package_exists("appmenu-gtk"):
packages.append("appmenu-gtk") if package_exists("libgnome-keyring0"):
packages.append("libgnome-keyring0") if package_exists("libgnome-keyring-dev"):
packages.append("libgnome-keyring-dev") if package_exists("libvulkan1"):
packages.append("libvulkan1") if package_exists("libinput10"):
packages.append("libinput10")
if package_exists("libncurses6"):
packages.append("libncurses6") else:
packages.append("libncurses5")
if package_exists("libasound2t64"):
packages.append("libasound2t64") else:
packages.append("libasound2")
# Run-time packages required by interactive_ui_tests on mutter if package_exists("libgraphene-1.0-0"):
packages.append("libgraphene-1.0-0") if package_exists("mutter-common"):
packages.append("mutter-common")
packages = [ # 32-bit libraries needed for a 32-bit build # includes some 32-bit libraries required by the Android SDK # See https://developer.android.com/sdk/installing/index.html?pkg=tools "libasound2:i386", "libatk-bridge2.0-0:i386", "libatk1.0-0:i386", "libatspi2.0-0:i386", "libdbus-1-3:i386", "libegl1:i386", "libgl1:i386", "libglib2.0-0:i386", "libnss3:i386", "libpango-1.0-0:i386", "libpangocairo-1.0-0:i386", "libstdc++6:i386", "libwayland-egl1:i386", "libx11-xcb1:i386", "libxcomposite1:i386", "libxdamage1:i386", "libxkbcommon0:i386", "libxrandr2:i386", "libxtst6:i386", "zlib1g:i386", # 32-bit libraries needed e.g. to compile V8 snapshot for Android or armhf "linux-libc-dev:i386", "libexpat1:i386", "libpci3:i386",
]
# When cross building for arm/Android on 64-bit systems the host binaries # that are part of v8 need to be compiled with -m32 which means # that basic multilib support is needed. if"ELF 64-bit"in subprocess.check_output(["file", "-L", "/sbin/init"]).decode(): # gcc-multilib conflicts with the arm cross compiler but # g++-X.Y-multilib gives us the 32-bit support that we need. Find out the # appropriate value of X and Y by seeing what version the current # distribution's g++-multilib package depends on.
lines = subprocess.check_output(
["apt-cache", "depends", "g++-multilib", "--important"]).decode()
pattern = re.compile(r"g\+\+-[0-9.]+-multilib")
packages += re.findall(pattern, lines)
if package_exists("libncurses6:i386"):
packages.append("libncurses6:i386") else:
packages.append("libncurses5:i386")
return packages
# Packages that have been removed from this script. Regardless of configuration # or options passed to this script, whenever a package is removed, it should be # added here. def backwards_compatible_list(options): ifnot options.backwards_compatible:
print("Skipping backwards compatible packages.", file=sys.stderr) return []
print("Including backwards compatible packages.", file=sys.stderr)
for php_cgi, mod_php in php_versions: if package_exists(php_cgi):
packages.extend([php_cgi, mod_php]) break
return [package for package in packages if package_exists(package)]
def arm_list(options): ifnot options.arm:
print("Skipping ARM cross toolchain.", file=sys.stderr) return []
print("Including ARM cross toolchain.", file=sys.stderr)
# arm cross toolchain packages needed to build chrome on armhf
packages = [ "g++-arm-linux-gnueabihf", "gcc-arm-linux-gnueabihf", "libc6-dev-armhf-cross", "linux-libc-dev-armhf-cross",
]
# Work around an Ubuntu dependency issue. # TODO(https://crbug.com/40549424): Remove this when support for Focal # and Jammy are dropped. if distro_codename() == "focal":
packages.extend([ "g++-10-multilib-arm-linux-gnueabihf", "gcc-10-multilib-arm-linux-gnueabihf",
]) elif distro_codename() == "jammy":
packages.extend([ "g++-11-arm-linux-gnueabihf", "gcc-11-arm-linux-gnueabihf",
])
# Prefer lib32ncurses5-dev to match libncurses5:i386 if it exists. # In some Ubuntu releases, lib32ncurses5-dev is a transition package to # lib32ncurses-dev, so use that as a fallback. if package_exists("lib32ncurses5-dev"):
packages.append("lib32ncurses5-dev") else:
packages.append("lib32ncurses-dev")
return packages
# Packages suffixed with t64 are "transition packages" and should be preferred. def maybe_append_t64(package):
name = package.split(":")
name[0] += "t64"
renamed = ":".join(name) return renamed if package_exists(renamed) else package
# Debian is in the process of transitioning to automatic debug packages, which # have the -dbgsym suffix (https://wiki.debian.org/AutomaticDebugPackages). # Untransitioned packages have the -dbg suffix. And on some systems, neither # will be available, so exclude the ones that are missing. def dbg_package_name(package):
package = maybe_append_t64(package) if package_exists(package + "-dbgsym"): return [package + "-dbgsym"] if package_exists(package + "-dbg"): return [package + "-dbg"] return []
packages = [
dbg_package for package in lib_list() for dbg_package in dbg_package_name(package)
]
# Debugging symbols packages not following common naming scheme ifnot dbg_package_name("libstdc++6"): for version in ["8", "7", "6", "5", "4.9", "4.8", "4.7", "4.6"]: if package_exists("libstdc++6-%s-dbg" % version):
packages.append("libstdc++6-%s-dbg" % version) break
# Sort all the :i386 packages to the front, to avoid confusing dpkg-query # (https://crbug.com/446172). return sorted(packages, key=lambda x: (not x.endswith(":i386"), x))
def missing_packages(packages): try:
subprocess.run(
["dpkg-query", "-W", "-f", " "] + packages,
check=True,
capture_output=True,
) return [] except subprocess.CalledProcessError as e: return [
line.split(" ")[-1] for line in e.stderr.decode().strip().splitlines()
]
not_installed = []
unknown = [] for p in missing: if package_is_installable(p):
not_installed.append(p) else:
unknown.append(p)
if not_installed:
print("WARNING: The following packages are not installed:", file=sys.stderr)
print(" ".join(not_installed), file=sys.stderr)
if unknown:
print("WARNING: The following packages are unknown to your system",
file=sys.stderr)
print("(maybe missing a repo or need to 'sudo apt-get update'):",
file=sys.stderr)
print(" ".join(unknown), file=sys.stderr)
install = [] for pattern in ( "The following NEW packages will be installed:", "The following packages will be upgraded:",
): if pattern in lines: for line in lines[lines.index(pattern) + 1:]: ifnot line.startswith(" "): break
install += line.strip().split(" ") return install
def install_packages(options): try:
packages = find_missing_packages(options) if packages:
quiet = ["-qq", "--assume-yes"] if options.no_prompt else []
subprocess.check_call(["sudo", "apt-get", "install"] + quiet + packages)
print(file=sys.stderr) else:
print("No missing packages, and the packages are up to date.",
file=sys.stderr)
except subprocess.CalledProcessError as e: # An apt-get exit status of 100 indicates that a real error has occurred.
print("`apt-get --just-print install ...` failed", file=sys.stderr)
print("It produced the following output:", file=sys.stderr)
print(file=sys.stderr)
print("You will have to install the above packages yourself.",
file=sys.stderr)
print(file=sys.stderr)
sys.exit(100)
# Install the Chrome OS default fonts. This must go after running # apt-get, since install-chromeos-fonts depends on curl. def install_chromeos_fonts(options): ifnot options.chromeos_fonts:
print("Skipping installation of Chrome OS fonts.", file=sys.stderr) return
print("Installing Chrome OS fonts.", file=sys.stderr)
dir = os.path.abspath(os.path.dirname(__file__))
try:
subprocess.check_call(
["sudo",
os.path.join(dir, "linux", "install-chromeos-fonts.py")]) except subprocess.CalledProcessError:
print("ERROR: The installation of the Chrome OS default fonts failed.",
file=sys.stderr) if (subprocess.check_output(
["stat", "-f", "-c", "%T", dir], ).decode().startswith("nfs")):
print( "The reason is that your repo is installed on a remote file system.",
file=sys.stderr) else:
print( "This is expected if your repo is installed on a remote file system.",
file=sys.stderr)
print("It is recommended to install your repo on a local file system.",
file=sys.stderr)
print("You can skip the installation of the Chrome OS default fonts with",
file=sys.stderr)
print("the command line option: --no-chromeos-fonts.", file=sys.stderr)
sys.exit(1)
# Regenerating locales can take a while, so only do it if we need to.
locale_gen = open(LOCALE_GEN).read() if locale_gen != old_locale_gen:
subprocess.check_call(["sudo", "locale-gen"]) else:
print("Locales already up-to-date.", file=sys.stderr) else: for locale in CHROMIUM_LOCALES:
subprocess.check_call(["sudo", "locale-gen", locale])
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.