From 36db9f37849159b320e3a3ab83d5653b92c87b11 Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Thu, 29 Feb 2024 12:13:14 -0700 Subject: [PATCH 1/8] fix(chromium): Build and install missing crashpad handler Adds missing crashpad handler for catching exceptions and generating crash reports Signed-off-by: RJ Sampson --- chromium.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chromium.yaml b/chromium.yaml index 8089b167889..f8c0d1b5d09 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -160,12 +160,13 @@ pipeline: " # === INFO === Compile: takes about 3 hours, 60 GB of disk (on a 32xXeon, 128GBxRAM, 2TBxNVME system) cd /home/src - time autoninja -C /home/src/out/Default chrome chromedriver chrome_sandbox + time autoninja -C /home/src/out/Default chrome chromedriver chrome_crashpad_handler chrome_sandbox # === INFO === Install the binaries and libraries cd /home/src/out/Default mkdir -p ${{targets.destdir}}/usr/bin ${{targets.destdir}}/usr/lib/${{package.name}} mv *.so* ${{targets.destdir}}/usr/lib/${{package.name}} mv chrome ${{targets.destdir}}/usr/lib/${{package.name}} + mv chrome_crashpad_handler ${{targets.destdir}}/usr/lib/${{package.name}} mv chrome_sandbox ${{targets.destdir}}/usr/lib/${{package.name}} mv chromedriver ${{targets.destdir}}/usr/lib/${{package.name}} # resources From 1aa6ece058d1c9de75ed82097be1bd368606cf23 Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Thu, 29 Feb 2024 12:16:35 -0700 Subject: [PATCH 2/8] fix(chromium): Use lld Fixes linking between libraries (namely libui_qt) Signed-off-by: RJ Sampson --- chromium.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/chromium.yaml b/chromium.yaml index f8c0d1b5d09..3ba9a089511 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -149,6 +149,7 @@ pipeline: is_debug=false is_official_build=true symbol_level=0 + use_lld=true use_sysroot=false use_system_freetype=true use_system_harfbuzz=true From 0731c33f894039b793801526e1a4094e8b764cfc Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Thu, 29 Feb 2024 17:49:32 -0700 Subject: [PATCH 3/8] fix(chromium): Provide en-US locale in base package Without at least one locale, Chromium is no-op out of the box Signed-off-by: RJ Sampson --- chromium.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chromium.yaml b/chromium.yaml index 3ba9a089511..6589317079f 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -204,6 +204,9 @@ subpackages: mkdir -p ${{targets.subpkgdir}}/usr/lib/${{package.name}} mv ${{targets.destdir}}/usr/lib/${{package.name}}/locales ${{targets.subpkgdir}}/usr/lib/${{package.name}} + # Ensure we provide one locale in the base package + mv ${{targets.subpkgdir}}/usr/lib/${{package.name}}/locales/en-US.pak ${{targets.destdir}}/usr/lib/${{package.name}}/locales + # https://github.com/SeleniumHQ/docker-selenium/blob/trunk/NodeChrome/Dockerfile - name: chromium-docker-selenium-compat pipeline: From 2d8d485cb515f2da0c9e8765025d47e6331540f8 Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Thu, 29 Feb 2024 18:00:37 -0700 Subject: [PATCH 4/8] chore(chromium): Test for unlinked libraries Given the scope of Chromium, it is beneficial to check whether or not libraries are properly linked Signed-off-by: RJ Sampson --- chromium.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chromium.yaml b/chromium.yaml index 6589317079f..9d182f94105 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -228,7 +228,13 @@ test: environment: contents: packages: + - grep + - posix-libc-utils - wolfi-base pipeline: - runs: | + # Ensure all libraries are linked + ldd /usr/lib/chromium/chrome + + # Check status chromium --no-sandbox --headless --disable-gpu --dump-dom https://www.chromestatus.com From b3e807fa0fac7186243f6f77f547fa2da6f98299 Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Thu, 29 Feb 2024 18:10:31 -0700 Subject: [PATCH 5/8] chore(chromium): Add ChromeDriver test Ensures ChromeDriver works Signed-off-by: RJ Sampson --- chromium.yaml | 8 +++++++- chromium/test-chromedriver.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 chromium/test-chromedriver.py diff --git a/chromium.yaml b/chromium.yaml index 9d182f94105..1f490500aae 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -2,7 +2,7 @@ package: name: chromium version: 122.0.6261.99 - epoch: 2 + epoch: 3 description: "Open souce version of Google's chrome web browser" copyright: - license: BSD-3-Clause @@ -230,6 +230,8 @@ test: packages: - grep - posix-libc-utils + - py3-pip + - python3 - wolfi-base pipeline: - runs: | @@ -238,3 +240,7 @@ test: # Check status chromium --no-sandbox --headless --disable-gpu --dump-dom https://www.chromestatus.com + + # Test ChromeDriver functionality + pip3 install selenium + python3 ./test-chromedriver.py diff --git a/chromium/test-chromedriver.py b/chromium/test-chromedriver.py new file mode 100755 index 00000000000..3ddcca73fa9 --- /dev/null +++ b/chromium/test-chromedriver.py @@ -0,0 +1,14 @@ +from selenium import webdriver + +options = webdriver.ChromeOptions() +options.add_argument('--disable-gpu') +options.add_argument('--no-sandbox') +options.add_argument('--headless') + +driver = webdriver.Chrome( + options=options +) + +driver.get('https://www.chainguard.dev/') + +driver.quit() From 5d0a19ad1779aa96c135e1f6a06ef90eb4bc89e6 Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Mon, 4 Mar 2024 10:30:13 -0500 Subject: [PATCH 6/8] chore(chromium): Add launcher for passing startup env vars Allows passing startup vars to Chromium via CHROMIUM_USER_FLAGS Signed-off-by: RJ Sampson --- chromium.yaml | 4 ++-- chromium/chromium-launcher.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 chromium/chromium-launcher.sh diff --git a/chromium.yaml b/chromium.yaml index 1f490500aae..d3ef84af979 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -180,9 +180,9 @@ pipeline: mv *.pak ${{targets.destdir}}/usr/lib/${{package.name}} mv locales ${{targets.destdir}}/usr/lib/${{package.name}} # links - ln -sf /usr/lib/${{package.name}}/chrome ${{targets.destdir}}/usr/bin/chromium-browser - ln -sf /usr/lib/${{package.name}}/chromedriver ${{targets.destdir}}/usr/bin/chromedriver ln -sf chromium-browser ${{targets.destdir}}/usr/bin/chromium + ln -sf /usr/lib/${{package.name}}/chromedriver ${{targets.destdir}}/usr/bin/chromedriver + ln -sf chromium-launcher.sh ${{targets.destdir}}/usr/bin/chromium-browser mkdir -p ${{targets.destdir}}/etc/chromium - uses: strip diff --git a/chromium/chromium-launcher.sh b/chromium/chromium-launcher.sh new file mode 100755 index 00000000000..e794f8aaf9f --- /dev/null +++ b/chromium/chromium-launcher.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +for f in /etc/chromium/*.conf; do + [ -f "$f" ] && . "$f" +done + +# Append CHROMIUM_USER_FLAGS (from env) on top of system +# default CHROMIUM_FLAGS (from /etc/chromium/chromium.conf). +CHROMIUM_FLAGS="$CHROMIUM_FLAGS ${CHROMIUM_USER_FLAGS:+"$CHROMIUM_USER_FLAGS"}" + +# Let the wrapped binary know that it has been run through the wrapper +export CHROME_WRAPPER="$(readlink -f "$0")" + +PROGDIR=${CHROME_WRAPPER%/*} + +case ":$PATH:" in +*:$PROGDIR:*) + # $PATH already contains $PROGDIR + ;; +*) + # Append $PROGDIR to $PATH + export PATH="$PATH:$PROGDIR" + ;; +esac + +if [ $(id -u) -eq 0 ] && [ $(stat -c %u -L ${XDG_CONFIG_HOME:-${HOME}}) -eq 0 ]; then + # Running as root with HOME owned by root. + # Pass --user-data-dir to work around upstream failsafe. + CHROMIUM_FLAGS="--user-data-dir=${XDG_CONFIG_HOME:-"$HOME"/.config}/chromium $CHROMIUM_FLAGS" +fi + +exec "$PROGDIR/chromium" ${CHROMIUM_FLAGS} "$@" From c2a5cfb4caf9a2c26fd875e28e9746629f37360d Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Mon, 4 Mar 2024 11:07:41 -0500 Subject: [PATCH 7/8] fix(chromium-docker-selenium-compat): Use Chromium launcher Signed-off-by: RJ Sampson --- chromium.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chromium.yaml b/chromium.yaml index d3ef84af979..5cdf7a4dc23 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -217,7 +217,7 @@ subpackages: echo "chrome" > ${{targets.subpkgdir}}/opt/selenium/browser_name echo ${{package.version}} > ${{targets.subpkgdir}}/opt/selenium/browser_version - echo "\"goog:chromeOptions\": {\"binary\": \"/usr/bin/chromium\"}" > ${{targets.subpkgdir}}/opt/selenium/browser_binary_location + echo "\"goog:chromeOptions\": {\"binary\": \"/usr/bin/chromium-browser\"}" > ${{targets.subpkgdir}}/opt/selenium/browser_binary_location update: enabled: true From 6a311b0264bfea80ea9c2b3477250a6fdba852c4 Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Mon, 4 Mar 2024 13:45:05 -0500 Subject: [PATCH 8/8] fix(chromium): Make chromium available in path Signed-off-by: RJ Sampson --- chromium.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chromium.yaml b/chromium.yaml index 5cdf7a4dc23..67d99583977 100644 --- a/chromium.yaml +++ b/chromium.yaml @@ -180,7 +180,7 @@ pipeline: mv *.pak ${{targets.destdir}}/usr/lib/${{package.name}} mv locales ${{targets.destdir}}/usr/lib/${{package.name}} # links - ln -sf chromium-browser ${{targets.destdir}}/usr/bin/chromium + ln -sf /usr/lib/${{package.name}}/chrome ${{targets.destdir}}/usr/bin/chromium ln -sf /usr/lib/${{package.name}}/chromedriver ${{targets.destdir}}/usr/bin/chromedriver ln -sf chromium-launcher.sh ${{targets.destdir}}/usr/bin/chromium-browser mkdir -p ${{targets.destdir}}/etc/chromium