Files
gallery-dl/snap/local/launchers/workaround-snap-arch-triplet-launch
林博仁(Buo-ren Lin) 77551bf01b Implement snap packaging, snaps are universal linux packages (#170)
This patch implements the necessary details to package gallery-dl as a snap that can be run on a broad range of supporting GNU/Linux distributions[1].

[1] https://snapcraft.io/

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
2019-03-01 14:12:41 +01:00

56 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# This launcher sets the Debian-specific multiarch tuples as the SNAP_ARCH_TRIPLET environmental variable for other launchers' ease
set \
-o errexit \
-o errtrace \
-o nounset \
-o pipefail
if ! test -v SNAP_ARCH; then
printf -- \
'%s: Error: This launcher requires SNAP_ARCH environmental variable to be set and exported.\n' \
"$(basename "${BASH_SOURCE[0]}")"
exit 1
fi
declare \
SNAP_ARCH_TRIPLET
# Refer:
#
# * Environmental variables - doc - snapcraft.io
# https://forum.snapcraft.io/t/environmental-variables/7983
# * Multiarch/Tuples - Debian Wiki
# https://wiki.debian.org/Multiarch/Tuples
# NOTE: Only consider Linux archs with the `released` status in Debian for now
case "${SNAP_ARCH}" in
# These are the special cases
amd64)
SNAP_ARCH_TRIPLET=x86_64-linux-gnu
;;
armel)
SNAP_ARCH_TRIPLET=arm-linux-gnueabi
;;
armhf)
SNAP_ARCH_TRIPLET=arm-linux-gnueabihf
;;
arm64)
SNAP_ARCH_TRIPLET=aarch64-linux-gnu
;;
ppc64el)
SNAP_ARCH_TRIPLET=powerpc64le-linux-gnu
;;
# Consider rest of them not exceptions
s390x \
|*)
SNAP_ARCH_TRIPLET="${SNAP_ARCH}"-linux-gnu
;;
esac
export \
SNAP_ARCH_TRIPLET
# Finally run the launching command
exec "${@}"