Botspot / pi-apps

Raspberry Pi App Store for Open Source Projects
GNU General Public License v3.0
2k stars 206 forks source link

Better Chromium breaks "Chromium" debian package #2497

Closed ghost closed 10 months ago

ghost commented 10 months ago

Confirmations

What happened?

There are two Chromium packages in RPI repo. Chromium-browser and Chromium. Better Chromium does not work with the "Chromium" package.

Description

Due to the mouse cursor sizing issues of the Chromium-browser package (under wayland), i wanted to try if the same issue was on Chromium (debian's own package) package as well. Et voila, it wasn't. So i wanted to continue to use the Chromium instead of Chromium-browser. I removed both the chromium-browser and better chromium. Then i installed Chromium only. And on top of it i installed Better Chromium. It did not give me any error messages during the install however, once i tried to run Chromium, it did not start. First it seems like starting then nothing comes on screen. So i assume it crashes while initializing. Removing the Better Chromium fixes this and it runs without it.

I peeked at the installation script of Better Chromium and it does list a number of different folders for different Chromium installations. Chromium package's installation folder is not listed as it is in "etc/chromium". There is however also a chromium.d folder in there.

I could enable chromium sync by setting some environment variables however, i still can not play DRM content in Chromium package. Widevine package is installed.

So can we get Better Chromium to work with the debian Chromium package?

What are your system specs (run the following command in your terminal)?

OS: Debian GNU/Linux 12 (bookworm)
OS architecture: 64-bit
Last updated Pi-Apps on: 12/06/2023
Latest Pi-Apps version: 12/07/2023
Kernel: aarch64 6.1.0-rpi7-rpi-2712
Device model: Raspberry Pi 5 Model B Rev 1.0
SOC identifier: bcm2712
Cpu name: Cortex-A76
Ram size: 4.04 GB
Raspberry Pi OS image version: 2023-10-10
Language: en_US.UTF-8

(Recommended) Error log? Terminal output? Debug messages?

No response

github-actions[bot] commented 10 months ago

Hello there 👋 Thanks for submitting your first issue to the Pi-Apps project! We'll try to get back to you as soon as possible. In the meantime, we encourage you join our Discord server, where you can ask any questions you might have.

Please respond as soon as possible if a Pi-Apps maintainer requests more information from you. Stale issues will be closed after a lengthy period of time with no response.

Botspot commented 10 months ago

Better Chromium will create a variety of different files in the /etc/chromium.d folder. I'm fairly certain this is the right folder for the chromium package. I think that only some of the customization scripts are causing a crash - that it is not Better Chromium itself but a subset of the options it provides.

Try this: Please install Better Chromium and only enable one of the options, while disabling all others. Then check if chromium launches. My prediction is that all of the options will work except for one or two of them. Rather than install and then uninstall Better Chromium repeatedly, it would save a bit of time to just run this in a terminal repeatedly:

~/pi-apps/manage install 'Better Chromium'

In other words, Better Chromium is designed to have its install script run multiple times in a row without issue.

ghost commented 10 months ago

Thanks for the quick reply. I only selected "widevine" during the install and Chromium refused to run after that. The only modification that Better Chromium did was adding this zzz something (sorry for the confusion) file into the chromium.d folder which included these lines:

This script combines multiple invocations of --enable-features and --disable-features into one argument so that Chromium does not ignore any.

Written by Botspot for the Pi-Apps Better Chromium script.

IFS=' ' enable='' disable='' new_flags='' for word in $CHROMIUM_FLAGS ;do if [[ "$word" == '--enable-features=' ]];then enable+=",${word/--enable-features=/}" elif [[ "$word" == '--disable-features=' ]];then enable+=",${word/--disable-features=/}" else new_flags+=" $word" fi done

remove initial comma

enable="${enable/,/}" disable="${disable/,/}"

CHROMIUM_FLAGS="$new_flags" [ ! -z "$enable" ] && CHROMIUM_FLAGS+=" --enable-features=$enable" [ ! -z "$disable" ] && CHROMIUM_FLAGS+=" --disable-features=$disable"

Botspot commented 10 months ago

So if you enable everything but widevine, does chromium work?

ghost commented 10 months ago

This time i selected only "chromium sync" option and again, Chromium failed to start after that. I uninstalled Better Chromium and it starts again. How can i get an error log for Chromium? I tried various dmesg entries but they do not give me any errors.

Botspot commented 10 months ago

Just run chromium in a terminal.

ghost commented 10 months ago

I think we are getting somewhere. Here is the output when Better Chromium is installed:

/usr/bin/chromium: 77: test: /etc/chromium.d/exte: unexpected operator expr: syntax error: unexpected argument ‘sio’ /usr/bin/chromium: 77: .: cannot open /etc/chromium.d/exte: No such file

theofficialgman commented 10 months ago

Due to the mouse cursor sizing issues of the Chromium-browser package (under wayland), i wanted to try if the same issue was on Chromium (debian's own package) package as well.

Debian's default chromium package is almost certainly not using wayland by default, but x11 through xwayland. The chromium-browser package from Raspberry Pi LTD is HIGHLY modified for performance, wayland support under piOS wayfire, HW video decoding, accelerated rendering, etc. You can go to the chrome://gpu/ webpage and scroll down till you see the OZONE platform.

theofficialgman commented 10 months ago

There are two Chromium packages in RPI repo. Chromium-browser and Chromium. Better Chromium does not work with the "Chromium" package.

No, there is one Chromium package in the RPI repo (http://archive.raspberrypi.com), that is the raspberry pi LTD customized and built chromium-browser package

In the official debian repo (http://deb.debian.org/debian), there is the chromium package which is packaged by debian.

Two different packages but not both in the RPI repo.

theofficialgman commented 10 months ago

I think we are getting somewhere. Here is the output when Better Chromium is installed:

/usr/bin/chromium: 77: test: /etc/chromium.d/exte: unexpected operator expr: syntax error: unexpected argument ‘sio’ /usr/bin/chromium: 77: .: cannot open /etc/chromium.d/exte: No such file

related to https://github.com/Botspot/pi-apps/issues/2410

@sudo-splinter-cell please provide the information requested from that user in this comment: https://github.com/Botspot/pi-apps/issues/2410#issuecomment-1679984020 as well as the information requested here https://github.com/Botspot/pi-apps/issues/2410#issuecomment-1692508543

ghost commented 10 months ago

There are two Chromium packages in RPI repo. Chromium-browser and Chromium. Better Chromium does not work with the "Chromium" package.

No, there is one Chromium package in the RPI repo (http://archive.raspberrypi.com), that is the raspberry pi LTD customized and built chromium-browser package

In the official debian repo (http://deb.debian.org/debian), there is the chromium package which is packaged by debian.

Two different packages but not both in the RPI repo.

Sorry for the blunder. However, i can not see the mouse cursor on the "RPI improved" Chromium which is why i have been soul searching in other repositories. I filed a bug report in their github so we'll see if anything will change. Wayland has been nothing but a train of issues for me from the start when bookworm came with it default. I prefer X11 whenever i can. I am on a RPI 5 now and performance is not really an issue with this beast.

ghost commented 10 months ago

Here is the information requested:

grep . -r /etc/chromium.d

/etc/chromium.d/default-flags:# A set of command line flags that we want to set by default.
/etc/chromium.d/default-flags:# Do not hide any extensions in the about:extensions dialog
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --show-component-extension-options"
/etc/chromium.d/default-flags:# Enable GPU rasterization.
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-gpu-rasterization"
/etc/chromium.d/default-flags:# Don't display any warnings about not being the default browser
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --no-default-browser-check"
/etc/chromium.d/default-flags:# Disable pinging
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-pings"
/etc/chromium.d/default-flags:# Disable the builtin media router (bug #833477)
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --media-router=0"
/etc/chromium.d/README:Any files placed in this directory will be sourced prior to executing chromium.
/etc/chromium.d/extensions:# remote extensions on by default
/etc/chromium.d/extensions:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-remote-extensions"
/etc/chromium.d/extensions:# load all of the extensions installed to /usr/share/chromium/extensions
/etc/chromium.d/extensions:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --load-extension=`ls -dm /usr/share/chromium/extensions/* 2>/dev/null | tr -d '\n'`"

cat /usr/bin/chromium

#!/bin/sh

# Chromium launcher

# Authors:
#  Fabien Tassin <fta@sofaraway.org>
# License: GPLv2 or later

APPNAME=chromium

GDB=/usr/bin/gdb
LIBDIR=/usr/lib/$APPNAME
BUILD_DIST="12.2"

usage () {
  echo "$APPNAME [-h|--help] [-g|--debug] [--temp-profile] [options] [URL]"
  echo
  echo "        -g or --debug              Start within $GDB"
  echo "        -h or --help               This help screen"
  echo "        --temp-profile             Start with a new and temporary profile"
  echo "        --enable-remote-extensions Allow extensions from remote sites"
  echo
  echo " Other supported options are:"
  MANWIDTH=80 man chromium | sed -e '1,/OPTIONS/d; /ENVIRONMENT/,$d'
  echo " See 'man chromium' for more details"
}

display_msg() {
  if [ -z "$DISPLAY" ]; then
    echo "$@" 1>&2
  else
    xmessage "$@"
  fi
}

nosse3="\
The hardware on this system lacks support for the sse3 instruction set.
The upstream chromium project no longer supports this configuration.
For more information, please read and possibly provide input to their
bug tracking system at http://crbug.com/1123353"

noneon="\
The hardware on this system lacks support for NEON SIMD extensions.
We now require NEON or equivalent architecture extensions on ARM-based
machines. See https://lists.debian.org/debian-devel/2023/09/msg00175.html
for more information."

case `uname -m` in
    i386|i586|i686|x86_64)
        # Check whether this system supports SSE3 (aka PNI)
        if ! grep -q 'sse3\|pni' /proc/cpuinfo; then
            display_msg "$nosse3"
            exit 1
        fi
        ;;
    armv7l)
        # Check whether this system supports NEON or ASIMD. Even though there
        # could be ARMv8 systems without ASIMD, we're far more likely to hit
        # v8 hardware emulating v7 systems with buggy VMs; so don't even
        # bother checking armv8l for now. If we do check in the future, they
        # advertise 'asimd' instead of 'neon'.
        if ! grep -q 'neon\|asimd' /proc/cpuinfo; then
            display_msg "$noneon"
            exit 1
        fi
        ;;
esac

# Clean up old crash reports (see https://bugs.debian.org/1015931)
# after 30 days.
test -d "$HOME/.config/chromium/Crash Reports/pending/" && \
  find "$HOME/.config/chromium/Crash Reports/pending/" -mtime +30 \
  \( -name "*.meta" -o -name "*.dmp" \) -exec rm \{\} \;

# Source additional settings
for file in /etc/chromium.d/*; do
  test $file = /etc/chromium.d/README || expr $file : .*\.dpkg > /dev/null || . $file
done

# Use the /usr/bin helper script for generated launchers
if test -z "$CHROME_WRAPPER"; then
    export CHROME_WRAPPER="/usr/bin/$APPNAME"
fi

# Set the correct file name for the desktop file
export CHROME_DESKTOP="chromium.desktop"

# Set CHROME_VERSION_EXTRA text, which is displayed in the About dialog
DIST=`cat /etc/debian_version`
export CHROME_VERSION_EXTRA="built on Debian $BUILD_DIST, running on Debian $DIST"

want_debug=0
want_temp_profile=0
while [ $# -gt 0 ]; do
  case "$1" in
    -h | --help | -help )
      usage
      exit 0 ;;
    -g | --debug )
      want_debug=1
      shift ;;
    --temp-profile )
      want_temp_profile=1
      shift ;;
    --enable-remote-extensions )
      CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-remote-extensions"
      shift ;;
    -- ) # Stop option prcessing
      shift
      break ;;
    * )
      break ;;
  esac
done

# Whitelist installed extensions that are specified via --load-extension
if [ -z "$(echo $CHROMIUM_FLAGS | grep \\-\\-enable-remote-extensions)" ]; then
  export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-background-networking"
  export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-extensions-except=$(echo $CHROMIUM_FLAGS | tr ' ' \\n | grep \\-\\-load-extension | cut -d= -f2 | tr \\n ,)"
fi

if [ $want_temp_profile -eq 1 ] ; then
  TEMP_PROFILE=`mktemp -d`
  echo "Using temporary profile: $TEMP_PROFILE"
  CHROMIUM_FLAGS="$CHROMIUM_FLAGS --user-data-dir=$TEMP_PROFILE"
fi

if [ $want_debug -eq 1 ] ; then
  if [ ! -x $GDB ] ; then
    echo "Sorry, can't find usable $GDB. Please install it."
    exit 1
  fi
  tmpfile=`mktemp /tmp/chromiumargs.XXXXXX` || { echo "Cannot create temporary file" >&2; exit 1; }
  trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
  echo "set args $CHROMIUM_FLAGS --single-process ${1+"$@"}" > $tmpfile
  echo "# Env:"
  echo "#     LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
  echo "#                PATH=$PATH"
  echo "#            GTK_PATH=$GTK_PATH"
  echo "#      CHROMIUM_FLAGS=$CHROMIUM_FLAGS"
  echo "$GDB $LIBDIR/$APPNAME -x $tmpfile"
  $GDB "$LIBDIR/$APPNAME" -x $tmpfile
  if [ $want_temp_profile -eq 1 ] ; then
    rm -rf $TEMP_PROFILE
  fi
  exit $?
else
  if [ $want_temp_profile -eq 0 ] ; then
    exec $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@"
  else
    # we can't exec here as we need to clean-up the temporary profile
    $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@"
    rm -rf $TEMP_PROFILE
  fi
fi
ghost commented 10 months ago

By the way, the above outputs are "without" better chromium installed. Should i install better chromium and then get those ?

theofficialgman commented 10 months ago

yes, please post the output with better chromium installed

theofficialgman commented 10 months ago

I think I already discovered the issue regardless

#!/bin/sh

# Chromium launcher

debian chromium package uses sh for its startup wrapper script which does not support all bashisms. chromium-browser (which is based on ubuntu's old chromium-browser package) uses bash and does not have this issue.

Trying to run the script generated with better chromium with sh results in 19: Bad substitution while bash has no such error. sh does not support this type of variable substitution

specifically the issue starts here:

$ enable=''
$ enable="${enable/,/}"
/bin/sh: 2: Bad substitution
$ 

which then causes cascading failures

ghost commented 10 months ago

Here the same outputs "with" Better Chromium installed.

 /etc/chromium.d/enable_sync:#!/bin/bash
/etc/chromium.d/enable_sync:profiles="$(find "$HOME/.config/chromium/" -maxdepth 1 -type d '(' -name Default -o -name 'Profile *' ')' | sed 's+.*/++g')"
/etc/chromium.d/enable_sync:IFS=$'\n'
/etc/chromium.d/enable_sync:for profile in $profiles ;do
/etc/chromium.d/enable_sync:  [ ! -f "$HOME/.config/chromium/$profile/Preferences" ] && continue
/etc/chromium.d/enable_sync:  sed -i 's/"signin":{"allowed":false}/"signin":{"allowed":true,"allowed_on_next_startup":true}/g' "$HOME/.config/chromium/$profile/Preferences"
/etc/chromium.d/enable_sync:  sed -i 's/"signin":{"allowed":false,"allowed_on_next_startup":false}/"signin":{"allowed":true,"allowed_on_next_startup":true}/g' "$HOME/.config/chromium/$profile/Preferences"
/etc/chromium.d/enable_sync:  sed -i 's/"signin":{"AccountReconcilor":{"kDiceMigrationOnStartup2":true},"allowed":false,"allowed_on_next_startup":false}/"signin":{"AccountReconcilor":{"kDiceMigrationOnStartup2":true},"allowed":true,"allowed_on_next_startup":true}/g' "$HOME/.config/chromium/$profile/Preferences"
/etc/chromium.d/enable_sync:done
/etc/chromium.d/zzzz_combine_values:#This script combines multiple invocations of --enable-features and --disable-features into one argument so that Chromium does not ignore any.
/etc/chromium.d/zzzz_combine_values:#Written by Botspot for the Pi-Apps Better Chromium script.
/etc/chromium.d/zzzz_combine_values:IFS=' '
/etc/chromium.d/zzzz_combine_values:enable=''
/etc/chromium.d/zzzz_combine_values:disable=''
/etc/chromium.d/zzzz_combine_values:new_flags=''
/etc/chromium.d/zzzz_combine_values:for word in $CHROMIUM_FLAGS ;do
/etc/chromium.d/zzzz_combine_values:  if [[ "$word" == '--enable-features='* ]];then
/etc/chromium.d/zzzz_combine_values:    enable+=",${word/--enable-features=/}"
/etc/chromium.d/zzzz_combine_values:  elif [[ "$word" == '--disable-features='* ]];then
/etc/chromium.d/zzzz_combine_values:    enable+=",${word/--disable-features=/}"
/etc/chromium.d/zzzz_combine_values:  else
/etc/chromium.d/zzzz_combine_values:    new_flags+=" $word"
/etc/chromium.d/zzzz_combine_values:  fi
/etc/chromium.d/zzzz_combine_values:done
/etc/chromium.d/zzzz_combine_values:#remove initial comma
/etc/chromium.d/zzzz_combine_values:enable="${enable/,/}"
/etc/chromium.d/zzzz_combine_values:disable="${disable/,/}"
/etc/chromium.d/zzzz_combine_values:CHROMIUM_FLAGS="$new_flags"
/etc/chromium.d/zzzz_combine_values:[ ! -z "$enable" ] && CHROMIUM_FLAGS+=" --enable-features=$enable"
/etc/chromium.d/zzzz_combine_values:[ ! -z "$disable" ] && CHROMIUM_FLAGS+=" --disable-features=$disable"
/etc/chromium.d/performance_improvements:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --ignore-gpu-blacklist --enable-checker-imaging --cc-scroll-animation-duration-in-seconds=0.6 --disable-quic --enable-tcp-fast-open --enable-experimental-canvas-features --enable-scroll-prediction --enable-simple-cache-backend --max-tiles-for-interest-area=512 --num-raster-threads=4 --default-tile-height=512 --enable-features=VaapiVideoDecoder,VaapiVideoEncoder --disable-features=UseChromeOSDirectVideoDecoder --enable-accelerated-video-decode --enable-low-res-tiling --process-per-site"
/etc/chromium.d/default-flags:# A set of command line flags that we want to set by default.
/etc/chromium.d/default-flags:# Do not hide any extensions in the about:extensions dialog
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --show-component-extension-options"
/etc/chromium.d/default-flags:# Enable GPU rasterization.
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-gpu-rasterization"
/etc/chromium.d/default-flags:# Don't display any warnings about not being the default browser
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --no-default-browser-check"
/etc/chromium.d/default-flags:# Disable pinging
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-pings"
/etc/chromium.d/default-flags:# Disable the builtin media router (bug #833477)
/etc/chromium.d/default-flags:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --media-router=0"
/etc/chromium.d/apikeys:# API keys found in chromium source code https://chromium.googlesource.com/experimental/chromium/src/+/b08bf82b0df37d15a822b478e23ce633616ed959/google_apis/google_api_keys.cc
/etc/chromium.d/apikeys:export GOOGLE_API_KEY="AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k"
/etc/chromium.d/apikeys:export GOOGLE_DEFAULT_CLIENT_ID="77185425430.apps.googleusercontent.com"
/etc/chromium.d/apikeys:export GOOGLE_DEFAULT_CLIENT_SECRET="OTJgUOQcT7lO7GsGZq2G4IlT"
/etc/chromium.d/README:Any files placed in this directory will be sourced prior to executing chromium.
/etc/chromium.d/extensions:# remote extensions on by default
/etc/chromium.d/extensions:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-remote-extensions"
/etc/chromium.d/extensions:# load all of the extensions installed to /usr/share/chromium/extensions
/etc/chromium.d/extensions:export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --load-extension=`ls -dm /usr/share/chromium/extensions/* 2>/dev/null | tr -d '\n'`"
#!/bin/sh

# Chromium launcher

# Authors:
#  Fabien Tassin <fta@sofaraway.org>
# License: GPLv2 or later

APPNAME=chromium

GDB=/usr/bin/gdb
LIBDIR=/usr/lib/$APPNAME
BUILD_DIST="12.2"

usage () {
  echo "$APPNAME [-h|--help] [-g|--debug] [--temp-profile] [options] [URL]"
  echo
  echo "        -g or --debug              Start within $GDB"
  echo "        -h or --help               This help screen"
  echo "        --temp-profile             Start with a new and temporary profile"
  echo "        --enable-remote-extensions Allow extensions from remote sites"
  echo
  echo " Other supported options are:"
  MANWIDTH=80 man chromium | sed -e '1,/OPTIONS/d; /ENVIRONMENT/,$d'
  echo " See 'man chromium' for more details"
}

display_msg() {
  if [ -z "$DISPLAY" ]; then
    echo "$@" 1>&2
  else
    xmessage "$@"
  fi
}

nosse3="\
The hardware on this system lacks support for the sse3 instruction set.
The upstream chromium project no longer supports this configuration.
For more information, please read and possibly provide input to their
bug tracking system at http://crbug.com/1123353"

noneon="\
The hardware on this system lacks support for NEON SIMD extensions.
We now require NEON or equivalent architecture extensions on ARM-based
machines. See https://lists.debian.org/debian-devel/2023/09/msg00175.html
for more information."

case `uname -m` in
    i386|i586|i686|x86_64)
        # Check whether this system supports SSE3 (aka PNI)
        if ! grep -q 'sse3\|pni' /proc/cpuinfo; then
            display_msg "$nosse3"
            exit 1
        fi
        ;;
    armv7l)
        # Check whether this system supports NEON or ASIMD. Even though there
        # could be ARMv8 systems without ASIMD, we're far more likely to hit
        # v8 hardware emulating v7 systems with buggy VMs; so don't even
        # bother checking armv8l for now. If we do check in the future, they
        # advertise 'asimd' instead of 'neon'.
        if ! grep -q 'neon\|asimd' /proc/cpuinfo; then
            display_msg "$noneon"
            exit 1
        fi
        ;;
esac

# Clean up old crash reports (see https://bugs.debian.org/1015931)
# after 30 days.
test -d "$HOME/.config/chromium/Crash Reports/pending/" && \
  find "$HOME/.config/chromium/Crash Reports/pending/" -mtime +30 \
  \( -name "*.meta" -o -name "*.dmp" \) -exec rm \{\} \;

# Source additional settings
for file in /etc/chromium.d/*; do
  test $file = /etc/chromium.d/README || expr $file : .*\.dpkg > /dev/null || . $file
done

# Use the /usr/bin helper script for generated launchers
if test -z "$CHROME_WRAPPER"; then
    export CHROME_WRAPPER="/usr/bin/$APPNAME"
fi

# Set the correct file name for the desktop file
export CHROME_DESKTOP="chromium.desktop"

# Set CHROME_VERSION_EXTRA text, which is displayed in the About dialog
DIST=`cat /etc/debian_version`
export CHROME_VERSION_EXTRA="built on Debian $BUILD_DIST, running on Debian $DIST"

want_debug=0
want_temp_profile=0
while [ $# -gt 0 ]; do
  case "$1" in
    -h | --help | -help )
      usage
      exit 0 ;;
    -g | --debug )
      want_debug=1
      shift ;;
    --temp-profile )
      want_temp_profile=1
      shift ;;
    --enable-remote-extensions )
      CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-remote-extensions"
      shift ;;
    -- ) # Stop option prcessing
      shift
      break ;;
    * )
      break ;;
  esac
done

# Whitelist installed extensions that are specified via --load-extension
if [ -z "$(echo $CHROMIUM_FLAGS | grep \\-\\-enable-remote-extensions)" ]; then
  export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-background-networking"
  export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-extensions-except=$(echo $CHROMIUM_FLAGS | tr ' ' \\n | grep \\-\\-load-extension | cut -d= -f2 | tr \\n ,)"
fi

if [ $want_temp_profile -eq 1 ] ; then
  TEMP_PROFILE=`mktemp -d`
  echo "Using temporary profile: $TEMP_PROFILE"
  CHROMIUM_FLAGS="$CHROMIUM_FLAGS --user-data-dir=$TEMP_PROFILE"
fi

if [ $want_debug -eq 1 ] ; then
  if [ ! -x $GDB ] ; then
    echo "Sorry, can't find usable $GDB. Please install it."
    exit 1
  fi
  tmpfile=`mktemp /tmp/chromiumargs.XXXXXX` || { echo "Cannot create temporary file" >&2; exit 1; }
  trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
  echo "set args $CHROMIUM_FLAGS --single-process ${1+"$@"}" > $tmpfile
  echo "# Env:"
  echo "#     LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
  echo "#                PATH=$PATH"
  echo "#            GTK_PATH=$GTK_PATH"
  echo "#      CHROMIUM_FLAGS=$CHROMIUM_FLAGS"
  echo "$GDB $LIBDIR/$APPNAME -x $tmpfile"
  $GDB "$LIBDIR/$APPNAME" -x $tmpfile
  if [ $want_temp_profile -eq 1 ] ; then
    rm -rf $TEMP_PROFILE
  fi
  exit $?
else
  if [ $want_temp_profile -eq 0 ] ; then
    exec $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@"
  else
    # we can't exec here as we need to clean-up the temporary profile
    $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@"
    rm -rf $TEMP_PROFILE
  fi
fi
theofficialgman commented 10 months ago

basically all scripts would need to be rewritten in better chromium to support sh only execution. that really is not possible as sh lacks many features that are needed for the scripts that better chromium makes use of (or if possible it would be very unnecessarily difficult).

It would be much easier if upstream debian switched to using bash as their execution for the chromium wrapper script.

I am in favor of switching "Better Chromium" to throw a user error if the detected startup script for chromium uses sh and not bash

Botspot commented 10 months ago

I am fairly sure only my zzzz_combine_values script was not sh-compliant. All of the other scripts were extremely simple and should require no further modification. @sudo-splinter-cell, try running this command to replace the problematic script with this new one and report back if it solves your issue?

cat << "EOF" | sudo tee "/etc/chromium.d/zzzz_combine_values" >/dev/null
#This script combines multiple invocations of --enable-features and --disable-features into one argument so that Chromium does not ignore any.
#Written by Botspot for the Pi-Apps Better Chromium script.

IFS=' '
enable=''
disable=''
new_flags=''
for word in $CHROMIUM_FLAGS ;do
  if echo "$word" grep -q '^--enable-features=' ;then
    enable="${enable},$(echo "$word" | sed 's/^--enable-features=//g')"
  elif echo "$word" grep -q '^--disable-features=' ;then
    disable="${disable},$(echo "$word" | sed 's/^--disable-features=//g')"
  else
    new_flags="$new_flags $word"
  fi
done

#remove initial comma
enable="$(echo "$enable" | sed 's/^,//g')"
disable="$(echo "$disable" | sed 's/^,//g')"

CHROMIUM_FLAGS="$new_flags"
[ ! -z "$enable" ] && CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-features=$enable"
[ ! -z "$disable" ] && CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-features=$disable"
EOF

Just copy and paste this whole code block into your terminal at once.

theofficialgman commented 10 months ago

@Botspot I was concerned that enable_sync would need to be rewritten to be sh compliant as well. As previously posted, the chromium wrapper script starts the script with . $file which basically means "run the script $file in the current terminal process". That basically means that this /etc/chromium.d/enable_sync:#!/bin/bash is a no-op. I was concerned that sh would not properly execute the for loop with the IFS=$'\n' statement but it seems fine.

ghost commented 10 months ago

So shall i do this after installing Better Chromium?

Botspot commented 10 months ago

Yes.

ghost commented 10 months ago

I get the same error.

/usr/bin/chromium: 77: test: /etc/chromium.d/exte: unexpected operator
expr: syntax error: unexpected argument ‘sio’
/usr/bin/chromium: 77: .: cannot open /etc/chromium.d/exte: No such file
Botspot commented 10 months ago

OK I will try to install chromium myself to solve the problem later today.

Botspot commented 10 months ago

I ended up needing to change a few more places, but overall it was pretty easy.

@sudo-splinter-cell, please allow Better Chromium to update through Pi-Apps, and your issue should be resolved now. Check out the changes I made in commit https://github.com/Botspot/pi-apps/commit/1c5abf13f93491d545b76ea2c43f1580b606c651.

ghost commented 10 months ago

I ended up needing to change a few more places, but overall it was pretty easy.

@sudo-splinter-cell, please allow Better Chromium to update through Pi-Apps, and your issue should be resolved now. Check out the changes I made in commit 1c5abf1.

Good news is, yes this works. Better Chromium is installed and Chromium (debian) package runs. However, probably irrelevant to Better Chromium's functionality, spotify web player still tells me that the browser is not properly set up to play DRM protected content. Widevine package is installed by the way. I know that "Chromium-browser" probably has some extra thrown in to be enabled in that regard. So i am going to dismiss that. And i will assume that all the other functionalities of Better Chromium are working with both packages (other than widevine).

Botspot commented 10 months ago

I know that "Chromium-browser" probably has some extra thrown in to be enabled in that regard. So i am going to dismiss that.

Yes it does. Just now I've changed the logic to only show the widevine option if chromium-browser is installed.