X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=.bin%2Fcros-cbuildbot;h=cdc6b43db2dce5bacd6e86053c6f25eece73ad06;hb=f7555918c8180c281c91caec2cb5f7990e1719bb;hp=aae5a5651301edbf2f0ad1659045474d64a5e624;hpb=eab23be4162f077845b0b14bea7ec9069ba9f12f;p=home.git diff --git a/.bin/cros-cbuildbot b/.bin/cros-cbuildbot index aae5a56..cdc6b43 100755 --- a/.bin/cros-cbuildbot +++ b/.bin/cros-cbuildbot @@ -1,42 +1,71 @@ #!/bin/bash -cd ~/chromiumos || exit 1 +set -e -# cache the sudo timestamp -sudo echo "" >/dev/null +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 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 @@ -69,6 +98,6 @@ if [[ -n ${repos} ]] ; then set -- -p "${p_flag}" "$@" fi +set -- --cache-dir=~/chromiumos/.cache "$@" -vexec() { echo "$@"; exec "$@"; } vexec cbuildbot --buildroot=${d} "$@"