Merge branch 'osxnetradiant'
[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 set -e
8
9 pack()
10 {
11         pack=$1; shift
12         license=$1; shift
13         sourcetype=$1; shift
14         source=$1; shift
15
16         if [ -d "games/$pack" ]; then
17                 echo "Updating $pack..."
18                 case "$sourcetype" in
19                         svn)
20                                 svn update "games/$pack" "$@"
21                                 ;;
22                         zip1)
23                                 rm -rf zipdownload
24                                 mkdir zipdownload
25                                 cd zipdownload
26                                 wget "$source" "$@"
27                                 unzip *
28                                 cd ..
29                                 rm -rf "games/$pack"
30                                 mkdir "games/$pack"
31                                 mv zipdownload/*/* "games/$pack/"
32                                 rm -rf zipdownload
33                                 ;;
34                         gitdir)
35                                 rm -rf "games/$pack"
36                                 git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
37                                 ;;
38                 esac
39                 return
40         fi
41
42         echo
43         echo "Available pack: $pack"
44         echo "  License: $license"
45         echo "  Download via $sourcetype from $source"
46         echo
47         case " $PACKFILTER " in
48                 "  ")
49                         ;;
50                 *" $pack "*)
51                         ;;
52                 *)
53                         echo "Pack $pack rejected because it is not in PACKFILTER."
54                         return
55                         ;;
56         esac
57         case " $LICENSEFILTER " in
58                 "  ")
59                         ;;
60                 *" $license "*)
61                         ;;
62                 *)
63                         echo "Pack $pack rejected because its license is not in LICENSEFILTER."
64                         return
65                         ;;
66         esac
67         case "$BATCH" in
68                 '')
69                         while :; do
70                                 echo "Download this pack? (y/n)"
71                                 read -r P
72                                 case "$P" in
73                                         y*)
74                                                 break
75                                                 ;;
76                                         n*)
77                                                 return
78                                                 ;;
79                                 esac
80                         done
81                         ;;
82                 *)
83                         ;;
84         esac
85         
86         echo "Downloading $pack..."
87         case "$sourcetype" in
88                 svn)
89                         svn checkout "$source" "games/$pack" "$@"
90                         ;;
91                 zip1)
92                         rm -rf zipdownload
93                         mkdir zipdownload
94                         cd zipdownload
95                         wget "$source" "$@"
96                         unzip *
97                         cd ..
98                         mkdir "games/$pack"
99                         mv zipdownload/*/* "games/$pack/"
100                         rm -rf zipdownload
101                         ;;
102                 gitdir)
103                         rm -rf "games/$pack"
104                         git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
105                         ;;
106         esac
107 }
108
109 mkdir -p games
110 pack DarkPlacesPack  GPL         svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/DarkPlacesPack/branches/1.5/
111 pack NexuizPack      GPL         gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
112 pack OpenArenaPack   unknown     zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/OpenArenaPack.zip
113 pack Q3Pack          proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/Q3Pack/trunk/ -r29
114 pack Quake2Pack      proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/Quake2Pack.zip
115 pack Quake2WorldPack GPL         svn    svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
116 pack QuakePack       proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/QuakePack.zip
117 pack TremulousPack   proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/TremulousPack.zip
118 pack UFOAIPack       proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/UFOAIPack/branches/1.5/
119 pack WarsowPack      GPL         svn    http://opensvn.csie.org/warsowgamepack/netradiant/games/WarsowPack/