merged tag ooo/DEV300_m102
[LibreOffice.git] / fetch_tarballs.sh
blobe08b553f81710728dab5a664f62477eaf4e53ea3
1 #!/bin/sh
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 # Copyright 2000, 2010 Oracle and/or its affiliates.
8 # OpenOffice.org - a multi-platform office productivity suite
10 # This file is part of OpenOffice.org.
12 # OpenOffice.org is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License version 3
14 # only, as published by the Free Software Foundation.
16 # OpenOffice.org is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU Lesser General Public License version 3 for more details
20 # (a copy is included in the LICENSE file that accompanied this code).
22 # You should have received a copy of the GNU Lesser General Public License
23 # version 3 along with OpenOffice.org. If not, see
24 # <http://www.openoffice.org/license.html>
25 # for a copy of the LGPLv3 License.
27 #*************************************************************************
29 if [ -z "$TARFILE_LOCATION" ]; then
30 echo "ERROR: no destination defined! please set TARFILE_LOCATION!"
31 exit
34 if [ ! -d "$TARFILE_LOCATION" ]; then
35 mkdir $TARFILE_LOCATION
37 if [ ! -d "$TARFILE_LOCATION" ]; then
38 echo "ERROR: can't create"
39 exit
42 if [ -z "$1" ]; then
43 echo "ERROR: parameter missing!"
44 echo "usage: $0 <fetch list>"
45 echo "first line must define the base url."
46 exit
49 # check for wget and md5sum
50 wget=
51 md5sum=
52 curl=
54 for i in wget /usr/bin/wget /usr/local/bin/wget /usr/sfw/bin/wget /opt/sfw/bin/wget /opt/local/bin/wget; do
55 eval "$i --version" > /dev/null 2>&1
56 ret=$?
57 if [ $ret -eq 0 ]; then
58 wget=$i
59 echo found wget: $wget
60 break 2
62 done
64 if [ -z "$wget" ]; then
65 for i in curl /usr/bin/curl /usr/local/bin/curl /usr/sfw/bin/curl /opt/sfw/bin/curl /opt/local/bin/curl; do
66 # mac curl returns "2" on --version
67 # eval "$i --version" > /dev/null 2>&1
68 # ret=$?
69 # if [ $ret -eq 0 ]; then
70 if [ -x $i ]; then
71 curl=$i
72 echo found curl: $curl
73 break 2
75 done
78 if [ -z "$wget" -a -z "$curl" ]; then
79 echo "ERROR: neither wget nor curl found!"
80 exit
83 for i in md5 md5sum /usr/local/bin/md5sum gmd5sum /usr/sfw/bin/md5sum /opt/sfw/bin/gmd5sum /opt/local/bin/md5sum; do
84 if [ "$i" = "md5" ]; then
85 eval "$i -x" > /dev/null 2>&1
86 else
87 eval "$i --version" > /dev/null 2>&1
89 ret=$?
90 if [ $ret -eq 0 ]; then
91 md5sum=$i
92 echo found md5sum: $md5sum
93 break 2
95 done
97 if [ "$md5sum" = "md5" ]; then
98 md5special=-r
101 if [ -z "$md5sum" ]; then
102 echo "Warning: no md5sum: found!"
105 start_dir=`pwd`
106 logfile=$TARFILE_LOCATION/fetch.log
107 date >> $logfile
109 filelist=`cat $1`
110 mkdir -p $TARFILE_LOCATION/tmp
111 cd $TARFILE_LOCATION/tmp
112 echo $$ > fetch-running
113 for i in $filelist ; do
114 # echo $i
115 if [ "$i" != `echo $i | sed "s/^http:\///"` ]; then
116 tarurl=$i
117 # TODO: check for comment
118 else
119 if [ "$tarurl" != "" ]; then
120 if [ ! -f "../$i" ]; then
121 echo $i
122 if [ ! -z "$wget" ]; then
123 $wget -nv -N $tarurl/$i 2>&1 | tee -a $logfile
124 else
125 echo fetching $i
126 $curl $file_date_check -O $tarurl/$i 2>&1 | tee -a $logfile
128 wret=$?
129 if [ $wret -ne 0 ]; then
130 mv $i ${i}_broken
131 failed="$failed $i"
132 wret=0
134 if [ -f $i -a -n "$md5sum" ]; then
135 sum=`$md5sum $md5special $i | sed "s/ .*//"`
136 sum2=`echo $i | sed "s/-.*//"`
137 if [ "$sum" != "$sum2" ]; then
138 echo checksum failure for $i 2>&1 | tee -a $logfile
139 failed="$failed $i"
140 mv $i ${i}_broken
141 else
142 mv $i ..
144 else
145 mv $i ..
150 done
151 rm $TARFILE_LOCATION/tmp/*-*
152 cd $start_dir
154 if [ ! -z "$failed" ]; then
155 echo
156 echo ERROR: failed on:
157 for i in $failed ; do
158 echo $i
159 done
160 exit 1