-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·212 lines (172 loc) · 6.15 KB
/
build.sh
File metadata and controls
executable file
·212 lines (172 loc) · 6.15 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#! /bin/bash
set -euo pipefail
# use RAM disk if possible
if [ -d /dev/shm ] && mount | grep /dev/shm | grep -v -q noexec; then
TEMP_BASE=/dev/shm
elif [ -d /docker-ramdisk ]; then
TEMP_BASE=/docker-ramdisk
else
TEMP_BASE=/tmp
fi
BUILD_DIR="$(mktemp -d -p "$TEMP_BASE" AppImageLauncher-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 .)"
pushd "$BUILD_DIR"
# list available versions of Qt to be able to choose the right one for the build
cat <<\EOF
##########################
# Available Qt versions: #
##########################
EOF
qtchooser -list-versions
echo
# the Docker images provide a clang/clang++ symlink to the actual clang[++] binaries
# see install-deps.sh for more information
cmake_args=(
"-DCMAKE_C_COMPILER=clang"
"-DCMAKE_CXX_COMPILER=clang++"
"-DCMAKE_INSTALL_PREFIX=/usr"
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
"-DBUILD_TESTING=OFF"
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
# TODO: we don't necessarily want to hardcode this here
"-DBINFMT_INTERPRETER_PATH_PREPEND_LD_P_NATIVE_PACKAGES_PREFIX=/opt/appimagelauncher.AppDir/"
)
if [[ "${BUILD_LITE:-}" == "" ]]; then
cmake_args+=("-DENABLE_UPDATE_HELPER=ON")
else
cmake_args+=("-DBUILD_LITE=ON")
fi
export QT_SELECT=qt5
cmake "$REPO_ROOT" "${cmake_args[@]}"
make -j$(nproc)
# prepare AppDir
make install DESTDIR=AppDir
ARCH="$(dpkg --print-architecture)"
# "translate" to linuxdeploy/AppImage architecture
# note: linuxdeploy and AppImage differ in i386/i686, but we don't support that any more anyway
case "$ARCH" in
amd64)
ARCH=x86_64
;;
arm64)
ARCH=aarch64
;;
esac
# build release formats
curl -LO https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-"$ARCH".AppImage
curl -LO https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-"$ARCH".AppImage
VERSION=$(src/cli/ail-cli --version | awk '{print $3}')
gha_build="${GITHUB_RUN_NUMBER:-}"
if [[ "$gha_build" != "" ]]; then
VERSION="${VERSION}-gha${gha_build}"
else
VERSION="${VERSION}-local"
fi
# should be overwritten for every output plugin below, this is a fallback only
export LINUXDEPLOY_OUTPUT_APP_NAME=appimagelauncher
LINUXDEPLOY_OUTPUT_VERSION="${VERSION}~$(cd "$REPO_ROOT" && git rev-parse --short HEAD)"
export LINUXDEPLOY_OUTPUT_VERSION
export APPIMAGE_EXTRACT_AND_RUN=1
linuxdeploy_extra_args=()
if [[ "${BUILD_LITE:-}" == "" ]]; then
# configure linuxdeploy-plugin-native_packages
export LDNP_PACKAGE_NAME=appimagelauncher
export LDNP_BUILD="deb rpm"
export LDNP_DESCRIPTION=""
export LDNP_SHORT_DESCRIPTION=""
rpm_lib_suffix=""
case "$ARCH" in
x86_64)
rpm_build_arch=x86_64
rpm_lib_suffix="()(64bit)"
deb_build_arch=amd64
;;
i?86)
rpm_build_arch=i386
deb_build_arch=i386
;;
aarch64)
rpm_build_arch=aarch64
deb_build_arch=arm64
;;
armhf)
deb_build_arch=armhf
rpm_build_arch=armv7hl
;;
*)
echo "Unsupported architecture: $ARCH"
exit 2
;;
esac
# common meta info
export LDNP_META_URL="https://github.com/TheAssassin/AppImageLauncher"
export LDNP_META_BUG_URL="https://github.com/TheAssassin/AppImageLauncher/issues"
export LDNP_META_VENDOR="TheAssassin"
export LDNP_META_DEB_DEPENDS="systemd, libgl1, libfontconfig1, libharfbuzz0b, libfribidi0"
export LDNP_META_DEB_ARCHITECTURE="$deb_build_arch"
export LDNP_META_DEB_PRE_DEPENDS="bash"
export LDNP_DEB_EXTRA_DEBIAN_FILES="${BUILD_DIR}/cmake/debian/postinst;${BUILD_DIR}/cmake/debian/postrm"
rpm_requires=(
"systemd"
"libGL.so.1${rpm_lib_suffix}"
"libfontconfig.so.1${rpm_lib_suffix}"
"libfreetype.so.6${rpm_lib_suffix}"
"libfribidi.so.0${rpm_lib_suffix}"
"libgpg-error.so.0${rpm_lib_suffix}"
"libharfbuzz.so.0${rpm_lib_suffix}"
)
export LDNP_META_RPM_REQUIRES="${rpm_requires[*]}"
export LDNP_META_RPM_BUILD_ARCH="$rpm_build_arch"
export LDNP_RPM_SCRIPTLET_POST="${BUILD_DIR}/cmake/debian/postinst"
export LDNP_RPM_SCRIPTLET_PREUN="${BUILD_DIR}/cmake/debian/postrm"
# updater is not available for the lite build
linuxdeploy_extra_args+=(
-e "$(find AppDir/usr/lib/*/appimagelauncher/update | head -n1)"
--output native_packages
)
# tools like pipx would have side effects on the build host and it's generally a bit overkill for our purpose
if which python3.13 &> /dev/null; then
# python3.13, installed from the deadsnakes PPA for the Docker builds
python3() {
python3.13 "$@"
}
fi
python3 -m venv venv
venv/bin/pip install git+https://github.com/linuxdeploy/linuxdeploy-plugin-native_packages
export PATH="$PWD/venv/bin:$PATH"
else
linuxdeploy_extra_args+=(
--custom-apprun "$REPO_ROOT"/resources/appimagelauncher-lite-AppRun.sh
--output appimage
)
LDAI_OUTPUT="$(echo appimagelauncher-lite-"$VERSION"-"$ARCH".AppImage | tr '~' -)"
export LDAI_OUTPUT
# since we extracted common parts from the installer built into the AppRun script, we have to copy the "library" script
# before building an AppImage
install "$REPO_ROOT"/resources/appimagelauncher-lite-installer-common.sh "$(readlink -f AppDir/)"
fi
chmod -v +x linuxdeploy*-"$ARCH".AppImage
# workaround for QEMU
for appimage in *.AppImage; do
dd if=/dev/zero bs=1 count=3 seek=8 conv=notrunc of="$appimage"
done
ldd AppDir/usr/bin/AppImageLauncherSettings
./linuxdeploy-"$ARCH".AppImage -v0 \
--appdir "$(readlink -f AppDir)" \
--plugin qt \
-d AppDir/usr/share/applications/appimagelauncher.desktop \
-e "$(find AppDir/usr/lib/*/appimagelauncher/remove | head -n1)" \
"${linuxdeploy_extra_args[@]}"
if [[ "${BUILD_LITE:-}" == "" ]]; then
mv "$LDNP_PACKAGE_NAME"*.{rpm,deb} "$OLD_CWD"
else
mv "$LDAI_OUTPUT" "$OLD_CWD"
fi