Backed out 2 changesets (bug 1943998) for causing wd failures @ phases.py CLOSED...
[gecko.git] / tools / update-verify / release / common / download_mars.sh
blob84cbfe2ccc9277a85dd6aba39b5fa90c917b6444
1 #!/bin/bash
3 download_mars () {
4 update_url="$1"
5 only="$2"
6 test_only="$3"
7 to_build_id="$4"
8 to_app_version="$5"
9 to_display_version="$6"
11 max_tries=5
12 try=1
13 # retrying until we get offered an update
14 while [ "$try" -le "$max_tries" ]; do
15 echo "Using $update_url"
16 # retrying until AUS gives us any response at all
17 cached_download update.xml "${update_url}"
19 echo "Got this response:"
20 cat update.xml
21 # If the first line after <updates> is </updates> then we have an
22 # empty snippet. Otherwise we're done
23 if [ "$(grep -A1 '<updates>' update.xml | tail -1)" != "</updates>" ]; then
24 break;
26 echo "Empty response, sleeping"
27 sleep 5
28 try=$((try+1))
29 done
31 echo; echo; # padding
33 update_line=$(grep -F "<update " update.xml)
34 grep_rv=$?
35 if [ 0 -ne $grep_rv ]; then
36 echo "TEST-UNEXPECTED-FAIL: no <update/> found for $update_url"
37 return 1
39 command=$(echo "$update_line" | sed -e 's/^.*<update //' -e 's:>.*$::' -e 's:\&amp;:\&:g')
40 eval "export $command"
42 # buildID and some other variables further down are gathered by eval'ing
43 # the massaged `update.xml` file a bit further up. Because of this, shellcheck
44 # cannot verify their existence, and gets grumpy. Ideally we would do this
45 # differently, but it's not worth the trouble at the time of writing.
46 # shellcheck disable=SC2154
47 if [ -n "$to_build_id" ] && [ "$buildID" != "$to_build_id" ]; then
48 echo "TEST-UNEXPECTED-FAIL: expected buildID $to_build_id does not match actual $buildID"
49 return 1
52 # shellcheck disable=SC2154
53 if [ -n "$to_display_version" ] && [ "$displayVersion" != "$to_display_version" ]; then
54 echo "TEST-UNEXPECTED-FAIL: expected displayVersion $to_display_version does not match actual $displayVersion"
55 return 1
58 # shellcheck disable=SC2154
59 if [ -n "$to_app_version" ] && [ "$appVersion" != "$to_app_version" ]; then
60 echo "TEST-UNEXPECTED-FAIL: expected appVersion $to_app_version does not match actual $appVersion"
61 return 1
64 mkdir -p update/
65 if [ -z "$only" ]; then
66 only="partial complete"
68 for patch_type in $only
70 line=$(grep -F "patch type=\"$patch_type" update.xml)
71 grep_rv=$?
73 if [ 0 -ne $grep_rv ]; then
74 echo "TEST-UNEXPECTED-FAIL: no $patch_type update found for $update_url"
75 return 1
78 command=$(echo "$line" | sed -e 's/^.*<patch //' -e 's:/>.*$::' -e 's:\&amp;:\&:g')
79 eval "export $command"
81 if [ "$test_only" == "1" ]
82 then
83 echo "Testing $URL"
84 curl -s -I -L "$URL"
85 return
86 else
87 if ! cached_download "update/${patch_type}.mar" "${URL}"; then
88 echo "Could not download $patch_type!"
89 echo "from: $URL"
92 actual_size=$(perl -e "printf \"%d\n\", (stat(\"update/$patch_type.mar\"))[7]")
93 # shellcheck disable=SC2154
94 actual_hash=$(openssl dgst -"$hashFunction" update/"$patch_type".mar | sed -e 's/^.*= //')
96 # shellcheck disable=SC2154
97 if [ "$actual_size" != "$size" ]; then
98 echo "TEST-UNEXPECTED-FAIL: $patch_type from $update_url wrong size"
99 # shellcheck disable=SC2154
100 echo "TEST-UNEXPECTED-FAIL: update.xml size: $size"
101 echo "TEST-UNEXPECTED-FAIL: actual size: $actual_size"
102 return 1
105 # shellcheck disable=SC2154
106 if [ "$actual_hash" != "$hashValue" ]; then
107 echo "TEST-UNEXPECTED-FAIL: $patch_type from $update_url wrong hash"
108 # shellcheck disable=SC2154
109 echo "TEST-UNEXPECTED-FAIL: update.xml hash: $hashValue"
110 echo "TEST-UNEXPECTED-FAIL: actual hash: $actual_hash"
111 return 1
114 cp update/"$patch_type".mar update/update.mar
115 echo "$actual_size" > update/"$patch_type".size
117 done