Subversion Repositories KardasA Overlay

Rev

Rev 120 | 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
 
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
 
122 kardasa 47
GAMES_CHECK_LICENSE="yes"
48
 
119 kardasa 49
pkg_nofetch() {
50
	einfo "Please buy and download \"${SRC_URI}\" from:"
51
	einfo "  ${HOMEPAGE}"
52
	einfo "and move it to \"${DISTDIR}\""
53
	einfo
54
}
55
 
56
src_unpack() {
57
	mkdir "tmp" || die "mkdir \"tmp\" failed"
58
	cd "./tmp" || die "cd \"tmp\" failed"
59
 
60
	unpack_makeself || die "unpack_makeself failed"
61
 
62
	mv "subarch" "installer.tar.lzma" || die "move \"subarch\" failed"
63
	unpack "./installer.tar.lzma" || die "unpack \"installer.tar.lzma\" failed"
64
 
65
	mv "instarchive_all" "../${P}.tar.lzma" || die "move \"instarchive_all\" failed"
66
	if use amd64
67
	then
68
		mv "instarchive_all_x86_64" "../${P}-amd64.tar.lzma" || die "move \"instarchive_all_x86_64\" failed"
69
	fi
70
	if use x86
71
	then
72
		mv "instarchive_all_x86" "../${P}-x86.tar.lzma" || die "move \"instarchive_all_x86\" failed"
73
	fi
74
	mv "icon.xpm" "../${PN}.xpm"
75
 
76
	cd "${WORKDIR}" || die "cd \"${WORKDIR}\" failed"
77
	unpack ./*.tar.lzma || die "unpack failed"
78
	mv "Amnesia" "${PN}" || die "mv \"Amnesia\" failed"
79
 
80
	rm ./*.tar.lzma
81
	rm -r "./tmp"
82
}
83
 
84
src_prepare() {
85
	# Files to remove.
86
	REMOVE="libs*/all
87
		Amnesia.png
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"
120 kardasa 229
	# Used LibGlEW may not be installed the game is using 1.5, there is 1.6 in portage
230
	doexe libs*/libGLEW* die "doexe \"libs\" failed"
119 kardasa 231
 
232
	exeinto "${GAMEDIR}" || die "exeinto \"${GAMEDIR}\" failed"
233
	doexe *.bin || die "doexe \".bin\" binaries failed"
234
 
235
 
236
	# Make game wrapper
237
	mkdir -p "${D}/${GAMES_BINDIR}" || die "mkdir \"${D}/${GAMES_BINDIR}\" failed"
238
 
239
	local wrapper="${D}/${GAMES_BINDIR}/${PN}"
240
	touch "${wrapper}" || die "touch \"${wrapper}\" failed"
241
 
242
	cat << EOF >> "${wrapper}" || die "echo failed"
243
#!/bin/sh
244
cd "${GAMEDIR}"
245
if [[ -w "\${HOME}/.frictionalgames/Amnesia/Main/main_settings.cfg" ]]
246
then
247
  exec ./Amnesia.bin "\${@}"
248
else
249
  exec ./Launcher.bin "\${@}"
250
fi
251
EOF
252
 
253
 
254
	# Install icon and desktop file
255
	doicon "../${PN}.xpm" || die "newicon \"icon.xpm\" failed"
256
	make_desktop_entry "${PN}" "Amnesia: The Dark Descent" || die "make_desktop_entry failed"
257
 
258
 
259
	# Install documentation
260
	if use doc
261
	then
262
		docinto ${PN}
263
		dodoc *.rtf *.pdf || die "dodoc failed"
264
	fi
265
 
266
 
267
	# Setting permissions.
268
	einfo " Setting permissions ..."
269
	prepgamesdirs
270
}
271
 
272
pkg_postinst() {
273
	ewarn ""
274
	ewarn "Amnesia: The Dark Descent needs video drivers"
275
	ewarn "that provide a complete GLSL 1.20 implementation."
276
	ewarn ""
277
	ewarn "Please visit \"http://www.frictionalgames.com/forum/thread-3760.html\""
278
	ewarn "for more infos."
279
	ewarn ""
280
	ewarn "--------------------------------------------------------------------"
281
	ewarn ""
282
	ewarn "If you was playing version 1.0 you might experience some oddities"
283
	ewarn "due to save game differences between 1.0 and 1.0.1."
284
	ewarn ""
285
}