summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 90ca45e6fcdfc4804b6b90c8171f0899faa84435 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Maintainer: Joseph Lansdowne <J49137@gmail.com>
# Forked from dustforce-hib
#     Commit: https://aur.archlinux.org/cgit/aur.git/commit/?h=dustforce-hib&id=652033563defbd0b002b57a14ab0b4070714e9a4
#     Author: Sam S. <smls75@gmail.com>

# URL used for version checking: http://dustkid.com/backend8/dustmod_version.php

pkgname=dustforce-hib-dustmod
pkgver=1.0+h20141222_21.9.1
_hibver=2014-12-22
_hibver_windows=07012015
pkgrel=2
pkgdesc='A fast-paced 2D action platformer (Humble Bundle version, with Dustmod)'
url='http://dustmod.com/'
arch=('x86_64')
license=('custom:commercial')
depends=('mesa' 'libgl' 'sdl2' 'libxdamage' 'freealut' 'libidn11'
         'libvorbis' 'libxft' 'xdg-utils' 'openssl-1.0')
PKGEXT='.pkg.tar'
DLAGENTS+=('hib::/usr/bin/echo "Could not find %u. Manually download it to \"$(pwd)\", or set up a hib:// DLAGENT in /etc/makepkg.conf."; exit 1')

_installer="Dustforce-Linux-${_hibver}.sh"
_installer_windows="dustforce_dx_${_hibver_windows}.zip"
source=("hib://${_installer}"
        "hib://${_installer_windows}"
        'http://dustkid.com/getdustmod/linux64_drmfree'
        'dustmod-patch::http://dustkid.com/backend8/dustmod_package4.php?platform=linux64_drmfree'
        'dustforce-dustmod'
        'dustforce-hib-dustmod.desktop')
sha256sums=('f7bc7ac00ef9166c0b4550e1fc120ffe78307e92be1e379f9c40a4513660fae1'
            '386c82e28eb08eea443b9881ea360cc10f29d9baf7bdafa90457a96e75b3c72c'
            'edbc4d7d5e57f40effde6339023d53d97cda25e7cfcecb6f7dbb9d075751a0c7'
            'ce216893b2865d6bb25a674c86e0b84134f317d09cc1c049ac49d6d604993540'
            'ff3c4e8cb45f6e931b6545c55064aaf644b885eb99947b6e32c953faea77a3ce'
            '031d9d6a6ed41c4f6c69ea7dc7037d1a53f656e37f16d33f220ca25db7e2912b')
# zip with no top-level directory - will extract manually
noextract=('linux64_drmfree')


# extracts a Dustmod patch archive into the given directory
# I haven't worked out any existing archive format that this uses, so this is a
# simple inline implementation
unarchive-patch () {
    in="$1"
    out="$2"

    cat "$in" | while true; do
        read -n 8 path_len_hex || break
        read -n 8 data_len_hex || break
        printf -v path_len "%d" "0x$path_len_hex"
        printf -v data_len "%d" "0x$data_len_hex"
        read -n "$path_len" path
        mkdir -p "$(dirname "$out/$path")"
        echo $path
        if [ "$path" = "dustmod.bin.x86_64_dustmod" ]; then
            dest="$out/dustmod.bin.x86_64"
        else
            dest="$out/$path"
        fi
        head -c "$data_len" > "$dest"
    done
}

package() {
      cd "$srcdir"
      _installdir=/opt/dustforce-dustmod; _target="$pkgdir"/"$_installdir"

      # install game files
      mkdir -p "$pkgdir"/"$_installdir"
      cp -TRl data/noarch "$pkgdir"/"$_installdir"
      cp -TRl data/x86_64 "$pkgdir"/"$_installdir"

      # include missing music track from Windows version
      ln {"Dustforce DX","$pkgdir"/"$_installdir"}/"content/audio/music/Sun Bleach.ogg"

      # install Dustmod
      unzip -q "$srcdir"/linux64_drmfree -d "$pkgdir"/"$_installdir"/
      # Apply Dustmod updates, which aren't distributed in the main download
      unarchive-patch "$srcdir"/dustmod-patch "$pkgdir"/"$_installdir"

      # Dustmod expects a version of curl we can't really obtain, but works with
      # the version distributed with Dustforce
      pushd "$pkgdir"/"$_installdir"/"lib64" > /dev/null
      ln -s libcurl.so.{3,4}
      popd > /dev/null

      # fix permissions
      find "$pkgdir" -type d -exec chmod 755 "{}" +
      find "$pkgdir" -type f -exec chmod 644 "{}" +
      chmod 755 "$_target"/Dustforce.bin.x86_64
      chmod 755 "$_target"/dustmod.bin.x86_64

      # install icon & desktop entry
      install -Dm644 data/noarch/Dustforce.png \
                     "$pkgdir"/usr/share/pixmaps/dustforce-dustmod.png
      install -Dm644 "$pkgname".desktop \
                     "$pkgdir"/usr/share/applications/"$pkgname".desktop

      # install launcher
      install -d "$pkgdir"/usr/bin
      install -Dm755 dustforce-dustmod "$pkgdir"/usr/bin/dustforce-dustmod
}