3 # get usage help this way:
4 # ./gamepack_manager -h
7 : "${CP_R:=cp -r --preserve=timestamps}"
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 unknown zip http://ingar.intranifty.net/files/netradiant/gamepacks/OpenArenaPack.zip
47 # Quake proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
48 # Quake2World GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
49 # Tremulous proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
50 # Unvanquished unknown zip http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
51 # Warsow GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
52 # Warsow GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
54 #######################################################
56 #######################################################
58 DarkPlaces GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
59 Doom3 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
60 ET proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
61 Heretic2 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
62 JediAcademy proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
63 Neverball proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
64 Nexuiz GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
65 OpenArena GPL git https://github.com/NeonKnightOA/oagamepack.git
66 Osirion GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
67 Prey proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/PreyPack/trunk/
68 Q3 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ 29
69 Q3Rally proprietary svn https://svn.code.sf.net/p/q3rallysa/code/tools/radiant-config/radiant15-netradiant/
70 Quake2 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
71 Quake4 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
72 Quake GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
73 Quetoo GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
74 Tremulous proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
75 TurtleArena proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
76 UFOAI proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
77 Unvanquished BSD git https://github.com/Unvanquished/unvanquished-mapeditor-support.git
78 Warsow GPL git https://github.com/Warsow/NetRadiantPack.git
79 Wolf proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
80 Xonotic GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
85 sed -e 's/#.*//;s/[ \t][ \t][ \t]*/\t/g;s/^[ \t]*//;s/[ \t]*$//' \
90 [ "$(grep "^${1}$")" = "${1}" ]
111 printLicenseList () {
113 | awk '{ print $2 }' \
119 | awk '{ print $1 }' \
123 printNameListByLicense () {
124 local arg_license_list
128 arg_license_list="${1}"
131 for license in ${arg_license_list}
138 license_list="$(printLicenseList)"
142 license_list="${license_list} ${free_license_list}"
145 if printLicenseList | inList "${license}"
147 license_list="${license_list} ${license}"
149 printError "unknown license: ${license}"
155 license_list="$(dedupeList "${license_list}")"
157 for license in ${license_list}
160 | awk '$2 == "'"${license}"'"' \
165 printNameListByName () {
173 for name in ${argname_list}
181 name_list="$(printNameList)"
185 if printNameList | inList "${name}"
188 name_list="${name_list} ${name}"
190 printError "unknown name: ${name}"
196 name_list="$(dedupeList "${name_list}")"
198 for name in ${name_list}
201 | awk '$1 == "'"${name}"'"' \
212 | awk '$1 == "'"${name}"'"'
222 printPackLine "${name}" \
223 | awk '{ print $'"${key}"' }'
228 if [ -f 'extra-urls.txt' ]
230 while IFS=' ' read -r extra_file extra_url
233 ${WGET} -O "${extra_file}" "${extra_url}"
235 done < 'extra-urls.txt'
253 license="$(getValue "${name}" '2')"
254 source_type="$(getValue "${name}" '3')"
255 source_url="$(getValue "${name}" '4')"
257 pack="${name}${pack_suffix}"
259 ${MKDIR_P} "${download_dir}"
265 ${ECHO} "Available pack: ${pack}"
266 ${ECHO} " License: ${license}"
267 ${ECHO} " Download via ${source_type} from ${source_url}"
270 if [ -d "${download_dir}/${pack}" ]
272 ${ECHO} "Updating ${name}…"
274 ${ECHO} "Downloading ${pack}…"
277 case "${source_type}" in
279 reference="$(getValue "${name}" '5')"
280 if [ -z "${reference}" ]
287 if [ -d "${pack}/.git" ]
294 ${SVN} update -r"${reference}" "${pack}"
297 ${SVN} checkout -r"${reference}" "${source_url}" "${pack}" \
298 || ${GIT} svn clone "${source_url}" "${pack}"
302 ${RM_R} 'zipdownload'
303 ${MKDIR} 'zipdownload'
306 ${WGET} "${source_url}"
307 ${UNZIPPER} './'*.zip
311 ${MV} 'zipdownload/'*'/'* "${pack}/"
312 ${RM_R} 'zipdownload'
315 local subdir="$(getValue "${name}" '5')"
316 local branch="$(getValue "${name}" '6')"
318 ${GIT} archive --remote="${source_url}" --prefix="${pack}/" "${branch}":"${subdir}" \
329 ${GIT} clone "${source_url}" "${pack}"
345 downloadPackList () {
352 for name in ${name_list}
354 if printNameList | inList "${name}"
356 downloadPack "${download_dir}" "${name}"
358 printError "unknown name: ${name}"
376 pack="${name}${pack_suffix}"
378 ${MKDIR_P} "${install_dir}/${games_dir}"
380 # Some per-game workaround for malformed gamepack
393 # mkeditorpacks-based gamepack
394 if [ -d "${download_dir}/${pack}/build/netradiant" ]
396 pack="${pack}/build/netradiant"
399 path="${download_dir}/${pack}"
401 for game_file in "${path}/${games_dir}/"*'.game'
403 if [ x"${game_file}" != x"${path}/"*'.game' ]
405 ${CP} "${game_file}" "${real_install_dir}/${games_dir}/"
409 for game_dir in "${path}/"*'.game'
411 if [ x"${game_dir}" != x"${path}/"*'.game' ]
413 ${CP_R} "${game_dir}" "${real_install_dir}/"
427 for name in ${name_list}
429 if printNameList | inList "${name}"
431 installPack "${download_dir}" "${install_dir}" "${name}"
433 printError "unknown name: ${name}"
439 printf 'ERROR: %s\n' "${1}" >&2
448 prog_name="$(basename "$(readlink -f "${0}")")"
451 Usage: ${prog_name} [OPTION] [SELECTION <ARGUMENTS>] [ACTION]
454 ${tab}-dd, --download-dir DIRNAME
455 ${tab}${tab}store downloaded games to DIRNAME (default: ${default_download_dir})
457 ${tab}-id, --install-dir DIRNAME
458 ${tab}${tab}store installed games to DIRNAME (default: ${default_install_dir})
461 ${tab}-n, --name NAMES…
462 ${tab}${tab}select games by name (default: none)
463 ${tab}${tab}special keyword: all, none
464 ${tab}${tab}available games:
465 $(printNameList | sed -e 's/^/\t\t\t/')
467 ${tab}-l, --license LICENSES…
468 ${tab}${tab}select games by license (default: none)
469 ${tab}${tab}special keyword: free, all, none
470 ${tab}${tab}available licenses:
471 $(printLicenseList | sed -e 's/^/\t\t\t/')
474 ${tab}-ln, --list-names
475 ${tab}${tab}list all game names
477 ${tab}-ll, --list-licenses
478 ${tab}${tab}list all game licenses
481 ${tab}${tab}list selected games
484 ${tab}${tab}download selected games
487 ${tab}${tab}install selected games
490 ${tab}${tab}print this help
493 ${tab}${prog_name} --license GPL BSD --download --install
502 list_selected='false'
503 list_licenses='false'
506 download_packs='false'
507 install_packs='false'
509 mkdir_download='false'
510 mkdir_install='false'
521 while ! [ -z "${1}" ]
524 if printList "${option_list}" | inList "${1}"
526 printError "option called more than once: ${1}"
529 if echo "${@}" | tr ' ' '\n' | inList '--help'
532 elif echo "${@}" | tr ' ' '\n' | inList '-h'
538 '--list-licenses'|'-ll')
541 option_list="${option_list} ${1}"
543 '--list-names'|'-ln')
546 option_list="${option_list} ${1}"
548 '--list-selected'|'-ls')
551 option_list="${option_list} ${1}"
555 download_packs='true'
556 mkdir_download='true'
557 option_list="${option_list} ${1}"
562 mkdir_download='true'
564 option_list="${option_list} ${1}"
568 arg_type='pack-license'
569 option_list="${option_list} ${1}"
574 option_list="${option_list} ${1}"
576 '--download-dir'|'-dd')
577 arg_type='download-dir'
578 option_list="${option_list} ${1}"
580 '--install-dir'|'-id')
581 arg_type='install-dir'
582 option_list="${option_list} ${1}"
585 printError "unknown option: ${1}"
588 case "${arg_type}" in
590 license_list="${license_list} ${1}"
593 name_list="${name_list} ${1}"
596 if [ -z "${download_dir}" ]
600 printError "more than one download dir: ${1}"
604 if [ -z "${install_dir}" ]
608 printError "more than one install dir: ${1}"
612 printError "misplaced argument: ${1}"
621 # compatibility with legacy Makefile
622 if [ "${DOWNLOAD_GAMEPACKS}" = 'yes' ]
624 ! [ -z "${DOWNLOADDIR}" ] && download_dir="${DOWNLOADDIR}"
625 ! [ -z "${INSTALLDIR}" ] && install_dir="${INSTALDIR}"
628 download_packs='true'
632 if [ -z "${download_dir}" ]
634 download_dir="${default_download_dir}"
637 if [ -z "${install_dir}" ]
639 install_dir="${default_install_dir}"
644 selected_list="${selected_list} $(printNameListByLicense "${license_list}")"
649 selected_list="${selected_list} $(printNameListByName "${name_list}")"
652 selected_list="$(dedupeList "${selected_list}")"
654 if "${mkdir_download}"
656 ${MKDIR_P} "${download_dir}"
657 real_download_dir="$(readlink -f "${download_dir}")"
660 if "${mkdir_install}"
662 ${MKDIR_P} "${install_dir}"
663 real_install_dir="$(readlink -f "${install_dir}")"
666 if "${list_licenses}"
675 if "${list_selected}"
677 printList "${selected_list}"
680 if "${download_packs}"
682 downloadPackList "${real_download_dir}" "${selected_list}"
685 if "${install_packs}"
687 installPackList "${real_download_dir}" "${real_install_dir}" "${selected_list}"