From 9c10f13d652533239ba993d88474c1f03cee08d3 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 28 Feb 2016 19:32:12 +0100 Subject: [PATCH] exlibs: add love-app.exlib --- exlibs/love-app.exlib | 96 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 exlibs/love-app.exlib diff --git a/exlibs/love-app.exlib b/exlibs/love-app.exlib new file mode 100644 index 0000000..424d796 --- /dev/null +++ b/exlibs/love-app.exlib @@ -0,0 +1,96 @@ +# Copyright 2016 Julian Ospald +# Distributed under the terms of the GNU General Public License v2 + +# Purpose: an exlib dealing with installation of love applications +# Maintainer: Julian Ospald +# Exports: src_install +# Side-effects: - adds build and runtime dependencies +# - sets $WORK +# - imports desktop-utils +# +# Usage +# exparams: - loveslot: SLOT of games-engines/love to use +# - lovepn: name of the '.love' file to install without the extension +# - lovezip (boolean): whether a zip file needs to be unpacked + +require desktop-utils + +myexparam loveslot= +myexparam lovepn=${PN} +myexparam -b lovezip=false + +exparam -v LOVE_SLOT loveslot +exparam -v LOVE_PN lovepn + +if [[ -z $(exparam loveslot) ]]; then + die "loveslot exparam needs to be set!" +fi + +export_exlib_phases src_install + + +DEPENDENCIES+=" + run: + games-engines/love:$(exparam loveslot) +" + +if exparam -b lovezip ; then + DEPENDENCIES+=" + build: + virtual/unzip + " +fi + +WORK=${WORKBASE} + +# Outputs the common base directory used for installing love applications. +# +# Arguments: none +# Side-effects: outputs to stdout +# Inspection: none +# Errors: none +share_love() { + echo -n "/usr/share/love" +} + +# Outputs the directory used for installing the given love application. +# +# Arguments: none +# Side-effects: outputs to stdout +# Inspection: none +# Errors: none +share_love_with_me() { + echo -n "$(share_love)/${PN}" +} + +# Exported 'src_install'. +# +# Arguments: none +# Side-effects: carries out installation +# Inspection: $WORK, $PN{,V}, $FETCHEDDIR +# Errors: if exparam lovepn is not set properly and main '.love' file cannot be +# found +love-app_src_install() { + local ldir=$(share_love_with_me) + + exeinto "${ldir}" + + if [[ -e "${WORK}"/${LOVE_PN}.love ]] ; then + newexe "${WORK}"/${LOVE_PN}.love ${PN}.love + elif [[ -e "${FETCHEDDIR}"/${PNV}.love ]] ; then + newexe "${FETCHEDDIR}"/${LOVE_PN}.love ${PN}.love + else + die "Could not find ${LOVE_PN}.love for installation!" + fi + + emagicdocs + + herebin ${PN} << EOF +#!/bin/sh +cd "${ldir}" +exec love-${LOVE_SLOT} ${PN}.love "\$@" +EOF + + install_desktop_entry +} +