testing/release/common/download_mars.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/release/common/download_mars.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +download_mars () {
     1.9 +    update_url="$1"
    1.10 +    only="$2"
    1.11 +    test_only="$3"
    1.12 +
    1.13 +    echo "Using  $update_url"
    1.14 +    wget --no-check-certificate -q -O update.xml $update_url
    1.15 +
    1.16 +    mkdir -p update/
    1.17 +    if [ -z $only ]; then
    1.18 +      only="partial complete"
    1.19 +    fi
    1.20 +    for patch_type in $only
    1.21 +      do
    1.22 +      line=`fgrep "patch type=\"$patch_type" update.xml`
    1.23 +      grep_rv=$?
    1.24 +
    1.25 +      if [ 0 -ne $grep_rv ]; then
    1.26 +	      echo "FAIL: no $patch_type update found for $update_url" 
    1.27 +	      return 1
    1.28 +      fi
    1.29 +
    1.30 +      command=`echo $line | sed -e 's/^.*<patch //' -e 's:/>.*$::' -e 's:\&amp;:\&:g'`
    1.31 +      eval "export $command"
    1.32 +
    1.33 +      if [ "$test_only" == "1" ]
    1.34 +      then
    1.35 +        echo "Testing $URL"
    1.36 +        curl -k -s -I -L $URL
    1.37 +        return
    1.38 +      else
    1.39 +        wget --no-check-certificate -nv -O update/$patch_type.mar $URL 2>&1 
    1.40 +      fi
    1.41 +      if [ "$?" != 0 ]; then
    1.42 +        echo "Could not download $patch_type!"
    1.43 +        echo "from: $URL"
    1.44 +      fi
    1.45 +      actual_size=`perl -e "printf \"%d\n\", (stat(\"update/$patch_type.mar\"))[7]"`
    1.46 +      actual_hash=`openssl dgst -$hashFunction update/$patch_type.mar | sed -e 's/^.*= //'`
    1.47 +      
    1.48 +      if [ $actual_size != $size ]; then
    1.49 +	      echo "FAIL: $patch_type from $update_url wrong size"
    1.50 +	      echo "FAIL: update.xml size: $size"
    1.51 +	      echo "FAIL: actual size: $actual_size"
    1.52 +	      return 1
    1.53 +      fi
    1.54 +      
    1.55 +      if [ $actual_hash != $hashValue ]; then
    1.56 +	      echo "FAIL: $patch_type from $update_url wrong hash"
    1.57 +	      echo "FAIL: update.xml hash: $hashValue"
    1.58 +	      echo "FAIL: actual hash: $actual_hash"
    1.59 +	      return 1
    1.60 +      fi
    1.61 +
    1.62 +      cp update/$patch_type.mar update/update.mar
    1.63 +
    1.64 +    done
    1.65 +}

mercurial