2006-07-29 01:00:11 +04:00
|
|
|
download_mars () {
|
|
|
|
update_url="$1"
|
2006-07-29 02:52:34 +04:00
|
|
|
only="$2"
|
2006-09-26 04:13:53 +04:00
|
|
|
test_only="$3"
|
2006-07-29 01:00:11 +04:00
|
|
|
|
|
|
|
echo "Using $update_url"
|
2007-03-16 01:39:10 +03:00
|
|
|
wget --no-check-certificate -q -O update.xml $update_url
|
2006-07-29 01:00:11 +04:00
|
|
|
|
|
|
|
mkdir -p update/
|
2006-07-29 02:52:34 +04:00
|
|
|
if [ -z $only ]; then
|
|
|
|
only="partial complete"
|
|
|
|
fi
|
|
|
|
for patch_type in $only
|
2006-07-29 01:00:11 +04:00
|
|
|
do
|
|
|
|
line=`fgrep "patch type=\"$patch_type" update.xml`
|
|
|
|
grep_rv=$?
|
|
|
|
|
|
|
|
if [ 0 -ne $grep_rv ]; then
|
2007-03-03 02:53:55 +03:00
|
|
|
echo "FAIL: no $patch_type update found for $update_url"
|
2006-08-02 00:09:25 +04:00
|
|
|
return 1
|
2006-07-29 01:00:11 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
command=`echo $line | sed -e 's/^.*<patch //' -e 's:/>.*$::' -e 's:\&:\&:g'`
|
|
|
|
eval "export $command"
|
|
|
|
|
2006-09-26 04:13:53 +04:00
|
|
|
if [ "$test_only" == "1" ]
|
|
|
|
then
|
2006-11-01 02:56:57 +03:00
|
|
|
echo "Testing $URL"
|
2007-03-16 01:39:10 +03:00
|
|
|
curl -k -s -I -L $URL
|
2006-09-26 04:13:53 +04:00
|
|
|
return
|
|
|
|
else
|
2007-03-16 01:39:10 +03:00
|
|
|
wget --no-check-certificate -nv -O update/$patch_type.mar $URL 2>&1
|
2006-09-26 04:13:53 +04:00
|
|
|
fi
|
2006-07-29 01:00:11 +04:00
|
|
|
if [ "$?" != 0 ]; then
|
|
|
|
echo "Could not download $patch_type!"
|
|
|
|
echo "from: $URL"
|
|
|
|
fi
|
|
|
|
actual_size=`perl -e "printf \"%d\n\", (stat(\"update/$patch_type.mar\"))[7]"`
|
|
|
|
actual_hash=`openssl dgst -$hashFunction update/$patch_type.mar | sed -e 's/^.*= //'`
|
|
|
|
|
|
|
|
if [ $actual_size != $size ]; then
|
2007-03-03 02:53:55 +03:00
|
|
|
echo "FAIL: $patch_type from $update_url wrong size"
|
|
|
|
echo "FAIL: update.xml size: $size"
|
|
|
|
echo "FAIL: actual size: $actual_size"
|
2006-08-02 00:09:25 +04:00
|
|
|
return 1
|
2006-07-29 01:00:11 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $actual_hash != $hashValue ]; then
|
2007-03-03 02:53:55 +03:00
|
|
|
echo "FAIL: $patch_type from $update_url wrong hash"
|
|
|
|
echo "FAIL: update.xml hash: $hashValue"
|
|
|
|
echo "FAIL: actual hash: $actual_hash"
|
2006-08-02 00:09:25 +04:00
|
|
|
return 1
|
2006-07-29 01:00:11 +04:00
|
|
|
fi
|
|
|
|
|
2006-09-26 03:11:42 +04:00
|
|
|
cp update/$patch_type.mar update/update.mar
|
|
|
|
|
2006-07-29 01:00:11 +04:00
|
|
|
done
|
|
|
|
}
|