Subversion Repositories KardasA Overlay

Rev

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