love-linux-builder/flatpak/build.sh

77 lines
1.7 KiB
Bash
Raw Normal View History

2016-12-03 12:57:47 +00:00
#!/bin/bash
set -eo >/dev/null
2017-09-06 16:01:36 +00:00
ARCH="$(uname -m)"
REPO="${REPO:-repo}"
2017-09-06 16:01:36 +00:00
2016-12-03 12:57:47 +00:00
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <version>"
exit 0
fi
VERSION="$1"
2017-09-06 16:01:36 +00:00
if ! test -f ../tarball/love-${VERSION}-${ARCH}.tar.gz; then
2016-12-03 12:57:47 +00:00
echo "No tarball found for $VERSION"
exit 1
fi
if ! which flatpak >/dev/null; then
echo "Please install flatpak and try again"
exit 1
fi
# Extract the tarball build into a folder
rm -rf files
mkdir files
2017-09-06 16:01:36 +00:00
tar xf ../tarball/love-${VERSION}-${ARCH}.tar.gz -C files --strip-components=1
2016-12-03 12:57:47 +00:00
cd files
2017-09-09 10:36:53 +00:00
# The export dir contains metadata for the host
rm -rf ../export
2017-09-09 10:54:19 +00:00
mkdir ../export
# If we're packaging a game, move its data in place and extract the relevant metadata
target="love-${VERSION}"
targetversion="$VERSION"
rdns="org.love2d.love"
if test -f ../../game.rdns && test -f ../../game.version; then
rdns="$(cat ../../game.rdns)"
targetversion="$(cat ../../game.version)"
if test -f ../../game.desktop.in; then
cp ../../game.desktop.in love.desktop.in
fi
if test -f ../../game.svg; then
cp ../../game.svg love.svg
fi
if test -f ../../game.love; then
target="game"
cat usr/bin/love ../../game.love > usr/bin/love-fused
mv usr/bin/love-fused usr/bin/love
chmod +x usr/bin/love
fi
fi
2016-12-03 12:57:47 +00:00
# Add our desktop file
2017-09-09 10:54:19 +00:00
sed -e 's|%BINARY%|/app/love|' -e "s/%ICON%/${rdns}/" love.desktop.in > "../export/${rdns}.desktop"
2016-12-03 12:57:47 +00:00
rm love.desktop.in
# "Install" the icon
2017-09-09 10:54:19 +00:00
mv love.svg "../export/${rdns}.svg"
2016-12-03 12:57:47 +00:00
2017-09-09 10:54:19 +00:00
# Make sure app/lib/GL exists, for the extension mount point (no longer needed?)
2016-12-03 12:57:47 +00:00
mkdir -p lib/GL
2017-09-09 10:54:19 +00:00
# Process metadata.in
2016-12-03 12:57:47 +00:00
cd ..
2017-09-09 10:54:19 +00:00
sed -e "s/%RDNS%/${rdns}/" metadata.in > metadata
# Now build the final AppImage
2016-12-03 12:57:47 +00:00
#rm -rf repo
flatpak build-export "$REPO" . "$targetversion"
flatpak build-bundle "$REPO" "${target}-${ARCH}.flatpak" "$rdns" "$targetversion"