began making the client AppImage-aware
[citadel.git] / appimage / build_appimage.sh
1 #!/bin/bash
2
3 # Work from the directory this script is in
4 APPIMAGE_BUILD_DIR=$(dirname $(readlink -f $0))
5 cd $APPIMAGE_BUILD_DIR || exit 28
6 echo APPIMAGE_BUILD_DIR is `pwd`
7
8 # Remove old versions
9 rm -vf citadel-*appimage
10
11 export CITADEL_BUILD_DIR=/tmp/citadel-build-$$
12 export WEBCIT_BUILD_DIR=/tmp/webcit-build-$$
13
14 # libcitadel has to be built in a "real" library directory
15 pushd ../libcitadel || exit 1
16 make distclean 2>/dev/null
17 ./bootstrap || exit 2
18 ./configure || exit 3
19 make || exit 4
20 make install || exit 5
21 popd
22
23 # Build the text mode client
24 pushd ../textclient || exit 22
25 make distclean 2>/dev/null
26 ./bootstrap || exit 23
27 ./configure --prefix=`pwd` || exit 24
28 make || exit 25
29 popd
30
31 # Build the Citadel server
32 pushd ../citadel || exit 6
33 make distclean 2>/dev/null
34 ./bootstrap || exit 7
35 ./configure --prefix=$CITADEL_BUILD_DIR || exit 8
36 make || exit 9
37 make install || exit 10
38 popd
39
40 # Build WebCit
41 pushd ../webcit || exit 11
42 make distclean 2>/dev/null
43 ./bootstrap || exit 12
44 ./configure --prefix=$WEBCIT_BUILD_DIR || exit 13
45 make || exit 14
46 make install || exit 15
47 popd
48
49 # Clear out any old versions in the AppDir
50 rm -frv citadel.AppDir/usr
51 mkdir -p citadel.AppDir/usr/bin
52 mkdir -p citadel.AppDir/usr/lib
53
54 # Copy over all the libraries we used
55 for bin in \
56         $CITADEL_BUILD_DIR/citserver \
57         $WEBCIT_BUILD_DIR/webcit \
58         $CITADEL_BUILD_DIR/ctdlmigrate \
59         ../textclient/citadel \
60         `which gdb`
61 do
62         ldd $bin
63 done | sort | while read libname junk libpath
64 do
65         if [ ! -e ${libpath} 2>/dev/null ] ; then
66                 echo -e \\033[31m ${libname} was not found and will not be packaged. \\033[0m
67         elif grep ^${libname}$ excludelist >/dev/null 2>/dev/null ; then
68                 echo -e \\033[33m ${libname} is in the exclude list and will not be packaged. \\033[0m
69         else
70                 echo -e \\033[32m ${libname} will be packaged. \\033[0m
71                 cp -L ${libpath} citadel.AppDir/usr/lib/ 2>/dev/null
72         fi
73 done
74 ldconfig -v citadel.AppDir/usr/lib
75
76 # Copy over some utilities
77 for bin in db_dump db_load db_recover gdb
78 do
79         cp `which $bin` citadel.AppDir/usr/bin/ || exit 16
80 done
81
82 # Copy over the client
83 cp ../textclient/citadel citadel.AppDir/usr/bin/ || exit 26
84 cp ../textclient/citadel.rc citadel.AppDir/ || exit 27
85
86 # Install the Citadel Server application tree
87 mkdir -p citadel.AppDir/usr/local/citadel || exit 17
88 rsync -va $CITADEL_BUILD_DIR/ ./citadel.AppDir/usr/local/citadel/ || exit 18
89
90 # Install the WebCit application tree
91 mkdir -p citadel.AppDir/usr/local/webcit || exit 19
92 rsync -va $WEBCIT_BUILD_DIR/ ./citadel.AppDir/usr/local/webcit/ || exit 20
93
94 # Remove the build directories
95 rm -fr $CITADEL_BUILD_DIR $WEBCIT_BUILD_DIR
96
97 cc ctdlvisor.c -o citadel.AppDir/usr/bin/ctdlvisor || exit 21
98
99 CPU=`uname -m`
100 basefilename=citadel-`cat ../release_version.txt`
101 if [ $CPU == x86_64 ] ; then
102         export ARCH=x86_64
103 elif [ $CPU == armv7l ] ; then
104         export ARCH=armhf
105 elif [ $CPU == aarch64 ] ; then
106         export ARCH=aarch64
107 fi
108 echo ARCH: $ARCH
109 echo CPU: $CPU
110 appimagetool citadel.AppDir/ ${basefilename}-${CPU}.appimage