Fix #200: externalizing the Prosody AppImage build:

The build process for the Prosody AppImage only worked on Debian based
stations.
See: https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/200

With this commit, the Prosody AppImage is no more built in this plugin, but downloaded from [prosody-appimage](https://github.com/JohnXLivingston/prosody-appimage).
This commit is contained in:
John Livingston
2023-08-07 16:29:51 +02:00
parent 306a0cbf4c
commit 22f7d8fcef
42 changed files with 297 additions and 799 deletions

View File

@ -1,70 +1,73 @@
#!/bin/bash
set -euo pipefail
set -x
# set -x
rootdir="$(pwd)"
prosody_build_dir="$rootdir/build/prosody"
prosody_destination_dir="$rootdir/dist/server/prosody"
# This script download the Prosody AppImage from the https://github.com/JohnXLivingston/prosody-appimage project.
if [[ ! -d "$prosody_build_dir" ]]; then
mkdir -p "$prosody_build_dir"
fi
repo_base_url='https://github.com/JohnXLivingston/prosody-appimage/releases/download'
wanted_release='v0.12.3-1'
cd "$prosody_build_dir"
x86_64_filename='prosody-x86_64.AppImage'
x86_64_sha256sum='f4af9bfefa2f804ad7e8b03a68f04194abb801f070ae620b3d4bcedb144e8523'
aarch64_filename='prosody-aarch64.AppImage'
aarch64_sha256sum='878c5be719e1e36a84d637fd2bd44e3059aa91ddb6906ad05f1dd0334078df09'
if [ -f "$prosody_build_dir/livechat-prosody-x86_64.AppImage" ] && [ -f "$prosody_build_dir/livechat-prosody-aarch64.AppImage" ]; then
# if [ -f "$prosody_build_dir/livechat-prosody-x86_64.AppImage" ]; then
echo "Prosody images already built."
else
echo "Prosody images must be build..."
download_dir="$(pwd)/vendor/prosody-appimage"
dist_dir="$(pwd)/dist/server/prosody"
# Prerequisite: you must have python3-venv installed on your system
if [[ ! -d "venv" ]]; then
echo "Creating the python venv..."
python3 -m venv venv
mkdir -p $download_dir
cd $download_dir
function check_sha256() {
echo "Testing if file exists, and have correct checksums"
if [ ! -f $x86_64_filename ]; then
echo "File $x86_64_filename does not exists"
return 1
fi
if echo "$x86_64_sha256sum $x86_64_filename" | sha256sum --check; then
echo "File $x86_64_filename has the correct hashsum."
else
echo "File $x86_64_filename has not the correct hashsum."
return 1
fi
echo "Activating the python venv..."
source venv/bin/activate
if [ ! -f $aarch64_filename ]; then
echo "File $aarch64_filename does not exists"
return 1
fi
if echo "$aarch64_sha256sum $aarch64_filename" | sha256sum --check; then
echo "File $aarch64_filename has the correct hashsum."
else
echo "File $aarch64_filename has not the correct hashsum."
return 1
fi
return 0
}
echo "Installing appimage-builder..."
pip3 install appimage-builder==1.1.0
if check_sha256; then
echo "Files are present in $download_dir"
else
echo "Missing or incorrect Prosody AppImage files, downloading"
rm -f $x86_64_filename
rm -f $aarch64_filename
wget "$repo_base_url/$wanted_release/$x86_64_filename"
wget "$repo_base_url/$wanted_release/$aarch64_filename"
echo "Unpatching appimage-builder for ARM..."
sed -i -E 's/^\s*"\*\*\/ld-linux-aarch64.so\*",\s*$//' venv/lib/*/site-packages/appimagebuilder/modules/setup/apprun_2/apprun2.py
echo "Copying appimage source files..."
cp "$rootdir/prosody/appimage_x86_64.yml" "$prosody_build_dir/appimage_x86_64.yml"
cp "$rootdir/prosody/appimage_aarch64.yml" "$prosody_build_dir/appimage_aarch64.yml"
cp "$rootdir/prosody/launcher.lua" "$prosody_build_dir/launcher.lua"
echo "Building Prosody x86_64..."
appimage-builder --recipe "$prosody_build_dir/appimage_x86_64.yml"
echo "Cleaning build folders before building aarch64..."
rm -rf "$prosody_build_dir/AppDir"
rm -rf "$prosody_build_dir/appimage-build"
echo "Patching appimage-builder for ARM..."
sed -i -E 's/^\s*"\*\*\/ld-linux-x86-64.so.2",\s*$/"**\/ld-linux-x86-64.so.2", "**\/ld-linux-aarch64.so*",/' venv/lib/*/site-packages/appimagebuilder/modules/setup/apprun_2/apprun2.py
echo "Building Prosody aarch64..."
appimage-builder --recipe "$prosody_build_dir/appimage_aarch64.yml"
# For some obscur reason, if we keep AppDir and appimage-build folders,
# and if we try to install the plugin using the Peertube CLI,
# the installation fails because there are some subfolders that are right protected.
# To avoid that, we clean them:
echo "Cleaning build folders..."
rm -rf "$prosody_build_dir/AppDir"
rm -rf "$prosody_build_dir/appimage-build"
echo "Checking that newly downloaded files are correct"
if check_sha256; then
echo "Yep, they are correct"
else
echo "Can't correctly download Prosody AppImage files"
exit 1
fi
fi
echo "Copying Prosody dist files..."
mkdir -p "$prosody_destination_dir" && cp $prosody_build_dir/livechat-prosody-x86_64.AppImage "$prosody_destination_dir/"
mkdir -p "$prosody_destination_dir" && cp $prosody_build_dir/livechat-prosody-aarch64.AppImage "$prosody_destination_dir/"
echo "Prosody AppImages OK."
echo "Copying Prosody AppImage files in the dist folder"
mkdir -p "$dist_dir" && cp $x86_64_filename "$dist_dir/livechat-prosody-x86_64.AppImage"
mkdir -p "$dist_dir" && cp $aarch64_filename "$dist_dir/livechat-prosody-aarch64.AppImage"
echo "Chmod+x for the AppImages in the dist dir"
chmod u+x "$dist_dir/livechat-prosody-x86_64.AppImage"
chmod u+x "$dist_dir/livechat-prosody-aarch64.AppImage"
exit 0