Merge commit '830125fad042fad35dc029b6eb57c8156ad7e176'
[xonotic/netradiant.git] / download-gamepacks.sh
index 6869ea2..6de58af 100755 (executable)
@@ -4,13 +4,22 @@
 #   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 -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"
+                       $WGET -O "$1/$FILE" "$URL"
                done < "$1/extra-urls.txt"
        fi
 }
@@ -23,32 +32,32 @@ pack()
        source=$1; shift
 
        if [ -d "games/$pack" ]; then
-               echo "Updating $pack..."
+               $ECHO "Updating $pack..."
                case "$sourcetype" in
                        svn)
-                               svn update "games/$pack" "$@"
+                               $SVN update "games/$pack" "$@" || true
                                ;;
                        zip1)
-                               rm -rf zipdownload
-                               mkdir zipdownload
+                               $RM_R zipdownload
+                               $MKDIR zipdownload
                                cd zipdownload
-                               wget "$source" "$@"
-                               unzip *
+                               $WGET "$source" "$@" || true
+                               $UNZIPPER *.zip || true
                                cd ..
-                               rm -rf "games/$pack"
-                               mkdir "games/$pack"
-                               mv zipdownload/*/* "games/$pack/"
-                               rm -rf zipdownload
+                               $RM_R "games/$pack"
+                               $MKDIR "games/$pack"
+                               $MV zipdownload/*/* "games/$pack/" || true
+                               $RM_R zipdownload
                                ;;
                        gitdir)
-                               rm -rf "games/$pack"
+                               $RM_R "games/$pack"
                                cd games
-                               git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
+                               $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - || true
                                cd ..
                                ;;
                        git)
                                cd "games/$pack"
-                               git pull
+                               $GIT pull || true
                                cd ../..
                                ;;
                esac
@@ -56,18 +65,18 @@ pack()
                return
        fi
 
-       echo
-       echo "Available pack: $pack"
-       echo "  License: $license"
-       echo "  Download via $sourcetype from $source"
-       echo
+       $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."
+                       $ECHO "Pack $pack rejected because it is not in PACKFILTER."
                        return
                        ;;
        esac
@@ -77,14 +86,14 @@ pack()
                *" $license "*)
                        ;;
                *)
-                       echo "Pack $pack rejected because its license is not in LICENSEFILTER."
+                       $ECHO "Pack $pack rejected because its license is not in LICENSEFILTER."
                        return
                        ;;
        esac
        case "$BATCH" in
                '')
                        while :; do
-                               echo "Download this pack? (y/n)"
+                               $ECHO "Download this pack? (y/n)"
                                read -r P
                                case "$P" in
                                        y*)
@@ -100,45 +109,54 @@ pack()
                        ;;
        esac
        
-       echo "Downloading $pack..."
+       $ECHO "Downloading $pack..."
        case "$sourcetype" in
                svn)
-                       svn checkout "$source" "games/$pack" "$@"
+                       $SVN checkout "$source" "games/$pack" "$@" || true
                        ;;
                zip1)
-                       rm -rf zipdownload
-                       mkdir zipdownload
+                       $RM_R zipdownload
+                       $MKDIR zipdownload
                        cd zipdownload
-                       wget "$source" "$@"
-                       unzip *
+                       $WGET "$source" "$@" || true
+                       $UNZIPPER *.zip || true
                        cd ..
-                       mkdir "games/$pack"
-                       mv zipdownload/*/* "games/$pack/"
-                       rm -rf zipdownload
+                       $MKDIR "games/$pack"
+                       $MV zipdownload/*/* "games/$pack/" || true
+                       $RM_R zipdownload
                        ;;
                gitdir)
                        cd games
-                       git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
+                       $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - || true
                        cd ..
                        ;;
                git)
                        cd games
-                       git clone "$source" "$pack"
+                       $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    https://zerowing.idsoftware.com/svn/radiant.gamepacks/DarkPlacesPack/branches/1.5/
+pack DarkPlacesPack  GPL         svn    svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
 pack NexuizPack      GPL         gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
 pack OpenArenaPack   unknown     zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/OpenArenaPack.zip
-pack Q3Pack          proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/Q3Pack/trunk/ -r29
+pack OsirionPack     GPL         zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/OsirionPack.zip
+pack Q3Pack          proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ -r29
 pack Quake2Pack      proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/Quake2Pack.zip
 pack Quake2WorldPack GPL         svn    svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
-pack QuakePack       proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/QuakePack.zip
+pack QuakePack       GPL         zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/QuakePack.zip
 pack TremulousPack   proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/TremulousPack.zip
-pack UFOAIPack       proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/UFOAIPack/branches/1.5/
-pack WarsowPack      GPL         svn    http://opensvn.csie.org/warsowgamepack/netradiant/games/WarsowPack/
+pack UFOAIPack       proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
+#pack WarsowPack     GPL         svn    https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
+pack WarsowPack      GPL         zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/WarsowPack.zip
 pack XonoticPack     GPL         git    git://git.xonotic.org/xonotic/netradiant-xonoticpack.git