Last active
October 14, 2019 14:11
-
-
Save ckujau/b3291d2a25a5d250747a256b49c182a5 to your computer and use it in GitHub Desktop.
Workaround for #1630
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# (c)2018 Christian Kujau <lists@nerdbynature.de> | |
# | |
# A (far too complicated) script to get the Ubuntu package of | |
# Signal on a non-Debian based Desktop. | |
# | |
# Packages for rpm-based linux distributions like Fedora #1630 | |
# https://github.com/signalapp/Signal-Desktop/issues/1630 | |
# | |
BASEURL=https://updates.signal.org/desktop/apt | |
DIST=dists/xenial | |
# Kill it with fire | |
_die() { | |
echo "$@" | |
exit 1 | |
} | |
case $1 in | |
download) | |
TEMP=$(mktemp -d) | |
;; | |
install) | |
[ -d "$2" ] && TEMP="$2" || TEMP=$(mktemp -d) | |
INSTALL=1 | |
;; | |
*) | |
_die "Usage: $(basename $0) [download|install] || [install] (DIR)" | |
;; | |
esac | |
cd "$TEMP" || _die "Could not change to directory $TEMP" | |
# Download & verify the InRelease file | |
if [ ! -f InRelease ]; then | |
curl -sLO "$BASEURL"/"$DIST"/InRelease || _die "Failed to download InRelease" | |
fi | |
gpg --verify InRelease || _die "Signature verification failed" | |
SHA256=$(grep -A5 ^SHA256 InRelease | awk '/main\/binary-amd64\/Packages.bz2/ {print $1}') | |
# Download & verify the Packages.bz2 file | |
if [ ! -f Packages.bz2 ]; then | |
curl -sLO "$BASEURL"/"$DIST"/main/binary-amd64/Packages.bz2 \ | |
|| _die "Failed to download Packages.bz2" | |
fi | |
sha256sum Packages.bz2 | grep -q $SHA256 || _die "Checksum verification of Packages.bz2 failed" | |
echo "### Available versions:" | |
bzip2 -dc Packages.bz2 | grep ^Version | sort -n && echo | |
# Try to find out the newest version | |
VER=$(bzip2 -dc Packages.bz2 | awk '/^Version:/ {print $NF}' | sort -n | head -1) | |
# There must be a better way to do this... | |
bzip2 -dc Packages.bz2 | grep -m1 -A20 'Package: signal-desktop-beta' | \ | |
awk '/^Filename/ || /^Version/ || /SHA256/ {print $2}' | xargs echo | while read v f s; do | |
# echo "### DEBUG: v: $v f: $f s: $s" | |
[ $v = $VER ] || continue | |
echo "### Downloading ${f}..." | |
if [ ! -f "$(basename "$f")" ]; then | |
curl -LO "$BASEURL"/"$f" || _die "Failed to download package" | |
fi | |
sha256sum signal-desktop*amd64.deb | grep -q $s || _die "Checksum verification of package failed" | |
done | |
# Extract the data part of the Debian package | |
ar x signal-desktop*amd64.deb data.tar.xz || _die "Package extraction failed" | |
# Install | |
if [ "$INSTALL" = 1 ]; then | |
echo "### Installing in /opt/Signal Beta..." | |
sudo rm -r "/opt/Signal Beta.old" | |
sudo mv -v "/opt/Signal Beta" "/opt/Signal Beta.old" | |
sudo tar -C / -xJf data.tar.xz ./opt | |
tar -C / --transform="s|usr|$HOME/.local|" -xJf data.tar.xz ./usr/share/icons/ | |
sudo chown -R root:root "/opt/Signal Beta" | |
sudo ln -svf "/opt/Signal Beta/signal-desktop-beta" /usr/local/bin/signal-desktop-beta | |
rm -r InRelease Packages.bz2 signal-desktop*amd64.deb data.tar.xz "$TEMP" | |
else | |
echo "Files can be found in "$TEMP"" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment