Skip to content

Instantly share code, notes, and snippets.

@quotepilgrim
Created May 9, 2024 19:38
Show Gist options
  • Select an option

  • Save quotepilgrim/40a25b465d5ab8702afcbb84fca6b602 to your computer and use it in GitHub Desktop.

Select an option

Save quotepilgrim/40a25b465d5ab8702afcbb84fca6b602 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script is used to package a game made with the LÖVE framework
# for Windows and Linux. It was made for the one specific game but can be
# easily modified to package any game made with LÖVE with minimal changes.
# It may require more significant changes for future versions of LÖVE.
# It relies on the game's source code being in a directory named 'src'
# within the same directory as this script, alongside both a 32 bit and a
# 64 bit version of LÖVE for Windows, plus appimagetool and the AppImage
# version of LÖVE for Linux.
title="Armed with Springs"
description="A game made with LÖVE."
basename=armed_with_springs
love_w32=love-11.5-win32
love_w64=love-11.5-win64
love_appimage=love-11.5-x86_64.AppImage
game_love_file=$basename.love
game_win32_zip=$basename-win32.zip
game_win64_zip=$basename-win64.zip
game_appimage=$basename.AppImage
include_files="src/Font-License.txt"
appimagetool=/home/pilgrim/Applications/appimagetool-x86_64.AppImage
if [ -f $game_love_file ]; then
f="-u"
else
f=
fi
cd src || exit
# This needs to be changed depending on the source files that need to be included.
zip $f ../$game_love_file ./*.lua levels/*.lua -r graphics sounds
cd ..
if [ -f $game_win32_zip ]; then
f="-u"
else
f=
fi
cd $love_w32 || exit
cat love.exe ../$game_love_file >game.exe
zip $f ../$game_win32_zip ./*.dll game.exe game.ico license.txt
cd ..
if [ -f $game_win64_zip ]; then
f="-u"
else
f=
fi
cd $love_w64 || exit
cat love.exe ../$game_love_file >game.exe
zip $f ../$game_win64_zip ./*.dll game.exe game.ico license.txt
cd ..
if [ ! -d squashfs-root ]; then
./$love_appimage --appimage-extract
fi
if [ -n "$include_files" ]; then
zip -u -j $game_win32_zip $include_files
zip -u -j $game_win64_zip $include_files
cp -u $include_files squashfs-root
fi
cat squashfs-root/bin/love $game_love_file >squashfs-root/bin/game
chmod +x squashfs-root/bin/game
sed -i "s/LÖVE/$title/" squashfs-root/love.desktop
sed -Ei "s/(Comment=).*/\1$description/" squashfs-root/love.desktop
sed -Ei "s/(Exec=)love/\1game/" squashfs-root/love.desktop
sed -Ei "s/(Categories=).*/\1Game/" squashfs-root/love.desktop
sed -Ei "s/(exec.*)love/\1game/" squashfs-root/AppRun
mv squashfs-root/bin/love .
$appimagetool squashfs-root $game_appimage
mv love squashfs-root/bin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment