X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=merge_old_version;h=c5975ecc75e5f150b4d86408fdd644021ec199e7;hb=HEAD;hp=c273d03d01132ac6da87ee5653cdf06f8ff1ea93;hpb=35400d29e3434d1e738836f75c14b27648f5647c;p=next-scripts diff --git a/merge_old_version b/merge_old_version index c273d03..c5975ec 100755 --- a/merge_old_version +++ b/merge_old_version @@ -1,34 +1,25 @@ #!/bin/bash -LOG_FILE="../merge.log" -SHA1_FILE="../SHA1s" -build_host="ka2" -build_dir="/scratch/sfr/next" -build_cmd="bin/build_next" - no_build=false [ "$1" = "-n" ] && { shift no_build=true } -tree=$1 -ver=$2 - -rev=$(git show next-${ver}:Next/SHA1s | sed -n "s/^$tree\t\t*//p") -[ "$rev" ] || { - echo "No such tree/date" 1>&2 - exit 1 -} - -[ -n "$3" ] && { - build_host="$3" +if [ "$1" ]; then + tree=$1 shift -} -[ -n "$3" ] && { - build_dir="$3" +else + tree= +fi +if [ "$1" ]; then + ver="next-${1#next-}" shift -} +else + ver=$(git tag -l next-\* | sort | tail -n 1) +fi + +. "$(dirname $0)/common.sh" log() { @@ -42,13 +33,33 @@ execute() return ${PIPESTATUS[0]} } +line="$(tail -n 1 $SHA1_FILE)" + +# strip everything after the first tab character +stree=${line%% *} +if [ "$tree" ]; then + [ "$tree" = "$stree" ] || { + echo "That is not the last tree merged ($tree v $stree)" 1>&2 + exit 1 + } +else + tree="$stree" +fi + +rev=$(git show ${ver}:Next/SHA1s | sed -n "s/^$tree\t\t*//p") +[ "$rev" ] || { + echo "No previous tree/date ($tree/$ver)" 1>&2 + exit 1 +} + bad_rev=$(git rev-parse --verify 'HEAD^2') -line="$(tail -n 1 $SHA1_FILE)" tab="\t" [ $(echo "$tree" | wc -c) -le 8 ] && tab="\t\t" -expected=$(printf "%s$tab%s" $tree $bad_rev) -[ "$line" = "$expected" ] || { + +# strip evrything up to the last tab character +srev=${line##* } +[ "$bad_rev" = "$srev" ] || { echo "bad last line in $SHA1_FILE" 1>&2 exit 1 } @@ -82,15 +93,14 @@ d=$(date --date "5 hours ago" '+%Y%m%d') sed -i '$d' $SHA1_FILE printf "%s$tab%s\n" $tree $rev >>$SHA1_FILE -$no_build && exit 0 - -git push -f "$build_host":"$build_dir" master:refs/heads/next || { +git push -f "${build_host}${build_host:+:}${build_dir}" master:refs/heads/next || { echo git push failed 1>&2 bash -i || exit } -echo "Building using $build_cmd on $build_host" -ssh "$build_host" "$build_cmd" || { +$no_build && exit 0 + +"$bin_dir/do_build" "$tree" || { echo Build failed 1>&2 bash -i || exit }