Subversion Repositories KardasA Overlay

Rev

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