X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=.bin%2Fcros-board;h=228ff2c47c949e21226312bdeb1ec45deddaf887;hb=HEAD;hp=1b7406c982bf0f52c9e922bf79cfcafe4490dd3c;hpb=2834209effb28c1ec7224513ea26ad18d738955a;p=home.git diff --git a/.bin/cros-board b/.bin/cros-board index 1b7406c..228ff2c 100755 --- a/.bin/cros-board +++ b/.bin/cros-board @@ -3,29 +3,73 @@ die() { eerror "$*"; exit 1; } set -e -cd ${HOME}/trunk/src/scripts/ +BASE="/mnt/host/source" +BUILD_DIR="${BASE}/src/build" +cd "${BASE}/src/scripts/" +: "${BOARD:="$(cat .default_board 2>/dev/null)"}" if [[ -z ${BOARD} ]] ; then die "missing BOARD" fi -IMAGES="${HOME}/trunk/src/build/images/${BOARD}" +IMAGES="${BASE}/src/build/images/${BOARD}" BUILD="/build/${BOARD}" +usage() { + exec cat < Write image to w/out prompting. + + -p Pretend -- show commands that would be run. + -v Verbose -- send command output to stdout. +EOF +} + +find_first_removable() { + local d + cd /sys/block + for d in sd? ; do + if [[ $(cat "${d}/removable" 2>/dev/null) == "1" ]]; then + echo "/dev/${d}" + return 0 + fi + done + return 0 +} + ARG_CLEAN=false -ARG_DEV="/dev/sdc" +ARG_DEV="$(find_first_removable)" ARG_DEV_USER=false ARG_PRETEND=false ARG_NOPKG=false +ARG_AUTOTEST=false +ARG_FACTORY=false ARG_VERBOSE=false ARG_TEST=false while [[ $# -ne 0 ]] ; do case $1 in --clean) ARG_CLEAN=true;; -p) ARG_PRETEND=true;; + -Y) ARG_DEV_USER=true;; -y) shift; ARG_DEV=$1; ARG_DEV_USER=true;; -v) ARG_VERBOSE=true;; -t) ARG_TEST=true;; --nousepkg) ARG_NOPKG=true;; + --autotest) ARG_AUTOTEST=true;; + --factory) ARG_FACTORY=true;; + -h) usage;; *) echo "unknown opt: $*"; exit 1;; esac shift @@ -34,8 +78,8 @@ done piperet() { set -- ${PIPESTATUS[@]/0}; [[ $# -eq 0 ]]; } run() { set +e - ebegin "$*" if ! ${ARG_PRETEND} ; then + ebegin "$*" local log="${IMAGES}"/log.${1##*/} if ${ARG_VERBOSE} ; then "$@" |& tee "${log}" @@ -43,52 +87,71 @@ run() { "$@" >& "${log}" fi piperet + eend $? || exit $? + else + echo "$*" fi - eend $? || exit $? set -e } -tfe() { ($1 && echo $2 || :); } +tfe() { ($1 && echo $2 || echo $3); } mkdir -p "${IMAGES}" rm -f "${IMAGES}"/log.* einfo "Log root: ${IMAGES}/log." +run update_chroot + if ${ARG_CLEAN} || [[ ! -d ${BUILD} ]] ; then run sudo rm -rf "${BUILD}" - run ./setup_board --board=${BOARD} - if [ $? -ne 0 ] ; then + run setup_board --board=${BOARD} --skip-chroot-upgrade + if [[ $? -ne 0 ]] ; then run sudo rm -rf "${BUILD}" exit 1 fi fi -run ./build_packages --board=${BOARD} --oldchromebinary --nowithdebug $(tfe ${ARG_NOPKG} --nousepkg) $(tfe ${ARG_TEST} --withtest) -BUILD_IMG="./build_image --board=${BOARD} --withdev --noenable_rootfs_verification $(tfe ${ARG_TEST} --test)" +run cros build-packages \ + --board=${BOARD} \ + --nowithdebug \ + --nowithrevdeps \ + --skip-chroot-upgrade \ + $(tfe ${ARG_AUTOTEST} --{,no-}withautotest) \ + $(tfe ${ARG_FACTORY} --{,no-}withfactory) \ + $(tfe ${ARG_NOPKG} --{no-,}usepkg) \ + $(tfe ${ARG_TEST} --{,no-}withtest) +BUILD_IMG="cros build-image --board=${BOARD} --no-enable-rootfs-verification $(tfe ${ARG_TEST} test base)" run ${BUILD_IMG} -IMG_TO_USB="./image_to_usb.sh --board=${BOARD} -y --to=${ARG_DEV}" +IMG_TO_USB="cros flash --yes usb://${ARG_DEV} xbuddy://local/${BOARD}/latest/dev" if ${ARG_DEV_USER} ; then run ${IMG_TO_USB} sync & fi +cd "${IMAGES}" +rm -rf $(ls -td1R `find -mindepth 1 -maxdepth 1 -type d` | sed -e 1d -e 2d) + cat <