Skip to content
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

[testappimage] Support for Type 2 AppImages and passing arguments #1192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions testappimage
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#
# Test an AppDir or AppImage on a given ISO or squashfs or ext3 base system
# TODO:
# - Make compatible with type 2 AppImages (currently we have to first mount them by hand)
# - Check https://github.com/FGrose/livecd-tools/blob/liveimage-mount/tools/liveimage-mount
#

Expand All @@ -15,13 +14,9 @@ xhost + # Workaround for: QXcbConnection: Could not connect to display :0
HERE=$(dirname $(readlink -f "${0}"))
export PATH=$HERE:$HERE/usr/bin:$PATH

if [ "$1x" == "x" ] ; then
echo "Please specify a ISO or squashfs base system to run the AppImage on"
exit 1
fi

if [ "$2x" == "x" ] ; then
echo "Please specify an AppDir or AppImage outside the ISO or command inside the ISO to be run"
if [ $# -lt 2 ]
then
echo "Usage: $0 <iso name> <AppImage name> [<AppImage arguments>]" 1>&2
exit 1
fi

Expand Down Expand Up @@ -65,6 +60,12 @@ if [ ${1: -4} == "ext3" ] ; then
mount -o loop,ro "$ISO" /tmp/$PREF/unionfs/root
fi

shift

cmd_all="$@"
cmd_name="$1"
shift

echo ""
echo "===================================================="
echo ""
Expand Down Expand Up @@ -151,13 +152,20 @@ if [ "x$MNT" == "x" ] ; then
echo "Could not find free mountpoint"
exit 1
fi
if [ -f "$2" ] ; then
mount "$2" /tmp/$PREF/union/$MNT -o loop,ro
elif [ -d "$2" ] ; then
mount "$2" /tmp/$PREF/union/$MNT -o bind
if [ -f "$cmd_name" ] ; then
if [ "$(dd if="$cmd_name" bs=4 count=1 status=none)" = "$(printf '\x7FELF')" ]
then
# Type 2 AppImage
mount -t tmpfs "none" /tmp/$PREF/union/$MNT
cp "$cmd_name" "/tmp/$PREF/union/$MNT/AppRun"
else
# Type 1 AppImage
mount "$cmd_name" /tmp/$PREF/union/$MNT -o loop,ro
fi
elif [ -d "$cmd_name" ] ; then
mount "$cmd_name" /tmp/$PREF/union/$MNT -o bind
else
shift
export RUN_COMMAND=$1
export RUN_COMMAND=$cmd_name
export RUN_INSIDE=$@
fi

Expand Down Expand Up @@ -188,7 +196,7 @@ fi
if [ $(which $RUN_COMMAND) ] ; then
exec $RUN_INSIDE
else
$MNT/AppRun && echo "+++++++++ SUCCESS $ISO $2 +++++++++"
$MNT/AppRun $@ && echo "+++++++++ SUCCESS $ISO $cmd_all +++++++++"
fi
EOF
chmod a+x /tmp/$PREF/union/run.sh
Expand Down