appimageTools: fix appimage-exec.sh according to shellcheck
This commit is contained in:
parent
b36d3f2c4a
commit
2a6cd0e6c0
@ -1,15 +1,19 @@
|
|||||||
#!@shell@
|
#!@shell@
|
||||||
if [ ! -z "$DEBUG" ] ; then
|
if [ -n "$DEBUG" ] ; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PATH=@path@
|
#export PATH=@path@
|
||||||
|
PATH="@path@:$PATH"
|
||||||
|
#DEBUG=0
|
||||||
|
|
||||||
# src : AppImage
|
# src : AppImage
|
||||||
# dest : let's unpack() create the directory
|
# dest : let's unpack() create the directory
|
||||||
unpack() {
|
unpack() {
|
||||||
src=$1
|
local src=$1
|
||||||
out=$2
|
local out=$2
|
||||||
|
local appimageSignature=""
|
||||||
|
local appimageType=0
|
||||||
|
|
||||||
# https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63
|
# https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63
|
||||||
eval "$(r2 "$src" -nn -Nqc "p8j 3 @ 8" |
|
eval "$(r2 "$src" -nn -Nqc "p8j 3 @ 8" |
|
||||||
@ -19,16 +23,15 @@ unpack() {
|
|||||||
# check AppImage signature
|
# check AppImage signature
|
||||||
if [[ "$appimageSignature" != "AI" ]]; then
|
if [[ "$appimageSignature" != "AI" ]]; then
|
||||||
echo "Not an appimage."
|
echo "Not an appimage."
|
||||||
exit -1
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$appimageType" in
|
case "$appimageType" in
|
||||||
1) echo "Uncompress $(basename "$src") of Type: $appimageType."
|
1 ) echo "Uncompress $(basename "$src") of type $appimageType."
|
||||||
mkdir "$out"
|
mkdir "$out"
|
||||||
pv "$src" | bsdtar -x -C "$out" -f -
|
pv "$src" | bsdtar -x -C "$out" -f -
|
||||||
;;
|
;;
|
||||||
|
2)
|
||||||
2) echo "Uncompress $(basename "$src") of Type: $appimageType."
|
|
||||||
# This method avoid issues with non executable appimages,
|
# This method avoid issues with non executable appimages,
|
||||||
# non-native packer, packer patching and squashfs-root destination prefix.
|
# non-native packer, packer patching and squashfs-root destination prefix.
|
||||||
|
|
||||||
@ -37,6 +40,7 @@ unpack() {
|
|||||||
offset=$(r2 "$src" -nn -Nqc "pfj.elf_header @ 0" |\
|
offset=$(r2 "$src" -nn -Nqc "pfj.elf_header @ 0" |\
|
||||||
jq 'map({(.name): .value}) | add | .shoff + (.shnum * .shentsize)')
|
jq 'map({(.name): .value}) | add | .shoff + (.shnum * .shentsize)')
|
||||||
|
|
||||||
|
echo "Uncompress $(basename "$src") of type $appimageType @ offset $offset."
|
||||||
unsquashfs -q -d "$out" -o "$offset" "$src"
|
unsquashfs -q -d "$out" -o "$offset" "$src"
|
||||||
chmod go-w "$out"
|
chmod go-w "$out"
|
||||||
;;
|
;;
|
||||||
@ -52,26 +56,25 @@ unpack() {
|
|||||||
apprun() {
|
apprun() {
|
||||||
|
|
||||||
eval "$(rahash2 "$APPIMAGE" -j | jq -r '.[] | @sh "SHA256=\(.hash)"')"
|
eval "$(rahash2 "$APPIMAGE" -j | jq -r '.[] | @sh "SHA256=\(.hash)"')"
|
||||||
echo sha256 = \"$SHA256\"\;
|
echo sha256 = \""$SHA256"\"\;
|
||||||
export APPDIR="${XDG_CACHE_HOME:-$HOME/.cache}/appimage-run/$SHA256"
|
export APPDIR="${XDG_CACHE_HOME:-$HOME/.cache}/appimage-run/$SHA256"
|
||||||
|
|
||||||
#compatibility
|
#compatibility
|
||||||
if [ -x "$APPDIR/squashfs-root" ]; then APPDIR="$APPDIR/squashfs-root"; fi
|
if [ -x "$APPDIR/squashfs-root" ]; then APPDIR="$APPDIR/squashfs-root"; fi
|
||||||
|
|
||||||
if [ ! -x "$APPDIR" ]; then
|
if [ ! -x "$APPDIR" ]; then
|
||||||
mkdir -p $(dirname "$APPDIR")
|
mkdir -p "$(dirname "$APPDIR")"
|
||||||
unpack "$APPIMAGE" "$APPDIR"
|
unpack "$APPIMAGE" "$APPDIR"
|
||||||
|
else echo "$(basename "$APPIMAGE")" installed in "$APPDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $(basename "$APPIMAGE") installed in "$APPDIR"
|
|
||||||
|
|
||||||
export PATH="$PATH:$PWD/usr/bin"
|
export PATH="$PATH:$PWD/usr/bin"
|
||||||
wrap
|
wrap "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap() {
|
wrap() {
|
||||||
|
|
||||||
cd "$APPDIR"
|
cd "$APPDIR" || exit
|
||||||
# quite same in appimageTools
|
# quite same in appimageTools
|
||||||
export APPIMAGE_SILENT_INSTALL=1
|
export APPIMAGE_SILENT_INSTALL=1
|
||||||
|
|
||||||
@ -121,9 +124,11 @@ if [[ $unpack_opt = true ]] && [[ -f "$APPIMAGE" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $apprun_opt = true ]] && [[ -f "$APPIMAGE" ]]; then
|
if [[ $apprun_opt = true ]] && [[ -f "$APPIMAGE" ]]; then
|
||||||
apprun
|
apprun "$@"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $wrap_opt = true ]] && [[ -d "$APPDIR" ]]; then
|
if [[ $wrap_opt = true ]] && [[ -d "$APPDIR" ]]; then
|
||||||
wrap
|
wrap "$@"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user