appimage: unify extract functions
This commit is contained in:
parent
ebaedb5377
commit
04037d1e03
@ -1,26 +1,20 @@
|
|||||||
{ stdenv, libarchive, radare2, jq, buildFHSUserEnv, squashfsTools, writeScript }:
|
{ stdenv, libarchive, radare2, jq, buildFHSUserEnv, squashfsTools, writeScript }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
# Both extraction functions could be unified, but then
|
|
||||||
# it would depend on libmagic to correctly identify ISO 9660s
|
|
||||||
|
|
||||||
extractType1 = { name, src }: stdenv.mkDerivation {
|
extract = { name, src }: stdenv.mkDerivation {
|
||||||
name = "${name}-extracted";
|
name = "${name}-extracted";
|
||||||
inherit src;
|
inherit src;
|
||||||
|
nativeBuildInputs = [ radare2 libarchive jq squashfsTools ];
|
||||||
nativeBuildInputs = [ libarchive ];
|
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
|
# https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63
|
||||||
|
appimageType=$(r2 $src -nn -Nqc "p8 3 @ 8")
|
||||||
|
case "$appimageType" in
|
||||||
|
414901)
|
||||||
mkdir $out
|
mkdir $out
|
||||||
bsdtar -x -C $out -f $src
|
bsdtar -x -C $out -f $src;;
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
extractType2 = { name, src }: stdenv.mkDerivation {
|
414902)
|
||||||
name = "${name}-extracted";
|
|
||||||
inherit src;
|
|
||||||
|
|
||||||
nativeBuildInputs = [ radare2 jq squashfsTools ];
|
|
||||||
buildCommand = ''
|
|
||||||
install $src ./appimage
|
install $src ./appimage
|
||||||
|
|
||||||
# multiarch offset one-liner using same method as AppImage
|
# multiarch offset one-liner using same method as AppImage
|
||||||
@ -30,10 +24,17 @@ rec {
|
|||||||
|
|
||||||
unsquashfs -o $offset ./appimage
|
unsquashfs -o $offset ./appimage
|
||||||
|
|
||||||
cp -rv squashfs-root $out
|
cp -rv squashfs-root $out;;
|
||||||
|
|
||||||
|
# 414903) get prepared, https://github.com/TheAssassin/type3-runtime
|
||||||
|
*) echo "Unsupported AppImage Signature: $appimageType";;
|
||||||
|
esac
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extractType1 = extract;
|
||||||
|
extractType2 = extract;
|
||||||
|
|
||||||
wrapAppImage = args@{ name, src, extraPkgs, ... }: buildFHSUserEnv (defaultFhsEnvArgs // {
|
wrapAppImage = args@{ name, src, extraPkgs, ... }: buildFHSUserEnv (defaultFhsEnvArgs // {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user