Subversion Repositories KardasA Overlay

Rev

Rev 120 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 kardasa 1
# Copyright 1999-2010 Gentoo Foundation
2
# Distributed under the terms of the GNU General Public License v2
3
# $Header: $
4
 
5
EAPI=3
6
 
7
inherit eutils games
8
 
9
MY_PN="${PN//-/_}"
10
 
11
DESCRIPTION="Amnesia: The Dark Descent is a first person survival horror. A game about immersion, discovery and living through a nightmare."
12
HOMEPAGE="http://www.amnesiagame.com"
13
SRC_URI="${MY_PN}_${PV}.sh"
14
 
15
RESTRICT="fetch strip"
16
LICENSE="Frictional_Games-EULA"
17
 
18
SLOT="0"
19
KEYWORDS="amd64 x86"
20
IUSE="doc linguas_de linguas_en linguas_es linguas_fr linguas_it"
21
 
22
DEPEND="app-arch/xz-utils"
23
RDEPEND="media-libs/freealut
24
	media-libs/glew
25
	media-libs/jpeg:62
26
	media-libs/libogg
27
	media-libs/libvorbis
28
	media-libs/libpng:1.2
29
	media-libs/libtheora
30
	media-libs/openal
31
	media-libs/sdl-image
32
	media-libs/sdl-ttf
33
	sys-libs/zlib
34
	x11-libs/fltk:1
35
	x11-libs/libX11
36
	x11-libs/libXau
37
	x11-libs/libxcb
38
	x11-libs/libXdmcp
39
	x11-libs/libXext
40
	virtual/glu
41
	virtual/opengl"
42
 
43
S="${WORKDIR}/${PN}"
44
 
45
GAMEDIR="${GAMES_PREFIX_OPT}/${PN}"
46
 
47
pkg_nofetch() {
48
	einfo "Please buy and download \"${SRC_URI}\" from:"
49
	einfo "  ${HOMEPAGE}"
50
	einfo "and move it to \"${DISTDIR}\""
51
	einfo
52
}
53
 
54
src_unpack() {
55
	mkdir "tmp" || die "mkdir \"tmp\" failed"
56
	cd "./tmp" || die "cd \"tmp\" failed"
57
 
58
	unpack_makeself || die "unpack_makeself failed"
59
 
60
	mv "subarch" "installer.tar.lzma" || die "move \"subarch\" failed"
61
	unpack "./installer.tar.lzma" || die "unpack \"installer.tar.lzma\" failed"
62
 
63
	mv "instarchive_all" "../${P}.tar.lzma" || die "move \"instarchive_all\" failed"
64
	if use amd64
65
	then
66
		mv "instarchive_all_x86_64" "../${P}-amd64.tar.lzma" || die "move \"instarchive_all_x86_64\" failed"
67
	fi
68
	if use x86
69
	then
70
		mv "instarchive_all_x86" "../${P}-x86.tar.lzma" || die "move \"instarchive_all_x86\" failed"
71
	fi
72
	mv "icon.xpm" "../${PN}.xpm"
73
 
74
	cd "${WORKDIR}" || die "cd \"${WORKDIR}\" failed"
75
	unpack ./*.tar.lzma || die "unpack failed"
76
	mv "Amnesia" "${PN}" || die "mv \"Amnesia\" failed"
77
 
78
	rm ./*.tar.lzma
79
	rm -r "./tmp"
80
}
81
 
82
src_prepare() {
83
	# Files to remove.
84
	REMOVE="libs*/all
85
		Amnesia.png
86
		AmnesiaPDF.png
87
		checklibs*.sh"
88
 
89
	# Collect infos about languages...
90
	LINGUAS_ARRAY=()
91
	LANG_ARRAY=()
92
	LANGUAGE_ARRAY=()
93
	USE_ARRAY=()
94
	DEF_ARRAY=()
95
	DOC_ARRAY=()
96
 
97
	local linguas_def="0"
98
	local linguas_in_use="0"
99
	for use in ${IUSE}
100
	do
101
		if [[ "${use%%_*}" == "linguas" ]]
102
		then
103
			local tmp="${use}"
104
			LINGUAS_ARRAY=(${LINGUAS_ARRAY[@]} "${tmp}")
105
 
106
			tmp="${tmp##linguas_}"
107
			LANG_ARRAY=(${LANG_ARRAY[@]} "${tmp}")
108
 
109
			case "${tmp}" in
110
			    "de") tmp="german";;
111
			    "en") tmp="english";;
112
			    "es") tmp="spanish";;
113
			    "fr") tmp="french";;
114
			    "it") tmp="italian";;
115
			    *) tmp="";;
116
			esac
117
			LANGUAGE_ARRAY=(${LANGUAGE_ARRAY[@]} "${tmp}")
118
 
119
			if use ${use}
120
			then
121
				USE_ARRAY=(${USE_ARRAY[@]} "1")
122
 
123
				case "${use}" in
124
					"linguas_${LANG:0:2}") DEF_ARRAY=(${DEF_ARRAY[@]} "2"); linguas_def="2";;
125
					"linguas_en") DEF_ARRAY=(${DEF_ARRAY[@]} "1"); linguas_def="$(( ${linguas_def:-0} < 2 ? 1 : 2 ))";;
126
					*) DEF_ARRAY=(${DEF_ARRAY[@]} "0");;
127
				esac
128
 
129
				if use doc
130
				then
131
					DOC_ARRAY=(${DOC_ARRAY[@]} "1")
132
				else
133
					DOC_ARRAY=(${DOC_ARRAY[@]} "0")
134
				fi
135
 
136
				linguas_in_use="$(( ${linguas_in_use} + 1 ))"
137
			else
138
				USE_ARRAY=(${USE_ARRAY[@]} "0")
139
				DEF_ARRAY=(${DEF_ARRAY[@]} "0")
140
				DOC_ARRAY=(${DOC_ARRAY[@]} "0")
141
			fi
142
		fi
143
	done
144
 
145
	# ...then process them.
146
	local n="0"
147
	local linguas_set="0"
148
	while [[ "${n}" -lt "${#LINGUAS_ARRAY[@]}" ]]
149
	do
150
		if [[ "${USE_ARRAY[${n}]}" != "1" ]]
151
		then
152
			# If no linguas keep at least english.
153
			if [[ "${linguas_in_use}" == "0" && "${LINGUAS_ARRAY[${n}]}" == "linguas_en" ]]
154
			then
155
				if use doc
156
				then
157
					DOC_ARRAY[${n}]="1"
158
				fi
159
			else
160
				REMOVE="${REMOVE} config/base_${LANGUAGE_ARRAY[${n}]}.lang config/lang_main/${LANGUAGE_ARRAY[${n}]}.lang"
161
			fi
162
		else
163
			# Prefer languages in this order: system lang - english - first of others. Don't change anything if english (linguas_def == 1).
164
			if [[ "${DEF_ARRAY[${n}]}" == "${linguas_def}" && "${linguas_def}" != "1" && "${linguas_set}" != "1" ]]
165
			then
166
				sed -e "s#english.lang#${LANGUAGE_ARRAY[${n}]}.lang#g" \
167
				    -i "./config/main_init.cfg" || die "sed \"./config/main_init.cfg\" failed"
168
 
169
				linguas_set="1"
170
			fi
171
		fi
172
 
173
		if [[ "${DOC_ARRAY[${n}]}" != "1" ]]
174
		then
175
			REMOVE="${REMOVE} EULA_${LANG_ARRAY[${n}]}.rtf Manual_${LANG_ARRAY[${n}]}.pdf"
176
		fi
177
 
178
		n="$(( ${n} + 1 ))"
179
	done
180
 
181
	einfo " Removing useless files ..."
182
	for remove in ${REMOVE}
183
	do
184
		rm -r "${S}/"${remove} || die "rm \"${remove}\" failed"
185
	done
186
 
187
	if use amd64
188
	then
189
		mv "Amnesia.bin64" "Amnesia.bin" || die "mv \"Amnesia.bin64\" failed"
190
		mv "Launcher.bin64" "Launcher.bin" || die "mv \"Launcher.bin64\" failed"
191
	fi
192
}
193
 
194
src_install() {
195
	# Install data
196
	insinto "${GAMEDIR}" || die "insinto \"${GAMEDIR}\" failed"
197
 
198
	einfo " Installing game data files ..."
199
	for directory in $(find * -maxdepth 0 -type d ! -name "libs*")
200
	do
201
		doins -r ${directory} || die "doins game data files failed"
202
	done
203
 
204
	# Other files
205
	find . -maxdepth 1 -type f ! -name "*.bin" \
206
				   ! -name "*.pdf" \
207
				   ! -name "*.png" \
208
				   ! -name "*.rtf" \
209
				   ! -name "*.sh" \
210
				   -exec doins '{}' \; || die "doins other files failed"
211
 
212
 
213
	# Install libraries and executables
214
	einfo " Installing libraries and executables ..."
215
	if use amd64
216
	then
217
		local libsdir="${GAMEDIR}/libs64"
218
	fi
219
	if use x86
220
	then
221
		local libsdir="${GAMEDIR}/libs"
222
	fi
223
 
224
	# Used LibIL (media-libs/devil) isn't in portage as too old
225
	exeinto "${libsdir}" || die "exeinto \"${libsdir}\" failed"
226
	doexe libs*/libIL* || die "doexe \"libs\" failed"
227
 
228
	exeinto "${GAMEDIR}" || die "exeinto \"${GAMEDIR}\" failed"
229
	doexe *.bin || die "doexe \".bin\" binaries failed"
230
 
231
 
232
	# Make game wrapper
233
	mkdir -p "${D}/${GAMES_BINDIR}" || die "mkdir \"${D}/${GAMES_BINDIR}\" failed"
234
 
235
	local wrapper="${D}/${GAMES_BINDIR}/${PN}"
236
	touch "${wrapper}" || die "touch \"${wrapper}\" failed"
237
 
238
	cat << EOF >> "${wrapper}" || die "echo failed"
239
#!/bin/sh
240
cd "${GAMEDIR}"
241
if [[ -w "\${HOME}/.frictionalgames/Amnesia/Main/main_settings.cfg" ]]
242
then
243
  exec ./Amnesia.bin "\${@}"
244
else
245
  exec ./Launcher.bin "\${@}"
246
fi
247
EOF
248
 
249
 
250
	# Install icon and desktop file
251
	doicon "../${PN}.xpm" || die "newicon \"icon.xpm\" failed"
252
	make_desktop_entry "${PN}" "Amnesia: The Dark Descent" || die "make_desktop_entry failed"
253
 
254
 
255
	# Install documentation
256
	if use doc
257
	then
258
		docinto ${PN}
259
		dodoc *.rtf *.pdf || die "dodoc failed"
260
	fi
261
 
262
 
263
	# Setting permissions.
264
	einfo " Setting permissions ..."
265
	prepgamesdirs
266
}
267
 
268
pkg_postinst() {
269
	ewarn ""
270
	ewarn "Amnesia: The Dark Descent needs video drivers"
271
	ewarn "that provide a complete GLSL 1.20 implementation."
272
	ewarn ""
273
	ewarn "Please visit \"http://www.frictionalgames.com/forum/thread-3760.html\""
274
	ewarn "for more infos."
275
	ewarn ""
276
	ewarn "--------------------------------------------------------------------"
277
	ewarn ""
278
	ewarn "If you was playing version 1.0 you might experience some oddities"
279
	ewarn "due to save game differences between 1.0 and 1.0.1."
280
	ewarn ""
281
}