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 # JediAcademy and JediOutcast gamepacks are unusable.
45 # Other gamepacks have better version available.
47 # JediAcademy no proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
48 # JediOutcast no proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JK2Pack/branches/1.5/
49 # Kingpin no unknown zip http://download.kingpin.info/kingpin/editing/maps/map_editors/NetRadiant/addon/Kingpinpack.zip
50 # Neverball no proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
51 # OpenArena no unknown zip http://ingar.intranifty.net/files/netradiant/gamepacks/OpenArenaPack.zip
52 # Quake2World no GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
53 # Quake3 no proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ 29
54 # Quake no proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
55 # Tremulous no proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
56 # Tremulous no proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
57 # Unvanquished no unknown zip http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
58 # Warfork no GPL zip https://cdn.discordapp.com/attachments/611741789237411850/659512520553267201/netradiant_warfork_gamepack.zip
59 # Warsow no GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
60 # Warsow no GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
62 #######################################################
64 #######################################################
66 AlienArena yes GPL svn https://svn.code.sf.net/p/alienarena-cc/code/trunk/tools/netradiant_gamepack/AlienArenaPack
67 DarkPlaces yes GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
68 Doom3 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
69 ET yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
70 Heretic2 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
71 Kingpin yes unknown git https://gitlab.com/netradiant/gamepacks/kingpin-mapeditor-support.git
72 Neverball yes proprietary git https://gitlab.com/netradiant/gamepacks/neverball-mapeditor-support.git
73 Nexuiz yes GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
74 OpenArena yes GPL git https://github.com/NeonKnightOA/oagamepack.git
75 Osirion yes GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
76 Prey yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/PreyPack/trunk/
77 Q3Rally yes proprietary svn https://svn.code.sf.net/p/q3rallysa/code/tools/radiant-config/radiant15-netradiant/
78 Quake2 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
79 Quake3 yes proprietary git https://gitlab.com/netradiant/gamepacks/quake3-mapeditor-support.git
80 Quake4 yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
81 QuakeLive yes proprietary git https://gitlab.com/netradiant/gamepacks/quakelive-mapeditor-support.git
82 Quake yes GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
83 Quetoo yes GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
84 SmokinGuns yes unknown git https://github.com/smokin-guns/smokinguns-mapeditor-support.git
85 SoF2 yes unknown git https://gitlab.com/netradiant/gamepacks/sof2-mapeditor-support.git
86 STVEF yes unknown git https://gitlab.com/netradiant/gamepacks/stvef-mapeditor-support.git
87 Tremulous yes proprietary git https://gitlab.com/netradiant/gamepacks/tremulous-mapeditor-support.git
88 TurtleArena yes proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
89 UFOAI yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
90 Unvanquished yes BSD git https://github.com/Unvanquished/unvanquished-mapeditor-support.git
91 UrbanTerror yes unknown git https://gitlab.com/netradiant/gamepacks/urbanterror-mapeditor-support.git
92 Warfork yes GPL git https://gitlab.com/netradiant/gamepacks/warfork-mapeditor-support.git
93 Warsow yes GPL git https://github.com/Warsow/NetRadiantPack.git
94 Wolf yes proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
95 WoP yes proprietary git https://github.com/PadWorld-Entertainment/wop-mapeditor-support.git
96 Xonotic yes GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
97 ZEQ2Lite yes unknown git https://gitlab.com/netradiant/gamepacks/zeq2lite-mapeditor-support.git
101 if command -v gsed >/dev/null
104 elif sed --help >/dev/null 2>&1
108 printf 'ERROR: GNU sed is missing\n' >&2
114 if command -v grealpath >/dev/null
117 elif command -v realpath >/dev/null
120 elif command -v greadlink >/dev/null
122 # test greadlink first as greadlink has the feature on macos
123 # but readlink only has it on linux, note that it's probably
125 # note: (g)readlink requires the file to be create first
127 elif command -v readlink >/dev/null
129 # --help and -f options are GNU readlink things
130 if readlink --help >/dev/null 2>&1
134 if ! python -c "import os; print(os.path.realpath('${1}'))"
136 printf 'ERROR: GNU realpath or other way to compute real path of a file is missing\n' >&2
144 ${SED} -e 's/#.*//;s/[ \t][ \t][ \t]*/\t/g;s/^[ \t]*//;s/[ \t]*$//' \
149 [ "$(grep "^${1}$")" = "${1}" ]
170 printLicenseList () {
172 | awk '{ print $3 }' \
178 | awk '{ print $1 }' \
182 printNameListByLicense () {
183 local arg_license_list
187 arg_license_list="${1}"
190 for license in ${arg_license_list}
197 license_list="$(printLicenseList)"
201 license_list="${license_list} ${free_license_list}"
204 if printLicenseList | inList "${license}"
206 license_list="${license_list} ${license}"
208 printError "unknown license: ${license}"
214 license_list="$(dedupeList "${license_list}")"
216 for license in ${license_list}
219 | awk '$3 == "'"${license}"'"' \
224 printNameListByName () {
232 for name in ${argname_list}
239 name_list="$(printNameList)"
243 name_list="${name_list} validated"
246 if printNameList | inList "${name}"
248 name_list="${name_list} ${name}"
250 printError "unknown name: ${name}"
256 name_list="$(dedupeList "${name_list}")"
258 for name in ${name_list}
260 if [ "${name}" = 'validated' ]
263 | awk '$2 == "yes"' \
268 | awk '$1 == "'"${name}"'"' \
279 | awk '$1 == "'"${name}"'"'
289 printPackLine "${name}" \
290 | awk '{ print $'"${key}"' }'
295 if [ -f 'extra-urls.txt' ]
300 local extra_file="$(echo "${line}" | cut -f1 -d$'\t')"
301 local extra_url="$(echo "${line}" | cut -f2 -d$'\t')"
302 ${WGET} -O "${extra_file}" "${extra_url}" < /dev/null
303 done < 'extra-urls.txt'
321 validation="$(getValue "${name}" 2)"
322 license="$(getValue "${name}" 3)"
323 source_type="$(getValue "${name}" 4)"
324 source_url="$(getValue "${name}" 5)"
326 pack="${name}${pack_suffix}"
328 ${MKDIR_P} "${download_dir}"
334 ${ECHO} "Available pack: ${pack}"
335 ${ECHO} " License: ${license}"
336 ${ECHO} " Download via ${source_type} from ${source_url}"
339 if [ -d "${download_dir}/${pack}" ]
341 ${ECHO} "Updating ${name}…"
343 ${ECHO} "Downloading ${pack}…"
346 case "${source_type}" in
348 reference="$(getValue "${name}" 6)"
349 if [ -z "${reference}" ]
356 if [ -d "${pack}/.git" ]
363 ${SVN} update -r"${reference}" "${pack}"
366 ${SVN} checkout -r"${reference}" "${source_url}" "${pack}" \
367 || ${GIT} svn clone "${source_url}" "${pack}"
371 ${RM_R} 'zipdownload'
372 ${MKDIR} 'zipdownload'
375 ${WGET} "${source_url}"
376 ${UNZIPPER} './'*.zip
380 if [ -d 'zipdownload/games' ]
382 ${MV} 'zipdownload/'* "${pack}/"
384 ${MV} 'zipdownload/'*'/'* "${pack}/"
386 ${RM_R} 'zipdownload'
389 local subdir="$(getValue "${name}" 6)"
390 local branch="$(getValue "${name}" 7)"
392 ${GIT} archive --remote="${source_url}" --prefix="${pack}/" "${branch}":"${subdir}" \
403 ${GIT} clone "${source_url}" "${pack}"
419 downloadPackList () {
426 for name in ${name_list}
428 if printNameList | inList "${name}"
430 downloadPack "${download_dir}" "${name}"
432 printError "unknown name: ${name}"
450 pack="${name}${pack_suffix}"
452 ${MKDIR_P} "${install_dir}/${games_dir}"
454 # Some per-game workaround for malformed gamepack
467 if [ -d "${download_dir}/${pack}/build/netradiant" ]
469 # mkeditorpacks-based gamepack
470 pack="${pack}/build/netradiant"
471 elif [ -d "${download_dir}/${pack}/netradiant" ]
474 pack="${pack}/netradiant"
477 path="${download_dir}/${pack}"
479 for game_file in "${path}/${games_dir}/"*'.game'
481 if [ x"${game_file}" != x"${path}/"*'.game' ]
483 ${CP} "${game_file}" "${real_install_dir}/${games_dir}/"
487 for game_dir in "${path}/"*'.game'
489 if [ x"${game_dir}" != x"${path}/"*'.game' ]
491 ${CP_R} "${game_dir}" "${real_install_dir}/"
505 for name in ${name_list}
507 if printNameList | inList "${name}"
509 installPack "${download_dir}" "${install_dir}" "${name}"
511 printError "unknown name: ${name}"
517 printf 'ERROR: %s\n' "${1}" >&2
526 prog_name='gamepack-manager'
529 Usage: ${prog_name} [OPTION] [SELECTION <ARGUMENTS>] [ACTION]
532 ${tab}-dd, --download-dir DIRNAME
533 ${tab}${tab}store downloaded games to DIRNAME (default: ${default_download_dir})
535 ${tab}-id, --install-dir DIRNAME
536 ${tab}${tab}store installed games to DIRNAME (default: ${default_install_dir})
539 ${tab}-n, --name NAMES…
540 ${tab}${tab}select games by name (default: none)
541 ${tab}${tab}special keyword: validated, all, none
542 ${tab}${tab}available games:
543 $(printNameList | ${SED} -e 's/^/\t\t\t/')
545 ${tab}-l, --license LICENSES…
546 ${tab}${tab}select games by license (default: none)
547 ${tab}${tab}special keyword: free, all, none
548 ${tab}${tab}available licenses:
549 $(printLicenseList | ${SED} -e 's/^/\t\t\t/')
552 ${tab}-ln, --list-names
553 ${tab}${tab}list all game names
555 ${tab}-ll, --list-licenses
556 ${tab}${tab}list all game licenses
558 ${tab}-ls, --list-selected
559 ${tab}${tab}list selected games
562 ${tab}${tab}download selected games
565 ${tab}${tab}install selected games
568 ${tab}${tab}print this help
571 ${tab}${prog_name} --license GPL BSD --list-selected
572 ${tab}${prog_name} --license GPL BSD --download --install
574 ${tab}${prog_name} --name validated --list-selected
575 ${tab}${prog_name} --name validated --download --install
584 list_selected='false'
585 list_licenses='false'
588 download_packs='false'
589 install_packs='false'
591 mkdir_download='false'
592 mkdir_install='false'
603 while ! [ -z "${1}" ]
606 if printList "${option_list}" | inList "${1}"
608 printError "option called more than once: ${1}"
611 if echo "${@}" | tr ' ' '\n' | inList '--help'
614 elif echo "${@}" | tr ' ' '\n' | inList '-h'
620 '--list-names'|'-ln')
623 option_list="${option_list} ${1}"
625 '--list-licenses'|'-ll')
628 option_list="${option_list} ${1}"
630 '--list-selected'|'-ls')
633 option_list="${option_list} ${1}"
637 download_packs='true'
638 mkdir_download='true'
639 option_list="${option_list} ${1}"
644 mkdir_download='true'
646 option_list="${option_list} ${1}"
650 arg_type='pack-license'
651 option_list="${option_list} ${1}"
656 option_list="${option_list} ${1}"
658 '--download-dir'|'-dd')
659 arg_type='download-dir'
660 option_list="${option_list} ${1}"
662 '--install-dir'|'-id')
663 arg_type='install-dir'
664 option_list="${option_list} ${1}"
667 printError "unknown option: ${1}"
670 case "${arg_type}" in
672 name_list="${name_list} ${1}"
675 license_list="${license_list} ${1}"
678 if [ -z "${download_dir}" ]
682 printError "more than one download dir: ${1}"
686 if [ -z "${install_dir}" ]
690 printError "more than one install dir: ${1}"
694 printError "misplaced argument: ${1}"
703 # compatibility with legacy Makefile
704 if [ "${DOWNLOAD_GAMEPACKS}" = 'yes' ]
706 if ! [ -z "${DOWNLOADDIR}" ]
708 download_dir="${DOWNLOADDIR}"
711 if ! [ -z "${INSTALLDIR}" ]
713 install_dir="${INSTALLDIR}"
719 download_packs='true'
720 mkdir_download='true'
726 if [ -z "${download_dir}" ]
728 download_dir="${default_download_dir}"
731 if [ -z "${install_dir}" ]
733 install_dir="${default_install_dir}"
738 selected_list="${selected_list} $(printNameListByName "${name_list}")"
743 selected_list="${selected_list} $(printNameListByLicense "${license_list}")"
746 selected_list="$(dedupeList "${selected_list}")"
748 if "${mkdir_download}"
750 ${MKDIR_P} "${download_dir}"
751 real_download_dir="$(printRealPath "${download_dir}")"
754 if "${mkdir_install}"
756 ${MKDIR_P} "${install_dir}"
757 real_install_dir="$(printRealPath "${install_dir}")"
765 if "${list_licenses}"
770 if "${list_selected}"
772 printList "${selected_list}"
775 if "${download_packs}"
777 downloadPackList "${real_download_dir}" "${selected_list}"
780 if "${install_packs}"
782 installPackList "${real_download_dir}" "${real_install_dir}" "${selected_list}"