--- games-mods.eclass-orig 2006-12-02 09:23:26.000000000 +0000 +++ games-mods.eclass-orig 2006-12-02 10:19:49.000000000 +0000 @@ -6,8 +6,9 @@ # GAME - (doom3, quake4 or ut2004, etc), unless ${PN} starts with e.g. "doom3-" # MOD_BINS - Name of the binary to run # MOD_DESC - Description for the mod -# MOD_DIR - Subdirectory name for the mod, if applicable +# MOD_DIR - Subdirectory name for the mod, if applicable # MOD_ICON - Custom icon for the mod, instead of the default +# MOD_MAP - Name of map to load at start, if applicable # MOD_NAME - Creates a command-line wrapper and desktop icon for the mod # MOD_TBZ2 - File to extract within the Makeself archive @@ -15,57 +16,48 @@ EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst -[[ -z ${GAME} ]] && GAME=${PN%%-*} +[[ -z "${GAME}" ]] && GAME=${PN%%-*} +GAME_EXE=${GAME} +DED_EXE=${GAME_EXE}-ded +DED_OPTIONS="+set dedicated 1 +exec server.cfg" +SELECT_MOD="+set fs_game " +SELECT_MAP="+map " # Set our default title, icon, and cli options case "${GAME}" in "doom3") GAME_TITLE="Doom III" DEFAULT_MOD_ICON="doom3.png" - SELECT_MOD="+set fs_game " - GAME_EXE="doom3" - DED_EXE="doom3-ded" - DED_OPTIONS="+set dedicated 1 +exec server.cfg" ;; "enemy-territory") GAME_TITLE="Enemy Territory" DEFAULT_MOD_ICON="ET.xpm" - SELECT_MOD="+set fs_game " GAME_EXE="et" DED_EXE="et-ded" - DED_OPTIONS="+set dedicated 1 +exec server.cfg" ;; "quake3") GAME_TITLE="Quake III" DEFAULT_MOD_ICON="quake3.xpm" - SELECT_MOD="+set fs_game " - GAME_EXE="quake3" - DED_EXE="quake3-ded" - DED_OPTIONS="+set dedicated 1 +exec server.cfg" ;; "quake4") GAME_TITLE="Quake IV" DEFAULT_MOD_ICON="quake4.bmp" - SELECT_MOD="+set fs_game " - GAME_EXE="q4" - DED_EXE="q4-ded" - DED_OPTIONS="+set dedicated 1 +exec server.cfg" ;; "ut2003") GAME_TITLE="UT2003" DEFAULT_MOD_ICON="ut2003.xpm" SELECT_MOD="-mod=" - GAME_EXE="ut2003" DED_EXE="ucc" DED_OPTIONS="" + SELECT_MAP="" ;; "ut2004") GAME_TITLE="UT2004" DEFAULT_MOD_ICON="ut2004.xpm" SELECT_MOD="-mod=" - GAME_EXE="ut2004" DED_EXE="ucc" DED_OPTIONS="" + SELECT_MAP="" ;; *) eerror "This game is either not supported or you must set the GAME" @@ -105,23 +97,23 @@ games_pkg_setup - if has_version ${CATEGORY}/${GAME} + if has_version "${CATEGORY}/${GAME}" then - if use dedicated && ! built_with_use ${CATEGORY}/${GAME} dedicated + if use dedicated && ! built_with_use "${CATEGORY}/${GAME}" dedicated then die "You must merge ${CATEGORY}/${GAME} with USE=dedicated!" fi - if has_version ${CATEGORY}/${GAME}-bin + if has_version "${CATEGORY}/${GAME}-bin" then if use dedicated && \ - ! built_with_use ${CATEGORY}/${GAME}-bin dedicated + ! built_with_use "${CATEGORY}/${GAME}-bin" dedicated then die "You must merge ${CATEGORY}/${GAME}-bin with USE=dedicated!" fi fi - elif has_version ${CATEGORY}/${GAME}-bin + elif has_version "${CATEGORY}/${GAME}-bin" then - if use dedicated && ! built_with_use ${CATEGORY}/${GAME}-bin dedicated + if use dedicated && ! built_with_use "${CATEGORY}/${GAME}-bin" dedicated then die "You must merge ${CATEGORY}/${GAME}-bin with USE=dedicated!" fi @@ -135,7 +127,7 @@ for src_uri in ${A} do URI_SUFFIX="${src_uri##*.}" - case ${URI_SUFFIX##*.} in + case "${URI_SUFFIX##*.}" in bin|run) # We have a Makeself archive, use unpack_makeself unpack_makeself "${src_uri}" @@ -169,10 +161,11 @@ done done # Since we remove all of these anyway, let's move it to the eclass - rm -f 3355_patch + [[ -e 3355_patch ]] && rm -f 3355_patch } games-mods_src_install() { + local binary local readme MOD_ICON_EXT new_bin_name bin_name mod files directories i j INS_DIR=${dir} @@ -208,7 +201,7 @@ # Install custom icon MOD_ICON_EXT=${MOD_ICON##*.} newicon "${MOD_ICON}" "${PN}.${MOD_ICON_EXT}" - case ${MOD_ICON_EXT} in + case "${MOD_ICON_EXT}" in bmp|ico) MOD_ICON=/usr/share/pixmaps/${PN}.${MOD_ICON_EXT} ;; @@ -222,6 +215,10 @@ fi # Set up command-line and desktop menu entries + local game_select="${SELECT_MOD}${MOD_DIR}" + [[ -n "${MOD_MAP}" ]] \ + && game_select="${game_select} ${SELECT_MAP}${MOD_MAP}" + if [[ -n "${MOD_BINS}" ]] then for binary in ${MOD_BINS} @@ -229,20 +226,20 @@ if [[ -n "${MOD_DIR}" ]] then games_make_wrapper "${GAME_EXE}-${MOD_BINS}" \ - "${GAME_EXE} ${SELECT_MOD}${MOD_DIR}" "${dir}" "${dir}" + "${GAME_EXE} ${game_select}" "${dir}" "${dir}" make_desktop_entry "${GAME_EXE}-${MOD_BINS}" \ "${GAME_TITLE} - ${MOD_NAME}" "${MOD_ICON}" elif [[ -e "${S}"/bin/"${binary}" ]] then exeinto "${dir}" - newexe bin/${binary} ${GAME_EXE}-${binary} \ + newexe "bin/${binary} ${GAME_EXE}-${binary}" \ || die "newexe failed" new_bin_name= bin_name=$(echo ${binary} | sed -e 's:[-_.]: :g') # We want our wrapper to use the libraries/starting # directory of our game. If the game is in # GAMES_PREFIX_OPT, then we want to start there. - if [[ -d "${GAMES_PREFIX_OPT}"/${GAME} ]] + if [[ -d "${GAMES_PREFIX_OPT}/${GAME}" ]] then GAME_DIR="${GAMES_PREFIX_OPT}/${GAME}" else @@ -267,7 +264,7 @@ make_desktop_entry "${GAME_EXE}-${binary}" \ "${GAME_TITLE} - ${bin_name}" "${MOD_ICON}" # We remove the binary after we have installed it. - rm -f bin/${binary} + rm -f "bin/${binary}" fi done # We don't want to leave the binary directory around @@ -275,7 +272,7 @@ elif [[ -n "${MOD_DIR}" ]] then games_make_wrapper "${GAME_EXE}-${MOD_DIR}" \ - "${GAME_EXE} ${SELECT_MOD}${MOD_DIR}" "${dir}" "${dir}" + "${GAME_EXE} ${game_select}" "${dir}" "${dir}" make_desktop_entry "${GAME_EXE}-${MOD_DIR}" \ "${GAME_TITLE} - ${MOD_NAME}" "${MOD_ICON}" # Since only quake3 has both a binary and a source-based install, @@ -285,7 +282,7 @@ if has_version games-fps/quake3-bin then games_make_wrapper "${GAME_EXE}-bin-${MOD_DIR}" \ - "${GAME_EXE}-bin ${SELECT_MOD}${MOD_DIR}" \ + "${GAME_EXE}-bin ${game_select}" \ "${dir}" "${dir}" fi make_desktop_entry "${GAME_EXE}-bin-${MOD_DIR}" \ @@ -327,11 +324,11 @@ directories=$(cd "${D}"/"${INS_DIR}";find . -maxdepth 1 -type d -printf '%P ') for i in ${directories} do - if [[ -h "${GAMES_PREFIX_OPT}"/"${GAME}"/${i} ]] + if [[ -h "${GAMES_PREFIX_OPT}/${GAME}/${i}" ]] then # Skip this directory, and just run a symlink - dosym "${INS_DIR}"/${i} \ - "${GAMES_PREFIX_OPT}"/"${GAME}"/${i} || die + dosym "${INS_DIR}/${i}" \ + "${GAMES_PREFIX_OPT}/${GAME}/${i}" || die elif [[ -d "${GAMES_PREFIX_OPT}"/"${GAME}"/${i} ]] then dodir "${GAMES_PREFIX_OPT}"/"${GAME}"/${i} @@ -492,9 +489,9 @@ fi cat <<-EOF > "${T}"/${GAME_EXE}-${MOD_DIR}-ded.conf.d $(<${PORTDIR}/header.txt) - + # Any extra options you want to pass to the dedicated server # ${GAME_EXE}_${MOD_DIR}_OPTS="+set com_hunkmegs 64 +set com_zonemegs 32" - + EOF }