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 34APR_VERSION=${APR_VERSION:-"1.5.0"} 35APU_VERSION=${APU_VERSION:-"1.5.1"} 36PY3C_VERSION=${PY3C_VERSION:='1.1'} 37SERF_VERSION=${SERF_VERSION:-"1.3.8"} 38ZLIB_VERSION=${ZLIB_VERSION:-"1.2.8"} 39SQLITE_VERSION=${SQLITE_VERSION:-"3.8.11.1"} 40# Used to construct the SQLite download URL. 41SQLITE_VERSION_REL_YEAR=2015 42HTTPD_VERSION=${HTTPD_VERSION:-"2.4.10"} 43APR_ICONV_VERSION=${APR_ICONV_VERSION:-"1.2.1"} 44 45APR=apr-${APR_VERSION} 46APR_UTIL=apr-util-${APU_VERSION} 47PY3C=py3c-${PY3C_VERSION} 48SERF=serf-${SERF_VERSION} 49ZLIB=zlib-${ZLIB_VERSION} 50SQLITE_VERSION_LIST=`echo $SQLITE_VERSION | sed -e 's/\./ /g'` 51SQLITE=sqlite-amalgamation-`printf %d%02d%02d%02d $SQLITE_VERSION_LIST` 52 53HTTPD=httpd-${HTTPD_VERSION} 54APR_ICONV=apr-iconv-${APR_ICONV_VERSION} 55 56BASEDIR=`pwd` 57TEMPDIR=$BASEDIR/temp 58 59HTTP_FETCH= 60[ -z "$HTTP_FETCH" ] && type wget >/dev/null 2>&1 && HTTP_FETCH="wget -q -nc" 61[ -z "$HTTP_FETCH" ] && type curl >/dev/null 2>&1 && HTTP_FETCH="curl -sOL" 62[ -z "$HTTP_FETCH" ] && type fetch >/dev/null 2>&1 && HTTP_FETCH="fetch -q" 63 64# Need this uncommented if any of the specific versions of the ASF tarballs to 65# be downloaded are no longer available on the general mirrors. 66APACHE_MIRROR=https://archive.apache.org/dist 67 68# helpers 69usage() { 70 echo "Usage: $0" 71 echo "Usage: $0 [ apr | py3c | serf | zlib | sqlite ] ..." 72 exit $1 73} 74 75# getters 76get_apr() { 77 cd $TEMPDIR 78 test -d $BASEDIR/apr || $HTTP_FETCH $APACHE_MIRROR/apr/$APR.tar.bz2 79 test -d $BASEDIR/apr-util || $HTTP_FETCH $APACHE_MIRROR/apr/$APR_UTIL.tar.bz2 80 cd $BASEDIR 81 82 test -d $BASEDIR/apr || bzip2 -dc $TEMPDIR/$APR.tar.bz2 | tar -xf - 83 test -d $BASEDIR/apr-util || bzip2 -dc $TEMPDIR/$APR_UTIL.tar.bz2 | tar -xf - 84 85 test -d $BASEDIR/apr || mv $APR apr 86 test -d $BASEDIR/apr-util || mv $APR_UTIL apr-util 87} 88 89get_py3c() { 90 test -d $BASEDIR/py3c && return 91 py3cdist=v${PY3C_VERSION}.tar.gz 92 93 cd $TEMPDIR 94 $HTTP_FETCH https://github.com/encukou/py3c/archive/${py3cdist} 95 cd $BASEDIR 96 97 gzip -dc $TEMPDIR/${py3cdist} | tar -xf - 98 99 mv $PY3C py3c 100} 101 102get_serf() { 103 test -d $BASEDIR/serf && return 104 105 cd $TEMPDIR 106 $HTTP_FETCH https://archive.apache.org/dist/serf/$SERF.tar.bz2 107 cd $BASEDIR 108 109 bzip2 -dc $TEMPDIR/$SERF.tar.bz2 | tar -xf - 110 111 mv $SERF serf 112} 113 114get_zlib() { 115 test -d $BASEDIR/zlib && return 116 117 cd $TEMPDIR 118 $HTTP_FETCH https://sourceforge.net/projects/libpng/files/zlib/$ZLIB_VERSION/$ZLIB.tar.gz 119 cd $BASEDIR 120 121 gzip -dc $TEMPDIR/$ZLIB.tar.gz | tar -xf - 122 123 mv $ZLIB zlib 124} 125 126get_sqlite() { 127 test -d $BASEDIR/sqlite-amalgamation && return 128 129 cd $TEMPDIR 130 $HTTP_FETCH https://www.sqlite.org/$SQLITE_VERSION_REL_YEAR/$SQLITE.zip 131 cd $BASEDIR 132 133 unzip -q $TEMPDIR/$SQLITE.zip 134 135 mv $SQLITE sqlite-amalgamation 136 137} 138 139# main() 140get_deps() { 141 mkdir -p $TEMPDIR 142 143 for i in zlib serf sqlite-amalgamation py3c apr apr-util; do 144 if [ -d $i ]; then 145 echo "Local directory '$i' already exists; the downloaded copy won't be used" >&2 146 fi 147 done 148 149 if [ $# -gt 0 ]; then 150 for target in "$@"; do 151 if [ "$target" != "deps" ]; then 152 get_$target || usage 153 else 154 usage 155 fi 156 done 157 else 158 get_apr 159 get_py3c 160 get_serf 161 get_zlib 162 get_sqlite 163 164 echo 165 echo "If you require mod_dav_svn, the recommended version of httpd is:" 166 echo " $APACHE_MIRROR/httpd/$HTTPD.tar.bz2" 167 168 echo 169 echo "If you require apr-iconv, its recommended version is:" 170 echo " $APACHE_MIRROR/apr/$APR_ICONV.tar.bz2" 171 fi 172 173 rm -rf $TEMPDIR 174} 175 176get_deps "$@" 177