# Contributor: Ben R. <thebenj88 *AT* gmail *DOT* com>
pkgname=wakingmars-hib
pkgver=1.0.4
pkgrel=1
pkgdesc='Explore Mars in this 2D sidescrolling adventure game (Humble Bundle version)'
url='http://www.tigerstylegames.com/wakingmars/'
arch=('i686' 'x86_64')
license=('custom:commercial')
depends=('libgl' 'mesa')
optdepends=('catalyst: AMD Proprietary 3D driver'
'nvidia: NVIDIA Proprietary 3D driver')
PKGEXT='.pkg.tar'
_gamepkg="WakingMars-${pkgver}-Linux.tar.gz"
package() {
# Get installer
_get_humblebundle_source "${_gamepkg}" || {
error "Unable to find the game archive. Please download it from your Humble
Bundle page, and place it into one of the above locations."
exit 1;
}
msg "Extract files"
bsdtar -xf ${srcdir}/${_gamepkg}
msg "Create directories"
mkdir -p ${pkgdir}/usr/bin
mkdir -p ${pkgdir}/opt/${pkgname}/
mkdir -p ${pkgdir}/usr/share/{licenses,doc}/${pkgname}
mkdir ${pkgdir}/usr/share/applications
msg "Install license, documentation and desktop file"
install -Dm644 ${srcdir}/WakingMars-${pkgver}-Linux/Licenses/EULA.txt ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
install -Dm644 ${srcdir}/WakingMars-${pkgver}-Linux/README.txt ${pkgdir}/usr/share/doc/${pkgname}/README.html
sed -i 's|Path=/usr/local/games/wakingmars|Path=/usr/bin/wakingmars|g' ${srcdir}/WakingMars-${pkgver}-Linux/wakingmars.desktop
sed -i 's|Icon=/usr/local/games/wakingmars/wakingmars.png|Path=/opt/wakingmars-hib/wakingmars.png|g' ${srcdir}/WakingMars-${pkgver}-Linux/wakingmars.desktop
install -Dm644 ${srcdir}/WakingMars-${pkgver}-Linux/wakingmars.desktop ${pkgdir}/usr/share/applications/wakingmars.desktop
rm -r ${srcdir}/WakingMars-${pkgver}-Linux/{Licenses,install,README.txt,wakingmars.desktop}
msg "Install game contents"
mv -v ${srcdir}/WakingMars-${pkgver}-Linux/wakingmars/* ${pkgdir}/opt/${pkgname}/
msg "Set owner and permissions"
chown root:games ${pkgdir}/opt/${pkgname} -R
find ${pkgdir}/opt/${pkgname} -type f -print0 | xargs -0 chmod 644
find ${pkgdir}/opt/${pkgname} -type d -print0 | xargs -0 chmod 755
chmod 755 ${pkgdir}/opt/${pkgname}/wakingmars
msg "Link binary to /usr/bin"
ln -s /opt/${pkgname}/wakingmars ${pkgdir}/usr/bin/wakingmars
}
# Thanks again to smls for the following two functions, these saved me
# a lot of time.
# Locate a game archive from one of the Humble Bundles, and symlink it into $srcdir
_get_humblebundle_source() {
_get_local_source "$1" || return 1;
}
# Locate a file or folder provided by the user, and symlink it into $srcdir
_get_local_source() {
msg "Looking for '$1'..."
declare -A _search=(['build dir']="$startdir"
['$LOCAL_PACKAGE_SOURCES']="$LOCAL_PACKAGE_SOURCES")
for _key in "${!_search[@]}"; do local _dir="${_search["$_key"]}"
if [ -z "$_dir" ]; then _dir="<undefined>"; fi
echo -n " - in $_key ['$_dir'] ... ";
if [ -e "$_dir/$1" ]; then
echo "FOUND"; ln -sfT "$(readlink -f "$_dir/$1")" "$srcdir/$1"; break; fi
echo "NOT FOUND"
done
if [ ! -e "$srcdir/$1" ]; then return 1; fi
}