#!/bin/bash LOG_FILE="../merge.log" build_host="sprygo" build_dir="/scratch/sfr/next" build_cmd="bin/build_next" no_build=false start_from="" [ "$1" = "-n" ] && { shift no_build=true } [ "$1" = "-s" ] && { shift start_from="$1" [ -z "$start_from" ] && { echo "-s requires a start tree" 1>&2 exit 1 } shift } [ -n "$1" ] && build_host="$1" log() { echo "$@" | tee -a $LOG_FILE } execute() { log "$" $@ $@ 2>&1 | tee -a $LOG_FILE return ${PIPESTATUS[0]} } [ -n "$start_from" ] || { cp /dev/null $LOG_FILE execute git checkout master execute git reset --hard stable } heads=$(grep -v '^#' ../real_control | awk -F ' ' '$2=="quilt" { printf("quilt/%s ", $3); } $2=="git" { printf("%s/%s ", $3, $5); }') need_build=false for h in $heads; do tree=${h%/*} [ "$tree" == "quilt" ] && tree=${h#quilt/} [ -n "$start_from" ] && { if [ "$tree" = "$start_from" ]; then start_from="" else continue fi } log Merging $h old_head=$(git rev-parse HEAD) execute git merge $h || { echo Merge failed 1>&2 bash -i || exit GIT_EDITOR=: execute git commit -v -a execute git diff -M --stat --summary 'HEAD^..' } $no_build && continue $need_build || { # See if we need to build after merging this tree new_head=$(git rev-parse HEAD) [ "$old_head" = "$new_head" ] || need_build=true $need_build || [ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] || need_build=true } $need_build || continue do_build=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'$tree'" { print $6; }') [ "$do_build" = "yes" ] || continue rsync -avH --exclude .git --delete . "$build_host":"$build_dir"/. || { echo Rsync failed 1>&2 bash -i || exit } ssh "$build_host" "$build_cmd" || { echo Build failed 1>&2 bash -i || exit } need_build=false done exit 0