#!/bin/bash vexec() { local i fmt for (( i = 1; i <= $#; ++i )) ; do case ${!i} in *" "*) fmt="'%s'";; *) fmt="%s";; esac printf "${fmt}" "${!i}" if [[ $i -lt $# ]] ; then printf ' ' else echo fi done exec "$@" } cd ~/chromiumos || exit 1 case " $* " in *" --remote "*) export GIT_CONFIG=$PWD/.repo/manifests.git/config vexec cbuildbot "$@" ;; esac # cache the sudo timestamp sudo echo "" >/dev/null d=/usr/local/google/home/vapier if [[ ! -d ${d} ]] ; then exit 1 fi d+="/trybot" if mount | grep -qs $d ; then echo "mounts found in $d" exit 1 fi rd=$(readlink $d) if mount | grep -qs $rd ; then echo "mounts found in $rd" exit 1 fi if [[ $1 == "--noclean" ]] ; then shift else echo "Cleaning ${d}" pushd "${d}" >/dev/null clean=( built-sdk.tbz2 chroot new-sdk-chroot #sdks src/build test_results.tgz trybot_archive ) sudo rm -rf "${clean[@]}" if [[ -d ${d}/sdks ]] ; then sudo find "${d}"/sdks -mtime +3 -delete fi popd >/dev/null fi # find all the buildbot branches echo "Looking up repo branches" repos=$(r b | cut -b4- | awk '$1 == "bb" { # Single repo output: # bb | in src/third_party/portage-stable # Multi repo output: # bb | in: # src/third_party/portage-stable # src/third_party/chromiumos-overlay if ($3 == "in") print $NF while (getline) { if ($2 == "|") break; print $NF; } }') if [[ -n ${repos} ]] ; then echo "Auto pulling patches from 'bb' branch in repos:" printf '\t%s\n' ${repos} p_flag="" for r in ${repos} ; do r=$(r list | awk -v r="${r}" '$1 == r { print $NF }') p_flag+="${r}:bb " done set -- -p "${p_flag}" "$@" fi vexec cbuildbot --buildroot=${d} "$@"