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