q3map2: fix prt loading for vis computation when using -prtfile
[xonotic/netradiant.git] / download-gamepacks.sh
1 #!/bin/sh
2
3 # Usage:
4 #   sh download-gamepack.sh
5 #   LICENSEFILTER=GPL,BSD 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 -f -r}
13 : ${MV:=mv}
14 : ${UNZIPPER:=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" "$@" || true
39                                 ;;
40                         zip1)
41                                 $RM_R zipdownload
42                                 $MKDIR zipdownload
43                                 cd zipdownload
44                                 $WGET "$source" "$@" || true
45                                 $UNZIPPER *.zip || true
46                                 cd ..
47                                 $RM_R "games/$pack"
48                                 $MKDIR "games/$pack"
49                                 $MV zipdownload/*/* "games/$pack/" || true
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 - || true
56                                 cd ..
57                                 ;;
58                         git)
59                                 cd "games/$pack"
60                                 $GIT pull || true
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                 *)
87                         if ! echo "$LICENSEFILTER" | tr ',' '\n' | grep -F -q -x "$license"
88                         then
89                                 $ECHO "Pack $pack rejected because its license is not in LICENSEFILTER."
90                                 return
91                         fi
92                         ;;
93         esac
94         case "$BATCH" in
95                 '')
96                         while :; do
97                                 $ECHO "Download this pack? (y/n)"
98                                 read -r P
99                                 case "$P" in
100                                         y*)
101                                                 break
102                                                 ;;
103                                         n*)
104                                                 return
105                                                 ;;
106                                 esac
107                         done
108                         ;;
109                 *)
110                         ;;
111         esac
112         
113         $ECHO "Downloading $pack..."
114         case "$sourcetype" in
115                 svn)
116                         $SVN checkout "$source" "games/$pack" "$@" || true
117                         ;;
118                 zip1)
119                         $RM_R zipdownload
120                         $MKDIR zipdownload
121                         cd zipdownload
122                         $WGET "$source" "$@" || true
123                         $UNZIPPER *.zip || true
124                         cd ..
125                         $MKDIR "games/$pack"
126                         $MV zipdownload/*/* "games/$pack/" || true
127                         $RM_R zipdownload
128                         ;;
129                 gitdir)
130                         cd games
131                         $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - || true
132                         cd ..
133                         ;;
134                 git)
135                         cd games
136                         $GIT clone "$source" "$pack" || true
137                         cd ..
138                         ;;
139         esac
140         extra_urls "games/$pack"
141         good=false
142         for D in "games/$pack"/*.game; do
143                 if [ -d "$D" ]; then
144                         good=true
145                 fi
146         done
147         $good || rm -rf "$D"
148 }
149
150 mkdir -p games
151 pack DarkPlacesPack    GPL         svn    svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
152 pack Doom3Pack         proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
153 pack ETPack            proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
154 pack Heretic2Pack      proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
155 pack JediAcademyPack   proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
156 pack NeverballPack     proprietary zip1   http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
157 pack NexuizPack        GPL         gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
158 #pack OpenArenaPack    unknown     zip1   http://ingar.satgnu.net/files/netradiant/gamepacks/OpenArenaPack.zip
159 pack OpenArenaPack     GPL         git    https://github.com/NeonKnightOA/oagamepack.git
160 pack OsirionPack       GPL         zip1   http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
161 pack PreyPack          proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/PreyPack/trunk/
162 pack Q3Pack            proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ -r29
163 pack Quake2Pack        proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
164 pack Quake4Pack        proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
165 #pack QuakePack        proprietary zip1   http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
166 pack QuakePack         GPL         zip1   http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
167 #pack Quake2WorldPack  GPL         svn    svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
168 pack QuetooPack        GPL         svn    svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
169 #pack TremulousPack    proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
170 pack TremulousPack     proprietary zip1   http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
171 pack TurtleArenaPack   proprietary git    https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
172 pack UFOAIPack         proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
173 #pack UnvanquishedPack unknown     zip1   http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
174 pack UnvanquishedPack  BSD         svn    https://github.com/Unvanquished/unvanquished-mapeditor-support.git/trunk/build/netradiant
175 #pack WarsowPack       GPL         svn    https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
176 #pack WarsowPack       GPL         zip1   http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
177 pack WarsowPack        GPL         git    https://github.com/Warsow/NetRadiantPack.git
178 pack WolfPack          proprietary svn    svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
179 pack XonoticPack       GPL         git    https://gitlab.com/xonotic/netradiant-xonoticpack.git