# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 EAPI="3" inherit games MY_EXE="setup_rise_of_the_triad.exe" DESCRIPTION="Rise of the Triad game data" HOMEPAGE="http://www.3drealms.com/rott/" SRC_URI="!cdinstall? ( $MY_EXE )" LICENSE="as-is" SLOT="0" KEYWORDS="amd64 x86" PROPERTIES="cdinstall? ( interactive )" RESTRICT="!cdinstall? ( fetch )" IUSE="+cdinstall doc" DEPEND="!cdinstall? ( app-arch/innounp app-arch/unzip )" RDEPEND="" S=${WORKDIR} # Function to handle copying and renaming files from installation directory copy_file() { local dest="${2}" local f=$(basename "${1}") if [ "${f:0:1}" == '*' ]; then return 0 else echo "Copying '${f}'" local d=$(echo ${f} | tr "[:upper:]" "[:lower:]") cp -f "${1}" "${dest}/${d}" return $? fi } pkg_nofetch() { elog "You must place a copy of, or symlink to, the GOG setup package here:" elog "${DISTDIR}/${MY_EXE}" echo elog "If you wish to install from CD-ROM instead, please enable the cdinstall flag" } pkg_setup() { if use cdinstall; then export CDROM_NAME_SET=("Existing Install", "Existing Install", "RotT CD-ROM") cdrom_get_cds darkwar.wad:DARKWAR.RTC:rottinst/darkwar.wad case ${CDROM_SET} in [01]) ROTTDIR=. ;; 2) ROTTDIR=rottinst ;; *) 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 export src='gog' fi } src_install() { if use cdinstall; then local SRC="${CDROM_ROOT}"/"${ROTTDIR}" # Otherwise, extract files from GOG package else local SRC="${WORKDIR}/gog/{app}" 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" # Also unpack additional levels unzip -d "${SRC}" "${SRC}/MORELVLS.ZIP" fi local DST="${GAMES_DATADIR}"/rott dodir "${DST}" insinto "${DST}" # Copy all available data files (include optional levels, etc.) for i in "${SRC}"/*.{dmo,DMO,rtc,RTC,rtl,RTL,rts,RTS,wad,WAD}; do copy_file "$i" "${D}/${DST}" || die "copy '${i}' failed" done # Verify that, at least, the main data files are included if [ ! -f "${D}/${DST}"/darkwar.rtc \ -o ! -f "${D}/${DST}"/huntbgin.rtc ]; then die "Required data files not found" fi # Install optional documentation if use doc; then for i in "${SRC}"/*.{txt,TXT,pdf,PDF}; do copy_file "$i" "${WORKDIR}" || die "copy '${i}' failed" done dodoc {license,readme}.txt if [ $(ls "${SRC}"/*.pdf 2>/dev/null | wc -l) -gt 0 ]; then insinto usr/share/doc/"${PF}" doins *.pdf fi fi prepgamesdirs } pkg_postinst() { elog "This is just the data portion of the game. You also need to install" elog "a game engine, such as games-fps/rott, to play the game." }