# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="2" inherit eutils unpacker multilib games MY_INST="${PN}_${PV}-english-2.run" MY_EXE="setup_kingpin.exe" DESCRIPTION="Adult-oriented FPS featuring violent gang warfare" HOMEPAGE="http://www.liflg.org/?catid=6&gameid=2" SRC_URI="http://www.liflg.org/?what=dl&catid=6&gameid=2&filename=${MY_INST} -> ${MY_INST} !cdinstall? ( ${MY_EXE} )" LICENSE="as-is" SLOT="0" KEYWORDS="amd64 ~x86" IUSE="cdinstall" RESTRICT="strip !cdinstall? ( fetch )" PROPERTIES="cdinstall? ( interactive )" RDEPEND="x86? ( virtual/opengl x11-libs/libX11 x11-libs/libXau x11-libs/libXdmcp x11-libs/libXext ) amd64? ( app-emulation/emul-linux-x86-sdl app-emulation/emul-linux-x86-xlibs )" DEPEND="virtual/cdrtools !cdinstall? ( app-arch/innounp )" S=${WORKDIR} dir=${GAMES_PREFIX_OPT}/${PN} QA_TEXTRELS="${dir:1}/kphack.so ${dir:1}/ref_gl.so ${dir:1}/ref_glx.so" pkg_nofetch() { elog "You must place a copy of, or symlink to, the GOG setup package in:" elog "${DISTDIR}" echo elog "If you wish to install from CD-ROM instead, please enable the cdinstall flag" } pkg_setup() { games_pkg_setup if use cdinstall; then cdrom_get_cds kingpin/data1.cab case ${CDROM_SET} in 0) echo 'Found CD' ;; *) die "Unrecognized CD" ;; esac else if [ ! -e "${DISTDIR}/${MY_EXE}" ]; then ewarn "You must copy or symlink '${MY_EXE}' to your distfiles directory" die "GOG installer not found" fi fi } src_unpack() { unpack_makeself ${MY_INST} unpack ./kingpin_${PV}.tar unpack ./kphack.tar.gz # Extract files from CD-ROM if appropriate if use cdinstall; then einfo "Unpacking CD-ROM files. This will take a while..." # Fix installed script to support spaces in CD path sed -e 's/$SETUP_CDROMPATH/"$SETUP_CDROMPATH"/g' \ -e 's/${SETUP_CDROMPATH}/"${SETUP_CDROMPATH}"/g' \ -i setup.data/install-disc1.sh || die "sed install-disc1.sh" chmod a+x setup.data/install-disc1.sh SETUP_CDROMPATH="${CDROM_ROOT}" ./setup.data/install-disc1.sh \ || die "install-disc1.sh" # Delete duplicate files; bin package takes precedence rm data/program_executable_files/main/{server.cfg,teammaps.lst} # Otherwise, extract files from GOG package else einfo "Unpacking ${MY_EXE}. This will take a while..." mkdir -p "${HOME}/wine" || die "wine mkdir" HOME="${HOME}/wine" DISPLAY="" SANDBOX_PREDICT="/" \ innounp -x -dgog "${DISTDIR}/${MY_EXE}" >/dev/null 2>&1 \ || die "innounp" HOME="${HOME}/wine" wineserver -k || die "wineserver" # Remove files export app="gog/{app}" rm "${app}"/main/config.cfg rm "${app}"/main/gamex86.dll # Convert spaces OLDIFS=$IFS IFS=$(echo -en "\n\b") for i in $(find "${app}/main/sound/actors/player" -name "* *"); do local dest=$(echo "${i}" | tr " " "_") mv -f "${i}" "${dest}" done # Convert all files to lowercase case for i in $(find "${app}/main" -type f); do local ddir=$(dirname "${i}") local dfile=$(echo $(basename "${i}") | tr "[:upper:]" "[:lower:]") [ ! -f "${ddir}/${dfile}" ] && mv -f "${i}" "${ddir}/${dfile}" done for i in $(find "${app}/main" -type d); do local d=$(echo "${i}" | tr "[:upper:]" "[:lower:]") [ ! -d "${d}" ] && mv -f "${i}" "${d}" done IFS=$OLDIFS # Delete duplicate files; bin package takes precedence rm "${app}"/main/{server.cfg,teammaps.lst} rm "${app}"/main/maps/team_{rival,towers}.bsp fi } src_prepare() { # Disable public access to server by default sed -e 's/set public 1/set public 0/' \ -i main/server.cfg || die "sed server" # Work around GL extensions issue with recent nvidia drivers # see bug 326837 sed -e 's;^\(./${GAME_BINARY} \);__GL_ExtensionStringVersion=17700 \1;' \ -i "bin/${PN}.sh" || die "gl extensions fix" # Set installation path echo "${dir}" > kingpin.conf || die "echo" } src_install() { insinto "${dir}" if use cdinstall; then doins -r {data/*,.}/main kingpin.conf || die "doins main" else doins -r {"${app}",.}/main kingpin.conf || die "doins main" # Also install manual, which should be included with GOG package if [ -f "${app}"/MANUAL.PDF ]; then insinto usr/share/doc/"${PF}" newins "${app}"/MANUAL.PDF manual.pdf fi fi dodoc README* || die "dodoc" # Create fake cd image that can be used to workaround cd check; # This is necessary for the GOG version, which does not include a CD mkdir -p fakecd/kingpin touch fakecd/kingpin/data1.cab # cdrkit provides genisoimage and cdrtools provides mkisofs genisoimage -quiet -joliet -ucs-level 3 -input-charset iso8859-1 -appid '' -sysid 'CD-RTOS CD-BRIDGE' -volid KINGPIN -o fakecd.iso fakecd/ \ || mkisofs -quiet -J -ucs-level 3 -input-charset iso8859-1 -V KINGPIN -o fakecd.iso fakecd/ doins fakecd.iso exeinto "${dir}" doexe ${PN}.x86 bin/${PN}.sh *.so || die "doexe" exeinto "${dir}"/main doexe main/*.so || die "doexe main" doicon ${PN}.xpm || die "doicon" games_make_wrapper ${PN} ./${PN}.sh "${dir}" "${dir}" make_desktop_entry ${PN} "Kingpin" ${PN} prepgamesdirs } pkg_postinst() { games_pkg_postinst elog "If you installed from CD, please mount the Kingpin CD before playing." echo elog "If you installed from the GOG package, you must workaround the CD check:" elog " sudo mount -o loop -t iso9660 ${dir}/fakecd.iso /mnt/cdrom" echo }