Port PR #6970 Fix AppImage nightly autoupdates and update build scripts

This commit is contained in:
Peter Jonas 2021-02-19 15:12:01 +00:00 committed by Igor Korsukov
parent 9a80580cc1
commit 0df50eeca6
3 changed files with 44 additions and 46 deletions

View file

@ -15,13 +15,17 @@ INSTALL_DIR="$(cat $BUILD_DIR/PREFIX.txt)" # MuseScore was installed here
while [[ "$#" -gt 0 ]]; do
case $1 in
--build_mode) BUILD_MODE="$2"; shift ;;
-v|--version) BUILD_VERSION="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [ -z "$BUILD_MODE" ]; then BUILD_MODE=$(cat $ARTIFACTS_DIR/env/build_mode.env); fi
if [ -z "$BUILD_VERSION" ]; then BUILD_VERSION=$(cat $ARTIFACTS_DIR/env/build_version.env); fi
if [ -z "$BUILD_MODE" ]; then echo "error: not set BUILD_MODE"; exit 1; fi
if [ -z "$BUILD_VERSION" ]; then echo "error: not set BUILD_VERSION"; exit 1; fi
PACKTYPE=appimage
if [ "$BUILD_MODE" == "devel_build" ]; then PACKTYPE=appimage; fi
@ -29,7 +33,11 @@ if [ "$BUILD_MODE" == "nightly_build" ]; then PACKTYPE=appimage; fi
if [ "$BUILD_MODE" == "testing_build" ]; then PACKTYPE=appimage; fi
if [ "$BUILD_MODE" == "stable_build" ]; then PACKTYPE=appimage; fi
MAJOR_VERSION="${BUILD_VERSION%%.*}"
echo "BUILD_MODE: $BUILD_MODE"
echo "BUILD_VERSION: $BUILD_VERSION"
echo "MAJOR_VERSION: $MAJOR_VERSION"
echo "PACKTYPE: $PACKTYPE"
echo "INSTALL_DIR: $INSTALL_DIR"
@ -40,7 +48,7 @@ if [ "$BUILD_MODE" == "nightly_build" ]; then
ARTIFACT_NAME=MuseScoreNightly-${BUILD_DATETIME}-${BUILD_BRANCH}-${BUILD_REVISION}-x86_64
else
BUILD_VERSION=$(cat $ARTIFACTS_DIR/env/build_version.env)
ARTIFACT_NAME=MuseScore-${BUILD_VERSION}-x86_64
ARTIFACT_NAME=MuseScore-${BUILD_VERSION}-x86_64
fi
if [ "$PACKTYPE" == "7z" ]; then
@ -55,21 +63,20 @@ if [ "$PACKTYPE" == "appimage" ]; then
# https://github.com/AppImage/AppImageSpec/blob/master/draft.md#update-information
case "${BUILD_MODE}" in
"stable_build") export UPDATE_INFORMATION="gh-releases-zsync|musescore|MuseScore|latest|MuseScore-*x86_64.AppImage.zsync";;
"nightly_build") export UPDATE_INFORMATION="zsync|https://ftp.osuosl.org/pub/musescore-nightlies/linux/3x/nightly/MuseScoreNightly-latest-x86_64.AppImage.zsync";;
"nightly_build") export UPDATE_INFORMATION="zsync|https://ftp.osuosl.org/pub/musescore-nightlies/linux/${MAJOR_VERSION}x/nightly/MuseScoreNightly-latest-x86_64.AppImage.zsync";;
*) unset UPDATE_INFORMATION;; # disable updates for other build modes
esac
bash ./build/ci/linux/tools/make_appimage.sh $INSTALL_DIR
APPIMAGE_FILE="$(ls $BUILD_DIR/*.AppImage)"
mv $APPIMAGE_FILE $ARTIFACTS_DIR/$ARTIFACT_NAME.AppImage
bash ./build/ci/linux/tools/make_appimage.sh "${INSTALL_DIR}" "${ARTIFACT_NAME}.AppImage"
mv "${BUILD_DIR}/${ARTIFACT_NAME}.AppImage" "${ARTIFACTS_DIR}/"
bash ./build/ci/tools/make_artifact_name_env.sh $ARTIFACT_NAME.AppImage
if [ -v UPDATE_INFORMATION ]; then
ZSYNC_FILE="$(ls $BUILD_DIR/*.AppImage.zsync)" # data for delta updates
mv $ZSYNC_FILE $ARTIFACTS_DIR/$ARTIFACT_NAME.AppImage.zsync
# zsync file contains data for automatic delta updates
mv "${BUILD_DIR}/${ARTIFACT_NAME}.AppImage.zsync" "${ARTIFACTS_DIR}/"
fi
fi
fi
df -h .
echo "Package has finished!"
echo "Package has finished!"

View file

@ -1,7 +1,10 @@
#!/usr/bin/env bash
INSTALL_DIR=$1
INSTALL_DIR="$1" # MuseScore was installed here
APPIMAGE_NAME="$2" # name for AppImage file (created outside $INSTALL_DIR)
if [ -z "$INSTALL_DIR" ]; then echo "error: not set INSTALL_DIR"; exit 1; fi
if [ -z "$APPIMAGE_NAME" ]; then echo "error: not set APPIMAGE_NAME"; exit 1; fi
##########################################################################
# INSTALL APPIMAGETOOL AND LINUXDEPLOY
@ -239,7 +242,7 @@ done
# TURN APPDIR INTO AN APPIMAGE
##########################################################################
appimage="${appdir%.AppDir}.AppImage" # name to use for AppImage file
appimage="${APPIMAGE_NAME}" # name to use for AppImage file
appimagetool_args=( # array
# none

View file

@ -10,7 +10,7 @@ while [[ "$#" -gt 0 ]]; do
-s|--secret) OSUOSL_SSH_ENCRYPT_SECRET="$2"; shift ;;
--os) OS="$2"; shift ;;
-m|--mode) BUILD_MODE="$2"; shift ;;
-v|--version) MAJOR_VERSION="$2"; shift ;;
-v|--version) BUILD_VERSION="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
@ -18,11 +18,15 @@ done
if [ -z "$ARTIFACT_NAME" ]; then ARTIFACT_NAME="$(cat $ARTIFACTS_DIR/env/artifact_name.env)"; fi
if [ -z "$BUILD_MODE" ]; then BUILD_MODE=$(cat $ARTIFACTS_DIR/env/build_mode.env); fi
if [ -z "$BUILD_VERSION" ]; then BUILD_VERSION=$(cat $ARTIFACTS_DIR/env/build_version.env); fi
MAJOR_VERSION="${BUILD_VERSION%%.*}"
echo "ARTIFACT_NAME: $ARTIFACT_NAME"
echo "SECRET: $OSUOSL_SSH_ENCRYPT_SECRET"
echo "OS: $OS"
echo "BUILD_MODE: $BUILD_MODE"
echo "BUILD_VERSION: $BUILD_VERSION"
echo "MAJOR_VERSION: $MAJOR_VERSION"
OS_IS_VALID=0
@ -43,7 +47,7 @@ if [ -z "$OSUOSL_SSH_ENCRYPT_SECRET" ]; then echo "error: not set OSUOSL_SSH_ENC
SSH_KEY=build/ci/tools/osuosl/osuosl_nighlies_rsa
#if [ "$OS" == "windows" ]; then
#if [ "$OS" == "windows" ]; then
#Icacls $SSH_KEY
#Icacls $SSH_KEY /Inheritance:r
#Icacls $SSH_KEY /Grant:r "$(whoami)":'(R,W)'
@ -54,16 +58,19 @@ chmod 600 $SSH_KEY
FTP_PATH=${OS}/${MAJOR_VERSION}x/${BUILD_DIR}
file_extension="${ARTIFACT_NAME##*.}"
LATEST_NAME="MuseScoreNightly-latest-x86_64.${file_extension}"
echo "Copy ${ARTIFACTS_DIR}/${ARTIFACT_NAME} to $FTP_PATH"
scp -oStrictHostKeyChecking=no -C -i $SSH_KEY $ARTIFACTS_DIR/$ARTIFACT_NAME musescore-nightlies@ftp-osl.osuosl.org:~/ftp/$FTP_PATH
# For Linux, we also need to send a .zsync file, if exists
ZSYNC_EXISTS=0
if [ "$OS" == "linux" ]; then
if [ "$OS" == "linux" ]; then
if [ -f "$ARTIFACTS_DIR/${ARTIFACT_NAME}.zsync" ]; then
echo "Copy ${ARTIFACTS_DIR}/${ARTIFACT_NAME}.zsync to $FTP_PATH"
scp -oStrictHostKeyChecking=no -C -i $SSH_KEY $ARTIFACTS_DIR/${ARTIFACT_NAME}.zsync musescore-nightlies@ftp-osl.osuosl.org:~/ftp/$FTP_PATH
ZSYNC_EXISTS=1
# zsync file must be available at stable URL and we don't need historic versions of this file
ssh -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "cd ~/ftp/$FTP_PATH; mv -f ${ARTIFACT_NAME}.zsync ${LATEST_NAME}.zsync"
fi
fi
@ -71,43 +78,24 @@ PUBLISH_URL=https://ftp.osuosl.org/pub/musescore-nightlies/$FTP_PATH
echo $PUBLISH_URL > $ARTIFACTS_DIR/env/publish_url.env
cat $ARTIFACTS_DIR/env/publish_url.env
# Delete old files
if [ "$BUILD_MODE" == "nightly_build" ]; then
echo "Delete old MuseScoreNightly files"
if [ "$OS" == "linux" ]; then
ssh -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "cd ~/ftp/$FTP_PATH; ls MuseScoreNightly*.AppImage -t | tail -n +41 | xargs rm -f"
ssh -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "cd ~/ftp/$FTP_PATH; ls MuseScoreNightly*.AppImage.zsync -t | tail -n +41 | xargs rm -f"
else
ssh -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "cd ~/ftp/$FTP_PATH; ls MuseScoreNightly* -t | tail -n +41 | xargs rm -f"
fi
fi
# Create link to latest
if [ "$BUILD_MODE" == "nightly_build" ]; then
if [ "$BUILD_MODE" == "nightly_build" ]; then
echo "Create link to latest"
sleep 1m # For fine sort order on FTP
LATEST_NAME="MuseScoreNightly-latest-x86_64.AppImage"
ssh -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "cd ~/ftp/$FTP_PATH; ln -sf $ARTIFACT_NAME $LATEST_NAME"
if [ "$OS" == "linux" ]; then
if [ $ZSYNC_EXISTS -eq 1 ]; then
ssh -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "cd ~/ftp/$FTP_PATH; ln -sf ${ARTIFACT_NAME}.zsync ${LATEST_NAME}.zsync"
fi
fi
fi
# Delete old files
if [ "$BUILD_MODE" == "nightly_build" ]; then
echo "Delete old MuseScoreNightly files"
number_to_keep=42 # includes the one we just uploaded and the symlink to it
if [ "$OS" == "linux" ]; then
((++number_to_keep)) # one extra for the zsync file
fi
ssh -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "cd ~/ftp/$FTP_PATH; ls MuseScoreNightly* -t | tail -n +${number_to_keep} | xargs rm -f"
fi
# Sending index.html
scp -oStrictHostKeyChecking=no -C -i $SSH_KEY build/ci/tools/osuosl/index.html musescore-nightlies@ftp-osl.osuosl.org:~/ftp/
# Trigger
# Trigger
ssh -o StrictHostKeyChecking=no -i $SSH_KEY musescore-nightlies@ftp-osl.osuosl.org "~/trigger-musescore-nightlies"