Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /build /install-build-deps.py
blob: f7547ec5139235a68ee1d46b4a4e624b2767dfb1 [file] [log] [blame]
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]1#!/usr/bin/env python3
2
3# Copyright 2023 The Chromium Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Script to install everything needed to build chromium
8# including items requiring sudo privileges.
9# See https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md
10
11import argparse
12import functools
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]13import logging
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]14import os
15import re
16import shutil
17import subprocess
18import sys
19
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]20logging.basicConfig(stream=sys.stderr,
21 level=logging.INFO,
22 format='%(name)s [%(levelname)s]: %(message)s')
23logger= logging.getLogger(os.path.basename(sys.argv[0]))
24
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]25
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]26@functools.lru_cache(maxsize=1)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]27def build_apt_package_list():
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]28 logger.info("Building apt package list.")
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]29 output= subprocess.check_output(["apt-cache","dumpavail"]).decode()
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]30 arch_map={"i386":":i386"}
31 package_regex= re.compile(r"^Package: (.+?)$.+?^Architecture: (.+?)$",
32 re.M| re.S)
33return set(package+ arch_map.get(arch,"")
34for package, archin re.findall(package_regex, output))
35
36
37def package_exists(package_name: str)-> bool:
38return package_namein build_apt_package_list()
39
40
41def parse_args(argv):
42 parser= argparse.ArgumentParser(
43 description="Install Chromium build dependencies.")
44 parser.add_argument("--syms",
45 action="store_true",
46 help="Enable installation of debugging symbols")
47 parser.add_argument(
48"--no-syms",
49 action="store_false",
50 dest="syms",
51 help="Disable installation of debugging symbols",
52)
53 parser.add_argument(
54"--lib32",
55 action="store_true",
56 help="Enable installation of 32-bit libraries, e.g. for V8 snapshot",
57)
58 parser.add_argument(
59"--android",
60 action="store_true",
Alex N. Jose93e74012024-09-23 19:13:21[diff] [blame]61# Deprecated flag retained as functional for backward compatibility:
62# Enable installation of android dependencies
63 help=argparse.SUPPRESS)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]64 parser.add_argument(
65"--no-android",
66 action="store_false",
67 dest="android",
Alex N. Jose93e74012024-09-23 19:13:21[diff] [blame]68# Deprecated flag retained as functional for backward compatibility:
69# Enable installation of android dependencies
70 help=argparse.SUPPRESS)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]71 parser.add_argument("--arm",
72 action="store_true",
73 help="Enable installation of arm cross toolchain")
74 parser.add_argument(
75"--no-arm",
76 action="store_false",
77 dest="arm",
78 help="Disable installation of arm cross toolchain",
79)
80 parser.add_argument(
81"--chromeos-fonts",
82 action="store_true",
83 help="Enable installation of Chrome OS fonts",
84)
85 parser.add_argument(
86"--no-chromeos-fonts",
87 action="store_false",
88 dest="chromeos_fonts",
89 help="Disable installation of Chrome OS fonts",
90)
91 parser.add_argument(
92"--nacl",
93 action="store_true",
Fumitoshi Ukai2295c302025-06-20 00:24:37[diff] [blame]94# Deprecated flag retained as functional for backward compatibility:
95# Enable installation of nacl dependencies
96 help=argparse.SUPPRESS)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]97 parser.add_argument(
98"--no-nacl",
99 action="store_false",
100 dest="nacl",
Fumitoshi Ukai2295c302025-06-20 00:24:37[diff] [blame]101# Deprecated flag retained as functional for backward compatibility:
102# Enable installation of nacl dependencies
103 help=argparse.SUPPRESS)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]104 parser.add_argument(
105"--backwards-compatible",
106 action="store_true",
107 help=
108"Enable installation of packages that are no longer currently needed and"
109+"have been removed from this script. Useful for bisection.",
110)
111 parser.add_argument(
112"--no-backwards-compatible",
113 action="store_false",
114 dest="backwards_compatible",
115 help=
116"Disable installation of packages that are no longer currently needed and"
117+"have been removed from this script.",
118)
119 parser.add_argument("--no-prompt",
120 action="store_true",
121 help="Automatic yes to prompts")
122 parser.add_argument(
123"--quick-check",
124 action="store_true",
125 help="Quickly try to determine if dependencies are installed",
126)
127 parser.add_argument(
128"--unsupported",
129 action="store_true",
130 help="Attempt installation even on unsupported systems",
131)
132
133 options= parser.parse_args(argv)
134
135if options.armor options.android:
136 options.lib32=True
137
138return options
139
140
141def check_lsb_release():
142ifnot shutil.which("lsb_release"):
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]143 logger.error("lsb_release not found in $PATH")
144 logger.error("try: sudo apt-get install lsb-release")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]145 sys.exit(1)
146
147
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]148@functools.lru_cache(maxsize=1)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]149def distro_codename():
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]150return subprocess.check_output(["lsb_release","--codename",
151"--short"]).decode().strip()
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]152
153
Andrew Grieve349efa12025-04-03 19:38:19[diff] [blame]154@functools.lru_cache(maxsize=1)
155def requires_pinned_linux_libc():
156# See: https://crbug.com/403291652 and b/408002335
157 name= subprocess.check_output(["uname","-r"]).decode().strip()
158return name=='6.12.12-1rodete2-amd64'
159
160
161def add_version_workaround(packages):
162if'linux-libc-dev:i386'in packages:
163 idx= packages.index('linux-libc-dev:i386')
164 packages[idx]+='=5.8.14-1'
165 packages+=['linux-libc-dev=5.8.14-1']
166
167
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]168def check_distro(options):
169if options.unsupportedor options.quick_check:
170return
171
172 distro_id= subprocess.check_output(["lsb_release","--id",
Dmitry Vykochkod4159be92023-05-08 15:57:19[diff] [blame]173"--short"]).decode().strip()
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]174
Tom Anderson9f16b9e9b2024-06-06 00:20:34[diff] [blame]175 supported_codenames=["focal","jammy","noble"]
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]176 supported_ids=["Debian"]
177
178if(distro_codename()notin supported_codenames
179and distro_idnotin supported_ids):
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]180 logger.warning(
181("The following distributions are supported, "
182"but distributions not in the list below can also try to install "
183"dependencies by passing the `--unsupported` parameter."))
184 logger.warning(
185("EoS refers to end of standard support and does not include "
186"extended security support.\n"
187"\tUbuntu 20.04 LTS (focal with EoS April 2025)\n"
188"\tUbuntu 22.04 LTS (jammy with EoS June 2027)\n"
189"\tUbuntu 24.04 LTS (noble with EoS June 2029)\n"
190"\tDebian 11 (bullseye) or later"))
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]191 sys.exit(1)
192
193
194def check_architecture():
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]195 architecture= subprocess.check_output(["uname","-m"]).decode().strip()
Randolf Jung37deea42024-03-04 22:12:16[diff] [blame]196if architecturenotin["i686","x86_64",'aarch64']:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]197 logger.error("Only x86 and ARM64 architectures are currently supported")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]198 sys.exit(1)
199
200
201def check_root():
202if os.geteuid()!=0:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]203 logger.info("Running as non-root user.")
204 logger.info(
205"You might have to enter your password one or more times for 'sudo'.\n")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]206
207
208def apt_update(options):
Fumitoshi Ukai2295c302025-06-20 00:24:37[diff] [blame]209if options.lib32or options.backwards_compatible:
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]210 subprocess.check_call(["sudo","dpkg","--add-architecture","i386"])
211 subprocess.check_call(["sudo","apt-get","update"])
212
213
214# Packages needed for development
215def dev_list():
216 packages=[
Tom Andersonadbbe7e2023-05-19 18:39:06[diff] [blame]217"binutils",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]218"bison",
219"bzip2",
220"cdbs",
221"curl",
222"dbus-x11",
223"devscripts",
224"dpkg-dev",
225"elfutils",
226"fakeroot",
227"flex",
228"git-core",
229"gperf",
230"libasound2-dev",
231"libatspi2.0-dev",
232"libbrlapi-dev",
233"libbz2-dev",
234"libc6-dev",
235"libcairo2-dev",
236"libcap-dev",
237"libcups2-dev",
238"libcurl4-gnutls-dev",
239"libdrm-dev",
240"libelf-dev",
241"libevdev-dev",
242"libffi-dev",
Tom Anderson47a8cc652023-06-15 05:29:42[diff] [blame]243"libfuse2",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]244"libgbm-dev",
245"libglib2.0-dev",
246"libglu1-mesa-dev",
247"libgtk-3-dev",
248"libkrb5-dev",
249"libnspr4-dev",
250"libnss3-dev",
251"libpam0g-dev",
252"libpci-dev",
253"libpulse-dev",
254"libsctp-dev",
255"libspeechd-dev",
256"libsqlite3-dev",
Tom Andersonc1c1ed2d2024-06-25 00:04:56[diff] [blame]257"libssl-dev",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]258"libsystemd-dev",
259"libudev-dev",
Lei Zhang00fdd3552024-07-30 02:28:13[diff] [blame]260"libudev1",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]261"libva-dev",
262"libwww-perl",
263"libxshmfence-dev",
264"libxslt1-dev",
265"libxss-dev",
266"libxt-dev",
267"libxtst-dev",
268"lighttpd",
269"locales",
270"openbox",
271"p7zip",
272"patch",
273"perl",
Tom Anderson96d3a6f2024-07-16 17:57:20[diff] [blame]274"pkgconf",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]275"rpm",
276"ruby",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]277"uuid-dev",
278"wdiff",
279"x11-utils",
280"xcompmgr",
281"xz-utils",
282"zip",
283]
284
285# Packages needed for chromeos only
286 packages+=[
287"libbluetooth-dev",
288"libxkbcommon-dev",
289"mesa-common-dev",
290"zstd",
291]
292
293if package_exists("realpath"):
294 packages.append("realpath")
295
296if package_exists("libjpeg-dev"):
297 packages.append("libjpeg-dev")
298else:
299 packages.append("libjpeg62-dev")
300
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]301if package_exists("libbrlapi0.8"):
302 packages.append("libbrlapi0.8")
303elif package_exists("libbrlapi0.7"):
304 packages.append("libbrlapi0.7")
305elif package_exists("libbrlapi0.6"):
306 packages.append("libbrlapi0.6")
307else:
308 packages.append("libbrlapi0.5")
309
310if package_exists("libav-tools"):
311 packages.append("libav-tools")
312
313if package_exists("libvulkan-dev"):
314 packages.append("libvulkan-dev")
315
316if package_exists("libinput-dev"):
317 packages.append("libinput-dev")
318
Adrian Taylor0877e9402024-10-23 11:38:33[diff] [blame]319# So accessibility APIs work, needed for AX fuzzer
320if package_exists("at-spi2-core"):
321 packages.append("at-spi2-core")
322
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]323# Cross-toolchain strip is needed for building the sysroots.
324if package_exists("binutils-arm-linux-gnueabihf"):
325 packages.append("binutils-arm-linux-gnueabihf")
326if package_exists("binutils-aarch64-linux-gnu"):
327 packages.append("binutils-aarch64-linux-gnu")
328if package_exists("binutils-mipsel-linux-gnu"):
329 packages.append("binutils-mipsel-linux-gnu")
330if package_exists("binutils-mips64el-linux-gnuabi64"):
331 packages.append("binutils-mips64el-linux-gnuabi64")
332
333# 64-bit systems need a minimum set of 32-bit compat packages for the
Fumitoshi Ukai2295c302025-06-20 00:24:37[diff] [blame]334# pre-built NaCl binaries or Android SDK
335# See https://developer.android.com/sdk/installing/index.html?pkg=tools
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]336if"ELF 64-bit"in subprocess.check_output(["file","-L",
337"/sbin/init"]).decode():
Randolf Jungbd9e34a2024-03-05 21:59:34[diff] [blame]338# ARM64 may not support these.
339if package_exists("libc6-i386"):
340 packages.append("libc6-i386")
341if package_exists("lib32stdc++6"):
342 packages.append("lib32stdc++6")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]343
344# lib32gcc-s1 used to be called lib32gcc1 in older distros.
345if package_exists("lib32gcc-s1"):
346 packages.append("lib32gcc-s1")
347elif package_exists("lib32gcc1"):
348 packages.append("lib32gcc1")
349
350return packages
351
352
353# List of required run-time libraries
354def lib_list():
355 packages=[
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]356"libatk1.0-0",
357"libatspi2.0-0",
358"libc6",
359"libcairo2",
360"libcap2",
361"libcgi-session-perl",
362"libcups2",
363"libdrm2",
364"libegl1",
365"libevdev2",
366"libexpat1",
367"libfontconfig1",
368"libfreetype6",
369"libgbm1",
370"libglib2.0-0",
371"libgl1",
372"libgtk-3-0",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]373"libpam0g",
374"libpango-1.0-0",
375"libpangocairo-1.0-0",
376"libpci3",
377"libpcre3",
378"libpixman-1-0",
379"libspeechd2",
380"libstdc++6",
381"libsqlite3-0",
382"libuuid1",
383"libwayland-egl1",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]384"libx11-6",
385"libx11-xcb1",
386"libxau6",
387"libxcb1",
388"libxcomposite1",
389"libxcursor1",
390"libxdamage1",
391"libxdmcp6",
392"libxext6",
393"libxfixes3",
394"libxi6",
395"libxinerama1",
396"libxrandr2",
397"libxrender1",
398"libxtst6",
399"x11-utils",
Brad Triebwasser3e1ff3682024-05-07 17:43:38[diff] [blame]400"x11-xserver-utils",
401"xserver-xorg-core",
402"xserver-xorg-video-dummy",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]403"xvfb",
404"zlib1g",
405]
406
407# Run-time libraries required by chromeos only
408 packages+=[
409"libpulse0",
410"libbz2-1.0",
411]
412
Randolf Jung37deea42024-03-04 22:12:16[diff] [blame]413# May not exist (e.g. ARM64)
414if package_exists("lib32z1"):
415 packages.append("lib32z1")
416
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]417if package_exists("libffi8"):
418 packages.append("libffi8")
419elif package_exists("libffi7"):
420 packages.append("libffi7")
421elif package_exists("libffi6"):
422 packages.append("libffi6")
423
Lei Zhangec95ddd52024-07-30 05:31:23[diff] [blame]424if package_exists("libpng16-16t64"):
Ho Cheung75fc93e2024-04-23 02:51:57[diff] [blame]425 packages.append("libpng16-16t64")
426elif package_exists("libpng16-16"):
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]427 packages.append("libpng16-16")
428else:
429 packages.append("libpng12-0")
430
431if package_exists("libnspr4"):
432 packages.extend(["libnspr4","libnss3"])
433else:
434 packages.extend(["libnspr4-0d","libnss3-1d"])
435
436if package_exists("appmenu-gtk"):
437 packages.append("appmenu-gtk")
438if package_exists("libgnome-keyring0"):
439 packages.append("libgnome-keyring0")
440if package_exists("libgnome-keyring-dev"):
441 packages.append("libgnome-keyring-dev")
442if package_exists("libvulkan1"):
443 packages.append("libvulkan1")
444if package_exists("libinput10"):
445 packages.append("libinput10")
446
Lei Zhangec95ddd52024-07-30 05:31:23[diff] [blame]447if package_exists("libncurses6"):
Ho Cheung6b3d57b02023-12-05 03:15:51[diff] [blame]448 packages.append("libncurses6")
449else:
450 packages.append("libncurses5")
Lei Zhangec95ddd52024-07-30 05:31:23[diff] [blame]451
452if package_exists("libasound2t64"):
453 packages.append("libasound2t64")
454else:
Ho Cheung75fc93e2024-04-23 02:51:57[diff] [blame]455 packages.append("libasound2")
Ho Cheung6b3d57b02023-12-05 03:15:51[diff] [blame]456
Orko Garaif682a9b2025-03-06 22:50:03[diff] [blame]457# Run-time packages required by interactive_ui_tests on mutter
458if package_exists("libgraphene-1.0-0"):
459 packages.append("libgraphene-1.0-0")
460if package_exists("mutter-common"):
461 packages.append("mutter-common")
462
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]463return packages
464
465
466def lib32_list(options):
467ifnot options.lib32:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]468 logger.info("Skipping 32-bit libraries.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]469return[]
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]470 logger.info("Including 32-bit libraries.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]471
472 packages=[
473# 32-bit libraries needed for a 32-bit build
474# includes some 32-bit libraries required by the Android SDK
475# See https://developer.android.com/sdk/installing/index.html?pkg=tools
476"libasound2:i386",
477"libatk-bridge2.0-0:i386",
478"libatk1.0-0:i386",
479"libatspi2.0-0:i386",
480"libdbus-1-3:i386",
481"libegl1:i386",
482"libgl1:i386",
483"libglib2.0-0:i386",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]484"libnss3:i386",
485"libpango-1.0-0:i386",
486"libpangocairo-1.0-0:i386",
487"libstdc++6:i386",
488"libwayland-egl1:i386",
489"libx11-xcb1:i386",
490"libxcomposite1:i386",
491"libxdamage1:i386",
492"libxkbcommon0:i386",
493"libxrandr2:i386",
494"libxtst6:i386",
495"zlib1g:i386",
496# 32-bit libraries needed e.g. to compile V8 snapshot for Android or armhf
497"linux-libc-dev:i386",
Andrew Grieve04d83132024-06-07 18:19:06[diff] [blame]498"libexpat1:i386",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]499"libpci3:i386",
500]
501
502# When cross building for arm/Android on 64-bit systems the host binaries
503# that are part of v8 need to be compiled with -m32 which means
504# that basic multilib support is needed.
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]505if"ELF 64-bit"in subprocess.check_output(["file","-L",
506"/sbin/init"]).decode():
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]507# gcc-multilib conflicts with the arm cross compiler but
508# g++-X.Y-multilib gives us the 32-bit support that we need. Find out the
509# appropriate value of X and Y by seeing what version the current
510# distribution's g++-multilib package depends on.
Tom Andersonadbbe7e2023-05-19 18:39:06[diff] [blame]511 lines= subprocess.check_output(
512["apt-cache","depends","g++-multilib","--important"]).decode()
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]513 pattern= re.compile(r"g\+\+-[0-9.]+-multilib")
Tom Andersonadbbe7e2023-05-19 18:39:06[diff] [blame]514 packages+= re.findall(pattern, lines)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]515
Lei Zhangec95ddd52024-07-30 05:31:23[diff] [blame]516if package_exists("libncurses6:i386"):
Ho Cheung6b3d57b02023-12-05 03:15:51[diff] [blame]517 packages.append("libncurses6:i386")
518else:
519 packages.append("libncurses5:i386")
520
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]521return packages
522
523
524# Packages that have been removed from this script. Regardless of configuration
525# or options passed to this script, whenever a package is removed, it should be
526# added here.
527def backwards_compatible_list(options):
528ifnot options.backwards_compatible:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]529 logger.info("Skipping backwards compatible packages.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]530return[]
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]531 logger.info("Including backwards compatible packages.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]532
533 packages=[
534"7za",
535"fonts-indic",
536"fonts-ipafont",
537"fonts-stix",
538"fonts-thai-tlwg",
539"fonts-tlwg-garuda",
540"g++",
541"g++-4.8-multilib-arm-linux-gnueabihf",
542"gcc-4.8-multilib-arm-linux-gnueabihf",
543"g++-9-multilib-arm-linux-gnueabihf",
544"gcc-9-multilib-arm-linux-gnueabihf",
545"gcc-arm-linux-gnueabihf",
546"g++-10-multilib-arm-linux-gnueabihf",
547"gcc-10-multilib-arm-linux-gnueabihf",
548"g++-10-arm-linux-gnueabihf",
549"gcc-10-arm-linux-gnueabihf",
550"git-svn",
551"language-pack-da",
552"language-pack-fr",
553"language-pack-he",
554"language-pack-zh-hant",
555"libappindicator-dev",
556"libappindicator1",
557"libappindicator3-1",
558"libappindicator3-dev",
559"libdconf-dev",
560"libdconf1",
561"libdconf1:i386",
562"libexif-dev",
563"libexif12",
564"libexif12:i386",
565"libgbm-dev",
566"libgbm-dev-lts-trusty",
567"libgbm-dev-lts-xenial",
568"libgconf-2-4:i386",
569"libgconf2-dev",
570"libgl1-mesa-dev",
571"libgl1-mesa-dev-lts-trusty",
572"libgl1-mesa-dev-lts-xenial",
573"libgl1-mesa-glx:i386",
574"libgl1-mesa-glx-lts-trusty:i386",
575"libgl1-mesa-glx-lts-xenial:i386",
576"libgles2-mesa-dev",
577"libgles2-mesa-dev-lts-trusty",
578"libgles2-mesa-dev-lts-xenial",
579"libgtk-3-0:i386",
580"libgtk2.0-0",
581"libgtk2.0-0:i386",
582"libgtk2.0-dev",
583"mesa-common-dev",
584"mesa-common-dev-lts-trusty",
585"mesa-common-dev-lts-xenial",
586"msttcorefonts",
587"python-dev",
588"python-setuptools",
Tom Andersonc4a1b6742023-05-19 04:57:45[diff] [blame]589"snapcraft",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]590"ttf-dejavu-core",
591"ttf-indic-fonts",
592"ttf-kochi-gothic",
593"ttf-kochi-mincho",
594"ttf-mscorefonts-installer",
595"xfonts-mathml",
Fumitoshi Ukai2295c302025-06-20 00:24:37[diff] [blame]596
597# for NaCl
598"g++-mingw-w64-i686",
599"lib32z1-dev",
600"libasound2:i386",
601"libcap2:i386",
602"libelf-dev:i386",
603"libfontconfig1:i386",
604"libglib2.0-0:i386",
605"libgpm2:i386",
606"libncurses5:i386",
607"libnss3:i386",
608"libpango-1.0-0:i386",
609"libssl-dev:i386",
610"libtinfo-dev",
611"libtinfo-dev:i386",
612"libtool",
613"libudev1:i386",
614"libuuid1:i386",
615"libxcomposite1:i386",
616"libxcursor1:i386",
617"libxdamage1:i386",
618"libxi6:i386",
619"libxrandr2:i386",
620"libxss1:i386",
621"libxtst6:i386",
622"texinfo",
623"xvfb",
624
625# Packages to build NaCl, its toolchains, and its ports.
626"ant",
627"autoconf",
628"bison",
629"cmake",
630"gawk",
631"intltool",
632"libtinfo5",
633"xutils-dev",
634"xsltproc",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]635]
636
637if package_exists("python-is-python2"):
638 packages.extend(["python-is-python2","python2-dev"])
639else:
640 packages.append("python")
641
642if package_exists("python-crypto"):
643 packages.append("python-crypto")
644
645if package_exists("python-numpy"):
646 packages.append("python-numpy")
647
648if package_exists("python-openssl"):
649 packages.append("python-openssl")
650
651if package_exists("python-psutil"):
652 packages.append("python-psutil")
653
654if package_exists("python-yaml"):
655 packages.append("python-yaml")
656
657if package_exists("apache2.2-bin"):
658 packages.append("apache2.2-bin")
659else:
660 packages.append("apache2-bin")
661
Fumitoshi Ukai2295c302025-06-20 00:24:37[diff] [blame]662# for NaCl.
663# Prefer lib32ncurses5-dev to match libncurses5:i386 if it exists.
664# In some Ubuntu releases, lib32ncurses5-dev is a transition package to
665# lib32ncurses-dev, so use that as a fallback.
666if package_exists("lib32ncurses5-dev"):
667 packages.append("lib32ncurses5-dev")
668else:
669 packages.append("lib32ncurses-dev")
670
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]671 php_versions=[
672("php8.1-cgi","libapache2-mod-php8.1"),
673("php8.0-cgi","libapache2-mod-php8.0"),
674("php7.4-cgi","libapache2-mod-php7.4"),
675("php7.3-cgi","libapache2-mod-php7.3"),
676("php7.2-cgi","libapache2-mod-php7.2"),
677("php7.1-cgi","libapache2-mod-php7.1"),
678("php7.0-cgi","libapache2-mod-php7.0"),
679("php5-cgi","libapache2-mod-php5"),
680]
681
682for php_cgi, mod_phpin php_versions:
683if package_exists(php_cgi):
684 packages.extend([php_cgi, mod_php])
685break
686
687return[packagefor packagein packagesif package_exists(package)]
688
689
690def arm_list(options):
691ifnot options.arm:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]692 logger.info("Skipping ARM cross toolchain.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]693return[]
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]694 logger.info("Including ARM cross toolchain.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]695
696# arm cross toolchain packages needed to build chrome on armhf
697 packages=[
Tom Anderson9f16b9e9b2024-06-06 00:20:34[diff] [blame]698"g++-arm-linux-gnueabihf",
699"gcc-arm-linux-gnueabihf",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]700"libc6-dev-armhf-cross",
701"linux-libc-dev-armhf-cross",
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]702]
703
Tom Anderson823c1c32024-06-27 01:16:01[diff] [blame]704# Work around an Ubuntu dependency issue.
705# TODO(https://crbug.com/40549424): Remove this when support for Focal
706# and Jammy are dropped.
707if distro_codename()=="focal":
708 packages.extend([
709"g++-10-multilib-arm-linux-gnueabihf",
710"gcc-10-multilib-arm-linux-gnueabihf",
711])
712elif distro_codename()=="jammy":
713 packages.extend([
714"g++-11-arm-linux-gnueabihf",
715"gcc-11-arm-linux-gnueabihf",
716])
717
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]718return packages
719
720
Tom Andersonb44961a2024-07-11 22:51:22[diff] [blame]721# Packages suffixed with t64 are "transition packages" and should be preferred.
722def maybe_append_t64(package):
723 name= package.split(":")
724 name[0]+="t64"
725 renamed=":".join(name)
726return renamedif package_exists(renamed)else package
727
728
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]729# Debian is in the process of transitioning to automatic debug packages, which
730# have the -dbgsym suffix (https://wiki.debian.org/AutomaticDebugPackages).
731# Untransitioned packages have the -dbg suffix. And on some systems, neither
732# will be available, so exclude the ones that are missing.
733def dbg_package_name(package):
Tom Andersonb44961a2024-07-11 22:51:22[diff] [blame]734 package= maybe_append_t64(package)
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]735if package_exists(package+"-dbgsym"):
736return[package+"-dbgsym"]
737if package_exists(package+"-dbg"):
738return[package+"-dbg"]
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]739return[]
740
741
742def dbg_list(options):
743ifnot options.syms:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]744 logger.info("Skipping debugging symbols.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]745return[]
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]746 logger.info("Including debugging symbols.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]747
748 packages=[
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]749 dbg_packagefor packagein lib_list()
750for dbg_packagein dbg_package_name(package)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]751]
752
753# Debugging symbols packages not following common naming scheme
754ifnot dbg_package_name("libstdc++6"):
755for versionin["8","7","6","5","4.9","4.8","4.7","4.6"]:
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]756if package_exists("libstdc++6-%s-dbg"% version):
757 packages.append("libstdc++6-%s-dbg"% version)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]758break
759
760ifnot dbg_package_name("libatk1.0-0"):
761 packages.extend(dbg_package_name("libatk1.0"))
762
763ifnot dbg_package_name("libpango-1.0-0"):
764 packages.extend(dbg_package_name("libpango1.0-dev"))
765
766return packages
767
768
769def package_list(options):
770 packages=(dev_list()+ lib_list()+ dbg_list(options)+
Fumitoshi Ukai2295c302025-06-20 00:24:37[diff] [blame]771 lib32_list(options)+ arm_list(options)+
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]772 backwards_compatible_list(options))
Tom Andersonb44961a2024-07-11 22:51:22[diff] [blame]773 packages=[maybe_append_t64(package)for packagein set(packages)]
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]774
Andrew Grieve349efa12025-04-03 19:38:19[diff] [blame]775if requires_pinned_linux_libc():
776 add_version_workaround(packages)
777
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]778# Sort all the :i386 packages to the front, to avoid confusing dpkg-query
779# (https://crbug.com/446172).
Tom Andersonb44961a2024-07-11 22:51:22[diff] [blame]780return sorted(packages, key=lambda x:(not x.endswith(":i386"), x))
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]781
782
783def missing_packages(packages):
784try:
785 subprocess.run(
786["dpkg-query","-W","-f"," "]+ packages,
787 check=True,
788 capture_output=True,
Tom Anderson72dac622023-08-12 00:28:51[diff] [blame]789)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]790return[]
791except subprocess.CalledProcessErroras e:
Tom Anderson72dac622023-08-12 00:28:51[diff] [blame]792return[
793 line.split(" ")[-1]for linein e.stderr.decode().strip().splitlines()
794]
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]795
796
797def package_is_installable(package):
Tom Anderson72dac622023-08-12 00:28:51[diff] [blame]798 result= subprocess.run(["apt-cache","show", package], capture_output=True)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]799return result.returncode==0
800
801
802def quick_check(options):
803ifnot options.quick_check:
804return
805
806 missing= missing_packages(package_list(options))
807ifnot missing:
808 sys.exit(0)
809
810 not_installed=[]
811 unknown=[]
812for pin missing:
813if package_is_installable(p):
814 not_installed.append(p)
815else:
816 unknown.append(p)
817
818if not_installed:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]819 logger.warning("The following packages are not installed:")
820 logger.warning(" ".join(not_installed))
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]821
822if unknown:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]823 logger.error("The following packages are unknown to your system")
824 logger.error("(maybe missing a repo or need to `sudo apt-get update`):")
825 logger.error(" ".join(unknown))
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]826
827 sys.exit(1)
828
829
830def find_missing_packages(options):
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]831 logger.info("Finding missing packages...")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]832
833 packages= package_list(options)
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]834 packages_str="\n ".join(packages)
835 logger.info("Packages required:\n "+ packages_str)
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]836
837 query_cmd=["apt-get","--just-print","install"]+ packages
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]838 env= os.environ.copy()
839 env["LANGUAGE"]="en"
840 env["LANG"]="C"
841 cmd_output= subprocess.check_output(query_cmd, env=env).decode()
842 lines= cmd_output.splitlines()
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]843
844 install=[]
845for patternin(
846"The following NEW packages will be installed:",
847"The following packages will be upgraded:",
848):
849if patternin lines:
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]850for linein lines[lines.index(pattern)+1:]:
851ifnot line.startswith(" "):
852break
853 install+= line.strip().split(" ")
Andrew Grieve349efa12025-04-03 19:38:19[diff] [blame]854
855if requires_pinned_linux_libc():
856 add_version_workaround(install)
857
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]858return install
859
860
861def install_packages(options):
862try:
863 packages= find_missing_packages(options)
864if packages:
865 quiet=["-qq","--assume-yes"]if options.no_promptelse[]
Ri Xucfb58be2024-08-31 16:52:59[diff] [blame]866 subprocess.check_call(["sudo","apt-get","install"]+ quiet+ packages)
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]867 logger.info("")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]868else:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]869 logger.info("No missing packages, and the packages are up to date.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]870
871except subprocess.CalledProcessErroras e:
872# An apt-get exit status of 100 indicates that a real error has occurred.
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]873 logger.error("`apt-get --just-print install ...` failed")
Andrew Grieve349efa12025-04-03 19:38:19[diff] [blame]874if e.stdoutisnotNone:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]875 logger.error("It produced the following output:\n")
876 logger.error(e.stdout.decode("utf-8"))
877 logger.error("You will have to install the above packages yourself.\n")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]878 sys.exit(100)
879
880
881# Install the Chrome OS default fonts. This must go after running
882# apt-get, since install-chromeos-fonts depends on curl.
883def install_chromeos_fonts(options):
884ifnot options.chromeos_fonts:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]885 logger.info("Skipping installation of Chrome OS fonts.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]886return
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]887 logger.info("Installing Chrome OS fonts.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]888
889 dir= os.path.abspath(os.path.dirname(__file__))
890
891try:
892 subprocess.check_call(
893["sudo",
894 os.path.join(dir,"linux","install-chromeos-fonts.py")])
895except subprocess.CalledProcessError:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]896 logger.error("The installation of the Chrome OS default fonts failed.")
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]897if(subprocess.check_output(
898["stat","-f","-c","%T", dir],).decode().startswith("nfs")):
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]899 logger.error(
900"The reason is that your repo is installed on a remote file system.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]901else:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]902 logger.info(
903"This is expected if your repo is installed on a remote file system.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]904
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]905 logger.info(
906"It is recommended to install your repo on a local file system.")
907 logger.info(
908"You can skip the installation of the Chrome OS default fonts with")
909 logger.info("the command line option: --no-chromeos-fonts.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]910 sys.exit(1)
911
912
913def install_locales():
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]914 logger.info("Installing locales.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]915 CHROMIUM_LOCALES=[
LuKe Tidd005b26a2023-11-27 15:31:23[diff] [blame]916"da_DK.UTF-8","en_US.UTF-8","fr_FR.UTF-8","he_IL.UTF-8","zh_TW.UTF-8"
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]917]
918 LOCALE_GEN="/etc/locale.gen"
919if os.path.exists(LOCALE_GEN):
920 old_locale_gen= open(LOCALE_GEN).read()
921for localein CHROMIUM_LOCALES:
922 subprocess.check_call(
Tom Andersonf78c5e12023-05-10 22:48:45[diff] [blame]923["sudo","sed","-i",
924"s/^# %s/%s/"%(locale, locale), LOCALE_GEN])
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]925
926# Regenerating locales can take a while, so only do it if we need to.
927 locale_gen= open(LOCALE_GEN).read()
928if locale_gen!= old_locale_gen:
929 subprocess.check_call(["sudo","locale-gen"])
930else:
Kalvin Leeaedef3ab2025-07-03 14:40:10[diff] [blame]931 logger.info("Locales already up-to-date.")
Tom Anderson174d85462023-05-05 21:37:04[diff] [blame]932else:
933for localein CHROMIUM_LOCALES:
934 subprocess.check_call(["sudo","locale-gen", locale])
935
936
937def main():
938 options= parse_args(sys.argv[1:])
939 check_lsb_release()
940 check_distro(options)
941 check_architecture()
942 quick_check(options)
943 check_root()
944 apt_update(options)
945 install_packages(options)
946 install_chromeos_fonts(options)
947 install_locales()
948return0
949
950
951if __name__=="__main__":
952 sys.exit(main())

[8]ページ先頭

©2009-2025 Movatter.jp