Skip to content

Commit

Permalink
chore(chromium): Add launcher for passing startup env vars
Browse files Browse the repository at this point in the history
Allows passing startup vars to Chromium via CHROMIUM_USER_FLAGS

Signed-off-by: RJ Sampson <[email protected]>
  • Loading branch information
EyeCantCU committed Mar 4, 2024
1 parent b3e807f commit 49be840
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions chromium.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}/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 Down
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} "$@"
3 changes: 0 additions & 3 deletions chromium/test-chromedriver.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
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
Expand Down

0 comments on commit 49be840

Please sign in to comment.