commit 5d4d8821bb0a2ba68f9be27c49040709c9d86ab8 Author: Bart van Strien Date: Fri Dec 2 14:26:53 2016 +0000 Add tarball build diff --git a/README.md b/README.md new file mode 100644 index 0000000..641db8d --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +The script in this git repository can be used (on a sufficiently old linux +system) to extract LÓVE binaries, and turn them into a portable build in +various different formats. + +This project is split up into multiple parts, and each part is responsible for +a different build. Note that the `tarball` build is used as a base for the +other builds. + +## tarball ## +`tarball` contains a build script that extracts the love version currently +installed on the system together with its dependencies to form a portable +build. It also creates a small wrapper script that does the correct search path +manipulations to be able to run the build. + +Lastly, it contains the icon and a stubbed desktop file. diff --git a/tarball/build.sh b/tarball/build.sh new file mode 100755 index 0000000..e98c129 --- /dev/null +++ b/tarball/build.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +DEST="$(pwd)/dest" +declare -a libpaths=() + +getdeps() +{ + ldd "$1" | awk '{print $3}' +} + +systemlib() +{ + case "$(basename "$1")" in + libc.so* | \ + libm.so* | \ + libdl.so* | \ + librt.so* | \ + libpthread.so* | \ + libstdc++.so* ) + return 0 + ;; + *) + return 1 + ;; + esac +} + +copy() +{ + # Skip system libraries + if ! test -f "$1" || systemlib "$1"; then + echo "Skipping $1" + return + fi + + # Copy files to their paths, with $DEST as prefix (so /usr/lib -> $DEST/usr/lib) + echo "Copying $1" + mkdir -p "$DEST/$(dirname "$1")" + cp "$1" "$DEST/$1" + libpaths+=("$(dirname "$1")") +} + +main() +{ + local appbin="$(which "$1")" + local appname="$(basename "$appbin")" + + # Now copy all binaries and libraries + copy "$appbin" + for dep in $(getdeps "$appbin"); do + copy "$dep" + done + + # Copy libstdc++ into its own location + echo "Copying libstdc++" + mkdir -p "$DEST/libstdc++/" + cp "/usr/lib/x86_64-linux-gnu/libstdc++.so.6" "$DEST/libstdc++/" # TODO: find libstdc++ on host + + # Build LD_LIBRARY_PATH string + local libpath="" + while read path; do + if [[ "$libpath" != "" ]]; then + libpath="$libpath:" + fi + libpath="${libpath}\${LOVE_LAUNCHER_LOCATION}$path" # TODO + done <<< "$(printf '%s\n' "${libpaths[@]}" | sort -u)" + + # Generate wrapper + ( + printf '#!/bin/sh\n' + printf 'export LOVE_LAUNCHER_LOCATION="$(dirname "$(which "$0")")"\n' + printf 'export LD_LIBRARY_PATH="%s:$LD_LIBRARY_PATH"\n' "$libpath" + printf 'ldconfig -p | grep -q libstdc++ || export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${LOVE_LAUNCHER_LOCATION}/libstdc++/"\n' + printf 'exec ${LOVE_BIN_WRAPPER} "${LOVE_LAUNCHER_LOCATION}%s" "$@"\n' "$appbin" + ) > "$DEST/$appname" + chmod +x "$DEST/$appname" + + # Add our icon and prototype desktop file + cp "$appname.desktop.in" "$DEST" + cp "$appname.svg" "$DEST" +} + +main love diff --git a/tarball/love.desktop.in b/tarball/love.desktop.in new file mode 100644 index 0000000..f1d336c --- /dev/null +++ b/tarball/love.desktop.in @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=LÖVE +Comment=The unquestionably awesome 2D game engine +MimeType=application/x-love-game; +Exec=%BINPREFIX%love %f +Type=Application +Categories=Development;Game; +Terminal=false +Icon=%ICONPREFIX%love +NoDisplay=true diff --git a/tarball/love.svg b/tarball/love.svg new file mode 100644 index 0000000..552ad17 --- /dev/null +++ b/tarball/love.svg @@ -0,0 +1,962 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +