# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils games DESCRIPTION="Unreal Tournament 99 - futuristic deathmatch shooter" HOMEPAGE="http://www.unrealtournament.com/ http://utpg.org/" # Downloads both small patches, rather than bothering the user with a USE flag SRC_URI="mirror://lokigames/../beta/ut/ut-install-436-GOTY.run mirror://lokigames/../patches/ut/ut-install-436.run http://utpg.org/patches/UTPGPatch${PV}.tar.bz2" LICENSE="as-is" SLOT="0" KEYWORDS="-* ~amd64 ~x86" IUSE="3dfx dedicated nls opengl S3TC sdl" RESTRICT="strip" UIDEPEND=">=app-arch/unshield-0.5-r1 x86? ( x11-libs/libXext x11-libs/libX11 x11-libs/libXau x11-libs/libXdmcp 3dfx? ( media-libs/glide ) opengl? ( virtual/opengl ) sdl? ( media-libs/libsdl ) =media-libs/libsdl-1.2* ) amd64? ( app-emulation/emul-linux-x86-sdl app-emulation/emul-linux-x86-baselibs app-emulation/emul-linux-x86-xlibs )" RDEPEND="dedicated? ( games-server/unreal-tournament-ded )" DEPEND="${UIDEPEND} !games-fps/unreal-tournament-goty" S=${WORKDIR} dir=${GAMES_PREFIX_OPT}/${PN} Ddir=${D}/${dir} set_dirs() { # The top-level directory names can change per CD if [[ -n "${IS_UT_ANTHOLOGY}" ]] || [[ -e "${CDROM_ROOT}/System" ]] ; then HELP_DIR="Help" LOGS_DIR="Logs" MUSIC_DIR="Music" SOUNDS_DIR="Sounds" SYSTEM_DIR="System" TEXTURES_DIR="Textures" WEB_DIR="Web" else HELP_DIR="HELP" LOGS_DIR="LOGS" MUSIC_DIR="MUSIC" SOUNDS_DIR="SOUNDS" SYSTEM_DIR="SYSTEM" TEXTURES_DIR="TEXTURES" WEB_DIR="WEB" fi if [[ -n "${IS_UT_ANTHOLOGY}" ]] || [[ -e "${CDROM_ROOT}/Maps" ]] ; then MAPS_DIR="Maps" elif [[ -e "${CDROM_ROOT}/MAPS" ]] ; then MAPS_DIR="MAPS" else MAPS_DIR="maps" fi } unpack_patches() { # This routine is run twice, to ensure that the patch files # take precedence over the CD files. if [[ -n "${IS_UT_GOTY}" ]] || [[ -n "${IS_UT_ANTHOLOGY}" ]] ; then einfo "Unpacking GOTY patch" unpack_makeself ut-install-436-GOTY.run else einfo "Unpacking standard (non-GOTY) patch" unpack_makeself ut-install-436.run fi # Grab files from the CD, to be able to apply the Loki patch. # Cache the first time, because the 2nd time might have a # different CD inserted. if [[ ! -e cdcache ]] ; then mkdir cdcache local f lst cd_f lst=$(grep "PATCH FILE " setup.data/patch.dat) lst=$(echo "${lst}" | sed -e "s:PATCH FILE ::g") for f in ${lst} ; do if [[ -n "${IS_UT_ANTHOLOGY}" ]] ; then # No need to look on DVD cd_f=${SYSTEM_DIR}/$(basename ${f}) else cd_f=${CDROM_ROOT}/${SYSTEM_DIR}/$(basename ${f}) fi cp -f "${cd_f}" "cdcache/$(basename ${f})" \ || die "cp ${cd_f} failed" done fi cp -f cdcache/* System || die "cp cdcache failed" if use 3dfx ; then unpack ./Glide.ini.tar.gz || die "unpack Glide.ini failed" else unpack ./OpenGL.ini.tar.gz || die "unpack OpenGL.ini failed" fi unpack ./{Credits,data,NetGamesUSA.com}.tar.gz # Check whether patching is necessary, # because loki_patch will fail if the patch makes no difference. local testfile sum_patched sum_actual testfile=$(grep "PATCH FILE " setup.data/patch.dat | head -n 1) testfile=$(echo "${testfile}" | sed -e "s:PATCH FILE ::") sum_patched=$(grep "newsum=" setup.data/patch.dat | head -n 1) sum_patched=$(echo "${sum_patched}" | sed -e "s:newsum=::") sum_actual=$(md5sum "${testfile}" | cut -d ' ' -f 1) if [[ "${sum_patched}" = "${sum_actual}" ]] ; then einfo "Skipping Loki patch - files are pre-patched" else # Apply Loki patch cd setup.data cp -f patch.dat{,.orig} || die "cp patch.dat failed" sed -e 's:sh uz-maps.sh:echo:' patch.dat.orig > patch.dat \ || die "sed patch.dat failed" if ! ./bin/Linux/x86/loki_patch patch.dat "${S}" ; then eerror "Check whether the correct non/GOTY patch is being applied." die "loki_patch failed." fi cd "${S}" fi # Apply UTPG patch last, to ensure that it overwrites the CD data unpack UTPGPatch${PV}.tar.bz2 rm -f System/{checkfiles.sh,patch.md5} # Tweak the default settings for today's standard of PCs, # and good preferences. sed -i System/UnrealTournament.ini \ -e "s/CacheSizeMegs=4/CacheSizeMegs=64/" \ -e "s/DoPrecache=0/DoPrecache=1/" \ -e "s/UseTrilinear=False/UseTrilinear=True/" \ -e "s/ScreenFlashes=True/ScreenFlashes=False/" \ -e "s/Channels=16/Channels=24/" \ || die "sed UnrealTournament.ini failed" if use S3TC ; then # Turn the hi-res textures on sed -i System/UnrealTournament.ini \ -e "s/UseS3TC=0/UseS3TC=1/" \ || die "sed UnrealTournament.ini S3TC failed" fi if ! use sdl ; then # Change default renderer if use opengl ; then # Recommended at http://icculus.org/lgfaq/#renderer , but intro movie # does not have the right colour depth it seems. # (RenderDevice is defaulted to *SDL*GLDrv by UTPG) sed -i System/UnrealTournament.ini \ -e "s/GameRenderDevice=SDLGLDrv\.SDLGLRenderDevice/GameRenderDevice=OpenGLDrv\.OpenGLRenderDevice/" \ -e "s/WindowedRenderDevice=SDLGLDrv\.SDLGLRenderDevice/WindowedRenderDevice=OpenGLDrv\.OpenGLRenderDevice/" \ -e "s/RenderDevice=SDLGLDrv\.SDLGLRenderDevice/RenderDevice=OpenGLDrv\.OpenGLRenderDevice/" \ || die "sed UnrealTournament.ini opengl failed" elif use 3dfx ; then sed -i System/UnrealTournament.ini \ -e "s/GameRenderDevice=SDLGLDrv\.SDLGLRenderDevice/GameRenderDevice=GlideDrv\.GlideRenderDevice/" \ -e "s/WindowedRenderDevice=SDLGLDrv\.SDLGLRenderDevice/WindowedRenderDevice=GlideDrv\.GlideRenderDevice/" \ -e "s/RenderDevice=SDLGLDrv\.SDLGLRenderDevice/RenderDevice=GlideDrv\.GlideRenderDevice/" \ || die "sed UnrealTournament.ini 3dfx failed" else # Switch to software renderer sed -i System/UnrealTournament.ini \ -e "s/GameRenderDevice=SDLGLDrv\.SDLGLRenderDevice/GameRenderDevice=SDLSoftDrv.SDLSoftwareRenderDevice/" \ -e "s/WindowedRenderDevice=SDLGLDrv\.SDLGLRenderDevice/WindowedRenderDevice=SDLSoftDrv.SDLSoftwareRenderDevice/" \ -e "s/RenderDevice=SDLGLDrv\.SDLGLRenderDevice/RenderDevice=SDLSoftDrv.SDLSoftwareRenderDevice/" \ || die "sed UnrealTournament.ini software failed" fi fi # Fix server vulnerability - part of bug #44351 sed -i System/Core.int \ -e "/^LoadClassMismatch/s:%s.%s:%s:" \ || die "sed Core.int failed" } pkg_setup() { games_pkg_setup # Can't use cdrom_get_cds initially, because some CDs have # all the top-level directories in upper-case. local r for r in "${CD_ROOT}" "${CD_ROOT_1}" \ `mount | egrep -e '(iso|cdrom)' | awk '{print $3}'` ; do if [[ -n "${r}" ]] ; then einfo "Searching ${r}" if [[ -e "${r}/Help/BonusPackReadme.txt" ]] ; then IS_UT_GOTY="y" einfo "Found UT99 \"Game Of The Year\" edition" cdrom_get_cds Help/BonusPackReadme.txt Help/chaosut break elif [[ -e "${r}/HELP/BonusPackReadme.txt" ]] ; then IS_UT_GOTY="y" einfo "Found UT99 \"Game Of The Year\" edition (with upper-case dirs)" # "Help" on the *2nd* CD is still mixed-case. cdrom_get_cds HELP/BonusPackReadme.txt Help/chaosut break elif [[ -e "${r}/System/Core.u" ]] \ || [[ -e "${r}/SYSTEM/Core.u" ]] ; then IS_UT_STANDARD="y" einfo "Found UT99 standard edition" cdrom_get_cds System/Core.u break elif [[ -e "${r}/AutoRunData/Unreal.ico" ]] ; then IS_UT_ANTHOLOGY="y" einfo "Found Midway Anthology DVD" cdrom_get_cds AutoRunData/Unreal.ico break fi fi done # CDROM_ROOT is set by cdrom_get_cds if [[ -z "${CDROM_ROOT}" ]] ; then eerror "Please mount the CD." die "Unreal Tournament 99 files not found." fi set_dirs } src_unpack() { if [[ -n "${IS_UT_ANTHOLOGY}" ]] ; then # Midway Anthology DVD. # Symlinks for unshield. data1&2.cab are both in Disk1. # unshield needs data1.hdr ln -sfn "${CDROM_ROOT}/Disk1/data1.hdr" "${T}" ln -sfn "${CDROM_ROOT}/Disk1/data1.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk1/data2.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk2/data3.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk3/data4.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk4/data5.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk5/data6.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk6/data7.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk7/data8.cab" "${T}" ln -sfn "${CDROM_ROOT}/Disk8/data9.cab" "${T}" # The big extraction einfo "Extracting from CAB files - this will take several minutes." unshield x "${T}"/data1.cab \ || die "unshield data1.cab failed" # Useful debugging information ls -R > extract-filelist.txt # Delete the other games on the Anthology DVD rm -rf {1,2,4}_* 3_UnrealTournament_EXE Launcher_English OCXFiles # Rename directories to be same as normal UT99 CD, # i.e. rename "3_UnrealTournament_Help" to "Help". for j in 3_UnrealTournament_* ; do mv -f "${j}" "${j:19}" || die "mv ${j} failed" done # Prevent Portage from getting confused about the symlinks. # The "logging" subdirectory is created by unshield. rm -rf "${T}"/logging rm -f "${T}"/*.{cab,hdr} for j in Help Manual Maps Music Sounds System Textures Web ; do einfo "Collating ${j}" if [[ -d "${j}_All" ]] ; then if [[ -d "${j}" ]] ; then cp -rf "${j}_All"/* "${j}" || die "cp ${j}_All" else mv -f "${j}_All" "${j}" || die "mv ${j}_All" fi fi if [[ -d "${j}_English" ]] ; then if [[ -d "${j}" ]] ; then cp -rf "${j}_English"/* "${j}" || die "cp ${j}_English" else mv -f "${j}_English" "${j}" || die "mv ${j}_English" fi fi done fi mkdir -p Help Logs Maps Music NetGamesUSA.com Sounds System Textures \ Web UTPG if [[ -z "${IS_UT_ANTHOLOGY}" ]] ; then cp -rf "${CDROM_ROOT}"/{${HELP_DIR},${LOGS_DIR},${MUSIC_DIR},${TEXTURES_DIR}} "${S}" \ || die "cp Help, Logs, Music, Textures failed" # Sounds if use nls ; then cp -f "${CDROM_ROOT}"/${SOUNDS_DIR}/* "${S}"/Sounds \ || die "cp Sounds/* failed" else cp -f "${CDROM_ROOT}"/${SOUNDS_DIR}/*.uax "${S}"/Sounds \ || die "cp Sounds/*.uax failed" fi # System cp -f "${CDROM_ROOT}"/${SYSTEM_DIR}/*.u "${S}"/System \ || die "cp System failed" if use nls ; then cp -f "${CDROM_ROOT}"/${SYSTEM_DIR}/*.{est,frt,itt} "${S}"/System \ || die "cp System (nls) failed" fi # Unpack ucc-bin, for uncompressing maps unpack_patches # Uncompress maps (GOTY edition installs maps as .uz) echo "Uncompressing Maps... this may take some time" cd "${S}"/System export HOME=${T} export UT_DATA_PATH=${S}/System for f in $(find "${CDROM_ROOT}/${MAPS_DIR}" -name '*.uz' -printf '%f ') ; do "${S}"/System/ucc-bin decompress "${CDROM_ROOT}/${MAPS_DIR}/${f}" -nohomedir \ || die "uncompress map ${f} failed" mv -f "${f:0:${#f}-3}" "${S}"/Maps \ || die "mv map ${f} failed" done # Some CDs contain uncompressed maps if [[ -d "${CDROM_ROOT}/${MAPS_DIR}" ]] ; then cp -f "${CDROM_ROOT}/${MAPS_DIR}"/*.unr "${S}"/Maps fi cd "${S}" if [[ -n "${IS_UT_GOTY}" ]] || use S3TC ; then # Disk 2 cdrom_load_next_cd set_dirs # S3TC Textures if use S3TC ; then cp -f "${CDROM_ROOT}/${TEXTURES_DIR}"/* "${S}"/Textures \ || die "cp S3TC Textures (CD 2) failed" fi if [[ -n "${IS_UT_GOTY}" ]] ; then # GOTY CD 2 - Help, Sounds cp -rf "${CDROM_ROOT}"/{${HELP_DIR},${SOUNDS_DIR}} "${S}" || die "cp Help Sounds (CD 2) failed" if ! use S3TC ; then cp -f "${CDROM_ROOT}/${TEXTURES_DIR}"/{JezzTex,Jezztex2,SnowDog,chaostex{,2}}.utx \ "${S}"/Textures \ || die "cp Textures (CD 2) failed" fi # System cp -f "${CDROM_ROOT}/${SYSTEM_DIR}"/*.{int,u} "${S}"/System \ || die "cp System (CD 2) failed" # Uncompress maps echo "Uncompressing GOTY CD 2 Maps... this may take some time" cd "${S}"/System export HOME=${T} export UT_DATA_PATH=${S}/System for f in $(find "${CDROM_ROOT}/${MAPS_DIR}" -name '*.uz' -printf '%f ') ; do "${S}"/System/ucc-bin decompress "${CDROM_ROOT}/${MAPS_DIR}/${f}" -nohomedir \ || die "uncompress map ${f} failed" mv -f "${f:0:${#f}-3}" "${S}"/Maps \ || die "mv map ${f} failed" done cd "${S}" fi fi fi # Extract the patches a second time (first time for Anthology DVD), # to ensure they overwrite the CD files. unpack_patches # Remove Windows-specific files find . -type f '(' -name '*.bat' -o -name '*.dll' -o -name '*.exe' ')' -delete } src_install() { insinto "${dir}" doins icon.{bmp,xpm} || die "doins icons failed" doins -r README Help Logs Maps Music NetGamesUSA.com Sounds System \ Textures Web || die "doins directories failed" rm -f "${Ddir}"/System/*{-bin,.so} exeinto "${dir}"/System # Deliberately don't install ucc-bin, due to bug #44351. # unreal-tournament-ded contains it instead. doexe System/{ut-bin,*.so} || die "doexe ut-bin *.so failed" # Scripts exeinto "${dir}" doexe bin/x86/u{cc,t} || die "doexe ucc/ut failed" dosed "s:\`FindPath \$0\`:${dir}:" "${dir}"/u{cc,t} # Desktop games_make_wrapper ut ./ut "${dir}" newicon icon.xpm ut.xpm || die "newicon failed" make_desktop_entry ut "Unreal Tournament 99" ut.xpm # Update file datestamps find "${Ddir}" -exec touch '{}' \; prepgamesdirs } pkg_postinst() { games_pkg_postinst if ! has_version "games-fps/unreal-tournament-bonuspacks" ; then elog "emerge games-fps/unreal-tournament-bonuspacks, to add many popular maps." echo fi if ! use dedicated && ! has_version "games-server/unreal-tournament-ded" ; then elog "The 'ucc' server executable has been moved to:" elog " games-server/unreal-tournament-ded" elog "Because it is insecure - see bug #44351." echo fi }