Skip to content

Commit

Permalink
Merge pull request #13921 from EyeCantCU/chromium-fixes
Browse files Browse the repository at this point in the history
fix(chromium): Add crashpad handler, enable ldd, add en-US locale to base package, and implement more tests
  • Loading branch information
ajayk authored Mar 4, 2024
2 parents 53ba435 + 6a311b0 commit 405febd
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
27 changes: 22 additions & 5 deletions chromium.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -160,12 +161,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
Expand All @@ -178,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}}/chrome ${{targets.destdir}}/usr/bin/chromium
ln -sf /usr/lib/${{package.name}}/chromedriver ${{targets.destdir}}/usr/bin/chromedriver
ln -sf chromium-browser ${{targets.destdir}}/usr/bin/chromium
ln -sf chromium-launcher.sh ${{targets.destdir}}/usr/bin/chromium-browser
mkdir -p ${{targets.destdir}}/etc/chromium
- uses: strip
Expand All @@ -202,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:
Expand All @@ -212,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
Expand All @@ -223,7 +228,19 @@ test:
environment:
contents:
packages:
- grep
- posix-libc-utils
- py3-pip
- python3
- 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
# Test ChromeDriver functionality
pip3 install selenium
python3 ./test-chromedriver.py
32 changes: 32 additions & 0 deletions chromium/chromium-launcher.sh
Original file line number Diff line number Diff line change
@@ -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} "$@"
14 changes: 14 additions & 0 deletions chromium/test-chromedriver.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 405febd

Please sign in to comment.