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' ]
297 while IFS=' ' read -r extra_file extra_url
300 ${WGET} -O "${extra_file}" "${extra_url}"
302 done < 'extra-urls.txt'
320 validation="$(getValue "${name}" 2)"
321 license="$(getValue "${name}" 3)"
322 source_type="$(getValue "${name}" 4)"
323 source_url="$(getValue "${name}" 5)"
325 pack="${name}${pack_suffix}"
327 ${MKDIR_P} "${download_dir}"
333 ${ECHO} "Available pack: ${pack}"
334 ${ECHO} " License: ${license}"
335 ${ECHO} " Download via ${source_type} from ${source_url}"
338 if [ -d "${download_dir}/${pack}" ]
340 ${ECHO} "Updating ${name}…"
342 ${ECHO} "Downloading ${pack}…"
345 case "${source_type}" in
347 reference="$(getValue "${name}" 6)"
348 if [ -z "${reference}" ]
355 if [ -d "${pack}/.git" ]
362 ${SVN} update -r"${reference}" "${pack}"
365 ${SVN} checkout -r"${reference}" "${source_url}" "${pack}" \
366 || ${GIT} svn clone "${source_url}" "${pack}"
370 ${RM_R} 'zipdownload'
371 ${MKDIR} 'zipdownload'
374 ${WGET} "${source_url}"
375 ${UNZIPPER} './'*.zip
379 if [ -d 'zipdownload/games' ]
381 ${MV} 'zipdownload/'* "${pack}/"
383 ${MV} 'zipdownload/'*'/'* "${pack}/"
385 ${RM_R} 'zipdownload'
388 local subdir="$(getValue "${name}" 6)"
389 local branch="$(getValue "${name}" 7)"
391 ${GIT} archive --remote="${source_url}" --prefix="${pack}/" "${branch}":"${subdir}" \
402 ${GIT} clone "${source_url}" "${pack}"
418 downloadPackList () {
425 for name in ${name_list}
427 if printNameList | inList "${name}"
429 downloadPack "${download_dir}" "${name}"
431 printError "unknown name: ${name}"
449 pack="${name}${pack_suffix}"
451 ${MKDIR_P} "${install_dir}/${games_dir}"
453 # Some per-game workaround for malformed gamepack
466 if [ -d "${download_dir}/${pack}/build/netradiant" ]
468 # mkeditorpacks-based gamepack
469 pack="${pack}/build/netradiant"
470 elif [ -d "${download_dir}/${pack}/netradiant" ]
473 pack="${pack}/netradiant"
476 path="${download_dir}/${pack}"
478 for game_file in "${path}/${games_dir}/"*'.game'
480 if [ x"${game_file}" != x"${path}/"*'.game' ]
482 ${CP} "${game_file}" "${real_install_dir}/${games_dir}/"
486 for game_dir in "${path}/"*'.game'
488 if [ x"${game_dir}" != x"${path}/"*'.game' ]
490 ${CP_R} "${game_dir}" "${real_install_dir}/"
504 for name in ${name_list}
506 if printNameList | inList "${name}"
508 installPack "${download_dir}" "${install_dir}" "${name}"
510 printError "unknown name: ${name}"
516 printf 'ERROR: %s\n' "${1}" >&2
525 prog_name='gamepack-manager'
528 Usage: ${prog_name} [OPTION] [SELECTION <ARGUMENTS>] [ACTION]
531 ${tab}-dd, --download-dir DIRNAME
532 ${tab}${tab}store downloaded games to DIRNAME (default: ${default_download_dir})
534 ${tab}-id, --install-dir DIRNAME
535 ${tab}${tab}store installed games to DIRNAME (default: ${default_install_dir})
538 ${tab}-n, --name NAMES…
539 ${tab}${tab}select games by name (default: none)
540 ${tab}${tab}special keyword: validated, all, none
541 ${tab}${tab}available games:
542 $(printNameList | ${SED} -e 's/^/\t\t\t/')
544 ${tab}-l, --license LICENSES…
545 ${tab}${tab}select games by license (default: none)
546 ${tab}${tab}special keyword: free, all, none
547 ${tab}${tab}available licenses:
548 $(printLicenseList | ${SED} -e 's/^/\t\t\t/')
551 ${tab}-ln, --list-names
552 ${tab}${tab}list all game names
554 ${tab}-ll, --list-licenses
555 ${tab}${tab}list all game licenses
557 ${tab}-ls, --list-selected
558 ${tab}${tab}list selected games
561 ${tab}${tab}download selected games
564 ${tab}${tab}install selected games
567 ${tab}${tab}print this help
570 ${tab}${prog_name} --license GPL BSD --list-selected
571 ${tab}${prog_name} --license GPL BSD --download --install
573 ${tab}${prog_name} --name validated --list-selected
574 ${tab}${prog_name} --name validated --download --install
583 list_selected='false'
584 list_licenses='false'
587 download_packs='false'
588 install_packs='false'
590 mkdir_download='false'
591 mkdir_install='false'
602 while ! [ -z "${1}" ]
605 if printList "${option_list}" | inList "${1}"
607 printError "option called more than once: ${1}"
610 if echo "${@}" | tr ' ' '\n' | inList '--help'
613 elif echo "${@}" | tr ' ' '\n' | inList '-h'
619 '--list-names'|'-ln')
622 option_list="${option_list} ${1}"
624 '--list-licenses'|'-ll')
627 option_list="${option_list} ${1}"
629 '--list-selected'|'-ls')
632 option_list="${option_list} ${1}"
636 download_packs='true'
637 mkdir_download='true'
638 option_list="${option_list} ${1}"
643 mkdir_download='true'
645 option_list="${option_list} ${1}"
649 arg_type='pack-license'
650 option_list="${option_list} ${1}"
655 option_list="${option_list} ${1}"
657 '--download-dir'|'-dd')
658 arg_type='download-dir'
659 option_list="${option_list} ${1}"
661 '--install-dir'|'-id')
662 arg_type='install-dir'
663 option_list="${option_list} ${1}"
666 printError "unknown option: ${1}"
669 case "${arg_type}" in
671 name_list="${name_list} ${1}"
674 license_list="${license_list} ${1}"
677 if [ -z "${download_dir}" ]
681 printError "more than one download dir: ${1}"
685 if [ -z "${install_dir}" ]
689 printError "more than one install dir: ${1}"
693 printError "misplaced argument: ${1}"
702 # compatibility with legacy Makefile
703 if [ "${DOWNLOAD_GAMEPACKS}" = 'yes' ]
705 if ! [ -z "${DOWNLOADDIR}" ]
707 download_dir="${DOWNLOADDIR}"
710 if ! [ -z "${INSTALLDIR}" ]
712 install_dir="${INSTALLDIR}"
718 download_packs='true'
719 mkdir_download='true'
725 if [ -z "${download_dir}" ]
727 download_dir="${default_download_dir}"
730 if [ -z "${install_dir}" ]
732 install_dir="${default_install_dir}"
737 selected_list="${selected_list} $(printNameListByName "${name_list}")"
742 selected_list="${selected_list} $(printNameListByLicense "${license_list}")"
745 selected_list="$(dedupeList "${selected_list}")"
747 if "${mkdir_download}"
749 ${MKDIR_P} "${download_dir}"
750 real_download_dir="$(printRealPath "${download_dir}")"
753 if "${mkdir_install}"
755 ${MKDIR_P} "${install_dir}"
756 real_install_dir="$(printRealPath "${install_dir}")"
764 if "${list_licenses}"
769 if "${list_selected}"
771 printList "${selected_list}"
774 if "${download_packs}"
776 downloadPackList "${real_download_dir}" "${selected_list}"
779 if "${install_packs}"
781 installPackList "${real_download_dir}" "${real_install_dir}" "${selected_list}"