forked from mpc-qt/mpc-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-release-linux.sh
executable file
·65 lines (52 loc) · 2.19 KB
/
make-release-linux.sh
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
#!/bin/bash
# Source: https://docs.appimage.org/packaging-guide/from-source/native-binaries.html
set -x
set -e
VERSION=""
if [ -v GITHUB_SHA ]; then
VERSION=$GITHUB_SHA
elif [ -v FORCE_VERSION ]; then
VERSION=$FORCE_VERSION
else
# v23.02-74-g60b18fa -> 23.02.74
VERSION=`git describe --tags | sed 's/[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\).*/\1.\2.\3/'`
fi
BUILD=release
SUFFIX="linux-x64-$VERSION"
DEST="mpc-qt-$SUFFIX"
# building in temporary directory to keep system clean
# use RAM disk if possible (as in: not building on CI system like Travis, and RAM disk is available)
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
TEMP_BASE=/dev/shm
else
TEMP_BASE=/tmp
fi
BUILD_DIR=$(mktemp -d -p "$TEMP_BASE" appimage-build-XXXXXX)
# make sure to clean up build dir, even if errors occur
cleanup () {
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
}
trap cleanup EXIT
# store repo root as variable
REPO_ROOT=$(readlink -f $(dirname $(dirname $0)))
OLD_CWD=$(readlink -f .)
# switch to build dir
pushd "$BUILD_DIR"
# configure build files with qmake
# we need to explicitly set the install prefix, as CMake's default is /usr/local for some reason...
qmake6 PREFIX=/usr "MPCQT_VERSION=$VERSION" "$REPO_ROOT"
# build project and install files into AppDir
make -j$(nproc)
make install INSTALL_ROOT=AppDir
# now, build AppImage using linuxdeploy and linuxdeploy-plugin-qt
# download linuxdeploy and its Qt plugin
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
# make them executable
chmod +x linuxdeploy*.AppImage
# initialize AppDir, bundle shared libraries, add desktop file and icon, use Qt plugin to bundle additional resources, and build AppImage, all in one command
EXTRA_QT_PLUGINS="svg;" QMAKE=/usr/bin/qmake6 ./linuxdeploy-x86_64.AppImage --appdir AppDir -e mpc-qt -i "$REPO_ROOT"/images/icon/mpc-qt.svg -d "$REPO_ROOT"/mpc-qt.desktop --plugin qt --output appimage
# move built AppImage back into original CWD
mv Media_Player_Classic_Qute_Theater-x86_64.AppImage "$OLD_CWD/$DEST.AppImage"