git.iko.soy/typeable/nixpkgs
on master help sign in
appimage-run: parse readelf's output in C locale

fixes #101137

commit4d51f95638a8ca1d1c8f911a9f6e6baf34b9a7c0 authorSymphorien Gibol <symphorien+git@xlumurb.eu> dateTue 24 Nov 2020, 13:55 (6 years ago) parent2247d82
1 file changed+7−3
pkgs/build-support/appimage/appimage-exec.sh+7−3
pkgs/build-support/appimage/appimage-exec.sh+7−3
@@ -1,4 +1,6 @@
11#!@shell@
2+# shellcheck shell=bash
3+
24if [ -n "$DEBUG" ] ; then
35 set -x
46fi
@@ -13,8 +15,10 @@ unpack() {
1315 local out="$2"
1416
1517 # https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63
16− local appimageSignature=$(readelf -h "$src" | awk 'NR==2{print $10$11;}')
17− local appimageType=$(readelf -h "$src" | awk 'NR==2{print $12;}')
18+ local appimageSignature;
19+ appimageSignature="$(LC_ALL=C readelf -h "$src" | awk 'NR==2{print $10$11;}')"
20+ local appimageType;
21+ appimageType="$(LC_ALL=C readelf -h "$src" | awk 'NR==2{print $12;}')"
1822
1923 # check AppImage signature
2024 if [ "$appimageSignature" != "4149" ]; then
@@ -35,7 +39,7 @@ unpack() {
3539
3640 # multiarch offset one-liner using same method as AppImage
3741 # 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}')
42+ offset=$(LC_ALL=C 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}')
3943 echo "Uncompress $(basename "$src") of type $appimageType @ offset $offset"
4044 unsquashfs -q -d "$out" -o "$offset" "$src"
4145 chmod go-w "$out"