···
# dest : let's unpack() create the directory
16
-
local appimageSignature=""
17
-
local appimageType=0
# https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63
20
-
eval "$(r2 -nn -Nqc "p8j 3 @ 8" "$src"|
21
-
jq -r '{appimageSignature: (.[:-1]|implode), appimageType: .[-1]}|
22
-
@sh "appimageSignature=\(.appimageSignature) appimageType=\(.appimageType)"')"
16
+
local appimageSignature=$(readelf -h "$src" | awk 'NR==2{print $10$11;}')
17
+
local appimageType=$(readelf -h "$src" | awk 'NR==2{print $12;}')
# check AppImage signature
25
-
if [[ "$appimageSignature" != "AI" ]]; then
26
-
echo "Not an appimage."
20
+
if [ "$appimageSignature" != "4149" ]; then
21
+
echo "Not an AppImage file"
31
-
1 ) echo "Uncompress $(basename "$src") of type $appimageType."
33
-
pv "$src" | bsdtar -x -C "$out" -f -
36
-
# This method avoid issues with non executable appimages,
37
-
# non-native packer, packer patching and squashfs-root destination prefix.
27
+
echo "Uncompress $(basename "$src") of type $appimageType"
29
+
pv "$src" | bsdtar -x -C "$out" -f -
39
-
# multiarch offset one-liner using same method as AppImage
40
-
# see https://gist.github.com/probonopd/a490ba3401b5ef7b881d5e603fa20c93
41
-
offset=$(r2 -nn -Nqc "pfj.elf_header @ 0" "$src"|\
42
-
jq 'map({(.name): .value}) | add | .shoff + (.shnum * .shentsize)')
33
+
# This method avoid issues with non executable appimages,
34
+
# non-native packer, packer patching and squashfs-root destination prefix.
44
-
echo "Uncompress $(basename "$src") of type $appimageType @ offset $offset."
45
-
unsquashfs -q -d "$out" -o "$offset" "$src"
36
+
# multiarch offset one-liner using same method as AppImage
37
+
# see https://gist.github.com/probonopd/a490ba3401b5ef7b881d5e603fa20c93
38
+
offset=$(readelf -h "$src" | awk 'NR==13{e_shoff=$5} NR==18{e_shentsize=$5} NR==19{e_shnum=$5} END{print e_shoff+e_shentsize*e_shnum}')
39
+
echo "Uncompress $(basename "$src") of type $appimageType @ offset $offset"
40
+
unsquashfs -q -d "$out" -o "$offset" "$src"
49
-
# 3) get ready, https://github.com/TheAssassin/type3-runtime
50
-
*) echo Unsupported AppImage Type: "$appimageType"
45
+
# get ready, https://github.com/TheAssassin/type3-runtime
48
+
echo Unsupported AppImage Type: "$appimageType"
echo "$(basename "$src") is now installed in $out"
59
-
eval "$(rahash2 "$APPIMAGE" -j | jq -r '.[] | @sh "SHA256=\(.hash)"')"
60
-
echo sha256 = \""$SHA256"\"\;
57
+
SHA256=$(sha256sum "$APPIMAGE" | awk '{print $1}')
export APPDIR="${XDG_CACHE_HOME:-$HOME/.cache}/appimage-run/$SHA256"
···
while getopts "x:w:dh" option; do
105
-
case "${option}" in
113
-
export APPDIR=${OPTARG}
102
+
case "${option}" in
110
+
export APPDIR=${OPTARG}
123
-
shift $((OPTIND-1))
119
+
shift "$((OPTIND-1))"
125
-
if [[ $wrap_opt = true ]] && [[ -d "$APPDIR" ]]; then
121
+
if [ -n "$wrap_opt" ] && [ -d "$APPDIR" ]; then
···
133
-
if [[ $unpack_opt = true ]] && [[ -f "$APPIMAGE" ]]; then
129
+
if [ -n "$unpack_opt" ] && [ -f "$APPIMAGE" ]; then
unpack "$APPIMAGE" "$APPDIR"
138
-
if [[ $apprun_opt = true ]] && [[ -f "$APPIMAGE" ]]; then
134
+
if [ -n "$apprun_opt" ] && [ -f "$APPIMAGE" ]; then