# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI=5 inherit cdrom eutils multilib games unpacker 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 music" 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=" !cdinstall? ( app-arch/innoextract virtual/cdrtools ) music? ( app-cdr/cdemu )" REQUIRED_USE="music? ( !cdinstall )" 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 unpack_makeself ${MY_INST} 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} \ || die "rm duplicate files failed" # Otherwise, extract files from GOG package else einfo "Unpacking ${MY_EXE}. This will take a while..." mkdir gog && cd gog || die "mkdir failed" innoextract -e -s -L "${DISTDIR}/${MY_EXE}" \ || die "innoextract failed" cd .. # Remove files export app="gog/app" rm "${app}"/main/config.cfg || die "remove unnecessary files" rm "${app}"/main/gamex86.dll || die "remove unnecessary files" # 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}" || die "rename failed" done IFS=$OLDIFS # Delete duplicate files; bin package takes precedence rm "${app}"/main/{server.cfg,teammaps.lst} || die "remove dupe files" rm "${app}"/main/maps/team_{rival,towers}.bsp || die "remove dupe files" 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 # Also enable mouse wheel support and high quality sounds sed -e 's;^\(./${GAME_BINARY} \);__GL_ExtensionStringVersion=17700 \1;' \ -e 's;KPHACK_WHEEL=0;KPHACK_WHEEL=1;' \ -e 's;_windowed_mouse 1;_windowed_mouse 1 +set sndspeed 44100;' \ -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 else doins -r {"${app}",.}/main kingpin.conf # 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 # 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 || die "mkdir fakecd" touch fakecd/kingpin/data1.cab || die "touch fakecd" # Handle proper syntax for both cdrkit and cdrtools if has_version app-cdr/cdrkit; then genisoimage -quiet -joliet -ucs-level 3 -input-charset iso8859-1 \ -appid '' -sysid 'CD-RTOS CD-BRIDGE' -volid KINGPIN -o kingpin.iso \ fakecd/ || die "genisoimage" elif has_version app-cdr/cdrtools; then mkisofs -quiet -J -ucs-level 3 -input-charset iso8859-1 -A '' \ -sysid 'CD-RTOS CD-BRIDGE' -V KINGPIN -o kingpin.iso fakecd/ \ || die "mkisofs" fi insinto "${dir}/fakecd" doins kingpin.iso if use music; then doins "${app}"/music/*.ogg touch "${D}/${dir}/fakecd/kingpin.cue" || die "touch cue failed" echo -e "FILE \"kingpin.iso\" BINARY\n TRACK 01 MODE1/2048\n INDEX 01 00:00:00" >"${D}/${dir}/fakecd/kingpin.cue" || die "cue data failed" for i in $(seq 2 7); do echo -e "FILE \"Track_0$((i-1)).ogg\" MP3\n TRACK 0${i} AUDIO\n INDEX 01 00:00:00" >>"${D}/${dir}/fakecd/kingpin.cue" || die "cue data failed" done fi dodoc "${app}"/readme.txt fi dodoc README* # Some files are case-sensitive; add symlinks to easily cover this case dosym l_pstl.mdx "${dir}"/main/models/actors/runt/L_pstl.mdx dosym r_pstl.mdx "${dir}"/main/models/actors/runt/R_pstl.mdx dosym l_pstl.mdx "${dir}"/main/models/actors/thug/L_pstl.mdx dosym r_pstl.mdx "${dir}"/main/models/actors/thug/R_pstl.mdx dosym l_pstl.mdx "${dir}"/main/models/actors/thug_sit/L_pstl.mdx dosym r_pstl.mdx "${dir}"/main/models/actors/thug_sit/R_pstl.mdx exeinto "${dir}" doexe ${PN}.x86 bin/${PN}.sh *.so exeinto "${dir}"/main doexe main/*.so doicon ${PN}.xpm games_make_wrapper ${PN} ./${PN}.sh "${dir}" "${dir}" make_desktop_entry ${PN} "Kingpin" ${PN} prepgamesdirs # Global save directory must be writable for save games to work properly mkdir "${D}/${dir}/main/save" fowners root:games "${dir}/main/save" fperms 770 "${dir}/main/save" } pkg_postinst() { games_pkg_postinst if ! use cdinstall; then elog "Kingpin has a mandatory CD check. To workaround, run the following before" elog "playing the game to make it think the original CD is mounted:" elog " sudo mount -o loop -t iso9660 ${dir}/fakecd/kingpin.iso /mnt/cdrom" if use music; then elog elog "Alternatively, if you wish to hear the original CD audio, you can use" elog "cdemu to mount a fake CD that includes the audio tracks. Use the following" elog "*example* as guidance for how to do this. Your devices will likely differ." elog " sudo modprobe vhba" elog " cdemu load 0 ${dir}/fakecd/kingpin.cue" elog " cdemu device-mapping" elog " sudo mount /dev/sr2 /mnt/cdrom" elog " kingpin +set cd_dev /dev/sr2" fi fi }