summaryrefslogtreecommitdiff
blob: 627cc43359be816b51b708b3edda7aeb67d729ad (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-rpg/nwn/nwn-1.68-r1.ebuild,v 1.9 2007/09/04 20:12:02 calchan Exp $

inherit eutils games

LANGUAGES="linguas_fr linguas_it linguas_es linguas_de linguas_en"

MY_PV=${PV//.}
PATCH_URL_BASE=http://files.bioware.com/neverwinternights/updates/linux/${MY_PV}
PACKAGE_NAME=_linuxclient${MY_PV}_orig.tar.gz
SOU_NAME=_linuxclient${MY_PV}_xp1.tar.gz
HOU_NAME=_linuxclient${MY_PV}_xp2.tar.gz

DESCRIPTION="role-playing game set in a huge medieval fantasy world of Dungeons and Dragons"
HOMEPAGE="http://nwn.bioware.com/downloads/linuxclient.html"
SRC_URI="linguas_fr? (
		!sou? ( !hou? ( ${PATCH_URL_BASE}/French${PACKAGE_NAME} ) )
		sou? ( ${PATCH_URL_BASE}/French${SOU_NAME} )
		hou? ( ${PATCH_URL_BASE}/French${HOU_NAME} ) )
	linguas_it? (
		!sou? ( !hou? ( ${PATCH_URL_BASE}/Italian${PACKAGE_NAME} ) )
		sou? ( ${PATCH_URL_BASE}/Italian${SOU_NAME} )
		hou? ( ${PATCH_URL_BASE}/Italian${HOU_NAME} ) )
	linguas_en? (
		!sou? ( !hou? ( ${PATCH_URL_BASE}/English${PACKAGE_NAME} ) )
		sou? ( ${PATCH_URL_BASE}/English${SOU_NAME} )
		hou? ( ${PATCH_URL_BASE}/English${HOU_NAME} ) )
	linguas_es? (
		!sou? ( !hou? ( ${PATCH_URL_BASE}/Spanish${PACKAGE_NAME} ) )
		sou? ( ${PATCH_URL_BASE}/Spanish${SOU_NAME} )
		hou? ( ${PATCH_URL_BASE}/Spanish${HOU_NAME} ) )
	linguas_de? (
		!sou? ( !hou? ( ${PATCH_URL_BASE}/German${PACKAGE_NAME} ) )
		sou? ( ${PATCH_URL_BASE}/German${SOU_NAME} )
		hou? ( ${PATCH_URL_BASE}/German${HOU_NAME} ) )
	!linguas_en? (
		!linguas_es? (
			!linguas_de? (
				!linguas_fr? (
					!linguas_it? (
		!sou? ( !hou? ( ${PATCH_URL_BASE}/English${PACKAGE_NAME} ) )
		sou? ( ${PATCH_URL_BASE}/English${SOU_NAME} )
		hou? ( ${PATCH_URL_BASE}/English${HOU_NAME} ) ) ) ) ) )"

LICENSE="NWN-EULA"
SLOT="0"
KEYWORDS="-* amd64 x86"
IUSE="sou hou ${LANGUAGES}"
# nowin USE flag not used anymore by pkg_setup()
RESTRICT="mirror strip"

RDEPEND=">=games-rpg/nwn-data-1.29-r1
	virtual/opengl
	>=media-libs/libsdl-1.2.5
	x86? (
		=virtual/libstdc++-3.3
		x11-libs/libXext
		x11-libs/libX11 )
	amd64? (
		app-emulation/emul-linux-x86-baselibs
		app-emulation/emul-linux-x86-compat
		app-emulation/emul-linux-x86-xlibs )"
DEPEND="app-arch/unzip"

S=${WORKDIR}/nwn

GAMES_LICENSE_CHECK="yes"
dir=${GAMES_PREFIX_OPT}/${PN}
Ddir=${D}/${dir}

die_from_busted_nwn-data() {
	local use=$*
	ewarn "You must emerge games-rpg/nwn-data with USE=$use.  You can fix this"
	ewarn "by doing the following:"
	echo
	elog "mkdir -p /etc/portage"
	elog "echo 'games-rpg/nwn-data $use' >> /etc/portage/package.use"
	elog "emerge --oneshot games-rpg/nwn-data"
	die "nwn-data requires USE=$use"
}

die_from_busted_linguas_nwn-data() {
	local use=$*
	ewarn "You must emerge games-rpg/nwn-data with LINGUAS=${use/linguas_/}."
	ewarn "You can fix this by doing the following:"
	echo
	elog "mkdir -p /etc/portage"
	elog "echo 'games-rpg/nwn-data $use' >> /etc/portage/package.use"
	elog "emerge --oneshot games-rpg/nwn-data"
	die "nwn-data requires LINGUAS='$use'"
}

pkg_setup() {
	games_pkg_setup
	if use sou
	then
		built_with_use games-rpg/nwn-data sou || die_from_busted_nwn-data sou
	fi
	if use hou
	then
		built_with_use games-rpg/nwn-data hou || die_from_busted_nwn-data hou
	fi

	strip-linguas de en es fr it
#	currentlocale=""
#	for i in ${LINGUAS}
#	do
#		case ${i} in
#			de)
#				if [ ! -e "${dir}"/.metadata/linguas_de ]
#				then
#					use nowin && die_from_busted_linguas_nwn-data linguas_de
#				fi
#				currentlocale=de
#				;;
#			en)
#				if [ ! -e "${dir}"/.metadata/linguas_en ]
#				then
#					use nowin && die_from_busted_linguas_nwn-data linguas_en
#				fi
#				currentlocale=en
#				;;
#			es)
#				if [ ! -e "${dir}"/.metadata/linguas_es ]
#				then
#					use nowin && die_from_busted_linguas_nwn-data linguas_es
#				fi
#				currentlocale=es
#				;;
#			fr)
#				if [ ! -e "${dir}"/.metadata/linguas_fr ]
#				then
#					use nowin && die_from_busted_linguas_nwn-data linguas_fr
#				fi
#				currentlocale=fr
#				;;
#			it)
#				if [ ! -e "${dir}"/.metadata/linguas_it ]
#				then
#					use nowin && die_from_busted_linguas_nwn-data linguas_it
#				fi
#				currentlocale=it
#				;;
#		esac
#	done
}

src_unpack() {
	mkdir -p "${S}"
	cd "${S}"
	mkdir -p .metadata
	for a in ${A}
	do
		if [ -z "${a/*orig*}" ]
		then
			currentlocale=""
			if [ -z "${a/*German*/}" ]
			then
				currentlocale=de
			elif [ -z "${a/*English*/}" ]
			then
				currentlocale=en
			elif [ -z "${a/*Spanish*/}" ]
			then
				currentlocale=es
			elif [ -z "${a/*Italian*/}" ]
			then
				currentlocale=it
			elif [ -z "${a/*French*/}" ]
			then
				currentlocale=fr
			fi
			if [ -n "$currentlocale" ]
			then
				mkdir -p "${currentlocale}"
				cd "${currentlocale}"
				unpack "${a}" || die "unpack ${a}"
				cd ..
			fi
		fi
	done
	use sou && (
	for a in ${A}
	do
		if [ -z "${a/*$SOU_NAME}" ]
		then
			currentlocale=""
			if [ -z "${a/*German*/}" ]
			then
				currentlocale=de
			elif [ -z "${a/*English*/}" ]
			then
				currentlocale=en
			elif [ -z "${a/*Spanish*/}" ]
			then
				currentlocale=es
			elif [ -z "${a/*Italian*/}" ]
			then
				currentlocale=it
			elif [ -z "${a/*French*/}" ]
			then
				currentlocale=fr
			fi
			if [ -n "$currentlocale" ]
			then
				mkdir -p "${currentlocale}"
				cd "${currentlocale}"
				rm -f data/patch.bif patch.key
				unpack "${a}" || die "unpack ${a}"
				cd ..
			fi
		fi
	done )
	use hou && (
	for a in ${A}
	do
		if [ -z "${a/*$HOU_NAME}" ]
		then
			currentlocale=""
			if [ -z "${a/*German*/}" ]
			then
				currentlocale=de
			elif [ -z "${a/*English*/}" ]
			then
				currentlocale=en
			elif [ -z "${a/*Spanish*/}" ]
			then
				currentlocale=es
			elif [ -z "${a/*Italian*/}" ]
			then
				currentlocale=it
			elif [ -z "${a/*French*/}" ]
			then
				currentlocale=fr
			fi
			if [ -n "$currentlocale" ]
			then
				mkdir -p "${currentlocale}"
				cd "${currentlocale}"
				rm -f data/patch.bif patch.key data/xp1patch.bif xp1patch.key override/*
				unpack "${a}" || die "unpack ${a}"
				cd ..
			fi
		fi
	done )
	for a in ${A}
	do
		if [ -z "${a/*dialog*}" ]
		then
			currentlocale=""
			if [ -z "${a/*German*/}" ]
			then
				currentlocale=de
			elif [ -z "${a/*English*/}" ]
			then
				currentlocale=en
			elif [ -z "${a/*Spanish*/}" ]
			then
				currentlocale=es
			elif [ -z "${a/*Italian*/}" ]
			then
				currentlocale=it
			elif [ -z "${a/*French*/}" ]
			then
				currentlocale=fr
			fi
			if [ -n "$currentlocale" ]
			then
				(cd "${currentlocale}" ; unpack ${a} ; cd .. )
			fi
		fi
	done
}

src_install() {
	dodir "${dir}"
	exeinto "${dir}"
	doexe "${FILESDIR}"/fixinstall
	sed -i \
		-e "s:GENTOO_USER:${GAMES_USER}:" \
		-e "s:GENTOO_GROUP:${GAMES_GROUP}:" \
		-e "s:GENTOO_DIR:${GAMES_PREFIX_OPT}:" \
		-e "s:override miles nwm:miles:" \
		-e "s:chitin.key dialog.tlk nwmain:chitin.key:" \
		-e "s:^chmod a-x:#chmod a-x:" \
		"${Ddir}"/fixinstall || die "sed"
	if use hou || use sou
	then
		sed -i \
			-e "s:chitin.key patch.key:chitin.key:" \
			"${Ddir}"/fixinstall || die "sed"
	fi
	fperms ug+x "${dir}"/fixinstall || die "perms"
	mv "${S}"/* ${Ddir}
	mv "${S}"/.metadata "${Ddir}"
	games_make_wrapper nwn ./nwn "${dir}" "${dir}"
	make_desktop_entry nwn "Neverwinter Nights"
	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst
	einfo "The NWN linux client is now installed."
	einfo "Proceed with the following step in order to get it working:"
	einfo "Run ${dir}/fixinstall as root"
}