X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=.bin%2Fcros-cbuildbot;h=cdc6b43db2dce5bacd6e86053c6f25eece73ad06;hb=fb5d2cb632ad05e57c8b257f5a3c85bb75c8ac31;hp=453e2734e4c71f0edb24efdd8169b49a363b1a39;hpb=420f8f8a58080e9f351da86316efbdf0b498e1bf;p=home.git diff --git a/.bin/cros-cbuildbot b/.bin/cros-cbuildbot index 453e273..cdc6b43 100755 --- a/.bin/cros-cbuildbot +++ b/.bin/cros-cbuildbot @@ -1,44 +1,71 @@ #!/bin/bash -if ! cbuildbot -h >& /dev/null ; then - cd ~/chromiumos || exit 1 -fi +set -e + +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 "$@" +} -# cache the sudo timestamp -sudo echo "" >/dev/null +cd ~/chromiumos d=/usr/local/google/home/vapier if [[ ! -d ${d} ]] ; then exit 1 fi +if [[ -z ${UNSHARE} ]] ; then + if type -P unshare >&/dev/null ; then + exec sudo unshare -m -- sudo -u ${USER} \ + UNSHARE=true PATH="${PATH}" "$0" "$@" + fi + unset UNSHARE +fi + d+="/trybot" +mkdir -p "${d}" 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 +if [[ -L $d ]] ; then + rd=$(readlink $d) + if mount | grep -qs $rd ; then + echo "mounts found in $rd" + exit 1 + fi fi if [[ $1 == "--noclean" ]] ; then shift -else +elif [[ " $* " != *" --remote "* ]] ; then echo "Cleaning ${d}" pushd "${d}" >/dev/null clean=( built-sdk.tbz2 - chroot +# chroot new-sdk-chroot - #sdks + sdks src/build test_results.tgz trybot_archive ) sudo rm -rf "${clean[@]}" - sudo find "${d}"/sdks -mtime +3 -delete +# [[ -L .cache ]] && rm -f .cache || : +# mkdir -p .cache +# sudo mount --bind -n ~/chromiumos/.cache .cache popd >/dev/null fi @@ -71,6 +98,6 @@ if [[ -n ${repos} ]] ; then set -- -p "${p_flag}" "$@" fi +set -- --cache-dir=~/chromiumos/.cache "$@" -vexec() { echo "$@"; exec "$@"; } vexec cbuildbot --buildroot=${d} "$@"