New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
appimage-run: unify appimageTools and appimage-run #81833
Conversation
Just for the avoidance of doubt, the payload applications inside different AppImages may require the |
To help people figure out what AppRun setup in the env, i start write some appimage-run hook, here an example :
|
I don't quite understand what you are doing there but you seem to have a plan ;-) |
@probonopd : in order to make binaries working on an appimage, we have often to patchelf/patchshebang them with our nixos tools. To use the autopatch* , we have to move them in the right directories so we change the structure of the appimage anyway. I first remove the need to use the packer in a previous PR, then in this, i turn some nix to make easily the fixing of an appimage. Edit : here i don't yet make any change to how the stuff runs currently. I try to keep really mirrored features exept removing /squashfs-root/ in appimage-run cache directories allowing by unsquashfs instead of packer extract feature option. |
This sounds good to me in principle, but I don't know enough about appimage to actually review. |
@timokau : could it be you missed add "$@" to 19e075b#diff-ae84e7b07459c504b804db2a1f54636dR51 ? |
Yeah, looks like I missed that. Good catch! |
Thanks @timokau , i don't touch that immediatly since it's the current behavior. i really think we would enjoy something like i said, but i'd like to listen people feeling.
|
with this last commit, appimage-run doesn't need special (and hidden) option to run the script, so default behavior is how appimage-run users use it, so now it's easier to understand and hack. Edit, so now, you can even do that : This illustrate that we can now improve the wrap() for both in same time. |
local appimageType=0 | ||
|
||
# https://github.com/AppImage/libappimage/blob/ca8d4b53bed5cbc0f3d0398e30806e0d3adeaaab/src/libappimage/utils/MagicBytesChecker.cpp#L45-L63 | ||
eval "$(r2 "$src" -nn -Nqc "p8j 3 @ 8" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this just extract 3 bytes at file offset 8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes and it could be done with hexdump or xdd or dd. but here there is a homogeneity with r2+jq for carving elf file by design choice.
|
||
# multiarch offset one-liner using same method as AppImage | ||
# see https://gist.github.com/probonopd/a490ba3401b5ef7b881d5e603fa20c93 | ||
offset=$(r2 "$src" -nn -Nqc "pfj.elf_header @ 0" |\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not having a radare2 as an dependency would be nice, it might be good enough for now, given that getting this sort of information might be hard to extract using other tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already discussed and merge on previous PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still haven't done any actual testing
|
||
apprun() { | ||
|
||
eval "$(rahash2 "$APPIMAGE" -j | jq -r '.[] | @sh "SHA256=\(.hash)"')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference/advantage to sha256="$(sha256sum "$APPIMAGE")"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to do homogeneity here around r2+jq, so despite the way that you can easily change the hash algo, not an immediate interest. But people reading the script to modify would perhaps be more interesting to use rarun2 and others tools in radare2 if they see some subliminal examples around the code ....
else echo "$(basename "$APPIMAGE")" installed in "$APPDIR" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else echo "$(basename "$APPIMAGE")" installed in "$APPDIR" | |
fi | |
else | |
echo "$(basename "$APPIMAGE")" installed in "$APPDIR" | |
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed
fi | ||
|
||
PATH="@path@:$PATH" | ||
apprun_opt=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is never changed from true, and could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but i thought to remove the -w option and rely on $1 type, then appimage-run <appimage|appimage directory> , but i'd more interested to do that after discussion how to write a useful wrap() function. i make test with rarun2 and will come with proposal. For now thanks to close the PR here, look if you would merge appimage-run in appimageTools, and finish wrapTypeX removing .
PATH="@path@:$PATH" | ||
apprun_opt=true | ||
|
||
#DEBUG=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a left-over?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more or less, the work is not yet finish, but i hope the step by step would help people understand the way i try to refactoring this stuff.
#DEBUG=0 | ||
|
||
# src : AppImage | ||
# dest : let's unpack() create the directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# dest : let's unpack() create the directory | |
# out : target directory, assumed to not exist yet |
|
||
case "$appimageType" in | ||
1 ) echo "Uncompress $(basename "$src") of type $appimageType." | ||
mkdir "$out" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps pass -p
to handle $out
existing already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i could not do that for unsquashfs, so i prefer not. the latest directory should not exist, that's a limitation of unsquashfs -d .
src = ./appimage-exec.sh; | ||
isExecutable = true; | ||
dir = "bin"; | ||
path = with pkgs; lib.makeBinPath [ pv ripgrep file radare2 libarchive jq squashfsTools coreutils bash ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path = with pkgs; lib.makeBinPath [ pv ripgrep file radare2 libarchive jq squashfsTools coreutils bash ]; | |
path = lib.makeBinPath [ pv ripgrep file radare2 libarchive jq squashfsTools coreutils bash ]; |
*) echo "Unsupported AppImage Type: $appimageType";; | ||
esac | ||
''; | ||
appimage-exec = pkgs.substituteAll { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appimage-exec = pkgs.substituteAll { | |
appimage-exec = substituteAll { |
@@ -0,0 +1,142 @@ | |||
#!@shell@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a .sh
suffix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's better to set in nixpkgs with the prefix, then it has no prefix when we use it through the wrapper.
wrap() { | ||
|
||
cd "$APPDIR" || exit | ||
# quite same in appimageTools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment loses its meaning after this PR is merged
@tilpner sorry. I saw your review too late after I already tested and merged it. |
appimage-run: unify appimageTools and appimage-run (cherry picked from commit 115a8e8)
cd $APPDIR | ||
exec ./AppRun "$@" | ||
''; | ||
runScript = "appimage-exec.sh -w ${src}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a --
to prevent appimage-exec.sh
from stealing further hyphenated arguments intended for the real executable: #128927
Motivation for this change
appimage-run :
/home/genesis/tmp/''/home/genesis/.cache/appimage-run/37e15e46f3c5fb6958c22c752050f4effc096745afb3c4f6a97a5c98607bfbe6/squashfs-root/AppRun: line 101: 10002 Segmentation fault (core dumped) pidof appimaged 2> /dev/null
avoiding AppRun in both would avoid such useless issue, as issue on packer. I'm working on it too.
one goal here is provide an improved appimage-run closer to appimageTools so the first really help to package with the second.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)cc @tilpner
cc @timokau
cc @jtojnar
cc @volth