michael@0: #!/bin/bash michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: #set -x michael@0: michael@0: . ../common/unpack.sh michael@0: . ../common/download_mars.sh michael@0: . ../common/download_builds.sh michael@0: . ../common/check_updates.sh michael@0: michael@0: ftp_server="http://stage.mozilla.org/pub/mozilla.org" michael@0: aus_server="https://aus2.mozilla.org" michael@0: michael@0: runmode=0 michael@0: config_file="updates.cfg" michael@0: UPDATE_ONLY=1 michael@0: TEST_ONLY=2 michael@0: MARS_ONLY=3 michael@0: COMPLETE=4 michael@0: michael@0: usage() michael@0: { michael@0: echo "Usage: verify.sh [OPTION] [CONFIG_FILE]" michael@0: echo " -u, --update-only only download update.xml" michael@0: echo " -t, --test-only only test that MARs exist" michael@0: echo " -m, --mars-only only test MARs" michael@0: echo " -c, --complete complete upgrade test" michael@0: } michael@0: michael@0: if [ -z "$*" ] michael@0: then michael@0: usage michael@0: exit 0 michael@0: fi michael@0: michael@0: pass_arg_count=0 michael@0: while [ "$#" -gt "$pass_arg_count" ] michael@0: do michael@0: case "$1" in michael@0: -u | --update-only) michael@0: runmode=$UPDATE_ONLY michael@0: shift michael@0: ;; michael@0: -t | --test-only) michael@0: runmode=$TEST_ONLY michael@0: shift michael@0: ;; michael@0: -m | --mars-only) michael@0: runmode=$MARS_ONLY michael@0: shift michael@0: ;; michael@0: -c | --complete) michael@0: runmode=$COMPLETE michael@0: shift michael@0: ;; michael@0: *) michael@0: # Move the unrecognized arg to the end of the list michael@0: arg="$1" michael@0: shift michael@0: set -- "$@" "$arg" michael@0: pass_arg_count=`expr $pass_arg_count + 1` michael@0: esac michael@0: done michael@0: michael@0: if [ -n "$arg" ] michael@0: then michael@0: config_file=$arg michael@0: echo "Using config file $config_file" michael@0: else michael@0: echo "Using default config file $config_file" michael@0: fi michael@0: michael@0: if [ "$runmode" == "0" ] michael@0: then michael@0: usage michael@0: exit 0 michael@0: fi michael@0: michael@0: while read entry michael@0: do michael@0: # initialize all config variables michael@0: release="" michael@0: product="" michael@0: platform="" michael@0: build_id="" michael@0: locales="" michael@0: channel="" michael@0: from="" michael@0: to="" michael@0: eval $entry michael@0: for locale in $locales michael@0: do michael@0: for patch_type in partial complete michael@0: do michael@0: if [ "$runmode" == "$MARS_ONLY" ] || [ "$runmode" == "$COMPLETE" ] || michael@0: [ "$runmode" == "$TEST_ONLY" ] michael@0: then michael@0: if [ "$runmode" == "$TEST_ONLY" ] michael@0: then michael@0: download_mars "${aus_server}/update/1/$product/$release/$build_id/$platform/$locale/$channel/update.xml" $patch_type 1 michael@0: err=$? michael@0: else michael@0: download_mars "${aus_server}/update/1/$product/$release/$build_id/$platform/$locale/$channel/update.xml" $patch_type michael@0: err=$? michael@0: fi michael@0: if [ "$err" != "0" ]; then michael@0: echo "FAIL: download_mars returned non-zero exit code: $err" michael@0: continue michael@0: fi michael@0: else michael@0: update_path="$product/$release/$build_id/$platform/$locale/$channel" michael@0: mkdir -p updates/$update_path/complete michael@0: mkdir -p updates/$update_path/partial michael@0: 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: michael@0: fi michael@0: if [ "$runmode" == "$COMPLETE" ] michael@0: then michael@0: if [ -z "$from" ] || [ -z "$to" ] michael@0: then michael@0: continue michael@0: fi michael@0: from_path=`echo $from | sed "s/%locale%/${locale}/"` michael@0: to_path=`echo $to | sed "s/%locale%/${locale}/"` michael@0: download_builds "${ftp_server}/${from_path}" "${ftp_server}/${to_path}" michael@0: err=$? michael@0: if [ "$err" != "0" ]; then michael@0: echo "FAIL: download_builds returned non-zero exit code: $err" michael@0: continue michael@0: fi michael@0: source_file=`basename "$from_path"` michael@0: target_file=`basename "$to_path"` michael@0: check_updates "$platform" "downloads/$source_file" "downloads/$target_file" $locale michael@0: err=$? michael@0: if [ "$err" == "0" ]; then michael@0: continue michael@0: elif [ "$err" == "1" ]; then michael@0: echo "FAIL: check_updates returned failure for $platform downloads/$source_file vs. downloads/$target_file: $err" michael@0: elif [ "$err" == "2" ]; then michael@0: echo "WARN: check_updates returned warning for $platform downloads/$source_file vs. downloads/$target_file: $err" michael@0: else michael@0: echo "FAIL: check_updates returned unknown error for $platform downloads/$source_file vs. downloads/$target_file: $err" michael@0: fi michael@0: fi michael@0: done michael@0: done michael@0: done < $config_file michael@0: