4 # Test an AppDir or AppImage on a given ISO or squashfs base system
10 HERE
=$
(dirname $
(readlink
-f "${0}"))
11 export PATH
=$HERE:$HERE/usr
/bin
:$PATH
13 if [ "$1x" == "x" ] ; then
14 echo "Please specify a ISO or squashfs base system to run the AppImage on"
18 if [ "$2x" == "x" ] ; then
19 echo "Please specify an AppDir or AppImage outside the ISO or command inside the ISO to be run"
25 mkdir
-p /tmp
/$PREF/unionfs
/ro
26 mkdir
-p /tmp
/$PREF/unionfs
/root
27 mkdir
-p /tmp
/$PREF/unionfs
/rw
28 mkdir
-p /tmp
/$PREF/union
29 mkdir
-p /tmp
/$PREF/iso
31 # If ISO was specified, then mount it and find contained filesystem
33 if [ ${1: -4} == ".iso" ] ; then
35 mount
-o loop
,ro
"$ISO" /tmp
/$PREF/iso
36 # If there is a squashfs file named $ISO.buildsquash then we overlay-
37 # mount this as well. This can significantly speed up subsequent builds
38 # because dependencies can be installed there. The squashfs file can be
39 # generated by squashing the unionfs/rw directory.
40 if [ -e $ISO.buildsquash
] ; then
41 mount
-o loop
,ro
"$ISO.buildsquash" /tmp
/$PREF/unionfs
/ro
45 # If sfs was provided, then assume it contains a rootfs use just that
47 if [ ${1: -4} == ".sfs" ] ; then
49 mount
-o loop
,ro
"$ISO" /tmp
/$PREF/unionfs
/root
53 echo "===================================================="
57 # In case of Ubuntu-like ISOs
58 if [ -e /tmp
/$PREF/iso
/casper
/filesystem.squashfs
] ; then
59 THEFS
=/tmp
/$PREF/iso
/casper
/filesystem.squashfs
60 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
63 # In case of Fedora-like ISOs
64 if [ -e /tmp
/$PREF/iso
/LiveOS
/squashfs.img
] ; then
65 mount
-o loop
,ro
/tmp
/$PREF/iso
/LiveOS
/squashfs.img
/tmp
/$PREF/iso
/
66 THEFS
=/tmp
/$PREF/iso
/LiveOS
/ext3fs.img ||
exit 1
67 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
70 # In case of debian-like ISOs
71 if [ -e /tmp
/$PREF/iso
/live
/filesystem.squashfs
] ; then
72 THEFS
=/tmp
/$PREF/iso
/live
/filesystem.squashfs
73 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
76 # In case of openSUSE-like ISOs
77 if [ -e /tmp
/$PREF/iso
/*-read-only.
* ] ; then
78 THEFS
=$
(ls /tmp
/$PREF/iso
/*-read-only.
* |
head -n 1)
79 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
86 umount
-l /tmp
/$PREF/union
/var
/lib
/dbus
2>/dev
/null
87 umount
-l /tmp
/$PREF/union
/etc
/resolv.conf
2>/dev
/null
88 umount
-l /tmp
/$PREF/union
/proc
2>/dev
/null
89 umount
-l /tmp
/$PREF/union
/dev
2>/dev
/null
90 umount
-l /tmp
/$PREF/union
/mnt
2>/dev
/null
91 umount
-l /tmp
/$PREF/union
2>/dev
/null
92 umount
-l /tmp
/$PREF/unionfs
/ro
2>/dev
/null
93 umount
-l /tmp
/$PREF/unionfs
/root
2>/dev
/null
94 umount
-l /tmp
/$PREF/iso
2>/dev
/null
95 umount
-l /tmp
/$PREF/iso
2>/dev
/null
96 umount
-l /tmp
/$PREF/iso
2>/dev
/null
97 rm -r /tmp
/$PREF/unionfs
/root
98 rm -r /tmp
/$PREF/unionfs
/rw
99 rm -r /tmp
/$PREF/unionfs
/ro
100 rm -r /tmp
/$PREF/unionfs
101 rm -r /tmp
/$PREF/union
106 unionfs-fuse
-o allow_other
,use_ino
,suid
,dev
,nonempty
-ocow,chroot
=/tmp
/$PREF/unionfs
/,max_files
=32768 /rw
=RW
:/ro
=RO
:/root
=RO
/tmp
/$PREF/union
108 ls /tmp
/$PREF/union
/mnt
>/dev
/null
&& MNT
=/mnt
109 # ls /tmp/$PREF/union/automake >/dev/null && MNT=/automake || echo "" # Puppy
111 if [ "x$MNT" == "x" ] ; then
112 echo "Could not find free mountpoint"
115 if [ -f "$2" ] ; then
116 mount
"$2" /tmp
/$PREF/union
/$MNT -o loop
,ro
117 elif [ -d "$2" ] ; then
118 mount
"$2" /tmp
/$PREF/union
/$MNT -o bind
121 export RUN_COMMAND
=$1
125 cat > /tmp
/$PREF/union
/run.sh
<<EOF
131 pango-querymodules > '/etc/pango/pango.modules' 2>/dev/null # otherwise only squares instead of text
132 [ -f /si-chroot ] && ln -s /lib/ld-lsb.so.3 /lib/ld-linux.so.2
133 LD_LIBRARY_PATH=$MNT/usr/lib:$MNT/usr/lib32:$MNT/usr/lib64:$MNT/lib/:$LD_LIBRARY_PATH ldd $MNT/usr/bin/* $MNT/usr/lib/* 2>/dev/null | grep "not found" | sort | uniq
135 export LANG="en_EN.UTF-8"
136 # export QT_PLUGIN_PATH=./lib/qt4/plugins ###################### !!!
137 #dbus-launch $MNT/AppRun ||
138 export LIBGL_DEBUG=verbose
139 export QT_DEBUG_PLUGINS=1
140 dbus-uuidgen > /var/lib/dbus/machine-id 2>/dev/null # Needed for CentOS 6.7 to launch graphical apps
141 if [ -f $MNT/usr/lib/qt5/plugins/platforms/libqxcb.so ] ; then
142 export LD_LIBRARY_PATH=$MNT/usr/lib/:$LD_LIBRARY_PATH
143 ldd $MNT/usr/lib/qt5/plugins/platforms/libqxcb.so | grep not
145 find $MNT/usr/lib -type f -exec sh -c 'ldd {} | grep "not found"' 2>/dev/null \;
146 if [ $(which $RUN_COMMAND) ] ; then
149 $MNT/AppRun && echo "+++++++++ SUCCESS $ISO $2 +++++++++"
152 chmod a
+x
/tmp
/$PREF/union
/run.sh
153 mount
-t proc proc
/tmp
/$PREF/union
/proc
154 mkdir
-p /tmp
/$PREF/union
/var
/lib
/dbus
155 mount
--bind /dev
/tmp
/$PREF/union
/dev
156 mount
--bind /var
/lib
/dbus
/tmp
/$PREF/union
/var
/lib
/dbus
157 touch /tmp
/$PREF/union
/etc
/resolv.conf ||
echo ""
158 mount
--bind /etc
/resolv.conf
/tmp
/$PREF/union
/etc
/resolv.conf
159 xhost
local: >/dev
/null
2>&1 # otherwise "cannot open display: :0.0"
161 chroot
/tmp
/$PREF/union
/ /run.sh
# $MNT/AppRun