|
1 #!/bin/bash |
|
2 # This Source Code Form is subject to the terms of the Mozilla Public |
|
3 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 |
|
6 #set -x |
|
7 |
|
8 . ../common/unpack.sh |
|
9 . ../common/download_mars.sh |
|
10 . ../common/download_builds.sh |
|
11 . ../common/check_updates.sh |
|
12 |
|
13 ftp_server="http://stage.mozilla.org/pub/mozilla.org" |
|
14 aus_server="https://aus2.mozilla.org" |
|
15 |
|
16 runmode=0 |
|
17 config_file="updates.cfg" |
|
18 UPDATE_ONLY=1 |
|
19 TEST_ONLY=2 |
|
20 MARS_ONLY=3 |
|
21 COMPLETE=4 |
|
22 |
|
23 usage() |
|
24 { |
|
25 echo "Usage: verify.sh [OPTION] [CONFIG_FILE]" |
|
26 echo " -u, --update-only only download update.xml" |
|
27 echo " -t, --test-only only test that MARs exist" |
|
28 echo " -m, --mars-only only test MARs" |
|
29 echo " -c, --complete complete upgrade test" |
|
30 } |
|
31 |
|
32 if [ -z "$*" ] |
|
33 then |
|
34 usage |
|
35 exit 0 |
|
36 fi |
|
37 |
|
38 pass_arg_count=0 |
|
39 while [ "$#" -gt "$pass_arg_count" ] |
|
40 do |
|
41 case "$1" in |
|
42 -u | --update-only) |
|
43 runmode=$UPDATE_ONLY |
|
44 shift |
|
45 ;; |
|
46 -t | --test-only) |
|
47 runmode=$TEST_ONLY |
|
48 shift |
|
49 ;; |
|
50 -m | --mars-only) |
|
51 runmode=$MARS_ONLY |
|
52 shift |
|
53 ;; |
|
54 -c | --complete) |
|
55 runmode=$COMPLETE |
|
56 shift |
|
57 ;; |
|
58 *) |
|
59 # Move the unrecognized arg to the end of the list |
|
60 arg="$1" |
|
61 shift |
|
62 set -- "$@" "$arg" |
|
63 pass_arg_count=`expr $pass_arg_count + 1` |
|
64 esac |
|
65 done |
|
66 |
|
67 if [ -n "$arg" ] |
|
68 then |
|
69 config_file=$arg |
|
70 echo "Using config file $config_file" |
|
71 else |
|
72 echo "Using default config file $config_file" |
|
73 fi |
|
74 |
|
75 if [ "$runmode" == "0" ] |
|
76 then |
|
77 usage |
|
78 exit 0 |
|
79 fi |
|
80 |
|
81 while read entry |
|
82 do |
|
83 # initialize all config variables |
|
84 release="" |
|
85 product="" |
|
86 platform="" |
|
87 build_id="" |
|
88 locales="" |
|
89 channel="" |
|
90 from="" |
|
91 to="" |
|
92 eval $entry |
|
93 for locale in $locales |
|
94 do |
|
95 for patch_type in partial complete |
|
96 do |
|
97 if [ "$runmode" == "$MARS_ONLY" ] || [ "$runmode" == "$COMPLETE" ] || |
|
98 [ "$runmode" == "$TEST_ONLY" ] |
|
99 then |
|
100 if [ "$runmode" == "$TEST_ONLY" ] |
|
101 then |
|
102 download_mars "${aus_server}/update/1/$product/$release/$build_id/$platform/$locale/$channel/update.xml" $patch_type 1 |
|
103 err=$? |
|
104 else |
|
105 download_mars "${aus_server}/update/1/$product/$release/$build_id/$platform/$locale/$channel/update.xml" $patch_type |
|
106 err=$? |
|
107 fi |
|
108 if [ "$err" != "0" ]; then |
|
109 echo "FAIL: download_mars returned non-zero exit code: $err" |
|
110 continue |
|
111 fi |
|
112 else |
|
113 update_path="$product/$release/$build_id/$platform/$locale/$channel" |
|
114 mkdir -p updates/$update_path/complete |
|
115 mkdir -p updates/$update_path/partial |
|
116 wget --no-check-certificate -q -O $patch_type updates/$update_path/$patch_type/update.xml "${aus_server}/update/1/$update_path/update.xml" |
|
117 |
|
118 fi |
|
119 if [ "$runmode" == "$COMPLETE" ] |
|
120 then |
|
121 if [ -z "$from" ] || [ -z "$to" ] |
|
122 then |
|
123 continue |
|
124 fi |
|
125 from_path=`echo $from | sed "s/%locale%/${locale}/"` |
|
126 to_path=`echo $to | sed "s/%locale%/${locale}/"` |
|
127 download_builds "${ftp_server}/${from_path}" "${ftp_server}/${to_path}" |
|
128 err=$? |
|
129 if [ "$err" != "0" ]; then |
|
130 echo "FAIL: download_builds returned non-zero exit code: $err" |
|
131 continue |
|
132 fi |
|
133 source_file=`basename "$from_path"` |
|
134 target_file=`basename "$to_path"` |
|
135 check_updates "$platform" "downloads/$source_file" "downloads/$target_file" $locale |
|
136 err=$? |
|
137 if [ "$err" == "0" ]; then |
|
138 continue |
|
139 elif [ "$err" == "1" ]; then |
|
140 echo "FAIL: check_updates returned failure for $platform downloads/$source_file vs. downloads/$target_file: $err" |
|
141 elif [ "$err" == "2" ]; then |
|
142 echo "WARN: check_updates returned warning for $platform downloads/$source_file vs. downloads/$target_file: $err" |
|
143 else |
|
144 echo "FAIL: check_updates returned unknown error for $platform downloads/$source_file vs. downloads/$target_file: $err" |
|
145 fi |
|
146 fi |
|
147 done |
|
148 done |
|
149 done < $config_file |
|
150 |