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