1#!/bin/sh
2
3# -- check for AppImageKit
4if [ -z $APPIMGTOOL ]; then
5  appimagetool=`locate -l 1 -r appimagetool-x86_64.AppImage$`
6else
7  appimagetool=$APPIMGTOOL
8fi
9
10if test "x$appimagetool" = "x" ; then
11  echo "This script requires AppImageKit"
12  echo "See https://github.com/AppImage/AppImageKit"
13  exit 1
14fi
15
16cwd=`pwd`
17adonthell_exe="adonthell-0.3"
18appname="adonthell-wastesedge"
19
20# -- check arg
21if test "x$1" = "x" ; then
22  echo "Usage: $0 <path/to/Adonthell.AppDir>"
23  exit 1
24fi
25
26if test ! -f $1"/usr/bin/$adonthell_exe" ; then
27  echo "Error: $1 is not the expected Adonthell.AppDir"
28  exit 1
29fi
30
31# -- we need absolute path to Adonthell.AppDir
32cd $1
33appdir=`pwd`
34prefix=$appdir/usr
35APP=$prefix/bin/$adonthell_exe
36cd $cwd
37
38# -- prepare build
39if [ ! -f "configure" ]; then
40  if [ ! -f "autogen.sh" ]; then
41    echo "This script must be run in the wastesedge-0.3.x directory"
42    exit 1
43  fi
44  ./autogen.sh
45fi
46
47# -- build wastesedge
48echo "Configuring $appname. This may take a while ..."
49./configure --with-adonthell-binary=$APP --disable-pyc --bindir=/tmp --mandir=/tmp --datadir=$prefix/share > /dev/null
50if [ $? -ne 0 ]; then
51   exit 1
52fi
53
54# -- compile wastesedge
55make V=0 -j 2
56if [ $? -ne 0 ]; then
57   exit 1
58fi
59
60# -- install wastesedge
61make V=0 install
62if [ $? -ne 0 ]; then
63   exit 1
64fi
65
66# -- copy icon
67cp pixmaps/48x48/apps/wastesedge.png $appdir/wastesedge.png
68
69# -- copy and update .desktop file
70sed "s%$APP wastesedge%$appname%" org.nongnu.wastesedge.desktop > $appdir/org.nongnu.wastesedge.desktop
71
72# -- create a launch script that works inside the app image
73cat > $prefix/bin/$appname <<EOF
74#!/bin/sh
75mypath=\$(dirname \$(readlink -f "\${0}"))
76PYTHONHOME=\$(dirname \${mypath}) "\$mypath/$adonthell_exe" wastesedge
77EOF
78chmod 755 $prefix/bin/$appname
79
80# -- copy AppRun
81wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-x86_64" -O $appdir/AppRun
82chmod a+x $appdir/AppRun
83
84# -- create app image
85version=`$APP -v`
86arch=`uname -i`
87rm Adonthell-$version-$arch.AppImage
88$appimagetool $1 Adonthell-$version-$arch.AppImage
89
90