2024-03-15 13:18:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2024-03-20 14:19:13 +00:00
|
|
|
APP_NAME="im.dino.Dino"
|
|
|
|
DIST_NAME=${DIST_NAME:-"${APP_NAME}.flatpak"}
|
2024-03-20 14:29:37 +00:00
|
|
|
DIST_DIR="$PWD/flatpak-dist"
|
2024-03-20 14:19:13 +00:00
|
|
|
BUILD_TEMP_DIR="$DIST_DIR/buildtemp"
|
|
|
|
BUILD_EXPORT_DIR="$DIST_DIR/export"
|
|
|
|
|
|
|
|
msg()
|
|
|
|
{
|
|
|
|
echo -e "\e[32m$1\e[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
fatal()
|
|
|
|
{
|
|
|
|
echo -e "\e[31m$1\e[0m"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2024-03-20 14:29:37 +00:00
|
|
|
get_flatpak_dependencies()
|
|
|
|
{
|
2024-03-20 14:19:13 +00:00
|
|
|
msg "Installing Flatpak dependencies..."
|
2024-04-02 16:17:31 +00:00
|
|
|
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
|
|
flatpak install --user -y flathub org.gnome.Sdk//44
|
|
|
|
flatpak install --user -y flathub org.gnome.Platform//44
|
2024-03-20 14:19:13 +00:00
|
|
|
msg "Flatpak dependencies installed"
|
2024-03-15 13:18:55 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 14:29:37 +00:00
|
|
|
pull_shared_modules()
|
|
|
|
{
|
2024-03-20 14:19:13 +00:00
|
|
|
msg "Pulling shared modules..."
|
2024-03-15 13:18:55 +00:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2024-03-20 14:19:13 +00:00
|
|
|
msg "Shared modules successfully pulled"
|
|
|
|
}
|
|
|
|
|
2024-03-20 14:29:37 +00:00
|
|
|
prepare()
|
|
|
|
{
|
|
|
|
get_flatpak_dependencies
|
|
|
|
pull_shared_modules
|
2024-03-15 13:18:55 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 14:29:37 +00:00
|
|
|
build()
|
|
|
|
{
|
2024-03-20 14:19:13 +00:00
|
|
|
msg "Build commencing!"
|
|
|
|
rm -rf $BUILD_TEMP_DIR
|
2024-03-21 14:49:48 +00:00
|
|
|
flatpak-builder --install-deps-from=flathub $BUILD_TEMP_DIR "${APP_NAME}.json"
|
2024-03-20 14:19:13 +00:00
|
|
|
flatpak build-export $BUILD_EXPORT_DIR $BUILD_TEMP_DIR
|
|
|
|
flatpak build-bundle $BUILD_EXPORT_DIR $DIST_NAME $APP_NAME
|
|
|
|
msg "Flatpack bundle ready and saved to ${DIST_NAME}"
|
|
|
|
}
|
|
|
|
|
2024-03-20 14:29:37 +00:00
|
|
|
clean()
|
|
|
|
{
|
2024-03-20 14:19:13 +00:00
|
|
|
msg "Wiping intermediate files..."
|
|
|
|
rm -rf $BUILD_TEMP_DIR $BUILD_EXPORT_DIR
|
|
|
|
msg "Cleanup complete!"
|
|
|
|
}
|
|
|
|
|
|
|
|
help()
|
|
|
|
{
|
|
|
|
cat << EOF
|
|
|
|
usage: $0 [OPTION]
|
|
|
|
--prepare install build dependencies
|
|
|
|
--build build the project
|
|
|
|
--clean remove build artifacts
|
|
|
|
--help show this help
|
|
|
|
|
|
|
|
Bundle is saved to ${APP_NAME}.flatpak by default.
|
|
|
|
Set DIST_NAME variable to customize output file name:
|
|
|
|
'DIST_NAME=customname.flatpak $0'
|
|
|
|
|
|
|
|
Running without parameters is equivalent to running:
|
|
|
|
'--prepare', '--build' and '--clean'
|
|
|
|
EOF
|
2024-03-15 13:18:55 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 14:19:13 +00:00
|
|
|
case $1 in
|
|
|
|
"--prepare" ) prepare ;;
|
|
|
|
"--build" ) build ;;
|
|
|
|
"--help" ) help ;;
|
|
|
|
"--clean" ) clean;;
|
|
|
|
"" )
|
|
|
|
prepare
|
|
|
|
build
|
|
|
|
clean
|
|
|
|
;;
|
|
|
|
*) fatal "Unknown argument!"
|
|
|
|
esac
|