summaryrefslogtreecommitdiff
blob: 3be3c811538ed4172f91b5a4bc46a3240f0ea69c (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-rpg/nwn-data/nwn-data-1.29.ebuild,v 1.8 2005/12/21 22:26:53 wolf31o2 Exp $

inherit eutils games

MY_PV=${PV//.}

DESCRIPTION="Neverwinter Nights Data Files"
HOMEPAGE="http://nwn.bioware.com/downloads/linuxclient.html"
SRC_URI="http://nwdownloads.bioware.com/neverwinternights/linux/${MY_PV}/nwclient${MY_PV}.tar.gz
	linguas_fr? (
		ftp://jeuxlinux.com/bioware/Neverwinter_Nights/nwfrench${MY_PV}.tar.gz )
	linguas_it? (
		http://nwdownloads.bioware.com/neverwinternights/linux/${MY_PV}/nwitalian${MY_PV}.tar.gz )
	linguas_es? (
		http://nwdownloads.bioware.com/neverwinternights/linux/${MY_PV}/nwspanish${MY_PV}.tar.gz )
	linguas_de? (
		http://xfer06.fileplanet.com/%5E389272944/082003/nwgerman${MY_PV}.tar.gz )
	nowin? (
		http://bsd.mikulas.com/nwresources${MY_PV}.tar.gz
		http://163.22.12.40/FreeBSD/distfiles/nwresources${MY_PV}.tar.gz
		ftp://jeuxlinux.com/bioware/Neverwinter_Nights/nwresources${MY_PV}.tar.gz )"

LICENSE="NWN-EULA"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="nowin sou hou"
RESTRICT="nostrip nomirror"

RDEPEND="virtual/x11
	virtual/opengl
	>=media-libs/libsdl-1.2.5
	amd64? ( app-emulation/emul-linux-x86-baselibs )"

S=${WORKDIR}/nwn

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

pkg_setup() {
	games_pkg_setup
	if use sou && use hou
	then
		echo "You will need the SoU and HoU CDs for this installation."
		cdrom_get_cds NWNSoUInstallGuide.rtf \
			ArcadeInstallNWNXP213f.EXE
	elif use sou
	then
		 echo "You will need the SoU CD for this installation."
		cdrom_get_cds NWNSoUInstallGuide.rtf
	elif use hou
	then
		 echo "You will need the HoU CD for this installation."
		cdrom_get_cds ArcadeInstallNWNXP213f.EXE
	fi
}

src_unpack() {
	mkdir "${S}"
	cd "${S}"
	# We create this .metadata directory so we can keep track of what we have
	# installed without needing to keep all of these multiple USE flags in all
	# of the ebuilds.
	mkdir -p "${S}"/.metadata || die "Creating .metadata"
	if use linguas_de
	then
		touch .metadata/linguas_de || die "touching de"
	elif use linguas_es
	then
		touch .metadata/linguas_es || die "touching es"
	elif use linguas_fr
	then
		touch .metadata/linguas_fr || die "touching fr"
	elif use linguas_it
	then
		touch .metadata/linguas_it || die "touching it"
	else
		touch .metadata/linguas_en || die "touching en"
	fi
	unpack nwclient129.tar.gz
	cd "${WORKDIR}"
	use nowin && unpack nwresources129.tar.gz
	cd "${S}"
	rm -rf override/*
	# the following is so ugly, please pretend it doesnt exist
	declare -a Aarray=(${A})
	use nowin && if [ "${#Aarray[*]}" == "3" ]
	then
		unpack ${Aarray[1]}
	fi
	if use sou
	then
		unzip -o ${CDROM_ROOT}/Data_Shared.zip
		unzip -o ${CDROM_ROOT}/Language_data.zip
		unzip -o ${CDROM_ROOT}/Language_update.zip
		unzip -o ${CDROM_ROOT}/Data_Linux.zip
		rm -f data/patch.bif patch.key
		touch .metadata/sou || die "touching sou"
	fi
	if use hou
	then
		if use sou && use hou
		then
			rm -f xp1patch.key data/xp1patch.bif override/*
			cdrom_load_next_cd
		fi
		rm -f data/patch.bif patch.key
		unzip -o ${CDROM_ROOT}/Data_Shared.zip
		unzip -o ${CDROM_ROOT}/Language_data.zip
		unzip -o ${CDROM_ROOT}/Language_update.zip
	fi
	touch .metadata/hou || die "touching hou"
	sed -i -e '\:^./nwmain .*:i \
if [[ -f ./nwmouse.so ]]; then \
	export XCURSOR_PATH="$(pwd)" \
	export XCURSOR_THEME=nwmouse \
	export LD_PRELOAD=./nwmouse.so:$LD_PRELOAD \
fi \
	' "${S}/nwn"
}

src_install() {
	dodir "${dir}"
	# Since the movies don't play anyway, we'll remove them
	rm -rf "${S}"/movies
	mkdir -p "${S}"/dmvault "${S}"/hak "${S}"/portraits "${S}"/localvault
	rm -rf "${S}"/dialog.tlk "${S}"/dialog.TLK "${S}"/dmclient "${S}"/nwmain \
		"${S}"/nwserver  "${S}"/nwm/* "${S}"/SDL-1.2.5 "${S}"/fixinstall
	mv "${S}"/* "${Ddir}"
	mv "${S}"/.metadata "${Ddir}"
	keepdir ${dir}/servervault
	keepdir ${dir}/scripttemplates
	keepdir ${dir}/saves
	keepdir ${dir}/portraits
	keepdir ${dir}/hak
	cd ${Ddir}
	for d in ambient data dmvault hak localvault music override portraits
	do
		if [ -d ${d} ]
		then
			cd ${d}
			for f in $(find . -name '*.*') ; do
				lcf=$(echo ${f} | tr [:upper:] [:lower:])
				if [ ${f} != ${lcf} ] && [ -f ${f} ]
				then
					mv ${f} $(echo ${f} | tr [:upper:] [:lower:])
				fi
			done
			cd ${Ddir}
		fi
	done
	if ! use sou && ! use hou && use nowin
	then
		chmod a-x ${Ddir}/data/patch.bif ${Ddir}/patch.key
	fi
	doicon "${FILESDIR}"/nwn.png
	prepgamesdirs
	chmod -R g+rwX ${Ddir}/saves ${Ddir}/localvault ${Ddir}/dmvault \
		2>&1 > /dev/null || die "could not chmod"
	chmod g+rwX ${Ddir} || die "could not chmod"
}

pkg_postinst() {
	games_pkg_postinst
	if ! use nowin ; then
		einfo "The NWN linux client data is now installed."
		einfo "Proceed with the following steps in order to get it working:"
		einfo "1) Copy the following directories/files from your installed and"
		einfo "   patched (1.66) Neverwinter Nights to ${dir}:"
		einfo "    ambient/"
		einfo "    data/"
		einfo "    dmvault/"
		einfo "    hak/"
		einfo "    localvault/"
		einfo "    modules/"
		einfo "    music/"
		einfo "    portraits/"
		einfo "    saves/"
		einfo "    servervault/"
		einfo "    texturepacks/"
		einfo "    chitin.key"
		einfo "2) Remove some files to make way for the patch"
		einfo "    rm ${dir}/music/mus_dd_{kingmaker,shadowgua,witchwake}.bmu"
		einfo "    rm ${dir}/override/iit_medkit_001.tga"
		einfo "    rm ${dir}/data/patch.bif"
		if use sou
		then
			einfo "    rm ${dir}/xp1patch.key ${dir}/data/xp1patch.bif"
		fi
		if use hou
		then
			einfo "    rm ${dir}/xp2patch.key ${dir}/data/xp2patch.bif"
		fi
		einfo "3) Chown and chmod the files with the following commands"
		einfo "    chown -R ${GAMES_USER}:${GAMES_GROUP} ${dir}"
		einfo "    chmod -R g+rwX ${dir}"
		echo
		einfo "Or try emerging with USE=nowin"
	else
		einfo "The NWN linux client data is now installed."
	fi
	echo
	einfo "This is only the data portion, you will also need games-rpg/nwn to"
	einfo "play Neverwinter Nights."
	echo
}