diff options
author | Bignaux Ronan <ronan@aimao.org> | 2020-03-04 05:40:19 +0100 |
---|---|---|
committer | Bignaux Ronan <ronan@aimao.org> | 2020-03-04 13:57:58 +0100 |
commit | 92b36343a8ea29de1bd6d2c3920323ce8b4a1ea8 (patch) | |
tree | d55df775e103659e25b500b41aaee1cbd362992f /pkgs/build-support/appimage | |
parent | 04037d1e03b9ee08f1b56ab3480e1ffdafd88155 (diff) |
appimage: split checks between appimageSignature and appimageType
Diffstat (limited to 'pkgs/build-support/appimage')
-rw-r--r-- | pkgs/build-support/appimage/default.nix | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/pkgs/build-support/appimage/default.nix b/pkgs/build-support/appimage/default.nix index f8e5206bbb5a2..7459a028f076e 100644 --- a/pkgs/build-support/appimage/default.nix +++ b/pkgs/build-support/appimage/default.nix @@ -8,13 +8,23 @@ rec { nativeBuildInputs = [ radare2 libarchive jq squashfsTools ]; buildCommand = '' # https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63 - appimageType=$(r2 $src -nn -Nqc "p8 3 @ 8") + eval $(r2 $src -nn -Nqc "p8j 3 @ 8" | + jq -r '{appimageSignature: (.[:-1]|implode), appimageType: .[-1]}| + @sh "appimageSignature=\(.appimageSignature) appimageType=\(.appimageType)"') + + # check AppImage signature + if [[ $appimageSignature != "AI" ]]; then + echo "Not an appimage." + exit + fi + case "$appimageType" in - 414901) + 1) mkdir $out - bsdtar -x -C $out -f $src;; + bsdtar -x -C $out -f $src + ;; - 414902) + 2) install $src ./appimage # multiarch offset one-liner using same method as AppImage @@ -22,12 +32,11 @@ rec { offset=$(r2 ./appimage -nn -Nqc "pfj.elf_header @ 0" |\ jq 'map({(.name): .value}) | add | .shoff + (.shnum * .shentsize)') - unsquashfs -o $offset ./appimage - - cp -rv squashfs-root $out;; + unsquashfs -q -d $out -o $offset ./appimage + ;; - # 414903) get prepared, https://github.com/TheAssassin/type3-runtime - *) echo "Unsupported AppImage Signature: $appimageType";; + # 3) get ready, https://github.com/TheAssassin/type3-runtime + *) echo "Unsupported AppImage Type: $appimageType";; esac ''; }; |