Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·105 lines (80 loc) · 2.85 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·105 lines (80 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#! /bin/bash
set -euxo pipefail
# use RAM disk if possible
if [ -d /docker-ramdisk ]; then
TEMP_BASE=/docker-ramdisk
else
TEMP_BASE=/tmp
fi
build_dir=$(mktemp -d -p "$TEMP_BASE" linuxdeploy-build-XXXXXX)
cleanup () {
if [ -d "$build_dir" ]; then
rm -rf "$build_dir"
fi
}
trap cleanup EXIT
# store repo root as variable
repo_root="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"/..
old_cwd="$(readlink -f "$PWD")"
pushd "$build_dir"
# work around ninja colors bug
extra_cmake_args=()
if [ -t 0 ]; then
extra_cmake_args+=(
"-DCMAKE_C_FLAGS=-fdiagnostics-color=always"
"-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always"
)
fi
# configure build for AppImage release
cmake \
-G Ninja \
"$repo_root" \
-DSTATIC_BUILD=ON \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
"${extra_cmake_args[@]}"
nprocs="$(nproc)"
[[ "${CI:-}" == "" ]] && [[ "$nprocs" -gt 2 ]] && nprocs="$(nproc --ignore=1)"
ninja -j"$nprocs" -v
## Run Unit Tests
ctest -V
# args are used more than once
patchelf_path="$(which patchelf)"
strip_path="$(which strip)"
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"
)
# deploy patchelf which is a dependency of linuxdeploy
bin/linuxdeploy "${linuxdeploy_args[@]}"
# bundle AppImage plugin
mkdir -p AppDir/plugins
if [ $# -ge 1 ] && [ "$1" = "--skip-plugins" ]; then
exit 0
fi
# build linuxdeploy-plugin-appimage instead of using prebuilt versions
# this prevents a circular dependency
# the other repository provides a script for this purpose that builds a bundle we can use
git clone --recursive https://github.com/linuxdeploy/linuxdeploy-plugin-appimage
bash linuxdeploy-plugin-appimage/ci/build-bundle.sh
mv linuxdeploy-plugin-appimage-bundle AppDir/plugins/linuxdeploy-plugin-appimage
ln -s ../../plugins/linuxdeploy-plugin-appimage/usr/bin/linuxdeploy-plugin-appimage AppDir/usr/bin/linuxdeploy-plugin-appimage
# interpreted by linuxdeploy-plugin-appimage
export UPD_INFO="gh-releases-zsync|linuxdeploy|linuxdeploy|continuous|linuxdeploy-$ARCH.AppImage.zsync"
export OUTPUT="linuxdeploy-$ARCH.AppImage"
# build AppImage using plugin
AppDir/usr/bin/linuxdeploy-plugin-appimage --appdir AppDir/
# rename AppImage to avoid "Text file busy" issues when using it to create another one
mv "$OUTPUT" test.AppImage
# qemu is not happy about the AppImage type 2 magic bytes, so we need to "fix" that
dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of=test.AppImage
# verify that the resulting AppImage works
./test.AppImage "${linuxdeploy_args[@]}"
# check whether AppImage plugin is found and works
./test.AppImage "${linuxdeploy_args[@]}" --output appimage
# using a glob because we want to include the .zsync file
mv "$OUTPUT"* "$old_cwd"/