1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Maintainer: Gadget30000 <gadget3000 at msn dot com>
pkgname=multiwinia
pkgver=1.3.1
pkgrel=2
pkgdesc="Battle to save Darwinias innocent inhabitants, the Darwinians, from an evil viral infection"
arch=('i686' 'x86_64')
url="http://www.introversion.co.uk/multiwinia/"
groups=('humbleintbundle' 'humblebundles')
license=('custom')
depends=('mesa' 'openal' 'sdl' 'libvorbis' 'libpng12')
source=('multiwinia.desktop')
md5sums=('8132259414180ad994c27cd2770ffc67')

if [ "${CARCH}" = "x86_64" ]; then
_carch=amd64
_archive_md5="5eaba188f84ad985fe9b5d36e3bf85a3"
_bin_postfix="_64"
else
_carch=i386
_archive_md5="bbc7d907431f15065a0f38f6623c4217"
_bin_postfix=
fi

_archive="multiwinia_${pkgver}-1_${_carch}.tar.gz"

build() {
  cd ${srcdir}

  if [ ! -f ${_multiwiniaarchivelocation}${_archive} ]; then
	  if [ ! -f ${_archive} ] && [ -n "${_humbleintbundlekey}" ]; then
		rm -f ${_archive}* index.html\?key\=${_humbleintbundlekey}*
		wget http://www.humblebundle.com/?key=${_humbleintbundlekey}
		wget $(cat index.html\?key\=${_humbleintbundlekey} | grep "${_archive}" | cut -d "'" -f 10)
		mv ${_archive}* ${_archive}
	  elif [ -z "${_humbleintbundlekey}" ]; then
		echo You can automate the download of the archive using the _humbleintbundlekey bash variable.
		echo Just add \'export _humbleintbundlekey\=\<Your key here\>\' to \.bashrc
		echo
		echo Otherwise please just place ${_archive} into $(pwd)/
		echo Press Enter to continue
		read -a _unused
	  fi
  fi

  if [ ! -f ${_multiwiniaarchivelocation}${_archive} ]; then
    echo "${_multiwiniaarchivelocation}${_archive} not found!"
    return 1
  fi  

  if ! echo "${_archive_md5}  ${_multiwiniaarchivelocation}${_archive}" | md5sum -c --quiet; then
    echo "Invalid checksum for ${_multiwiniaarchivelocation}${_archive}"
    return 1
  fi

  install -d ${pkgdir}/opt/games/
  tar xzf ${_multiwiniaarchivelocation}${_archive} -C ${pkgdir}/opt/games/
  install -d ${pkgdir}/usr/bin
  ln -s /opt/games/multiwinia/multiwinia.bin.x86${_bin_postfix} ${pkgdir}/usr/bin/multiwinia

  #Copy Icon
  install -d ${pkgdir}/usr/share/pixmaps/
  install -D -m644 ${pkgdir}/opt/games/multiwinia/multiwinia.png ${pkgdir}/usr/share/pixmaps/ || return 1

  #Copy Desktop File
  install -d ${pkgdir}/usr/share/applications
  cp ${srcdir}/multiwinia.desktop ${pkgdir}/usr/share/applications/

#  echo Installing the License
#  install -d ${pkgdir}/usr/share/licenses/${pkgname}
#  install -D -m644 ${pkgdir}/opt/games/multiwinia/license.txt ${pkgdir}/usr/share/licenses/${pkgname}/ || return 1

  chown -Rh root:root ${pkgdir}/opt/games/multiwinia
}