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 Quake2 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
70 Quake4 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
71 Quake GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
72 Quetoo GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
73 Tremulous proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
74 TurtleArena proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
75 UFOAI proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
76 Unvanquished BSD git https://github.com/Unvanquished/unvanquished-mapeditor-support.git
77 Warsow GPL git https://github.com/Warsow/NetRadiantPack.git
78 Wolf proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
79 Xonotic GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
84 sed -e 's/#.*//;s/[ \t][ \t][ \t]*/\t/g;s/^[ \t]*//;s/[ \t]*$//' \
89 [ "$(grep "^${1}$")" = "${1}" ]
110 printLicenseList () {
112 | awk '{ print $2 }' \
118 | awk '{ print $1 }' \
122 printNameListByLicense () {
123 local arg_license_list
127 arg_license_list="${1}"
130 for license in ${arg_license_list}
137 license_list="$(printLicenseList)"
141 license_list="${license_list} ${free_license_list}"
144 if printLicenseList | inList "${license}"
146 license_list="${license_list} ${license}"
148 printError "unknown license: ${license}"
154 license_list="$(dedupeList "${license_list}")"
156 for license in ${license_list}
159 | awk '$2 == "'"${license}"'"' \
164 printNameListByName () {
172 for name in ${argname_list}
180 name_list="$(printNameList)"
184 if printNameList | inList "${name}"
187 name_list="${name_list} ${name}"
189 printError "unknown name: ${name}"
195 name_list="$(dedupeList "${name_list}")"
197 for name in ${name_list}
200 | awk '$1 == "'"${name}"'"' \
211 | awk '$1 == "'"${name}"'"'
221 printPackLine "${name}" \
222 | awk '{ print $'"${key}"' }'
227 if [ -f 'extra-urls.txt' ]
229 while IFS=' ' read -r extra_file extra_url
232 ${WGET} -O "${extra_file}" "${extra_url}"
234 done < 'extra-urls.txt'
252 license="$(getValue "${name}" '2')"
253 source_type="$(getValue "${name}" '3')"
254 source_url="$(getValue "${name}" '4')"
256 pack="${name}${pack_suffix}"
258 ${MKDIR_P} "${download_dir}"
264 ${ECHO} "Available pack: ${pack}"
265 ${ECHO} " License: ${license}"
266 ${ECHO} " Download via ${source_type} from ${source_url}"
269 if [ -d "${download_dir}/${pack}" ]
271 ${ECHO} "Updating ${name}…"
273 ${ECHO} "Downloading ${pack}…"
276 case "${source_type}" in
278 reference="$(getValue "${name}" '5')"
279 if [ -z "${reference}" ]
286 if [ -d "${pack}/.git" ]
293 ${SVN} update -r"${reference}" "${pack}"
296 ${SVN} checkout -r"${reference}" "${source_url}" "${pack}" \
297 || ${GIT} svn clone "${source_url}" "${pack}"
301 ${RM_R} 'zipdownload'
302 ${MKDIR} 'zipdownload'
305 ${WGET} "${source_url}"
306 ${UNZIPPER} './'*.zip
310 ${MV} 'zipdownload/'*'/'* "${pack}/"
311 ${RM_R} 'zipdownload'
314 local subdir="$(getValue "${name}" '5')"
315 local branch="$(getValue "${name}" '6')"
317 ${GIT} archive --remote="${source_url}" --prefix="${pack}/" "${branch}":"${subdir}" \
328 ${GIT} clone "${source_url}" "${pack}"
344 downloadPackList () {
351 for name in ${name_list}
353 if printNameList | inList "${name}"
355 downloadPack "${download_dir}" "${name}"
357 printError "unknown name: ${name}"
375 pack="${name}${pack_suffix}"
377 ${MKDIR_P} "${install_dir}/${games_dir}"
379 # Some per-game workaround for malformed gamepack
392 # mkeditorpacks-based gamepack
393 if [ -d "${download_dir}/${pack}/build/netradiant" ]
395 pack="${pack}/build/netradiant"
398 path="${download_dir}/${pack}"
400 for game_file in "${path}/${games_dir}/"*'.game'
402 if [ x"${game_file}" != x"${path}/"*'.game' ]
404 ${CP} "${game_file}" "${real_install_dir}/${games_dir}/"
408 for game_dir in "${path}/"*'.game'
410 if [ x"${game_dir}" != x"${path}/"*'.game' ]
412 ${CP_R} "${game_dir}" "${real_install_dir}/"
426 for name in ${name_list}
428 if printNameList | inList "${name}"
430 installPack "${download_dir}" "${install_dir}" "${name}"
432 printError "unknown name: ${name}"
438 printf 'ERROR: %s\n' "${1}" >&2
447 prog_name="$(basename "$(readlink -f "${0}")")"
450 Usage: ${prog_name} [OPTION] [SELECTION <ARGUMENTS>] [ACTION]
453 ${tab}-dd, --download-dir DIRNAME
454 ${tab}${tab}store downloaded games to DIRNAME (default: ${default_download_dir})
456 ${tab}-id, --install-dir DIRNAME
457 ${tab}${tab}store installed games to DIRNAME (default: ${default_install_dir})
460 ${tab}-n, --name NAMES…
461 ${tab}${tab}select games by name (default: none)
462 ${tab}${tab}special keyword: all, none
463 ${tab}${tab}available games:
464 $(printNameList | sed -e 's/^/\t\t\t/')
466 ${tab}-l, --license LICENSES…
467 ${tab}${tab}select games by license (default: none)
468 ${tab}${tab}special keyword: free, all, none
469 ${tab}${tab}available licenses:
470 $(printLicenseList | sed -e 's/^/\t\t\t/')
473 ${tab}-ln, --list-names
474 ${tab}${tab}list all game names
476 ${tab}-ll, --list-licenses
477 ${tab}${tab}list all game licenses
480 ${tab}${tab}list selected games
483 ${tab}${tab}download selected games
486 ${tab}${tab}install selected games
489 ${tab}${tab}print this help
492 ${tab}${prog_name} --license GPL BSD --download --install
501 list_selected='false'
502 list_licenses='false'
505 download_packs='false'
506 install_packs='false'
508 mkdir_download='false'
509 mkdir_install='false'
520 while ! [ -z "${1}" ]
523 if printList "${option_list}" | inList "${1}"
525 printError "option called more than once: ${1}"
528 if echo "${@}" | tr ' ' '\n' | inList '--help'
531 elif echo "${@}" | tr ' ' '\n' | inList '-h'
537 '--list-licenses'|'-ll')
540 option_list="${option_list} ${1}"
542 '--list-names'|'-ln')
545 option_list="${option_list} ${1}"
547 '--list-selected'|'-ls')
550 option_list="${option_list} ${1}"
554 download_packs='true'
555 mkdir_download='true'
556 option_list="${option_list} ${1}"
561 mkdir_download='true'
563 option_list="${option_list} ${1}"
567 arg_type='pack-license'
568 option_list="${option_list} ${1}"
573 option_list="${option_list} ${1}"
575 '--download-dir'|'-dd')
576 arg_type='download-dir'
577 option_list="${option_list} ${1}"
579 '--install-dir'|'-id')
580 arg_type='install-dir'
581 option_list="${option_list} ${1}"
584 printError "unknown option: ${1}"
587 case "${arg_type}" in
589 license_list="${license_list} ${1}"
592 name_list="${name_list} ${1}"
595 if [ -z "${download_dir}" ]
599 printError "more than one download dir: ${1}"
603 if [ -z "${install_dir}" ]
607 printError "more than one install dir: ${1}"
611 printError "misplaced argument: ${1}"
620 # compatibility with legacy Makefile
621 if [ "${DOWNLOAD_GAMEPACKS}" = 'yes' ]
623 ! [ -z "${DOWNLOADDIR}" ] && download_dir="${DOWNLOADDIR}"
624 ! [ -z "${INSTALLDIR}" ] && install_dir="${INSTALDIR}"
627 download_packs='true'
631 if [ -z "${download_dir}" ]
633 download_dir="${default_download_dir}"
636 if [ -z "${install_dir}" ]
638 install_dir="${default_install_dir}"
643 selected_list="${selected_list} $(printNameListByLicense "${license_list}")"
648 selected_list="${selected_list} $(printNameListByName "${name_list}")"
651 selected_list="$(dedupeList "${selected_list}")"
653 if "${mkdir_download}"
655 ${MKDIR_P} "${download_dir}"
656 real_download_dir="$(readlink -f "${download_dir}")"
659 if "${mkdir_install}"
661 ${MKDIR_P} "${install_dir}"
662 real_install_dir="$(readlink -f "${install_dir}")"
665 if "${list_licenses}"
674 if "${list_selected}"
676 printList "${selected_list}"
679 if "${download_packs}"
681 downloadPackList "${real_download_dir}" "${selected_list}"
684 if "${install_packs}"
686 installPackList "${real_download_dir}" "${real_install_dir}" "${selected_list}"