# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI=5 inherit check-reqs eutils games MY_ARCH="${ARCH/amd64/x86_64}" MY_NAME=AmnesiaAMFP MY_REV="-3" DESCRIPTION="Amnesia: A Machine for Pigs is a first person survival horror. A game about immersion, discovery and living through a nightmare." HOMEPAGE="http://www.aamfp.com/" SRC_URI="${MY_NAME}-${PV}${MY_REV}.sh" RESTRICT="fetch strip" LICENSE="Frictional_Games-EULA" SLOT="0" KEYWORDS="amd64 ~x86" IUSE="doc linguas_br linguas_cz linguas_de linguas_es linguas_fr linguas_hu linguas_it linguas_pl linguas_ru" DEPEND="app-arch/unzip" RDEPEND="media-libs/devil media-libs/libsdl2 media-libs/libogg media-libs/libtheora media-libs/libvorbis media-libs/openal sys-libs/zlib x11-libs/libX11 x11-libs/libXau x11-libs/libXdmcp x11-libs/libXext x11-libs/libxcb virtual/glu virtual/opengl" CHECKREQS_DISK_BUILD="10G" S="${WORKDIR}/data" GAMEDIR="${GAMES_PREFIX_OPT}/${PN}" pkg_nofetch() { einfo "" einfo "Please buy and download \"${SRC_URI}\" from:" einfo " ${HOMEPAGE}" einfo "and move/link it to \"${DISTDIR}\"" einfo "" } pkg_setup() { games_pkg_setup } src_unpack() { einfo "\nUnpacking files. This will take several minutes." # unzip expected to return error code 1 because of wrapper unzip -q "${DISTDIR}/${A}" 2>/dev/null [ $? -gt 1 ] && die "unpacking failed" } src_prepare() { # Remove unneeded files cd "${S}/noarch" REMOVE="*.pdf uninstall-${MY_NAME}.sh" KEEP= # Collect info about languages... LINGUAS_ARRAY=() # Linguas - string: E.g.: "linguas_en" LANG_ARRAY=() # Lang - string: E.g.: "en" LANGUAGE_ARRAY=() # Language - string: E.g.: "english" LANGUAGE_SHORT_ARRAY=() # Language Short - string: E.g.: "eng" USE_ARRAY=() # Used - bool (0,1) local linguas_in_use="0" for use in ${IUSE}; do if [[ "${use%%_*}" == "linguas" ]]; then local tmp="${use}" LINGUAS_ARRAY=(${LINGUAS_ARRAY[@]} "${tmp}") tmp="${tmp##linguas_}" LANG_ARRAY=(${LANG_ARRAY[@]} "${tmp}") case "${tmp}" in "br") tmp="brazilian_portuguese";; "cz") tmp="czech";; "de") tmp="german";; "es") tmp="spanish";; "fr") tmp="french";; "hu") tmp="hungarian";; "it") tmp="italian";; "pl") tmp="polish";; "ru") tmp="russian";; *) tmp="";; esac LANGUAGE_ARRAY=(${LANGUAGE_ARRAY[@]} "${tmp}") LANGUAGE_SHORT_ARRAY=(${LANGUAGE_SHORT_ARRAY[@]} "${tmp:0:3}") if use ${use}; then USE_ARRAY=(${USE_ARRAY[@]} "1") linguas_in_use="$(( ${linguas_in_use} + 1 ))" else USE_ARRAY=(${USE_ARRAY[@]} "0") fi fi done # ...then process them. local n="0" local docs_eng="0" while [[ "${n}" -lt "${#LINGUAS_ARRAY[@]}" ]]; do if [[ "${USE_ARRAY[${n}]}" -gt "0" ]]; then # If only one lang is selected, use it as default. if [[ "${linguas_in_use}" == "1" ]]; then sed -e "s#english.lang#${LANGUAGE_ARRAY[${n}]}.lang#g" \ -i config/*main_init.cfg || die "sed 'config/*main_init.cfg' failed" fi else REMOVE="${REMOVE} $(find config -type f -name "*${LANGUAGE_ARRAY[${n}]}.lang")" if [[ -d "lang/${LANGUAGE_SHORT_ARRAY[${n}]}" ]]; then REMOVE="${REMOVE} lang/${LANGUAGE_SHORT_ARRAY[${n}]}" fi fi if use doc; then if use linguas_${LANG_ARRAY[${n}]} && [ -f "Manual_${LANG_ARRAY[${n}]}.pdf" ]; then KEEP="${KEEP} Manual_${LANG_ARRAY[${n}]}.pdf" else local docs_eng="1" fi fi n="$(( ${n} + 1 ))" done if use doc && [[ ( "${linguas_in_use}" == "0" || "${docs_eng}" != "0" ) ]]; then KEEP="${KEEP} Manual.pdf" fi einfo "Removing useless files ..." for remove in ${REMOVE}; do local removable="1" for keep in ${KEEP}; do if [[ "${remove}" == "${keep}" && "${removable}" == "1" ]]; then local removable="0" fi done if [[ "${removable}" == "1" ]]; then rm -r "${S}/gamedata/"${remove} &> /dev/null fi done } src_install() { # Install data insinto "${GAMEDIR}" exeinto "${GAMEDIR}" # Install and remove icon and documentation newicon "noarch/${MY_NAME}.png" "${PN}.png" || die "newicon failed" rm "${MY_NAME}.png" if use doc; then dodoc noarch/*.pdf || die "dodoc failed" rm noarch/*.pdf fi einfo "Installing game data files ..." doins -r noarch/* newexe "${MY_ARCH}/${MY_NAME}.bin.${MY_ARCH}" "${MY_NAME}.bin" # Launcher seems to crash when loading game (at least on amd64); # and isn't required, so don't install #newexe "${MY_ARCH}/Launcher.bin.${MY_ARCH}" "Launcher.bin" # Make game wrapper local wrapper="${S}/${PN}" cat << EOF > "${wrapper}" || die "echo failed" #!/bin/sh cd "${GAMEDIR}" #if [ -w "\${HOME}/.frictionalgames/Amnesia/Pig/main_settings.cfg" ]; then exec ./${MY_NAME}.bin "\${@}" #else # exec ./Launcher.bin "\${@}" #fi EOF # Install wrapper dogamesbin "${wrapper}" # Install icon and desktop file make_desktop_entry "${PN}" "Amnesia: A Machine for Pigs" "/usr/share/pixmaps/${PN}.png" } pkg_postinst() { prepgamesdirs }