testing/release/updates/verify.sh

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial