Subversion Repositories KardasA Overlay

Rev

Rev 122 | 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"
20
KEYWORDS="amd64 x86"
21
IUSE="doc linguas_de linguas_en linguas_es linguas_fr linguas_it"
22
 
23
DEPEND="app-arch/xz-utils"
24
RDEPEND="media-libs/freealut
25
	media-libs/glew
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
35
	x11-libs/fltk:1
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
 
122 kardasa 48
GAMES_CHECK_LICENSE="yes"
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.
87
	REMOVE="libs*/all
88
		Amnesia.png
89
		AmnesiaPDF.png
90
		checklibs*.sh"
91
 
92
	# Collect infos about languages...
93
	LINGUAS_ARRAY=()
94
	LANG_ARRAY=()
95
	LANGUAGE_ARRAY=()
96
	USE_ARRAY=()
97
	DEF_ARRAY=()
98
	DOC_ARRAY=()
99
 
100
	local linguas_def="0"
101
	local linguas_in_use="0"
102
	for use in ${IUSE}
103
	do
104
		if [[ "${use%%_*}" == "linguas" ]]
105
		then
106
			local tmp="${use}"
107
			LINGUAS_ARRAY=(${LINGUAS_ARRAY[@]} "${tmp}")
108
 
109
			tmp="${tmp##linguas_}"
110
			LANG_ARRAY=(${LANG_ARRAY[@]} "${tmp}")
111
 
112
			case "${tmp}" in
113
			    "de") tmp="german";;
114
			    "en") tmp="english";;
115
			    "es") tmp="spanish";;
116
			    "fr") tmp="french";;
117
			    "it") tmp="italian";;
118
			    *) tmp="";;
119
			esac
120
			LANGUAGE_ARRAY=(${LANGUAGE_ARRAY[@]} "${tmp}")
121
 
122
			if use ${use}
123
			then
124
				USE_ARRAY=(${USE_ARRAY[@]} "1")
125
 
126
				case "${use}" in
127
					"linguas_${LANG:0:2}") DEF_ARRAY=(${DEF_ARRAY[@]} "2"); linguas_def="2";;
128
					"linguas_en") DEF_ARRAY=(${DEF_ARRAY[@]} "1"); linguas_def="$(( ${linguas_def:-0} < 2 ? 1 : 2 ))";;
129
					*) DEF_ARRAY=(${DEF_ARRAY[@]} "0");;
130
				esac
131
 
132
				if use doc
133
				then
134
					DOC_ARRAY=(${DOC_ARRAY[@]} "1")
135
				else
136
					DOC_ARRAY=(${DOC_ARRAY[@]} "0")
137
				fi
138
 
139
				linguas_in_use="$(( ${linguas_in_use} + 1 ))"
140
			else
141
				USE_ARRAY=(${USE_ARRAY[@]} "0")
142
				DEF_ARRAY=(${DEF_ARRAY[@]} "0")
143
				DOC_ARRAY=(${DOC_ARRAY[@]} "0")
144
			fi
145
		fi
146
	done
147
 
148
	# ...then process them.
149
	local n="0"
150
	local linguas_set="0"
151
	while [[ "${n}" -lt "${#LINGUAS_ARRAY[@]}" ]]
152
	do
153
		if [[ "${USE_ARRAY[${n}]}" != "1" ]]
154
		then
155
			# If no linguas keep at least english.
156
			if [[ "${linguas_in_use}" == "0" && "${LINGUAS_ARRAY[${n}]}" == "linguas_en" ]]
157
			then
158
				if use doc
159
				then
160
					DOC_ARRAY[${n}]="1"
161
				fi
162
			else
163
				REMOVE="${REMOVE} config/base_${LANGUAGE_ARRAY[${n}]}.lang config/lang_main/${LANGUAGE_ARRAY[${n}]}.lang"
164
			fi
165
		else
166
			# Prefer languages in this order: system lang - english - first of others. Don't change anything if english (linguas_def == 1).
167
			if [[ "${DEF_ARRAY[${n}]}" == "${linguas_def}" && "${linguas_def}" != "1" && "${linguas_set}" != "1" ]]
168
			then
169
				sed -e "s#english.lang#${LANGUAGE_ARRAY[${n}]}.lang#g" \
170
				    -i "./config/main_init.cfg" || die "sed \"./config/main_init.cfg\" failed"
171
 
172
				linguas_set="1"
173
			fi
174
		fi
175
 
176
		if [[ "${DOC_ARRAY[${n}]}" != "1" ]]
177
		then
178
			REMOVE="${REMOVE} EULA_${LANG_ARRAY[${n}]}.rtf Manual_${LANG_ARRAY[${n}]}.pdf"
179
		fi
180
 
181
		n="$(( ${n} + 1 ))"
182
	done
183
 
184
	einfo " Removing useless files ..."
185
	for remove in ${REMOVE}
186
	do
187
		rm -r "${S}/"${remove} || die "rm \"${remove}\" failed"
188
	done
189
 
190
	if use amd64
191
	then
192
		mv "Amnesia.bin64" "Amnesia.bin" || die "mv \"Amnesia.bin64\" failed"
193
		mv "Launcher.bin64" "Launcher.bin" || die "mv \"Launcher.bin64\" failed"
194
	fi
195
}
196
 
197
src_install() {
198
	# Install data
199
	insinto "${GAMEDIR}" || die "insinto \"${GAMEDIR}\" failed"
200
 
201
	einfo " Installing game data files ..."
202
	for directory in $(find * -maxdepth 0 -type d ! -name "libs*")
203
	do
204
		doins -r ${directory} || die "doins game data files failed"
205
	done
206
 
207
	# Other files
208
	find . -maxdepth 1 -type f ! -name "*.bin" \
209
				   ! -name "*.pdf" \
210
				   ! -name "*.png" \
211
				   ! -name "*.rtf" \
212
				   ! -name "*.sh" \
213
				   -exec doins '{}' \; || die "doins other files failed"
214
 
215
 
216
	# Install libraries and executables
217
	einfo " Installing libraries and executables ..."
218
	if use amd64
219
	then
220
		local libsdir="${GAMEDIR}/libs64"
221
	fi
222
	if use x86
223
	then
224
		local libsdir="${GAMEDIR}/libs"
225
	fi
226
 
227
	# Used LibIL (media-libs/devil) isn't in portage as too old
228
	exeinto "${libsdir}" || die "exeinto \"${libsdir}\" failed"
229
	doexe libs*/libIL* || die "doexe \"libs\" failed"
120 kardasa 230
	# Used LibGlEW may not be installed the game is using 1.5, there is 1.6 in portage
123 kardasa 231
	doexe libs*/libGLEW* || die "doexe \"libs\" failed"
119 kardasa 232
 
233
	exeinto "${GAMEDIR}" || die "exeinto \"${GAMEDIR}\" failed"
234
	doexe *.bin || die "doexe \".bin\" binaries failed"
235
 
236
 
237
	# Make game wrapper
238
	mkdir -p "${D}/${GAMES_BINDIR}" || die "mkdir \"${D}/${GAMES_BINDIR}\" failed"
239
 
240
	local wrapper="${D}/${GAMES_BINDIR}/${PN}"
241
	touch "${wrapper}" || die "touch \"${wrapper}\" failed"
242
 
243
	cat << EOF >> "${wrapper}" || die "echo failed"
244
#!/bin/sh
245
cd "${GAMEDIR}"
246
if [[ -w "\${HOME}/.frictionalgames/Amnesia/Main/main_settings.cfg" ]]
247
then
248
  exec ./Amnesia.bin "\${@}"
249
else
250
  exec ./Launcher.bin "\${@}"
251
fi
252
EOF
253
 
254
 
255
	# Install icon and desktop file
256
	doicon "../${PN}.xpm" || die "newicon \"icon.xpm\" failed"
257
	make_desktop_entry "${PN}" "Amnesia: The Dark Descent" || die "make_desktop_entry failed"
258
 
259
 
260
	# Install documentation
261
	if use doc
262
	then
263
		docinto ${PN}
264
		dodoc *.rtf *.pdf || die "dodoc failed"
265
	fi
266
 
267
 
268
	# Setting permissions.
269
	einfo " Setting permissions ..."
270
	prepgamesdirs
271
}
272
 
273
pkg_postinst() {
274
	ewarn ""
275
	ewarn "Amnesia: The Dark Descent needs video drivers"
276
	ewarn "that provide a complete GLSL 1.20 implementation."
277
	ewarn ""
278
	ewarn "Please visit \"http://www.frictionalgames.com/forum/thread-3760.html\""
279
	ewarn "for more infos."
280
	ewarn ""
281
	ewarn "--------------------------------------------------------------------"
282
	ewarn ""
283
	ewarn "If you was playing version 1.0 you might experience some oddities"
284
	ewarn "due to save game differences between 1.0 and 1.0.1."
285
	ewarn ""
286
}