4 # Test an AppDir or AppImage on a given ISO or squashfs or ext3 base system
6 # - Make compatible with type 2 AppImages (currently we have to first mount them by hand)
7 # - Check https://github.com/FGrose/livecd-tools/blob/liveimage-mount/tools/liveimage-mount
13 xhost
+ # Workaround for: QXcbConnection: Could not connect to display :0
15 HERE
=$
(dirname $
(readlink
-f "${0}"))
16 export PATH
=$HERE:$HERE/usr
/bin
:$PATH
18 if [ "$1x" == "x" ] ; then
19 echo "Please specify a ISO or squashfs base system to run the AppImage on"
23 if [ "$2x" == "x" ] ; then
24 echo "Please specify an AppDir or AppImage outside the ISO or command inside the ISO to be run"
30 mkdir
-p /tmp
/$PREF/unionfs
/ro
31 mkdir
-p /tmp
/$PREF/unionfs
/root
32 mkdir
-p /tmp
/$PREF/unionfs
/rw
33 mkdir
-p /tmp
/$PREF/union
34 mkdir
-p /tmp
/$PREF/iso
35 mkdir
-p /tmp
/$PREF/workdir
37 # openSUSE LEAP 42.2 does not have a tmpfs in /tmp but we need this
38 mount |
grep "/tmp type tmpfs" && sudo mount
-t tmpfs tmpfs
/tmp
/
40 # If ISO was specified, then mount it and find contained filesystem
42 if [ ${1: -4} == ".iso" ] ; then
44 mount
-o loop
,ro
"$ISO" /tmp
/$PREF/iso
45 # If there is a squashfs file named $ISO.buildsquash then we overlay-
46 # mount this as well. This can significantly speed up subsequent builds
47 # because dependencies can be installed there. The squashfs file can be
48 # generated by squashing the unionfs/rw directory.
49 if [ -e $ISO.buildsquash
] ; then
50 mount
-o loop
,ro
"$ISO.buildsquash" /tmp
/$PREF/unionfs
/ro
54 # If sfs was provided, then assume it contains a rootfs use just that
56 if [ ${1: -4} == ".sfs" ] ; then
58 mount
-o loop
,ro
"$ISO" /tmp
/$PREF/unionfs
/root
61 # If ext3 was provided, then assume it contains a rootfs use just that
63 if [ ${1: -4} == "ext3" ] ; then
65 mount
-o loop
,ro
"$ISO" /tmp
/$PREF/unionfs
/root
69 echo "===================================================="
73 # In case of Ubuntu-like ISOs
74 if [ -e /tmp
/$PREF/iso
/casper
/filesystem.squashfs
] ; then
75 THEFS
=/tmp
/$PREF/iso
/casper
/filesystem.squashfs
76 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
79 # In case of Fedora-like ISOs
80 if [ -e /tmp
/$PREF/iso
/LiveOS
/squashfs.img
] ; then
81 mount
-o loop
,ro
/tmp
/$PREF/iso
/LiveOS
/squashfs.img
/tmp
/$PREF/iso
/
82 if [ -e /tmp
/$PREF/iso
/LiveOS
/ext3fs.img
] ; then
83 # F23 and below use https://github.com/rhinstaller/livecd-tools
84 THEFS
=/tmp
/$PREF/iso
/LiveOS
/ext3fs.img ||
exit 1
86 if [ -e /tmp
/$PREF/iso
/LiveOS
/rootfs.img
] ; then
87 # F24 and above use https://github.com/rhinstaller/lorax and livemedia-creator
88 THEFS
=/tmp
/$PREF/iso
/LiveOS
/rootfs.img ||
exit 1
90 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
93 # In case of debian-like ISOs
94 if [ -e /tmp
/$PREF/iso
/live
/filesystem.squashfs
] ; then
95 THEFS
=/tmp
/$PREF/iso
/live
/filesystem.squashfs
96 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
99 # In case of openSUSE-like ISOs
100 if [ -e /tmp
/$PREF/iso
/*-read-only.
* ] ; then
101 THEFS
=$
(ls /tmp
/$PREF/iso
/*-read-only.
* |
head -n 1)
102 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
105 # In case of puppy-like ISOs
106 if [ -e /tmp
/$PREF/iso
/puppy_
*.sfs
] ; then
107 THEFS
=$
(ls /tmp
/$PREF/iso
/puppy_
*.sfs |
head -n 1)
108 mount
"$THEFS" /tmp
/$PREF/unionfs
/root
-o loop
,ro ||
exit 1
115 umount
-l /tmp
/$PREF/union
/var
/lib
/dbus
2>/dev
/null
116 umount
-l /tmp
/$PREF/union
/etc
/resolv.conf
2>/dev
/null
117 umount
-l /tmp
/$PREF/union
/proc
2>/dev
/null
118 umount
-l /tmp
/$PREF/union
/dev
2>/dev
/null
119 umount
-l /tmp
/$PREF/union
/mnt
2>/dev
/null
120 umount
-l /tmp
/$PREF/union
2>/dev
/null
121 umount
-l /tmp
/$PREF/unionfs
/ro
2>/dev
/null
122 umount
-l /tmp
/$PREF/unionfs
/root
2>/dev
/null
123 umount
-l /tmp
/$PREF/iso
2>/dev
/null
124 umount
-l /tmp
/$PREF/iso
2>/dev
/null
125 umount
-l /tmp
/$PREF/iso
2>/dev
/null
126 rm -r /tmp
/$PREF/workdir
127 rm -r /tmp
/$PREF/unionfs
/root
128 rm -r /tmp
/$PREF/unionfs
/rw
129 rm -r /tmp
/$PREF/unionfs
/ro
130 rm -r /tmp
/$PREF/unionfs
131 rm -r /tmp
/$PREF/union
136 # Kernel 4.0 or newer required
137 kernel_major
=$
(uname
-r | cut
-d .
-f 1)
138 if [ ! $kernel_major -ge 4 ] ; then
139 echo "Falling back to unionfs-fuse because kernel is not 4.x or newer"
140 echo "This can potentially be unreliable"
141 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
143 echo "Using OverlayFS because kernel is 4.x or newer"
144 sudo mount
-t overlay
-o lowerdir
=/tmp
/$PREF/unionfs
/ro
:/tmp
/$PREF/unionfs
/root
,upperdir
=/tmp
/$PREF/unionfs
/rw
,workdir
=/tmp
/$PREF/workdir none
/tmp
/$PREF/union
147 ls /tmp
/$PREF/union
/mnt
>/dev
/null
&& MNT
=/mnt
148 # ls /tmp/$PREF/union/automake >/dev/null && MNT=/automake || echo "" # Puppy
150 if [ "x$MNT" == "x" ] ; then
151 echo "Could not find free mountpoint"
154 if [ -f "$2" ] ; then
155 mount
"$2" /tmp
/$PREF/union
/$MNT -o loop
,ro
156 elif [ -d "$2" ] ; then
157 mount
"$2" /tmp
/$PREF/union
/$MNT -o bind
160 export RUN_COMMAND
=$1
164 cat > /tmp
/$PREF/union
/run.sh
<<EOF
170 pango-querymodules > '/etc/pango/pango.modules' 2>/dev/null # otherwise only squares instead of text
171 [ -f /si-chroot ] && ln -s /lib/ld-lsb.so.3 /lib/ld-linux.so.2
172 # 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
174 export LANG="en_EN.UTF-8"
175 # export QT_PLUGIN_PATH=./lib/qt4/plugins ###################### !!!
176 #dbus-launch $MNT/AppRun ||
177 export LIBGL_DEBUG=verbose
178 export QT_DEBUG_PLUGINS=1
179 export LC_ALL=C.UTF-8
180 mkdir -p /usr/share/appimagekit
181 touch /usr/share/appimagekit/no_desktopintegration
182 dbus-uuidgen --ensure ; dbus-launch # Needed for CentOS 6.7 to launch apps that talk to dbus
183 if [ -f $MNT/usr/lib/qt5/plugins/platforms/libqxcb.so ] ; then
184 export LD_LIBRARY_PATH=$MNT/usr/lib/:$LD_LIBRARY_PATH
185 ##ldd $MNT/usr/lib/qt5/plugins/platforms/libqxcb.so | grep not
187 ##find $MNT/usr/lib -type f -exec sh -c 'ldd {} | grep "not found"' 2>/dev/null \;
188 if [ $(which $RUN_COMMAND) ] ; then
191 $MNT/AppRun && echo "+++++++++ SUCCESS $ISO $2 +++++++++"
194 chmod a
+x
/tmp
/$PREF/union
/run.sh
195 mount
-t proc proc
/tmp
/$PREF/union
/proc
196 mkdir
-p /tmp
/$PREF/union
/var
/lib
/dbus
197 mount
--bind /dev
/tmp
/$PREF/union
/dev
198 mount
--bind /var
/lib
/dbus
/tmp
/$PREF/union
/var
/lib
/dbus
199 touch /tmp
/$PREF/union
/etc
/resolv.conf ||
echo ""
200 mount
--bind /etc
/resolv.conf
/tmp
/$PREF/union
/etc
/resolv.conf
201 xhost
local: >/dev
/null
2>&1 # otherwise "cannot open display: :0.0"
203 chroot
/tmp
/$PREF/union
/ /run.sh
# $MNT/AppRun