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 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
48 # JediOutcast proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JK2Pack/trunk/
49 # Kingpin unknown zip http://download.kingpin.info/kingpin/editing/maps/map_editors/NetRadiant/addon/Kingpinpack.zip
50 # Neverball proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
51 # OpenArena unknown zip http://ingar.intranifty.net/files/netradiant/gamepacks/OpenArenaPack.zip
52 # Quake2World GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
53 # Quake3 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ 29
54 # Quake proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
55 # Tremulous proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
56 # Tremulous proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
57 # Unvanquished unknown zip http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
58 # Warfork GPL zip https://cdn.discordapp.com/attachments/611741789237411850/659512520553267201/netradiant_warfork_gamepack.zip
59 # Warsow GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
60 # Warsow GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
62 #######################################################
64 #######################################################
66 AlienArena GPL svn https://svn.code.sf.net/p/alienarena-cc/code/trunk/tools/netradiant_gamepack/AlienArenaPack
67 DarkPlaces GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
68 Doom3 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
69 ET proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
70 Heretic2 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
71 JediAcademy proprietary git https://gitlab.com/netradiant/gamepacks/jediacademy-mapeditor-support.git
72 JediOutcast proprietary git https://gitlab.com/netradiant/gamepacks/jedioutcast-mapeditor-support.git
73 Kingpin unknown git https://gitlab.com/netradiant/gamepacks/kingpin-mapeditor-support.git
74 Neverball proprietary git https://gitlab.com/netradiant/gamepacks/neverball-mapeditor-support.git
75 Nexuiz GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
76 OpenArena GPL git https://github.com/NeonKnightOA/oagamepack.git
77 Osirion GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
78 Prey proprietary git https://gitlab.com/netradiant/gamepacks/prey-mapeditor-support.git
79 Q3Rally proprietary svn https://svn.code.sf.net/p/q3rallysa/code/tools/radiant-config/radiant15-netradiant/
80 Quake2 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
81 Quake3 proprietary git https://gitlab.com/netradiant/gamepacks/quake3-mapeditor-support.git
82 Quake4 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
83 QuakeLive proprietary git https://gitlab.com/netradiant/gamepacks/quakelive-mapeditor-support.git
84 Quake GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
85 Quetoo GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
86 SmokinGuns unknown git https://github.com/smokin-guns/smokinguns-mapeditor-support.git
87 SoF2 unknown git https://gitlab.com/netradiant/gamepacks/sof2-mapeditor-support.git
88 STVEF unknown git https://gitlab.com/netradiant/gamepacks/stvef-mapeditor-support.git
89 Tremulous proprietary git https://gitlab.com/netradiant/gamepacks/tremulous-mapeditor-support.git
90 TurtleArena proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
91 UFOAI proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
92 Unvanquished BSD git https://github.com/Unvanquished/unvanquished-mapeditor-support.git
93 UrbanTerror unknown git https://gitlab.com/netradiant/gamepacks/urbanterror-mapeditor-support.git
94 Warfork GPL git https://gitlab.com/netradiant/gamepacks/warfork-mapeditor-support.git
95 Warsow GPL git https://github.com/Warsow/NetRadiantPack.git
96 Wolf proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
97 WoP proprietary git https://github.com/PadWorld-Entertainment/wop-mapeditor-support.git
98 Wrath GPL git https://gitlab.com/netradiant/gamepacks/wrath-mapeditor-support.git
99 Xonotic GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
100 ZEQ2Lite unknown git https://gitlab.com/netradiant/gamepacks/zeq2lite-mapeditor-support.git
104 if command -v gsed >/dev/null
107 elif sed --help >/dev/null 2>&1
111 printf 'ERROR: GNU sed is missing\n' >&2
117 if command -v grealpath >/dev/null
120 elif command -v realpath >/dev/null
123 elif command -v greadlink >/dev/null
125 # test greadlink first as greadlink has the feature on macos
126 # but readlink only has it on linux, note that it's probably
128 # note: (g)readlink requires the file to be create first
130 elif command -v readlink >/dev/null
132 # --help and -f options are GNU readlink things
133 if readlink --help >/dev/null 2>&1
137 if ! python -c "import os; print(os.path.realpath('${1}'))"
139 printf 'ERROR: GNU realpath or other way to compute real path of a file is missing\n' >&2
147 ${SED} -e 's/#.*//;s/[ \t][ \t][ \t]*/\t/g;s/^[ \t]*//;s/[ \t]*$//' \
152 [ "$(grep "^${1}$")" = "${1}" ]
173 printLicenseList () {
175 | awk '{ print $2 }' \
181 | awk '{ print $1 }' \
185 printNameListByLicense () {
186 local arg_license_list
190 arg_license_list="${1}"
193 for license in ${arg_license_list}
200 license_list="$(printLicenseList)"
204 license_list="${license_list} ${free_license_list}"
207 if printLicenseList | inList "${license}"
209 license_list="${license_list} ${license}"
211 printError "unknown license: ${license}"
217 license_list="$(dedupeList "${license_list}")"
219 for license in ${license_list}
222 | awk '$2 == "'"${license}"'"' \
227 printNameListByName () {
235 for name in ${argname_list}
242 name_list="$(printNameList)"
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}
261 | awk '$1 == "'"${name}"'"' \
272 | awk '$1 == "'"${name}"'"'
282 printPackLine "${name}" \
283 | awk '{ print $'"${key}"' }'
288 if [ -f 'extra-urls.txt' ]
293 local extra_file="$(echo "${line}" | cut -f1 -d$'\t')"
294 local extra_url="$(echo "${line}" | cut -f2 -d$'\t')"
295 ${WGET} -O "${extra_file}" "${extra_url}" < /dev/null
296 done < 'extra-urls.txt'
314 license="$(getValue "${name}" 2)"
315 source_type="$(getValue "${name}" 3)"
316 source_url="$(getValue "${name}" 4)"
318 pack="${name}${pack_suffix}"
320 ${MKDIR_P} "${download_dir}"
326 ${ECHO} "Available pack: ${pack}"
327 ${ECHO} " License: ${license}"
328 ${ECHO} " Download via ${source_type} from ${source_url}"
331 if [ -d "${download_dir}/${pack}" ]
333 ${ECHO} "Updating ${name}…"
335 ${ECHO} "Downloading ${pack}…"
338 case "${source_type}" in
340 reference="$(getValue "${name}" 5)"
341 if [ -z "${reference}" ]
348 if [ -d "${pack}/.git" ]
355 ${SVN} update -r"${reference}" "${pack}"
358 ${SVN} checkout -r"${reference}" "${source_url}" "${pack}" \
359 || ${GIT} svn clone "${source_url}" "${pack}"
363 ${RM_R} 'zipdownload'
364 ${MKDIR} 'zipdownload'
367 ${WGET} "${source_url}"
368 ${UNZIPPER} './'*.zip
372 if [ -d 'zipdownload/games' ]
374 ${MV} 'zipdownload/'* "${pack}/"
376 ${MV} 'zipdownload/'*'/'* "${pack}/"
378 ${RM_R} 'zipdownload'
381 local subdir="$(getValue "${name}" 5)"
382 local branch="$(getValue "${name}" 6)"
384 ${GIT} archive --remote="${source_url}" --prefix="${pack}/" "${branch}":"${subdir}" \
395 ${GIT} clone "${source_url}" "${pack}"
411 downloadPackList () {
418 for name in ${name_list}
420 if printNameList | inList "${name}"
422 downloadPack "${download_dir}" "${name}"
424 printError "unknown name: ${name}"
442 pack="${name}${pack_suffix}"
444 ${MKDIR_P} "${install_dir}/${games_dir}"
446 # Some per-game workaround for malformed gamepack
453 # Game packs built with mkeditorpacks
454 if [ -d "${download_dir}/${pack}/build/netradiant" ]
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: 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 all --list-selected
561 ${tab}${prog_name} --name all --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}"