]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - download-gamepacks.sh
Testing my commit ability
[xonotic/netradiant.git] / download-gamepacks.sh
1 #!/bin/sh
2
3 # Usage:
4 #   sh download-gamepack.sh
5 #   LICENSEFILTER=GPL BATCH=1 sh download-gamepack.sh
6
7 : ${GIT:=git}
8 : ${SVN:=svn}
9 : ${WGET:=wget}
10 : ${ECHO:=echo}
11 : ${MKDIR:=mkdir}
12 : ${RM_R:=rm -r}
13 : ${MV:=mv}
14 : ${UNZIP:=unzip}
15
16 set -e
17
18 extra_urls()
19 {
20         if [ -f "$1/extra-urls.txt" ]; then
21                 while IFS="     " read -r FILE URL; do
22                         $WGET -O "$1/$FILE" "$URL"
23                 done < "$1/extra-urls.txt"
24         fi
25 }
26
27 pack()
28 {
29         pack=$1; shift
30         license=$1; shift
31         sourcetype=$1; shift
32         source=$1; shift
33
34         if [ -d "games/$pack" ]; then
35                 $ECHO "Updating $pack..."
36                 case "$sourcetype" in
37                         svn)
38                                 $SVN update "games/$pack" "$@"
39                                 ;;
40                         zip1)
41                                 $RM_R zipdownload
42                                 $MKDIR zipdownload
43                                 cd zipdownload
44                                 $WGET "$source" "$@"
45                                 $UNZIP *
46                                 cd ..
47                                 $RM_R "games/$pack"
48                                 $MKDIR "games/$pack"
49                                 $MV zipdownload/*/* "games/$pack/"
50                                 $RM_R zipdownload
51                                 ;;
52                         gitdir)
53                                 $RM_R "games/$pack"
54                                 cd games
55                                 $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
56                                 cd ..
57                                 ;;
58                         git)
59                                 cd "games/$pack"
60                                 $GIT pull
61                                 cd ../..
62                                 ;;
63                 esac
64                 extra_urls "games/$pack"
65                 return
66         fi
67
68         $ECHO
69         $ECHO "Available pack: $pack"
70         $ECHO "  License: $license"
71         $ECHO "  Download via $sourcetype from $source"
72         $ECHO
73         case " $PACKFILTER " in
74                 "  ")
75                         ;;
76                 *" $pack "*)
77                         ;;
78                 *)
79                         $ECHO "Pack $pack rejected because it is not in PACKFILTER."
80                         return
81                         ;;
82         esac
83         case " $LICENSEFILTER " in
84                 "  ")
85                         ;;
86                 *" $license "*)
87                         ;;
88                 *)
89                         $ECHO "Pack $pack rejected because its license is not in LICENSEFILTER."
90                         return
91                         ;;
92         esac
93         case "$BATCH" in
94                 '')
95                         while :; do
96                                 $ECHO "Download this pack? (y/n)"
97                                 read -r P
98                                 case "$P" in
99                                         y*)
100                                                 break
101                                                 ;;
102                                         n*)
103                                                 return
104                                                 ;;
105                                 esac
106                         done
107                         ;;
108                 *)
109                         ;;
110         esac
111         
112         $ECHO "Downloading $pack..."
113         case "$sourcetype" in
114                 svn)
115                         $SVN checkout "$source" "games/$pack" "$@"
116                         ;;
117                 zip1)
118                         $RM_R zipdownload
119                         $MKDIR zipdownload
120                         cd zipdownload
121                         $WGET "$source" "$@"
122                         $UNZIP *
123                         cd ..
124                         $MKDIR "games/$pack"
125                         $MV zipdownload/*/* "games/$pack/"
126                         $RM_R zipdownload
127                         ;;
128                 gitdir)
129                         cd games
130                         $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
131                         cd ..
132                         ;;
133                 git)
134                         cd games
135                         $GIT clone "$source" "$pack"
136                         cd ..
137                         ;;
138         esac
139         extra_urls "games/$pack"
140 }
141
142 mkdir -p games
143 pack DarkPlacesPack  GPL         svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/DarkPlacesPack/branches/1.5/
144 pack NexuizPack      GPL         gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
145 pack OpenArenaPack   unknown     zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/OpenArenaPack.zip
146 pack Q3Pack          proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/Q3Pack/trunk/ -r29
147 pack Quake2Pack      proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/Quake2Pack.zip
148 pack Quake2WorldPack GPL         svn    svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
149 pack QuakePack       proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/QuakePack.zip
150 pack TremulousPack   proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/TremulousPack.zip
151 pack UFOAIPack       proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/UFOAIPack/branches/1.5/
152 pack WarsowPack      GPL         svn    http://opensvn.csie.org/warsowgamepack/netradiant/games/WarsowPack/
153 pack XonoticPack     GPL         git    git://git.xonotic.org/xonotic/netradiant-xonoticpack.git