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