1
1
#! /bin/bash
2
2
3
- set -e
4
- set -x
3
+ set -euxo pipefail
5
4
6
5
# use RAM disk if possible
7
- if [ " $CI " == " " ] && [ -d /dev/shm ]; then
8
- TEMP_BASE=/dev/shm
6
+ if [ -d /docker-ramdisk ]; then
7
+ TEMP_BASE=/docker-ramdisk
9
8
else
10
9
TEMP_BASE=/tmp
11
10
fi
@@ -26,49 +25,43 @@ old_cwd="$(readlink -f "$PWD")"
26
25
27
26
pushd " $build_dir "
28
27
28
+ # work around ninja colors bug
29
29
extra_cmake_args=()
30
-
31
- case " $ARCH " in
32
- " x86_64" )
33
- ;;
34
- " i386" )
35
- echo " Enabling x86_64->i386 cross-compile toolchain"
36
- extra_cmake_args=(" -DCMAKE_TOOLCHAIN_FILE=$repo_root /cmake/toolchains/i386-linux-gnu.cmake" " -DUSE_SYSTEM_CIMG=OFF" )
37
- ;;
38
- * )
39
- echo " Architecture not supported: $ARCH " 1>&2
40
- exit 1
41
- ;;
42
- esac
43
-
44
- # fetch up-to-date CMake
45
- mkdir cmake-prefix
46
- wget -O- https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1-Linux-x86_64.tar.gz | tar -xz -C cmake-prefix --strip-components=1
47
- export PATH=" $( readlink -f cmake-prefix/bin) :$PATH "
48
- cmake --version
30
+ if [ -t 0 ]; then
31
+ extra_cmake_args+=(
32
+ " -DCMAKE_C_FLAGS=-fdiagnostics-color=always"
33
+ " -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always"
34
+ )
35
+ fi
49
36
50
37
# configure build for AppImage release
51
- cmake " $repo_root " -DSTATIC_BUILD=On -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo " ${extra_cmake_args[@]} "
52
-
53
- make -j" $( nproc) "
38
+ cmake \
39
+ -G Ninja \
40
+ " $repo_root " \
41
+ -DSTATIC_BUILD=ON \
42
+ -DCMAKE_INSTALL_PREFIX=/usr \
43
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
44
+ " ${extra_cmake_args[@]} "
54
45
55
- # build patchelf
56
- " $repo_root " /ci/build-static-patchelf.sh " $( readlink -f out/) "
57
- patchelf_path=" $( readlink -f out/usr/bin/patchelf) "
46
+ nprocs=" $( nproc) "
47
+ [[ " ${CI:- } " == " " ]] && [[ " $nprocs " -gt 2 ]] && nprocs=" $( nproc --ignore=1) "
58
48
59
- # build custom strip
60
- " $repo_root " /ci/build-static-binutils.sh " $( readlink -f out/) "
61
- strip_path=" $( readlink -f out/usr/bin/strip) "
62
-
63
- # use tools we just built for linuxdeploy test run
64
- PATH=" $( readlink -f out/usr/bin) :$PATH "
65
- export PATH
49
+ ninja -j" $nprocs " -v
66
50
67
51
# # Run Unit Tests
68
52
ctest -V
69
53
70
54
# args are used more than once
71
- linuxdeploy_args=(" --appdir" " AppDir" " -e" " bin/linuxdeploy" " -i" " $repo_root /resources/linuxdeploy.png" " -d" " $repo_root /resources/linuxdeploy.desktop" " -e" " $patchelf_path " " -e" " $strip_path " )
55
+ patchelf_path=" $( which patchelf) "
56
+ strip_path=" $( which strip) "
57
+ linuxdeploy_args=(
58
+ --appdir AppDir
59
+ -e bin/linuxdeploy
60
+ -i " $repo_root /resources/linuxdeploy.png"
61
+ -d " $repo_root /resources/linuxdeploy.desktop"
62
+ -e " $patchelf_path "
63
+ -e " $strip_path "
64
+ )
72
65
73
66
# deploy patchelf which is a dependency of linuxdeploy
74
67
bin/linuxdeploy " ${linuxdeploy_args[@]} "
@@ -83,18 +76,20 @@ git clone --recursive https://github.com/linuxdeploy/linuxdeploy-plugin-appimage
83
76
bash linuxdeploy-plugin-appimage/ci/build-bundle.sh
84
77
mv linuxdeploy-plugin-appimage-bundle AppDir/plugins/linuxdeploy-plugin-appimage
85
78
86
- ln -s ../../plugins/linuxdeploy-plugin-appimage/AppRun AppDir/usr/bin/linuxdeploy-plugin-appimage
79
+ ln -s ../../plugins/linuxdeploy-plugin-appimage/usr/bin/linuxdeploy-plugin-appimage AppDir/usr/bin/linuxdeploy-plugin-appimage
87
80
88
81
# interpreted by linuxdeploy-plugin-appimage
89
82
export UPD_INFO=" gh-releases-zsync|linuxdeploy|linuxdeploy|continuous|linuxdeploy-$ARCH .AppImage.zsync"
90
83
export OUTPUT=" linuxdeploy-$ARCH .AppImage"
91
84
92
85
# special set of builds using a different experimental runtime, used for testing purposes
93
- if [[ " $USE_STATIC_RUNTIME " != " " ]]; then
86
+ if [[ " ${USE_STATIC_RUNTIME:- } " != " " ]]; then
87
+ custom_runtime_url=" https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-$ARCH "
88
+ wget " $custom_runtime_url "
89
+ runtime_filename=" $( echo " $custom_runtime_url " | rev | cut -d/ -f1 | rev) "
90
+ LDAI_RUNTIME_FILE=" $( readlink -f " $runtime_filename " ) "
91
+ export LDAI_RUNTIME_FILE
94
92
export OUTPUT=" linuxdeploy-static-$ARCH .AppImage"
95
- wget https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-" $ARCH "
96
- runtime_filename=" $( echo " $CUSTOM_RUNTIME_URL " | rev | cut -d/ -f1 | rev) "
97
- export LDAI_RUNTIME_FILE" $( readlink -f " $runtime_filename " ) "
98
93
fi
99
94
100
95
# build AppImage using plugin
@@ -103,6 +98,9 @@ AppDir/usr/bin/linuxdeploy-plugin-appimage --appdir AppDir/
103
98
# rename AppImage to avoid "Text file busy" issues when using it to create another one
104
99
mv " $OUTPUT " test.AppImage
105
100
101
+ # qemu is not happy about the AppImage type 2 magic bytes, so we need to "fix" that
102
+ dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of=test.AppImage
103
+
106
104
# verify that the resulting AppImage works
107
105
./test.AppImage " ${linuxdeploy_args[@]} "
108
106
0 commit comments