2018-04-14 18:22:49 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# MIT License
|
|
|
|
#
|
2019-07-14 02:42:11 +08:00
|
|
|
# Copyright © 2019 by The qTox Project Contributors
|
2018-04-14 18:22:49 +08:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE.
|
|
|
|
|
|
|
|
# Fail out on error
|
|
|
|
set -exuo pipefail
|
|
|
|
|
2021-11-08 13:27:45 +08:00
|
|
|
usage() {
|
|
|
|
echo "$0 --src-dir SRC_DIR"
|
|
|
|
echo "Builds an app image in the CWD based off qtox installation at SRC_DIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
while (( $# > 0 )); do
|
|
|
|
case $1 in
|
|
|
|
--src-dir) QTOX_SRC_DIR=$2; shift 2 ;;
|
|
|
|
--help|-h) usage; exit 1 ;;
|
|
|
|
*) echo "Unexpected argument $1"; usage; exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "${QTOX_SRC_DIR+x}" ]; then
|
|
|
|
echo "--src-dir is a required argument"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-04-14 18:22:49 +08:00
|
|
|
# directory paths
|
2021-11-08 13:27:45 +08:00
|
|
|
BUILD_DIR=$(realpath .)
|
|
|
|
readonly BUILD_DIR
|
|
|
|
QTOX_APP_DIR="$BUILD_DIR"/appdir
|
|
|
|
readonly QTOX_APP_DIR
|
2021-10-28 08:28:42 +08:00
|
|
|
readonly LOCAL_LIB_DIR="$QTOX_APP_DIR"/local/lib
|
2018-04-14 18:22:49 +08:00
|
|
|
# ldqt binary
|
2021-11-08 13:27:45 +08:00
|
|
|
readonly LDQT_BIN="/usr/lib/qt5/bin/linuxdeployqt"
|
2019-07-13 22:34:35 +08:00
|
|
|
|
|
|
|
# update information to be embeded in AppImage
|
|
|
|
if [ "cron" == "${TRAVIS_EVENT_TYPE:-}" ]
|
|
|
|
then
|
|
|
|
# update information for nightly version
|
|
|
|
readonly NIGHTLY_REPO_SLUG=$(echo "$CIRP_GITHUB_REPO_SLUG" | tr "/" "|")
|
|
|
|
readonly UPDATE_INFO="gh-releases-zsync|$NIGHTLY_REPO_SLUG|ci-master-latest|qTox-*-x86_64.AppImage.zsync"
|
|
|
|
else
|
|
|
|
# update information for stable version
|
|
|
|
readonly UPDATE_INFO="gh-releases-zsync|qTox|qTox|latest|qTox-*.x86_64.AppImage.zsync"
|
|
|
|
fi
|
2018-07-12 05:52:59 +08:00
|
|
|
|
2021-11-08 13:27:45 +08:00
|
|
|
export VERSION=$(git -C "${QTOX_SRC_DIR}" rev-parse --short HEAD)
|
|
|
|
|
|
|
|
echo $QTOX_APP_DIR
|
|
|
|
cmake "${QTOX_SRC_DIR}" -DDESKTOP_NOTIFICATIONS=ON -DUPDATE_CHECK=ON -DCMAKE_BUILD_TYPE=Release
|
|
|
|
make -j$(nproc)
|
|
|
|
rm -fr appdir
|
|
|
|
make DESTDIR=appdir install
|
|
|
|
|
2018-04-14 18:22:49 +08:00
|
|
|
unset QTDIR; unset QT_PLUGIN_PATH; unset LD_LIBRARY_PATH;
|
|
|
|
|
|
|
|
readonly QTOX_DESKTOP_FILE="$QTOX_APP_DIR"/usr/local/share/applications/*.desktop
|
2021-11-08 13:27:45 +08:00
|
|
|
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/x86_64-linux-gnu/
|
2018-04-14 18:22:49 +08:00
|
|
|
|
2018-07-12 05:52:59 +08:00
|
|
|
eval "$LDQT_BIN $QTOX_DESKTOP_FILE -bundle-non-qt-libs -extra-plugins=libsnore-qt5"
|
|
|
|
|
2019-07-13 22:34:35 +08:00
|
|
|
# Move the required files to the correct directory
|
|
|
|
mv "$QTOX_APP_DIR"/usr/* "$QTOX_APP_DIR/"
|
|
|
|
rm -rf "$QTOX_APP_DIR/usr"
|
|
|
|
|
2019-07-14 01:43:25 +08:00
|
|
|
# Warning: This is hard coded to debain:stretch.
|
2021-10-28 08:28:42 +08:00
|
|
|
libs=(
|
|
|
|
# copy OpenSSL libs to AppImage
|
|
|
|
/usr/lib/x86_64-linux-gnu/libssl.so
|
|
|
|
/usr/lib/x86_64-linux-gnu/libcrypt.so
|
|
|
|
/usr/lib/x86_64-linux-gnu/libcrypto.so
|
2019-07-15 15:33:20 +08:00
|
|
|
# Also bundle libjack.so* without which the AppImage does not work in Fedora Workstation
|
2021-10-28 08:28:42 +08:00
|
|
|
/usr/lib/x86_64-linux-gnu/libjack.so.0
|
2021-10-28 08:51:18 +08:00
|
|
|
# And libglib needed by Red Hat and derivatives to work with our old gnutls
|
2021-11-08 13:27:45 +08:00
|
|
|
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
|
|
|
|
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
|
|
|
|
/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
|
|
|
|
/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
|
|
|
|
/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0
|
2021-10-28 08:28:42 +08:00
|
|
|
)
|
2019-07-14 01:43:25 +08:00
|
|
|
|
2021-10-28 08:28:42 +08:00
|
|
|
for lib in "${libs[@]}"; do
|
2021-10-28 08:32:55 +08:00
|
|
|
lib_file_name=$(basename "$lib")
|
2021-10-28 08:28:42 +08:00
|
|
|
cp -P $(echo "$lib"*) "$LOCAL_LIB_DIR"
|
2021-10-28 08:32:55 +08:00
|
|
|
patchelf --set-rpath '$ORIGIN' "$LOCAL_LIB_DIR/$lib_file_name"
|
2021-10-28 08:28:42 +08:00
|
|
|
done
|
2021-09-23 11:05:36 +08:00
|
|
|
|
2021-10-28 08:28:42 +08:00
|
|
|
# this is important, aitool automatically uses the same filename in .zsync meta file.
|
|
|
|
# if this name does not match with the one we upload, the update always fails.
|
2021-09-23 11:05:36 +08:00
|
|
|
if [ -n "${TRAVIS_TAG-}" ]
|
|
|
|
then
|
|
|
|
VERSION_NAME="${TRAVIS_TAG}"
|
|
|
|
elif [ -n "${TRAVIS_COMMIT-}" ]
|
2019-07-13 22:34:35 +08:00
|
|
|
then
|
2021-09-23 11:05:36 +08:00
|
|
|
VERSION_NAME="${TRAVIS_COMMIT}"
|
2019-07-13 22:34:35 +08:00
|
|
|
else
|
2021-09-23 11:05:36 +08:00
|
|
|
VERSION_NAME="${VERSION}"
|
2019-07-13 22:34:35 +08:00
|
|
|
fi
|
2018-04-14 18:22:49 +08:00
|
|
|
|
2021-11-08 13:27:45 +08:00
|
|
|
appimagetool -u "$UPDATE_INFO" $QTOX_APP_DIR qTox-$VERSION_NAME.x86_64.AppImage
|