summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6b0a21457c82a56869c06cd994a1c64065abf5d4 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Maintainer: ProfessorKaos64 <mdeguzis@gmail.com>

pkgname=doomrl-git
pkgver=r8.0cbac80
doomrl_assets='doomrl-linux-assets-x64-0997'
pkgrel=10
pkgdesc="Doom: The Rogue-like (git-latest) (WIP!)."
arch=(any)
url="http://drl.chaosforge.org/"
license=('GPL3')
depends=('sdl_mixer' 'zlib' 'lua51' 'timidity++' 'sdl_image')
makedepends=('git' 'fpc-svn' 'lua')
source=("${pkgname}::git+https://github.com/ChaosForge/doomrl"
	"fpcvalkyrie::git+https://github.com/ChaosForge/fpcvalkyrie"
	"http://www.libregeek.org/Linux/game-files/doomrl/${doomrl_assets}.tar"
	'disable-asmcse-opt.patch'
	'disable-offending-shell-code.patch'
	'hard-code-svn-revision.patch'
	'fix-lua-dynamic-linking.patch'
	'doomrl-launch'
	)
sha256sums=('SKIP'
	    'SKIP'
	    '590c28b4e7f655e23c01bca0b2f9ddf9b8dd024f3a8b7ac5ec65d79877a6450b'
	    '1844d4698da23f31276f71e2fdd369959b41eac0b69677a147bd534b9c32b5ce'
	    '439de08ce548b0dc7ff6ba31ace7f375a1e6f0ebac32addf8a05d3d31283e192'
	    'e57148577e3152c99a61adb7ae841272491b7be62b168b8d62ee73b322b37418'
	    '8b7be4a787422722da65b3c184178f221d5ec76e60f11fda371aa27c9808ea9d'
	    '1bd87b0e8707ed7c41ad4f3b409515e5ac66aa9f14127cef584a68c7644615bc'
	    )

prepare()
{

  msg2 "Cleaning files"

  # clean
  find "${srcdir}/${pkgname}" "${srcdir}/fpcvalkyrie" \
  '(' -iname '*.o' -or -iname '*.ppu' ')' -exec rm -f '{}' ';'

  # assets
  cp -ru "${srcdir}/$doomrl_assets/mp3"/* "${srcdir}/${pkgname}/bin/mp3"
  cp -ru "${srcdir}/$doomrl_assets/wavhq"/* "${srcdir}/${pkgname}/bin/wavhq" 

  # symlinks
  rm -f "${srcdir}/${pkgname}/bin/lua5.1.so"

  msg2 "Patching"

  # patch
  cd "${srcdir}"
  patch -p1 < disable-asmcse-opt.patch
  patch -p1 < disable-offending-shell-code.patch
  patch -p1 < hard-code-svn-revision.patch
  patch -p1 < fix-lua-dynamic-linking.patch

}

pkgver() {
  cd "${pkgname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build()
{

  cd ${srcdir}/${pkgname}
  rm -rf tmp && mkdir tmp

  # add Linux config
  msg2 "Compiling doomrl"
  echo "OS=\"LINUX\"" > "${srcdir}/${pkgname}/config.lua"
  echo "VALKYRIE_ROOT=\"${srcdir}/fpcvalkyrie/\"" >> "${srcdir}/${pkgname}/config.lua"
  
  # lua makefile can be called to do the build 
  # but it seems to miss building makewad
  # use lazbuild instead
  # lua makefile.lua hq

  lazbuild "src/makewad.lpi"
  lazbuild "src/doomrl.lpi"

  # Generate wad
  msg2 "Generating wad file(s)"
  cd "${srcdir}/${pkgname}/bin"

  # makewad doesn't properly search for the lua lib, include our lib path
  # link and provide the path
  ln -s "/usr/lib/liblua5.1.so" "lua5.1.so"
  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./makewad

}

package() {

  msg2 "Installing doomrl files"

  # check for doomrl and wads
  # Even if compile fails, it often will just continue on
  # Doesn't seem to exit fully

  file_check="doomrl core.wad doomrl.wad"

  for file in ${file_check};
  do

	if [[ ! -f "${srcdir}/${pkgname}/bin/${file}" ]]; then

		echo "ERROR: Cannot find core file ${file}. Exiting build."
		exit 1

	fi

  done

  cd "${srcdir}/${pkgname}"

  #####################
  # Directories
  #####################

  install -d "$pkgdir/usr/share/games/doomrl"
  # Modules should not include original source content, just readme
  install -d "$pkgdir/usr/share/games/doomrl/modules"

  DIRS="backup mp3 wavhq screenshot backup mortem"

  for dir in $DIRS;
  do
	cp -dr "bin/${dir}" "$pkgdir/usr/share/games/doomrl/${dir}"

  done

  #####################
  # bin/share files
  #####################

  # Shouldn't need the extra scripts, but include them anyway

  FILES="core.wad
	 doomrl.wad 
	 doomrl 
	 manual.txt 
	 version.txt
	 version_api.txt
	 unix_notes.txt
	 config.lua
	 colors.lua
	 keybindings.lua 
	 sound.lua
	 manual.txt
	 music.lua
	 musichq.lua
	 doomrl_gnome-terminal
	 doomrl_konsole
	 doomrl_xterm
	 modules/!readme.txt"

  for file in $FILES;
  do

	install -m755 "bin/${file}" "$pkgdir/usr/share/games/doomrl/$(basename ${file})"	

  done

  # launcher
  install -Dm755 "$startdir/doomrl-launch" "$pkgdir/usr/bin/doomrl"

  msg2 "Fixing permissions"
  
  # doomrl must have write access to several files
  # Use a workaround, makeing the group owner games and
  # only modifying files we need to
  chown -R root:games "$pkgdir/usr/share/games/doomrl"
  chmod -R g+w "$pkgdir/usr/share/games/doomrl"

  #############
  # libs
  #############

  msg "Fixing up libs"

  # doomrl expects the lib to be "lua5.1.so", not our liblua5.1.so
  # Need to use a hack (until otherwise fixed) to trick doomrl to find it
  # copy in the existing symlink in the $srcdir/$pkgname/bin dir, preserving
  # the symlink path

  cp -P "bin/lua5.1.so" "$pkgdir/usr/share/games/doomrl"

}