Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | download_mars () { |
michael@0 | 6 | update_url="$1" |
michael@0 | 7 | only="$2" |
michael@0 | 8 | test_only="$3" |
michael@0 | 9 | |
michael@0 | 10 | echo "Using $update_url" |
michael@0 | 11 | wget --no-check-certificate -q -O update.xml $update_url |
michael@0 | 12 | |
michael@0 | 13 | mkdir -p update/ |
michael@0 | 14 | if [ -z $only ]; then |
michael@0 | 15 | only="partial complete" |
michael@0 | 16 | fi |
michael@0 | 17 | for patch_type in $only |
michael@0 | 18 | do |
michael@0 | 19 | line=`fgrep "patch type=\"$patch_type" update.xml` |
michael@0 | 20 | grep_rv=$? |
michael@0 | 21 | |
michael@0 | 22 | if [ 0 -ne $grep_rv ]; then |
michael@0 | 23 | echo "FAIL: no $patch_type update found for $update_url" |
michael@0 | 24 | return 1 |
michael@0 | 25 | fi |
michael@0 | 26 | |
michael@0 | 27 | command=`echo $line | sed -e 's/^.*<patch //' -e 's:/>.*$::' -e 's:\&:\&:g'` |
michael@0 | 28 | eval "export $command" |
michael@0 | 29 | |
michael@0 | 30 | if [ "$test_only" == "1" ] |
michael@0 | 31 | then |
michael@0 | 32 | echo "Testing $URL" |
michael@0 | 33 | curl -k -s -I -L $URL |
michael@0 | 34 | return |
michael@0 | 35 | else |
michael@0 | 36 | wget --no-check-certificate -nv -O update/$patch_type.mar $URL 2>&1 |
michael@0 | 37 | fi |
michael@0 | 38 | if [ "$?" != 0 ]; then |
michael@0 | 39 | echo "Could not download $patch_type!" |
michael@0 | 40 | echo "from: $URL" |
michael@0 | 41 | fi |
michael@0 | 42 | actual_size=`perl -e "printf \"%d\n\", (stat(\"update/$patch_type.mar\"))[7]"` |
michael@0 | 43 | actual_hash=`openssl dgst -$hashFunction update/$patch_type.mar | sed -e 's/^.*= //'` |
michael@0 | 44 | |
michael@0 | 45 | if [ $actual_size != $size ]; then |
michael@0 | 46 | echo "FAIL: $patch_type from $update_url wrong size" |
michael@0 | 47 | echo "FAIL: update.xml size: $size" |
michael@0 | 48 | echo "FAIL: actual size: $actual_size" |
michael@0 | 49 | return 1 |
michael@0 | 50 | fi |
michael@0 | 51 | |
michael@0 | 52 | if [ $actual_hash != $hashValue ]; then |
michael@0 | 53 | echo "FAIL: $patch_type from $update_url wrong hash" |
michael@0 | 54 | echo "FAIL: update.xml hash: $hashValue" |
michael@0 | 55 | echo "FAIL: actual hash: $actual_hash" |
michael@0 | 56 | return 1 |
michael@0 | 57 | fi |
michael@0 | 58 | |
michael@0 | 59 | cp update/$patch_type.mar update/update.mar |
michael@0 | 60 | |
michael@0 | 61 | done |
michael@0 | 62 | } |