Update README.md
[appimagekit/gsi.git] / AppImageAssistant.AppDir / testappimage
bloba52f2e19db06c9996fa07ef1065ba97101a65fe5
1 #!/bin/bash
4 # Test an AppDir or AppImage on a given ISO or squashfs base system
7 set -e
8 # set -x
10 HERE=$(dirname $(readlink -f "${0}"))
11 export PATH=$HERE:$PATH
13 if [ "$1x" == "x" ] ; then
14 echo "Please specify a ISO or squashfs base system to run the AppImage on"
15 exit 1
18 if [ "$2x" == "x" ] ; then
19 echo "Please specify an AppDir or AppImage to be run"
20 exit 1
23 mkdir -p /tmp/unionfs/root
24 mkdir -p /tmp/unionfs/rw
25 mkdir -p /tmp/union
26 mkdir -p /tmp/iso
28 # If ISO was specified, then mount it and find contained filesystem
29 THEFS="$1"
30 if [ ${1: -4} == ".iso" ] ; then
31 ISO="$1"
32 mount -o loop,ro "$ISO" /tmp/iso
35 # In case of Ubuntu-like ISOs
36 if [ -e /tmp/iso/casper/filesystem.squashfs ] ; then
37 THEFS=/tmp/iso/casper/filesystem.squashfs
38 mount "$THEFS" /tmp/unionfs/root -o loop,ro || exit 1
41 # In case of Fedora-like ISOs
42 if [ -e /tmp/iso/LiveOS/squashfs.img ] ; then
43 mount -o loop,ro /tmp/iso/LiveOS/squashfs.img /tmp/iso/
44 THEFS=/tmp/iso/LiveOS/ext3fs.img || exit 1
45 mount "$THEFS" /tmp/unionfs/root -o loop,ro || exit 1
48 trap atexit EXIT
50 atexit()
51 { set +e
52 umount -l /tmp/union/var/lib/dbus 2>/dev/null
53 umount -l /tmp/union/etc/resolv.conf 2>/dev/null
54 umount -l /tmp/union/proc 2>/dev/null
55 umount -l /tmp/union/boot 2>/dev/null
56 # umount -l /tmp/union/automake 2>/dev/null # Puppy
57 umount -l /tmp/union 2>/dev/null
58 umount -l /tmp/unionfs/root 2>/dev/null
59 umount -l /tmp/iso 2>/dev/null
60 umount -l /tmp/iso 2>/dev/null
61 umount -l /tmp/iso 2>/dev/null
62 sudo killall unionfs-fuse
63 rm -r /tmp/unionfs/root
64 rm -r /tmp/unionfs/rw
65 rm -r /tmp/unionfs
66 rm -r /tmp/union
67 rm -r /tmp/iso
71 unionfs-fuse -o allow_other,use_ino,suid,dev,nonempty -ocow,chroot=/tmp/unionfs/,max_files=32768 /rw=RW:/root=RO /tmp/union
73 ls /tmp/union/boot >/dev/null && MNT=/boot
74 # ls /tmp/union/automake >/dev/null && MNT=/automake || echo "" # Puppy
76 if [ "x$MNT" == "x" ] ; then
77 echo "Could not find free mountpoint"
78 exit 1
81 if [ -f "$2" ] ; then
82 mount "$2" /tmp/union/$MNT -o loop
83 elif [ -d "$2" ] ; then
84 mount "$2" /tmp/union/$MNT -o bind
87 cat > /tmp/union/run.sh <<EOF
88 #!/bin/sh
89 cat /etc/*release
90 echo ""
91 rm -rf /etc/pango
92 mkdir -p /etc/pango
93 pango-querymodules > '/etc/pango/pango.modules' # otherwise only squares instead of text
94 [ -f /si-chroot ] && ln -s /lib/ld-lsb.so.3 /lib/ld-linux.so.2
95 echo ""
96 echo "===================================================="
97 echo ""
98 LD_LIBRARY_PATH=$MNT/usr/lib:$MNT/lib/:$LD_LIBRARY_PATH ldd $MNT/usr/bin/* $MNT/usr/lib/* 2>/dev/null | grep "not found" | sort | uniq
99 echo ""
100 echo "===================================================="
101 echo ""
102 export HOME="/root"
103 export LANG="en_EN.UTF-8"
104 # export QT_PLUGIN_PATH=./lib/qt4/plugins ###################### !!!
105 dbus-launch $MNT/AppRun || $MNT/AppRun
107 chmod a+x /tmp/union/run.sh
108 mount -t proc proc /tmp/union/proc
109 mount --bind /var/lib/dbus /tmp/union/var/lib/dbus
110 touch /tmp/union/etc/resolv.conf || echo ""
111 mount --bind /etc/resolv.conf /tmp/union/etc/resolv.conf
112 xhost local: # otherwise "cannot open display: :0.0"
113 echo ""
114 echo "===================================================="
115 echo ""
116 chroot /tmp/union/ /run.sh # $MNT/AppRun
117 echo ""
118 echo "===================================================="
119 echo ""
120 exit $?