Update libappimage
[appimagekit.git] / build.sh
blobb69e99ab04376b02a66981fe8802cb29322e00bc
1 #!/bin/bash
4 # This script installs the required build-time dependencies
5 # and builds AppImages for AppImageKit
8 STRIP="strip"
9 STATIC_BUILD=1
10 JOBS=${JOBS:-1}
11 RUN_TESTS=0
13 while [ $1 ]; do
14 case $1 in
15 '--debug' | '-d' )
16 STRIP="true"
18 '--use-shared-libs' | '-s' )
19 STATIC_BUILD=0
21 '--run-tests' | '-t' )
22 RUN_TESTS=1
24 '--clean' | '-c' )
25 rm -rf build
26 git clean -df
27 rm -rf squashfuse/* squashfuse/.git
28 rm -rf squashfs-tools/* squashfs-tools/.git
29 exit
31 '--help' | '-h' )
32 echo 'Usage: ./build.sh [OPTIONS]'
33 echo
34 echo 'OPTIONS:'
35 echo ' -h, --help: Show this help screen'
36 echo ' -d, --debug: Build with debug info.'
37 echo ' -n, --no-dependencies: Do not try to install distro specific build dependencies.'
38 echo ' -s, --use-shared-libs: Use distro provided shared versions of inotify-tools and openssl.'
39 echo ' -c, --clean: Clean all artifacts generated by the build.'
40 exit
42 esac
44 shift
45 done
48 if cat /etc/*release | grep "CentOS" 2>&1 >/dev/null; then
49 if [ -e /opt/rh/devtoolset-4/enable ]; then
50 . /opt/rh/devtoolset-4/enable
54 echo "$KEY" | md5sum
56 set -e
57 set -x
59 HERE="$(dirname "$(readlink -f "${0}")")"
60 cd "$HERE"
62 # Fetch git submodules
63 git submodule update --init --recursive
65 # Clean up from previous run
66 [ -d build/ ] && rm -rf build/
68 # Build AppImage
69 mkdir build
70 cd build
72 # make sure that deps in separate install tree are found
73 export PKG_CONFIG_PATH=/deps/lib/pkgconfig/
75 # make CMake use the right tools for ARM cross-compiling using toolchain file
76 if [ "$ARCH" == "armhf" ]; then
77 export PATH=/deps/bin:"$PATH"
78 export EXTRA_CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$HERE/cmake/toolchains/arm-linux-gnueabihf.cmake"
79 elif [ "$ARCH" == "aarch64" ]; then
80 export PATH=/deps/bin:"$PATH"
81 export EXTRA_CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$HERE/cmake/toolchains/aarch64-linux-gnu.cmake"
84 cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DAPPIMAGEKIT_PACKAGE_DEBS=ON "${EXTRA_CMAKE_FLAGS[@]}"
85 make -j$JOBS
86 make install DESTDIR=install_prefix/
88 if [ -d /deps/lib ]; then
89 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/deps/lib/
92 xxd src/runtime | head -n 1
94 # Do NOT strip runtime
95 find install_prefix/usr/bin/ -not -iname runtime -print -exec "$STRIP" "{}" \; 2>/dev/null
97 ls -lh install_prefix/usr/bin/
98 for FILE in install_prefix/usr/bin/*; do
99 echo "$FILE"
100 ldd "$FILE" || true
101 done
103 bash -ex "$HERE/build-appdir.sh"
105 ls -lh
107 mkdir -p out
108 cp -r install_prefix/usr/{bin,lib/appimagekit}/* appdirs/*.AppDir out/