From 8217b88abe2b5e869ceec7064019df4ab3e2edcb Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Sat, 23 Apr 2022 22:18:26 +0100 Subject: [PATCH 1/2] [testappimage] Support Type 2 AppImages --- testappimage | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) mode change 100644 => 100755 testappimage diff --git a/testappimage b/testappimage old mode 100644 new mode 100755 index 958bae546..1760ad1f4 --- a/testappimage +++ b/testappimage @@ -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 # @@ -152,7 +151,15 @@ if [ "x$MNT" == "x" ] ; then exit 1 fi if [ -f "$2" ] ; then - mount "$2" /tmp/$PREF/union/$MNT -o loop,ro + if [ "$(dd if="$2" bs=4 count=1 status=none)" = "$(printf '\x7FELF')" ] + then + # Type 2 AppImage + mount -t tmpfs "$2" /tmp/$PREF/union/$MNT + cp "$2" "/tmp/$PREF/union/$MNT/AppRun" + else + # Type 1 AppImage + mount "$2" /tmp/$PREF/union/$MNT -o loop,ro + fi elif [ -d "$2" ] ; then mount "$2" /tmp/$PREF/union/$MNT -o bind else From 48d410c174fe9551a8bc168f4ece60230ac7d605 Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Sat, 23 Apr 2022 22:35:29 +0100 Subject: [PATCH 2/2] [testappimage] Support passing arguments to AppImage --- testappimage | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/testappimage b/testappimage index 1760ad1f4..19b093e89 100755 --- a/testappimage +++ b/testappimage @@ -14,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 []" 1>&2 exit 1 fi @@ -64,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 "" @@ -150,21 +152,20 @@ if [ "x$MNT" == "x" ] ; then echo "Could not find free mountpoint" exit 1 fi -if [ -f "$2" ] ; then - if [ "$(dd if="$2" bs=4 count=1 status=none)" = "$(printf '\x7FELF')" ] +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 "$2" /tmp/$PREF/union/$MNT - cp "$2" "/tmp/$PREF/union/$MNT/AppRun" + mount -t tmpfs "none" /tmp/$PREF/union/$MNT + cp "$cmd_name" "/tmp/$PREF/union/$MNT/AppRun" else # Type 1 AppImage - mount "$2" /tmp/$PREF/union/$MNT -o loop,ro + mount "$cmd_name" /tmp/$PREF/union/$MNT -o loop,ro fi -elif [ -d "$2" ] ; then - mount "$2" /tmp/$PREF/union/$MNT -o bind +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 @@ -195,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