]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/get-deps.sh
MFC r368207,368607:
[FreeBSD/stable/10.git] / contrib / subversion / get-deps.sh
1 #!/bin/sh
2 #
3 #
4 # Licensed to the Apache Software Foundation (ASF) under one
5 # or more contributor license agreements.  See the NOTICE file
6 # distributed with this work for additional information
7 # regarding copyright ownership.  The ASF licenses this file
8 # to you under the Apache License, Version 2.0 (the
9 # "License"); you may not use this file except in compliance
10 # with the License.  You may obtain a copy of the License at
11 #
12 #   http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing,
15 # software distributed under the License is distributed on an
16 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 # KIND, either express or implied.  See the License for the
18 # specific language governing permissions and limitations
19 # under the License.
20 #
21 #
22 #
23 # get-deps.sh -- download the dependencies useful for building Subversion
24 #
25
26 # If changing this file please take care to try to make your changes as
27 # portable as possible.  That means at a minimum only use POSIX supported
28 # features and functions.  However, it may be desirable to use an even
29 # more narrow set of features than POSIX, e.g. Solaris /bin/sh only has
30 # a subset of the POSIX shell features.  If in doubt, limit yourself to
31 # features already used in the file.  Reviewing the history of changes
32 # may be useful as well.
33
34 APR_VERSION=${APR_VERSION:-"1.4.6"}
35 APU_VERSION=${APU_VERSION:-"1.5.1"}
36 SERF_VERSION=${SERF_VERSION:-"1.3.8"}
37 ZLIB_VERSION=${ZLIB_VERSION:-"1.2.8"}
38 SQLITE_VERSION=${SQLITE_VERSION:-"3.7.15.1"}
39 GMOCK_VERSION=${GMOCK_VERSION:-"1.6.0"}
40 HTTPD_VERSION=${HTTPD_VERSION:-"2.4.10"}
41 APR_ICONV_VERSION=${APR_ICONV_VERSION:-"1.2.1"}
42
43 APR=apr-${APR_VERSION}
44 APR_UTIL=apr-util-${APU_VERSION}
45 SERF=serf-${SERF_VERSION}
46 ZLIB=zlib-${ZLIB_VERSION}
47 SQLITE_VERSION_LIST=`echo $SQLITE_VERSION | sed -e 's/\./ /g'`
48 SQLITE=sqlite-amalgamation-`printf %d%02d%02d%02d $SQLITE_VERSION_LIST`
49 GMOCK=gmock-${GMOCK_VERSION}
50 GMOCK_URL=https://googlemock.googlecode.com/files/
51
52 HTTPD=httpd-${HTTPD_VERSION}
53 APR_ICONV=apr-iconv-${APR_ICONV_VERSION}
54
55 BASEDIR=`pwd`
56 TEMPDIR=$BASEDIR/temp
57
58 HTTP_FETCH=
59 [ -z "$HTTP_FETCH" ] && type wget  >/dev/null 2>&1 && HTTP_FETCH="wget -q -nc"
60 [ -z "$HTTP_FETCH" ] && type curl  >/dev/null 2>&1 && HTTP_FETCH="curl -sOL"
61 [ -z "$HTTP_FETCH" ] && type fetch >/dev/null 2>&1 && HTTP_FETCH="fetch -q"
62
63 # Need this uncommented if any of the specific versions of the ASF tarballs to
64 # be downloaded are no longer available on the general mirrors.
65 APACHE_MIRROR=http://archive.apache.org/dist
66
67 # helpers
68 usage() {
69     echo "Usage: $0"
70     echo "Usage: $0 [ apr | serf | zlib | sqlite | gmock ] ..."
71     exit $1
72 }
73
74 # getters
75 get_apr() {
76     cd $TEMPDIR
77     test -d $BASEDIR/apr      || $HTTP_FETCH $APACHE_MIRROR/apr/$APR.tar.bz2
78     test -d $BASEDIR/apr-util || $HTTP_FETCH $APACHE_MIRROR/apr/$APR_UTIL.tar.bz2
79     cd $BASEDIR
80
81     test -d $BASEDIR/apr      || bzip2 -dc $TEMPDIR/$APR.tar.bz2 | tar -xf -
82     test -d $BASEDIR/apr-util || bzip2 -dc $TEMPDIR/$APR_UTIL.tar.bz2 | tar -xf -
83
84     test -d $BASEDIR/apr      || mv $APR apr
85     test -d $BASEDIR/apr-util || mv $APR_UTIL apr-util
86 }
87
88 get_serf() {
89     test -d $BASEDIR/serf && return
90
91     cd $TEMPDIR
92     $HTTP_FETCH https://archive.apache.org/dist/serf/$SERF.tar.bz2
93     cd $BASEDIR
94
95     bzip2 -dc $TEMPDIR/$SERF.tar.bz2 | tar -xf -
96
97     mv $SERF serf
98 }
99
100 get_zlib() {
101     test -d $BASEDIR/zlib && return
102
103     cd $TEMPDIR
104     $HTTP_FETCH http://sourceforge.net/projects/libpng/files/zlib/$ZLIB_VERSION/$ZLIB.tar.gz
105     cd $BASEDIR
106
107     gzip -dc $TEMPDIR/$ZLIB.tar.gz | tar -xf -
108
109     mv $ZLIB zlib
110 }
111
112 get_sqlite() {
113     test -d $BASEDIR/sqlite-amalgamation && return
114
115     cd $TEMPDIR
116     $HTTP_FETCH http://www.sqlite.org/$SQLITE.zip
117     cd $BASEDIR
118
119     unzip -q $TEMPDIR/$SQLITE.zip
120
121     mv $SQLITE sqlite-amalgamation
122
123 }
124
125 get_gmock() {
126     test -d $BASEDIR/gmock-fused && return
127
128     cd $TEMPDIR
129     $HTTP_FETCH ${GMOCK_URL}/${GMOCK}.zip
130     cd $BASEDIR
131
132     unzip -q $TEMPDIR/$GMOCK.zip
133
134     mv $GMOCK/fused-src gmock-fused
135     rm -fr $GMOCK
136 }
137
138 # main()
139 get_deps() {
140     mkdir -p $TEMPDIR
141
142     for i in zlib serf sqlite-amalgamation apr apr-util gmock-fused; do
143       if [ -d $i ]; then
144         echo "Local directory '$i' already exists; the downloaded copy won't be used" >&2
145       fi
146     done
147
148     if [ $# -gt 0 ]; then
149       for target in "$@"; do
150         if [ "$target" != "deps" ]; then
151           get_$target || usage
152         else
153           usage
154         fi
155       done
156     else
157       get_apr
158       get_serf
159       get_zlib
160       get_sqlite
161
162       echo
163       echo "If you require mod_dav_svn, the recommended version of httpd is:"
164       echo "   $APACHE_MIRROR/httpd/$HTTPD.tar.bz2"
165
166       echo
167       echo "If you require apr-iconv, its recommended version is:"
168       echo "   $APACHE_MIRROR/apr/$APR_ICONV.tar.bz2"
169     fi
170
171     rm -rf $TEMPDIR
172 }
173
174 get_deps "$@"