arrgh
[citadel.git] / appimage / build_appimage.sh
1 #!/bin/bash
2
3 rm -vf citadel-*appimage
4
5 export CITADEL_BUILD_DIR=/tmp/citadel-build-$$
6 export WEBCIT_BUILD_DIR=/tmp/webcit-build-$$
7 rm -fr $CITADEL_BUILD_DIR $WEBCIT_BUILD_DIR
8
9 # libcitadel has to be built in a "real" library directory
10 pushd ../libcitadel || exit 1
11 make distclean 2>/dev/null
12 ./bootstrap || exit 2
13 ./configure || exit 3
14 make || exit 4
15 make install || exit 5
16 popd
17
18 # Build the Citadel server
19 pushd ../citadel || exit 6
20 make distclean 2>/dev/null
21 ./bootstrap || exit 7
22 ./configure --prefix=$CITADEL_BUILD_DIR || exit 8
23 make || exit 9
24 make install || exit 10
25 popd
26
27 # Build WebCit
28 pushd ../webcit || exit 11
29 make distclean 2>/dev/null
30 ./bootstrap || exit 12
31 ./configure --prefix=$WEBCIT_BUILD_DIR || exit 13
32 make || exit 14
33 make install || exit 15
34 popd
35
36 # Clear out any old versions in the AppDir
37 rm -frv citadel.AppDir/usr
38 mkdir -p citadel.AppDir/usr/bin
39 mkdir -p citadel.AppDir/usr/lib
40
41 # Copy over all the libraries we used
42 for bin in $CITADEL_BUILD_DIR/citserver $WEBCIT_BUILD_DIR/webcit $CITADEL_BUILD_DIR/ctdlmigrate
43 do
44         #for x in `ldd $bin | awk ' { print $3 } ' | grep -v -e '^$' | grep -v 'libc.so' | grep -v 'libpthread.so' | grep -v 'libresolv.so'`
45         for x in `ldd $bin | awk ' { print $3 } ' | grep -v -e '^$' `
46         do
47                 cp -v -L $x citadel.AppDir/usr/lib/
48         done
49 done
50 ldconfig -v citadel.AppDir/usr/lib
51
52 # Copy over some utilities
53 for bin in db_dump db_load db_recover
54 do
55         cp `which $bin` citadel.AppDir/usr/bin/ || exit 16
56 done
57
58 # Install the Citadel Server application tree
59 mkdir -p citadel.AppDir/usr/local/citadel || exit 17
60 rsync -va $CITADEL_BUILD_DIR/ ./citadel.AppDir/usr/local/citadel/ || exit 18
61
62 # Install the WebCit application tree
63 mkdir -p citadel.AppDir/usr/local/webcit || exit 19
64 rsync -va $WEBCIT_BUILD_DIR/ ./citadel.AppDir/usr/local/webcit/ || exit 20
65
66 # Remove the build directories
67 rm -fr $CITADEL_BUILD_DIR $WEBCIT_BUILD_DIR
68
69 cc ctdlvisor.c -o citadel.AppDir/usr/bin/ctdlvisor || exit 21
70
71 CPU=`uname -m`
72 basefilename=citadel-`date +%s`
73 if [ $CPU == x86_64 ] ; then
74         export ARCH=x86_64
75 elif [ $CPU == armv7l ] ; then
76         export ARCH=ARM
77 fi
78 echo ARCH: $ARCH
79 echo CPU: $CPU
80 appimagetool citadel.AppDir/ ${basefilename}-${CPU}.appimage