Commit d8d8fd49 authored by Thomas Debesse's avatar Thomas Debesse

new gamepack-manager script to download and install game packs

New gamepack-manager script to download and install game packs
--------------------------------------------------------------

Just run `./gamepack-manager -h` to get an extensive help.

It obsoletes:

- `download-gamepacks.sh`
- `install-gamepack.sh`
- `install-gamepacks.sh`

New cmake options to configure game pack downloading
----------------------------------------------------

- `GAMEPACK_LICENSE`
- `GAMEPACK_NAME`

They must be used with `DOWNLOAD_GAMEPACKS=ON`

If set to `none`, those extra filters are not used.
By default `GAMEPACK_LICENSE` filters for free licenses only.
By default `GAMEPACK_NAME` does not filter anything.

Examples
--------

Configure to only fetch free game packs:

```sh
cmake .. \
	-DDOWNLOAD_GAMEPACKS=ON \
	-DGAMEPACKS_LICENSE=free \
	-DGAMEPACKS_NAME=none
```

Configure to only fetch Xonotic and Unvanquished game packs:

```sh
cmake .. \
	-DDOWNLOAD_GAMEPACKS=ON \
	-DGAMEPACKS_LICENSE=none \
	-DGAMEPACKS_NAME="Xonotic Unvanquished"
```

Configure to only fetch GPL game packs and Quake2 game pack:

```sh
cmake .. \
	-DDOWNLOAD_GAMEPACKS=ON \
	-DGAMEPACKS_LICENSE=GPL \
	-DGAMEPACKS_NAME="Quake2"
```

Fetch the game packs:

```
make game_packs
```

Note that it also works on `install` stage.
parent 2e64b0b9
......@@ -251,25 +251,16 @@ endif ()
#-----------------------------------------------------------------------
option(DOWNLOAD_GAMEPACKS "Download game packs" ON)
add_custom_target(game_packs_free
COMMAND ${CMAKE_COMMAND} -E make_directory games
COMMAND DOWNLOAD_GAMEPACKS=yes SOURCE_DIR="${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/install-gamepacks.sh" "${PROJECT_BINARY_DIR}"
COMMENT "Downloading free game packs"
)
add_custom_target(game_packs_all
COMMAND ${CMAKE_COMMAND} -E make_directory games
COMMAND DOWNLOAD_GAMEPACKS=all SOURCE_DIR="${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/install-gamepacks.sh" "${PROJECT_BINARY_DIR}"
COMMENT "Downloading all game packs"
)
set(GAMEPACKS_LICENSE_LIST free CACHE STRING "Download game packs by license")
set(GAMEPACKS_NAME_LIST none CACHE STRING "Download game packs by name")
if (DOWNLOAD_GAMEPACKS)
set(DOWNLOAD_GAMEPACKS "all")
add_custom_target(game_packs ALL
COMMAND "${PROJECT_SOURCE_DIR}/gamepack-manager" --license ${GAMEPACKS_LICENSE_LIST} --name ${GAMEPACKS_NAME_LIST} --download-dir "${PROJECT_BINARY_DIR}/download" --install-dir "${PROJECT_BINARY_DIR}" --download --install
COMMENT "Downloading ${GAMEPACKS_LICENSE_LIST} game packs"
)
endif()
if ("${DOWNLOAD_GAMEPACKS}" STREQUAL "free")
add_custom_target(game_packs_go ALL DEPENDS game_packs_free)
elseif ("${DOWNLOAD_GAMEPACKS}" STREQUAL "all")
add_custom_target(game_packs_go ALL DEPENDS game_packs_all)
endif ()
#-----------------------------------------------------------------------
# Install
......@@ -290,35 +281,7 @@ install(
DESTINATION .
)
set(GAME_FILES
DarkPlaces
Nexuiz
OpenArena
Osirion
Q3
Quake2
Quake
Quetoo
Tremulous
UFOAI
Unvanquished
Warsow
Xonotic
)
unset(_tmp)
foreach (it ${GAME_FILES})
set(dir "${PROJECT_BINARY_DIR}/games/${it}Pack")
string(TOLOWER "${it}" it)
list(APPEND _tmp "${dir}/games")
list(APPEND _tmp "${dir}/${it}.game")
endforeach ()
set(GAME_FILES ${_tmp})
install(
DIRECTORY
${GAME_FILES}
DESTINATION .
OPTIONAL
install(CODE "execute_process(COMMAND \"${PROJECT_SOURCE_DIR}/gamepack-manager\" --license ${GAMEPACKS_LICENSE_LIST} --name ${GAMEPACKS_NAME_LIST} --download-dir \"${PROJECT_BINARY_DIR}/download\" --install-dir \"${CMAKE_INSTALL_PREFIX}\" --install)"
)
include(cmake/scripts/package.cmake)
......@@ -18,6 +18,7 @@ RADIANT_ABOUTMSG ?= Custom build
# warning: this directory may NOT contain any files other than the ones written by this Makefile!
# NEVER SET THIS TO A SYSTEM WIDE "bin" DIRECTORY!
INSTALLDIR ?= install
DOWNLOADDIR ?= build/download
CC ?= gcc
CXX ?= g++
......@@ -36,7 +37,7 @@ ECHO_NOLF ?= echo -n
CAT ?= cat
MKDIR ?= mkdir -p
CP ?= cp
CP_R ?= $(CP) -r
CP_R ?= $(CP) -r --preserve=timestamps
LN ?= ln
LN_SNF ?= $(LN) -snf
RM ?= rm
......@@ -448,6 +449,7 @@ binaries-q3map2: \
.PHONY: clean
clean:
$(RM_R) $(INSTALLDIR_BASE)/
$(RM_R) $(DOWNLOADDIR)/
$(FIND) . \( -name \*.o -o -name \*.d -o -name \*.$(DLL) -o -name \*.$(A) -o -name \*.$(EXE) \) -exec $(RM) {} \;
$(RM) icons/*.rc
......@@ -1043,15 +1045,13 @@ $(INSTALLDIR)/heretic2/h2data.$(EXE): \
.PHONY: install-data
install-data: binaries
$(MKDIR) $(INSTALLDIR)/games
$(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIPPER="$(UNZIPPER)" ECHO="$(ECHO)" SH="$(SH)" CP="$(CP)" CP_R="$(CP_R)" $(SH) install-gamepacks.sh "$(INSTALLDIR)"
DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" DOWNLOADDIR="$(DOWNLOADDIR)" INSTALLDIR="$(INSTALLDIR)" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIPPER="$(UNZIPPER)" ECHO="$(ECHO)" SH="$(SH)" CP="$(CP)" CP_R="$(CP_R)" $(SH) gamepack-manager
$(ECHO) $(RADIANT_MAJOR_VERSION) > $(INSTALLDIR)/RADIANT_MAJOR
$(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
$(ECHO) $(RADIANT_PATCH_VERSION) > $(INSTALLDIR)/RADIANT_PATCH
$(CP_R) setup/data/tools/* $(INSTALLDIR)/
$(MKDIR) $(INSTALLDIR)/docs
$(CP_R) docs/* $(INSTALLDIR)/docs/
$(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
.PHONY: install-dll
ifeq ($(OS),Win32)
......
#!/bin/sh
# Usage:
# sh download-gamepack.sh
# LICENSEFILTER=GPL,BSD BATCH=1 sh download-gamepack.sh
: ${GIT:=git}
: ${SVN:=svn}
: ${WGET:=wget}
: ${ECHO:=echo}
: ${MKDIR:=mkdir}
: ${RM_R:=rm -f -r}
: ${MV:=mv}
: ${UNZIPPER:=unzip}
set -e
extra_urls()
{
if [ -f "$1/extra-urls.txt" ]; then
while IFS=" " read -r FILE URL; do
$WGET -O "$1/$FILE" "$URL"
done < "$1/extra-urls.txt"
fi
}
pack()
{
pack=$1; shift
license=$1; shift
sourcetype=$1; shift
source=$1; shift
if [ -d "games/$pack" ]; then
$ECHO "Updating $pack..."
case "$sourcetype" in
svn)
$SVN update "games/$pack" "$@" || true
;;
zip1)
$RM_R zipdownload
$MKDIR zipdownload
cd zipdownload
$WGET "$source" "$@" || true
$UNZIPPER *.zip || true
cd ..
$RM_R "games/$pack"
$MKDIR "games/$pack"
$MV zipdownload/*/* "games/$pack/" || true
$RM_R zipdownload
;;
gitdir)
$RM_R "games/$pack"
cd games
$GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - || true
cd ..
;;
git)
cd "games/$pack"
$GIT pull || true
cd ../..
;;
esac
extra_urls "games/$pack"
return
fi
$ECHO
$ECHO "Available pack: $pack"
$ECHO " License: $license"
$ECHO " Download via $sourcetype from $source"
$ECHO
case " $PACKFILTER " in
" ")
;;
*" $pack "*)
;;
*)
$ECHO "Pack $pack rejected because it is not in PACKFILTER."
return
;;
esac
case " $LICENSEFILTER " in
" ")
;;
*)
if ! echo "$LICENSEFILTER" | tr ',' '\n' | grep -F -q -x "$license"
then
$ECHO "Pack $pack rejected because its license is not in LICENSEFILTER."
return
fi
;;
esac
case "$BATCH" in
'')
while :; do
$ECHO "Download this pack? (y/n)"
read -r P
case "$P" in
y*)
break
;;
n*)
return
;;
esac
done
;;
*)
;;
esac
$ECHO "Downloading $pack..."
case "$sourcetype" in
svn)
$SVN checkout "$source" "games/$pack" "$@" || true
;;
zip1)
$RM_R zipdownload
$MKDIR zipdownload
cd zipdownload
$WGET "$source" "$@" || true
$UNZIPPER *.zip || true
cd ..
$MKDIR "games/$pack"
$MV zipdownload/*/* "games/$pack/" || true
$RM_R zipdownload
;;
gitdir)
cd games
$GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - || true
cd ..
;;
git)
cd games
$GIT clone "$source" "$pack" || true
cd ..
;;
esac
extra_urls "games/$pack"
good=false
for D in "games/$pack"/*.game; do
if [ -d "$D" ]; then
good=true
fi
done
$good || rm -rf "$D"
}
mkdir -p games
pack DarkPlacesPack GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
pack Doom3Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
pack ETPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
pack Heretic2Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
pack JediAcademyPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
pack NeverballPack proprietary zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
pack NexuizPack GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
#pack OpenArenaPack unknown zip1 http://ingar.satgnu.net/files/netradiant/gamepacks/OpenArenaPack.zip
pack OpenArenaPack GPL git https://github.com/NeonKnightOA/oagamepack.git
pack OsirionPack GPL zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
pack PreyPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/PreyPack/trunk/
pack Q3Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ -r29
pack Quake2Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
pack Quake4Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
#pack QuakePack proprietary zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
pack QuakePack GPL zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
#pack Quake2WorldPack GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
pack QuetooPack GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
#pack TremulousPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
pack TremulousPack proprietary zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
pack TurtleArenaPack proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
pack UFOAIPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
#pack UnvanquishedPack unknown zip1 http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
pack UnvanquishedPack BSD svn https://github.com/Unvanquished/unvanquished-mapeditor-support.git/trunk/build/netradiant
#pack WarsowPack GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
#pack WarsowPack GPL zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
pack WarsowPack GPL git https://github.com/Warsow/NetRadiantPack.git
pack WolfPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
pack XonoticPack GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
This diff is collapsed.
#!/bin/sh
# installs a game pack
# Usage:
# install-gamepack.sh gamepack installdir
set -ex
: ${CP:=cp}
: ${CP_R:=cp -r}
pack=$1
dest=$2
# Some per-game workaround for malformed gamepack
case $pack in
*/JediAcademyPack)
pack="$pack/Tools"
;;
*/PreyPack|*/Q3Pack)
pack="$pack/tools"
;;
*/WolfPack)
pack="$pack/bin"
;;
esac
for GAMEFILE in "$pack/games"/*.game; do
if [ x"$GAMEFILE" != x"$pack/games/*.game" ]; then
$CP "$GAMEFILE" "$dest/games/"
fi
done
for GAMEDIR in "$pack"/*.game; do
if [ x"$GAMEDIR" != x"$pack/*.game" ]; then
$CP_R "$GAMEDIR" "$dest/"
fi
done
#!/bin/sh
: ${ECHO:=echo}
: ${SH:=sh}
: ${CP:=cp}
: ${CP_R:=cp -r}
: ${SOURCE_DIR:=.}
dest=$1
case "$DOWNLOAD_GAMEPACKS" in
yes)
LICENSEFILTER=GPL,BSD BATCH=1 $SH "$SOURCE_DIR/download-gamepacks.sh"
;;
all)
BATCH=1 $SH "$SOURCE_DIR/download-gamepacks.sh"
;;
*)
;;
esac
set -e
for GAME in games/*Pack; do
if [ "$GAME" = "games/*Pack" ]; then
$ECHO "Game packs not found, please run"
$ECHO " $SOURCE_DIR/download-gamepacks.sh"
$ECHO "and then try again!"
else
$SH "$SOURCE_DIR/install-gamepack.sh" "$GAME" "$dest"
fi
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment