3 # get usage help this way:
4 # ./gamepack_manager -h
12 : "${MKDIR:=mkdir -v}"
13 : "${MKDIR_P:=mkdir -vp}"
17 : "${UNZIPPER:=unzip}"
21 default_download_dir='build/download'
22 default_install_dir='build'
27 free_license_list='BSD GPL'
31 #######################################################
33 # IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT #
35 # Use two whitespaces or more as column separator #
37 #######################################################
39 #######################################################
41 #######################################################
43 # Quake2World was renamed as Quetoo
44 # Other gamepacks have better version available
46 # OpenArena no unknown zip http://ingar.intranifty.net/files/netradiant/gamepacks/OpenArenaPack.zip
47 # Quake no proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
48 # Quake2World no GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
49 # Tremulous no proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
50 # Unvanquished no unknown zip http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
51 # Warsow no GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
52 # Warsow no GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
54 #######################################################
56 #######################################################
58 AlienArena yes GPL svn https://svn.code.sf.net/p/alienarena-cc/code/trunk/tools/netradiant_gamepack/AlienArenaPack
59 DarkPlaces yes GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
60 Doom3 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
61 ET yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
62 Heretic2 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
63 JediAcademy no proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
64 Kingpin yes unknown zip https://www.kingpin.info/download/kingpin/editing/maps/map_editors/NetRadiant/addon/Kingpinpack.zip
65 Neverball yes proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
66 Nexuiz yes GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
67 OpenArena yes GPL git https://github.com/NeonKnightOA/oagamepack.git
68 Osirion yes GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
69 Prey yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/PreyPack/trunk/
70 Q3 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ 29
71 Q3Rally yes proprietary svn https://svn.code.sf.net/p/q3rallysa/code/tools/radiant-config/radiant15-netradiant/
72 Quake2 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
73 Quake4 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
74 Quake yes GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
75 Quetoo yes GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
76 SmokinGuns yes unknown git https://github.com/smokin-guns/smokinguns-mapeditor-support.git
77 Tremulous yes proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
78 TurtleArena yes proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
79 UFOAI yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
80 Unvanquished yes BSD git https://github.com/Unvanquished/unvanquished-mapeditor-support.git
81 Warsow yes GPL git https://github.com/Warsow/NetRadiantPack.git
82 Wolf yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
83 WoP yes proprietary git https://github.com/PadWorld-Entertainment/wop-mapeditor-support.git
84 Xonotic yes GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
88 if command -v gsed >/dev/null
91 elif sed --help >/dev/null 2>&1
95 printf 'ERROR: GNU sed is missing\n' >&2
101 if command -v grealpath >/dev/null
104 elif command -v realpath >/dev/null
107 elif command -v greadlink >/dev/null
109 # test greadlink first as greadlink has the feature on macos
110 # but readlink only has it on linux, note that it's probably
112 # note: (g)readlink requires the file to be create first
114 elif command -v readlink >/dev/null
116 # --help and -f options are GNU readlink things
117 if readlink --help >/dev/null 2>&1
121 if ! python -c "import os; print(os.path.realpath('${1}'))"
123 printf 'ERROR: GNU realpath or other way to compute real path of a file is missing\n' >&2
131 ${SED} -e 's/#.*//;s/[ \t][ \t][ \t]*/\t/g;s/^[ \t]*//;s/[ \t]*$//' \
136 [ "$(grep "^${1}$")" = "${1}" ]
157 printLicenseList () {
159 | awk '{ print $3 }' \
165 | awk '{ print $1 }' \
169 printNameListByLicense () {
170 local arg_license_list
174 arg_license_list="${1}"
177 for license in ${arg_license_list}
184 license_list="$(printLicenseList)"
188 license_list="${license_list} ${free_license_list}"
191 if printLicenseList | inList "${license}"
193 license_list="${license_list} ${license}"
195 printError "unknown license: ${license}"
201 license_list="$(dedupeList "${license_list}")"
203 for license in ${license_list}
206 | awk '$3 == "'"${license}"'"' \
211 printNameListByName () {
219 for name in ${argname_list}
226 name_list="$(printNameList)"
230 name_list="${name_list} validated"
233 if printNameList | inList "${name}"
235 name_list="${name_list} ${name}"
237 printError "unknown name: ${name}"
243 name_list="$(dedupeList "${name_list}")"
245 for name in ${name_list}
247 if [ "${name}" = 'validated' ]
250 | awk '$2 == "yes"' \
255 | awk '$1 == "'"${name}"'"' \
266 | awk '$1 == "'"${name}"'"'
276 printPackLine "${name}" \
277 | awk '{ print $'"${key}"' }'
282 if [ -f 'extra-urls.txt' ]
284 while IFS=' ' read -r extra_file extra_url
287 ${WGET} -O "${extra_file}" "${extra_url}"
289 done < 'extra-urls.txt'
307 validation="$(getValue "${name}" 2)"
308 license="$(getValue "${name}" 3)"
309 source_type="$(getValue "${name}" 4)"
310 source_url="$(getValue "${name}" 5)"
312 pack="${name}${pack_suffix}"
314 ${MKDIR_P} "${download_dir}"
320 ${ECHO} "Available pack: ${pack}"
321 ${ECHO} " License: ${license}"
322 ${ECHO} " Download via ${source_type} from ${source_url}"
325 if [ -d "${download_dir}/${pack}" ]
327 ${ECHO} "Updating ${name}…"
329 ${ECHO} "Downloading ${pack}…"
332 case "${source_type}" in
334 reference="$(getValue "${name}" 6)"
335 if [ -z "${reference}" ]
342 if [ -d "${pack}/.git" ]
349 ${SVN} update -r"${reference}" "${pack}"
352 ${SVN} checkout -r"${reference}" "${source_url}" "${pack}" \
353 || ${GIT} svn clone "${source_url}" "${pack}"
357 ${RM_R} 'zipdownload'
358 ${MKDIR} 'zipdownload'
361 ${WGET} "${source_url}"
362 ${UNZIPPER} './'*.zip
366 if [ -d 'zipdownload/games' ]
368 ${MV} 'zipdownload/'* "${pack}/"
370 ${MV} 'zipdownload/'*'/'* "${pack}/"
372 ${RM_R} 'zipdownload'
375 local subdir="$(getValue "${name}" 6)"
376 local branch="$(getValue "${name}" 7)"
378 ${GIT} archive --remote="${source_url}" --prefix="${pack}/" "${branch}":"${subdir}" \
389 ${GIT} clone "${source_url}" "${pack}"
405 downloadPackList () {
412 for name in ${name_list}
414 if printNameList | inList "${name}"
416 downloadPack "${download_dir}" "${name}"
418 printError "unknown name: ${name}"
436 pack="${name}${pack_suffix}"
438 ${MKDIR_P} "${install_dir}/${games_dir}"
440 # Some per-game workaround for malformed gamepack
453 if [ -d "${download_dir}/${pack}/build/netradiant" ]
455 # mkeditorpacks-based gamepack
456 pack="${pack}/build/netradiant"
457 elif [ -d "${download_dir}/${pack}/netradiant" ]
460 pack="${pack}/netradiant"
463 path="${download_dir}/${pack}"
465 for game_file in "${path}/${games_dir}/"*'.game'
467 if [ x"${game_file}" != x"${path}/"*'.game' ]
469 ${CP} "${game_file}" "${real_install_dir}/${games_dir}/"
473 for game_dir in "${path}/"*'.game'
475 if [ x"${game_dir}" != x"${path}/"*'.game' ]
477 ${CP_R} "${game_dir}" "${real_install_dir}/"
491 for name in ${name_list}
493 if printNameList | inList "${name}"
495 installPack "${download_dir}" "${install_dir}" "${name}"
497 printError "unknown name: ${name}"
503 printf 'ERROR: %s\n' "${1}" >&2
512 prog_name='gamepack-manager'
515 Usage: ${prog_name} [OPTION] [SELECTION <ARGUMENTS>] [ACTION]
518 ${tab}-dd, --download-dir DIRNAME
519 ${tab}${tab}store downloaded games to DIRNAME (default: ${default_download_dir})
521 ${tab}-id, --install-dir DIRNAME
522 ${tab}${tab}store installed games to DIRNAME (default: ${default_install_dir})
525 ${tab}-n, --name NAMES…
526 ${tab}${tab}select games by name (default: none)
527 ${tab}${tab}special keyword: validated, all, none
528 ${tab}${tab}available games:
529 $(printNameList | ${SED} -e 's/^/\t\t\t/')
531 ${tab}-l, --license LICENSES…
532 ${tab}${tab}select games by license (default: none)
533 ${tab}${tab}special keyword: free, all, none
534 ${tab}${tab}available licenses:
535 $(printLicenseList | ${SED} -e 's/^/\t\t\t/')
538 ${tab}-ln, --list-names
539 ${tab}${tab}list all game names
541 ${tab}-ll, --list-licenses
542 ${tab}${tab}list all game licenses
544 ${tab}-ls, --list-selected
545 ${tab}${tab}list selected games
548 ${tab}${tab}download selected games
551 ${tab}${tab}install selected games
554 ${tab}${tab}print this help
557 ${tab}${prog_name} --license GPL BSD --list-selected
558 ${tab}${prog_name} --license GPL BSD --download --install
560 ${tab}${prog_name} --name validated --list-selected
561 ${tab}${prog_name} --name validated --download --install
570 list_selected='false'
571 list_licenses='false'
574 download_packs='false'
575 install_packs='false'
577 mkdir_download='false'
578 mkdir_install='false'
589 while ! [ -z "${1}" ]
592 if printList "${option_list}" | inList "${1}"
594 printError "option called more than once: ${1}"
597 if echo "${@}" | tr ' ' '\n' | inList '--help'
600 elif echo "${@}" | tr ' ' '\n' | inList '-h'
606 '--list-names'|'-ln')
609 option_list="${option_list} ${1}"
611 '--list-licenses'|'-ll')
614 option_list="${option_list} ${1}"
616 '--list-selected'|'-ls')
619 option_list="${option_list} ${1}"
623 download_packs='true'
624 mkdir_download='true'
625 option_list="${option_list} ${1}"
630 mkdir_download='true'
632 option_list="${option_list} ${1}"
636 arg_type='pack-license'
637 option_list="${option_list} ${1}"
642 option_list="${option_list} ${1}"
644 '--download-dir'|'-dd')
645 arg_type='download-dir'
646 option_list="${option_list} ${1}"
648 '--install-dir'|'-id')
649 arg_type='install-dir'
650 option_list="${option_list} ${1}"
653 printError "unknown option: ${1}"
656 case "${arg_type}" in
658 name_list="${name_list} ${1}"
661 license_list="${license_list} ${1}"
664 if [ -z "${download_dir}" ]
668 printError "more than one download dir: ${1}"
672 if [ -z "${install_dir}" ]
676 printError "more than one install dir: ${1}"
680 printError "misplaced argument: ${1}"
689 # compatibility with legacy Makefile
690 if [ "${DOWNLOAD_GAMEPACKS}" = 'yes' ]
692 if ! [ -z "${DOWNLOADDIR}" ]
694 download_dir="${DOWNLOADDIR}"
697 if ! [ -z "${INSTALLDIR}" ]
699 install_dir="${INSTALLDIR}"
705 download_packs='true'
706 mkdir_download='true'
712 if [ -z "${download_dir}" ]
714 download_dir="${default_download_dir}"
717 if [ -z "${install_dir}" ]
719 install_dir="${default_install_dir}"
724 selected_list="${selected_list} $(printNameListByName "${name_list}")"
729 selected_list="${selected_list} $(printNameListByLicense "${license_list}")"
732 selected_list="$(dedupeList "${selected_list}")"
734 if "${mkdir_download}"
736 ${MKDIR_P} "${download_dir}"
737 real_download_dir="$(printRealPath "${download_dir}")"
740 if "${mkdir_install}"
742 ${MKDIR_P} "${install_dir}"
743 real_install_dir="$(printRealPath "${install_dir}")"
751 if "${list_licenses}"
756 if "${list_selected}"
758 printList "${selected_list}"
761 if "${download_packs}"
763 downloadPackList "${real_download_dir}" "${selected_list}"
766 if "${install_packs}"
768 installPackList "${real_download_dir}" "${real_install_dir}" "${selected_list}"