ungoogled-chromium build script

For discussions about programming and projects not necessarily associated with Porteus.
User avatar
M. Eerie
Moderator
Moderator
Posts: 711
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

ungoogled-chromium build script

Post#1 by M. Eerie » 12 Mar 2025, 13:14

Here's a simple script to download the latest version of ungoogled-chromium and build a module from it.

Code: Select all

#!/bin/bash

APP="ungoogled-chromium"
FILE="/tmp/$APP.tar.xz"
WORKDIR=$(mktemp -d) || exit 1

# Download latest release if necessary
if [ ! -f "$FILE" ]; then
    curl -# -L $(curl -s https://api.github.com/repos/ungoogled-software/ungoogled-chromium-portablelinux/releases/latest | grep "browser_download_url.*tar.xz" | cut -d '"' -f 4) -o "$FILE"
fi
tar -xf "$FILE" -C $WORKDIR

# Prepare APP dir
mkdir -p "$WORKDIR"/{opt,usr/{local/bin,share/{applications,icons/hicolor/48x48/apps}}}
DIR=$(tar -tf "${FILE}" | head -1 | cut -f1 -d"/")
mv "$WORKDIR/$DIR" "$WORKDIR/opt/$APP"

# Create symlinks
echo -e "chrome\nchromium" | xargs -I {} ln -sf /opt/"$APP"/chrome "$WORKDIR"/usr/local/bin/{}

# Create .desktop launcher
cp "$WORKDIR/opt/$APP"/product_logo_48.png "$WORKDIR"/usr/share/icons/hicolor/48x48/apps/ungoogled-chromium.png
cat > "$WORKDIR/usr/share/applications/$APP.desktop" << EOF
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Chromium (ungoogled)
GenericName=Web Browser
Comment=Access the Internet
Exec=chromium %U
StartupNotify=true
Terminal=false
Icon=ungoogled-chromium
Type=Application
Categories=Application;Network;WebBrowser;
MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;
Actions=new-window;new-private-window;

[Desktop Action new-window]
Name=Open New Window
Exec=chromium %U

[Desktop Action new-private-window]
Name=Open New Incognito Window
Exec=chromium --incognito %U
EOF

sudo chown 0:0 -R "$WORKDIR"

# If everything went fine create module and remove leftovers 
if test $? -eq 0 ; then
dir2xzm "$WORKDIR" "$APP-$(date +%Y%m%d).xzm"
echo "Ungoogled Chromium module created in: /tmp/$APP-$(date +%Y%m%d).xzm"
sudo rm "$FILE"
fi
Hope it helps.
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741