# Maintainer: Wido <widowild at myopera dot com>
# HIB environment variable contributor: TastyPi
# a PKGBUILD is now compatible with:
# Official Store http://store.zachtronicsindustries.com/product/spacechem
# Store Gameolith http://www.gameolith.com/game/spacechem/
# The Humble Idie Bundle http://www.humblebundle.com/
pkgname=spacechem
_pkgname=SpaceChem
pkgver=1011
_pkgver=1012 # Just for HIB
pkgrel=4
pkgdesc="An obscenely addictive, design-based puzzle game about building machines and fighting monsters in the name of science!"
url="http://spacechemthegame.com/"
license=('custom: "commercial"')
arch=('i686' 'x86_64')
makedepends=()
options=(!strip)
source=("${pkgname}.sh" "${pkgname}.desktop")
md5sums=('dff2d4a980e324c46198fb9193a23099'
'b458899c445a8baa8238b9594ebee6c1')
if [[ $CARCH == x86_64 ]]; then
_gamepkg="${pkgname}_${pkgver}_amd64.tar.gz"
_gamepkg2="${_pkgname}-${pkgver}.tar.gz"
_gamepkg3="${_pkgname}-${_pkgver}-hib.tar.gz"
else
_gamepkg="${pkgname}_${pkgver}_i386.tar.gz"
_gamepkg2="${_pkgname}-${pkgver}.tar.gz"
_gamepkg3="${_pkgname}-${_pkgver}-hib.tar.gz"
fi
depends=('mono' 'sdl' 'sdl_image' 'sdl_mixer' 'xclip')
build() {
cd ${srcdir}
msg "You need a full copy of this game in order to install it"
msg "Searching for ${_gamepkg} or ${_gamepkg2} or ${_gamepkg3} in dir: \"$startdir\""
pkgpath=$startdir
if [[ ! -f "$startdir/${_gamepkg}" ]] && [[ ! -f "$startdir/${_gamepkg2}" ]] && [[ ! -f "$startdir/${_gamepkg3}" ]]; then
msg "Checking HIB_FROZENSYNAPSE environment variable"
if [ -n "$HIB_FROZENSYNAPSE" ]; then
msg "Environment variable found, checking key"
wget -O ${startdir}/${_gamepkg3} $(wget -O - http://www.humblebundle.com/?key=${HIB_FROZENSYNAPSE} | grep "${_gamepkg3}" | cut -d "'" -f 10)
else
error "Game package not found. Either set the HIB_FROZENSYNAPSE environment variable to your Humble Indie Bundle key, or give the absolute path to the directory containing the game archive:"
read pkgpath
if [[ ! -f "${pkgpath}/${_gamepkg}" ]] && [[ ! -f "${pkgpath}/${_gamepkg2}" ]] && [[ ! -f "${pkgpath}/${_gamepkg3}" ]] ; then
error "Unable to find game package." && return 1
fi
fi
fi
msg "Found game package, installing..."
## Store Gameolith
if [[ -f ${pkgpath}/${_gamepkg} ]] ; then
ln -fs ${pkgpath}/${_gamepkg} . || return 1
tar xvf ${pkgpath}/${_gamepkg} || return 1
install -d ${pkgdir}/opt/${pkgname}
cp -R ${srcdir}/* ${pkgdir}/opt/${pkgname}/
# Clean package
rm ${pkgdir}/opt/${pkgname}/${_gamepkg}
rm ${pkgdir}/opt/${pkgname}/${pkgname}.desktop
rm ${pkgdir}/opt/${pkgname}/${pkgname}.sh
fi
## Official Store
if [[ -f ${pkgpath}/${_gamepkg2} ]] ; then
ln -fs ${pkgpath}/${_gamepkg2} . || return 1
tar xvf ${pkgpath}/${_gamepkg2} || return 1
ar x ${srcdir}/${_pkgname}-i386.deb
tar -zxf ${srcdir}/data.tar.gz
rm -R ${srcdir}/usr
install -d ${pkgdir}/opt/${pkgname}
cp -R ${srcdir}/opt/zachtronicsindustries/${pkgname}/* ${pkgdir}/opt/${pkgname}/
fi
## Humble Indie Bundle
if [[ -f ${pkgpath}/${_gamepkg3} ]] ; then
ln -fs ${pkgpath}/${_gamepkg3} . || return 1
tar xvf ${pkgpath}/${_gamepkg3} || return 1
ar x ${srcdir}/${_pkgname}-i386.deb
tar -zxf ${srcdir}/data.tar.gz
rm -R ${srcdir}/usr
install -d ${pkgdir}/opt/${pkgname}
cp -R ${srcdir}/opt/zachtronicsindustries/${pkgname}/* ${pkgdir}/opt/${pkgname}/
fi
}
package(){
cd ${srcdir}
# Install Launcher
install -Dm 755 ${srcdir}/${pkgname}.sh ${pkgdir}/usr/bin/${pkgname}
# Install Desktop
install -D -m644 ${srcdir}/${pkgname}.desktop \
${pkgdir}/usr/share/applications/${pkgname}.desktop
# Install license
install -Dm 644 ${pkgdir}/opt/${pkgname}/readme/LICENSE.txt ${pkgdir}/usr/share/licenses/${pkgname}/license
}