2020-03-06 21:17:06 +01:00
#!/bin/bash
2019-07-17 20:50:38 +02:00
printf "\n\n---------------------------------------- FLATPAK BUILD --------------------------------------------\n" ;
2019-07-26 07:16:56 +02:00
# Aborts the script upon any faliure
set -e;
2019-07-21 07:30:19 +02:00
# Setup Script Variables
BINARY_TARBALL = $1 ;
2019-07-26 07:16:56 +02:00
FLATPAK_REPO = $2 ;
FLATPAK_BUNDLE = $3 ;
2019-07-28 00:57:23 +02:00
_SCRIPT_FOLDER = $( realpath $( dirname $0 ) ) ;
2019-07-21 07:30:19 +02:00
_FLATHUB_REPO = "flathub https://flathub.org/repo/flathub.flatpakrepo" ;
2021-01-01 01:38:44 +01:00
_FLATHUB_PACKAGES_TO_INSTALL = " org.gnome.Platform/ ${ CARCH } /3.36 org.gnome.Sdk/ ${ CARCH } /3.36 org.freedesktop.Platform//19.08 org.freedesktop.Sdk//19.08 " ;
2019-08-24 09:57:55 +02:00
_EXTRACTED_BINARY_TARBALL_FOLDER = $_SCRIPT_FOLDER /librewolf
2019-07-28 00:57:23 +02:00
_FLATPAK_JSON_FILE = $_SCRIPT_FOLDER /content/io.gitlab.LibreWolf.json;
2019-08-24 09:57:55 +02:00
_FLATPAK_BUILD_SOURCE_FOLDER = $_SCRIPT_FOLDER /source;
2019-07-21 07:30:19 +02:00
_FLATPAK_BUILD_FOLDER = build-dir;
2020-03-28 23:15:41 +01:00
2020-03-28 23:56:49 +01:00
if [ [ ! -z " ${ TARBALL_URL } " ] ] ; then
apt update && apt install -y wget
2020-03-28 23:15:41 +01:00
wget " ${ TARBALL_URL } "
fi
if [ [ ! -f " ${ BINARY_TARBALL } " ] ] ; then
echo "Tarball not provided via pipeline or download."
exit 1
fi
2019-07-17 20:50:38 +02:00
# Install build dependencies
printf "\nInstalling flatpak build dependencies\n" ;
2020-03-06 21:17:06 +01:00
# we're using a pre-prepared flatpak-image witch aarch64
apt update && apt install -y software-properties-common
add-apt-repository -y ppa:alexlarsson/flatpak
2020-03-30 11:58:28 +02:00
apt update && apt install -y flatpak-builder bzip2
2019-07-21 07:30:19 +02:00
flatpak remote-add --if-not-exists $_FLATHUB_REPO ;
2019-07-23 19:38:46 +02:00
flatpak install -y flathub $_FLATHUB_PACKAGES_TO_INSTALL ;
2019-07-21 07:30:19 +02:00
# Extracts the binary tarball
printf "\nExtracting librewolf binary tarball\n" ;
2020-03-06 21:17:06 +01:00
mkdir -p $_EXTRACTED_BINARY_TARBALL_FOLDER ;
2019-08-24 09:57:55 +02:00
tar -xvf $BINARY_TARBALL -C $_EXTRACTED_BINARY_TARBALL_FOLDER ;
2019-07-17 20:50:38 +02:00
# Prepare for flatpak build
printf "\nPreparing files for flatpak build\n" ;
2020-03-06 21:17:06 +01:00
mkdir -p $_FLATPAK_BUILD_SOURCE_FOLDER ;
mv $_EXTRACTED_BINARY_TARBALL_FOLDER $_FLATPAK_BUILD_SOURCE_FOLDER ;
2019-07-17 20:50:38 +02:00
2019-07-24 00:44:01 +02:00
# Build Repo
printf "\nBuilding flatpak repository\n" ;
2019-07-26 07:16:56 +02:00
cp " $_FLATPAK_JSON_FILE " ./;
2019-07-24 00:44:01 +02:00
2020-03-31 12:09:05 +02:00
# add appstream metadata
2021-01-01 01:38:44 +01:00
# TODO: firefox uses files/share/appdata/ in their flatpak, but https://docs.flatpak.org/en/latest/conventions.html says otherwise. which is "more" correct? => using both for now, just in case...
install -Dvm644 " $_FLATPAK_BUILD_SOURCE_FOLDER /librewolf/io.gitlab.LibreWolf.appdata.xml " " $_SCRIPT_FOLDER /source/share/metainfo/io.gitlab.LibreWolf.appdata.xml "
install -Dvm644 " $_FLATPAK_BUILD_SOURCE_FOLDER /librewolf/io.gitlab.LibreWolf.appdata.xml " " $_SCRIPT_FOLDER /source/share/appdata/LibreWolf.appdata.xml "
install -Dvm644 " $_SCRIPT_FOLDER /content/io.gitlab.LibreWolf.desktop " " $_SCRIPT_FOLDER /source/share/applications/LibreWolf.desktop "
2020-03-31 12:09:05 +02:00
2021-01-01 01:38:44 +01:00
install -Dvm644 " $_FLATPAK_BUILD_SOURCE_FOLDER /librewolf/browser/chrome/icons/default/default128.png " " $_SCRIPT_FOLDER /source/share/icons/hicolor/128x128/apps/io.gitlab.LibreWolf.png "
flatpak-builder --disable-rofiles-fuse --repo= " $FLATPAK_REPO " " $_FLATPAK_BUILD_FOLDER " io.gitlab.LibreWolf.json;
2020-03-31 21:09:30 +02:00
2019-07-24 00:44:01 +02:00
# Build bundle
printf "\nBuilding flatpak bundle\n" ;
2019-07-21 07:30:19 +02:00
flatpak build-bundle $FLATPAK_REPO $FLATPAK_BUNDLE io.gitlab.LibreWolf master;
2019-07-17 20:50:38 +02:00
# Clean up flatpak files
printf "\nCleaning up flatpak related files\n" ;
2019-07-21 07:30:19 +02:00
rm -rf $_FLATPAK_BUILD_FOLDER ;
rm -rf $_FLATPAK_BUILD_SOURCE_FOLDER ;
2020-03-31 01:28:24 +02:00
# keep it cached
# rm -rf ./.flatpak-builder;
2019-07-17 20:50:38 +02:00
# Delete the extracted binary tarball folder
printf "\nDeleting extracted binary tarball folder\n" ;
2019-07-21 07:30:19 +02:00
rm -rf $_EXTRACTED_BINARY_TARBALL_FOLDER ;