autodownload gamepacks from make

This commit is contained in:
Rudolf Polzer 2010-04-12 08:15:27 +02:00
parent b235832755
commit eeda7cae23
3 changed files with 83 additions and 45 deletions

View File

@ -44,9 +44,11 @@ TR ?= tr
FIND ?= find FIND ?= find
DIFF ?= diff DIFF ?= diff
SED ?= sed SED ?= sed
# optional:
GIT ?= git GIT ?= git
SVN ?= svn
WGET ?= wget
MV ?= mv
UNZIP ?= unzip
STDOUT_TO_DEVNULL ?= >/dev/null STDOUT_TO_DEVNULL ?= >/dev/null
STDERR_TO_DEVNULL ?= 2>/dev/null STDERR_TO_DEVNULL ?= 2>/dev/null
@ -75,6 +77,7 @@ LIBS_DL ?= -ldl # nothing on Win32
CPPFLAGS_ZLIB ?= CPPFLAGS_ZLIB ?=
LIBS_ZLIB ?= -lz LIBS_ZLIB ?= -lz
DEPEND_ON_MAKEFILE ?= yes DEPEND_ON_MAKEFILE ?= yes
DOWNLOAD_GAMEPACKS ?= yes # set to no to disable gamepack, set to all to even download undistributable gamepacks
DEPENDENCIES_CHECK ?= quiet DEPENDENCIES_CHECK ?= quiet
# or: off, verbose # or: off, verbose
@ -268,6 +271,7 @@ dependencies-check:
checkbinary coreutils "$(CP_R)"; \ checkbinary coreutils "$(CP_R)"; \
checkbinary coreutils "$(RM)"; \ checkbinary coreutils "$(RM)"; \
checkbinary coreutils "$(RM_R)"; \ checkbinary coreutils "$(RM_R)"; \
checkbinary coreutils "$(MV)"; \
checkbinary coreutils "$(ECHO) test $(TEE_STDERR)"; \ checkbinary coreutils "$(ECHO) test $(TEE_STDERR)"; \
checkbinary sed "$(SED)"; \ checkbinary sed "$(SED)"; \
checkbinary findutils "$(FIND)"; \ checkbinary findutils "$(FIND)"; \
@ -277,6 +281,10 @@ dependencies-check:
checkbinary binutils "$(RANLIB)"; \ checkbinary binutils "$(RANLIB)"; \
checkbinary binutils "$(AR)"; \ checkbinary binutils "$(AR)"; \
checkbinary pkg-config "$(PKGCONFIG)"; \ checkbinary pkg-config "$(PKGCONFIG)"; \
checkbinary unzip "$(UNZIP)"; \
checkbinary git-core "$(GIT)"; \
checkbinary subversion "$(SVN)"; \
checkbinary wget "$(WGET)"; \
[ "$(OS)" = "Win32" ] && checkbinary mingw32 "$(WINDRES)"; \ [ "$(OS)" = "Win32" ] && checkbinary mingw32 "$(WINDRES)"; \
[ -n "$(LDD)" ] && checkbinary libc6 "$(LDD)"; \ [ -n "$(LDD)" ] && checkbinary libc6 "$(LDD)"; \
[ -n "$(OTOOL)" ] && checkbinary xcode "$(OTOOL)"; \ [ -n "$(OTOOL)" ] && checkbinary xcode "$(OTOOL)"; \
@ -958,16 +966,7 @@ install-data: binaries
$(MKDIR) $(INSTALLDIR)/games $(MKDIR) $(INSTALLDIR)/games
$(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune $(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
[ "$(OS)" != "Darwin" ] || $(CP_R) setup/data/osx/NetRadiant.app/* $(INSTALLDIR_BASE)/NetRadiant.app/ [ "$(OS)" != "Darwin" ] || $(CP_R) setup/data/osx/NetRadiant.app/* $(INSTALLDIR_BASE)/NetRadiant.app/
set -ex; \ DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIP="$(UNZIP)" ECHO="$(ECHO)" SH="$(SH)" CP="$(CP)" CP_R="$(CP_R)" $(SH) install-gamepacks.sh "$(INSTALLDIR)"
for GAME in games/*; do \
if [ "$$GAME" = "games/*" ]; then \
$(ECHO) "Game packs not found, please run"; \
$(ECHO) " ./download-gamepacks.sh"; \
$(ECHO) "and then try again!"; \
else \
CP="$(CP)" CP_R="$(CP_R)" $(SH) install-gamepack.sh "$$GAME" "$(INSTALLDIR)"; \
fi; \
done
$(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR $(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
$(ECHO) $(RADIANT_MAJOR_VERSION) > $(INSTALLDIR)/RADIANT_MAJOR $(ECHO) $(RADIANT_MAJOR_VERSION) > $(INSTALLDIR)/RADIANT_MAJOR
$(CP_R) setup/data/tools/* $(INSTALLDIR)/ $(CP_R) setup/data/tools/* $(INSTALLDIR)/

View File

@ -4,13 +4,22 @@
# sh download-gamepack.sh # sh download-gamepack.sh
# LICENSEFILTER=GPL BATCH=1 sh download-gamepack.sh # LICENSEFILTER=GPL BATCH=1 sh download-gamepack.sh
: ${GIT:=git}
: ${SVN:=svn}
: ${WGET:=wget}
: ${ECHO:=echo}
: ${MKDIR:=mkdir}
: ${RM_R:=rm -r}
: ${MV:=mv}
: ${UNZIP:=unzip}
set -e set -e
extra_urls() extra_urls()
{ {
if [ -f "$1/extra-urls.txt" ]; then if [ -f "$1/extra-urls.txt" ]; then
while IFS=" " read -r FILE URL; do while IFS=" " read -r FILE URL; do
wget -O "$1/$FILE" "$URL" $WGET -O "$1/$FILE" "$URL"
done < "$1/extra-urls.txt" done < "$1/extra-urls.txt"
fi fi
} }
@ -23,32 +32,32 @@ pack()
source=$1; shift source=$1; shift
if [ -d "games/$pack" ]; then if [ -d "games/$pack" ]; then
echo "Updating $pack..." $ECHO "Updating $pack..."
case "$sourcetype" in case "$sourcetype" in
svn) svn)
svn update "games/$pack" "$@" $SVN update "games/$pack" "$@"
;; ;;
zip1) zip1)
rm -rf zipdownload $RM_R zipdownload
mkdir zipdownload $MKDIR zipdownload
cd zipdownload cd zipdownload
wget "$source" "$@" $WGET "$source" "$@"
unzip * $UNZIP *
cd .. cd ..
rm -rf "games/$pack" $RM_R "games/$pack"
mkdir "games/$pack" $MKDIR "games/$pack"
mv zipdownload/*/* "games/$pack/" $MV zipdownload/*/* "games/$pack/"
rm -rf zipdownload $RM_R zipdownload
;; ;;
gitdir) gitdir)
rm -rf "games/$pack" $RM_R "games/$pack"
cd games cd games
git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
cd .. cd ..
;; ;;
git) git)
cd "games/$pack" cd "games/$pack"
git pull $GIT pull
cd ../.. cd ../..
;; ;;
esac esac
@ -56,18 +65,18 @@ pack()
return return
fi fi
echo $ECHO
echo "Available pack: $pack" $ECHO "Available pack: $pack"
echo " License: $license" $ECHO " License: $license"
echo " Download via $sourcetype from $source" $ECHO " Download via $sourcetype from $source"
echo $ECHO
case " $PACKFILTER " in case " $PACKFILTER " in
" ") " ")
;; ;;
*" $pack "*) *" $pack "*)
;; ;;
*) *)
echo "Pack $pack rejected because it is not in PACKFILTER." $ECHO "Pack $pack rejected because it is not in PACKFILTER."
return return
;; ;;
esac esac
@ -77,14 +86,14 @@ pack()
*" $license "*) *" $license "*)
;; ;;
*) *)
echo "Pack $pack rejected because its license is not in LICENSEFILTER." $ECHO "Pack $pack rejected because its license is not in LICENSEFILTER."
return return
;; ;;
esac esac
case "$BATCH" in case "$BATCH" in
'') '')
while :; do while :; do
echo "Download this pack? (y/n)" $ECHO "Download this pack? (y/n)"
read -r P read -r P
case "$P" in case "$P" in
y*) y*)
@ -100,30 +109,30 @@ pack()
;; ;;
esac esac
echo "Downloading $pack..." $ECHO "Downloading $pack..."
case "$sourcetype" in case "$sourcetype" in
svn) svn)
svn checkout "$source" "games/$pack" "$@" $SVN checkout "$source" "games/$pack" "$@"
;; ;;
zip1) zip1)
rm -rf zipdownload $RM_R zipdownload
mkdir zipdownload $MKDIR zipdownload
cd zipdownload cd zipdownload
wget "$source" "$@" $WGET "$source" "$@"
unzip * $UNZIP *
cd .. cd ..
mkdir "games/$pack" $MKDIR "games/$pack"
mv zipdownload/*/* "games/$pack/" $MV zipdownload/*/* "games/$pack/"
rm -rf zipdownload $RM_R zipdownload
;; ;;
gitdir) gitdir)
cd games cd games
git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
cd .. cd ..
;; ;;
git) git)
cd games cd games
git clone "$source" "$pack" $GIT clone "$source" "$pack"
cd .. cd ..
;; ;;
esac esac

30
install-gamepacks.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
: ${ECHO:=echo}
: ${SH:=sh}
: ${CP:=cp}
: ${CP_R:=cp -r}
dest=$1
case "$DOWNLOAD_GAMEPACKS" in
yes)
LICENSEFILTER=GPL BATCH=1 $SH download-gamepacks.sh
;;
all)
BATCH=1 $SH download-gamepacks.sh
;;
*)
;;
esac
set -e
for GAME in games/*; do
if [ "$GAME" = "games/*" ]; then
$ECHO "Game packs not found, please run"
$ECHO " ./download-gamepacks.sh"
$ECHO "and then try again!"
else
$SH install-gamepack.sh "$GAME" "$dest"
fi
done