]> git.wh0rd.org - home.git/blobdiff - .bin/cros-board
cros-board: use echo for commands it runs
[home.git] / .bin / cros-board
index 30603da89010153b1be3efa89d75eafc0ce4c668..e9ff570a99cff7e5f2a794a8ffaf40f0f02e3f7a 100755 (executable)
@@ -3,31 +3,59 @@
 die() { eerror "$*"; exit 1; }
 set -e
 
-cd ${HOME}/trunk/src/scripts/
+cd "${HOME}/trunk/src/scripts/"
 
+: "${BOARD:="$(cat .default_board 2>/dev/null)"}"
 if [[ -z ${BOARD} ]] ; then
        die "missing BOARD"
 fi
 IMAGES="${HOME}/trunk/src/build/images/${BOARD}"
 BUILD="/build/${BOARD}"
 
+usage() {
+       exec cat <<EOF
+Usage: cros-board [options]
+
+Build for the board listed in \${BOARD} (current: ${BOARD}).
+Normally only builds a dev image.
+
+Options:
+  -t          Build test packages & image
+  --autotest  Build & install autotest packages.
+  --factory   Build factory packages & image.
+  --nousepkg  Force build from source.
+
+  --clean     ?
+
+  -Y          Write image to ${ARG_DEV} w/out prompting.
+  -y <dev>    Write image to <dev> w/out prompting.
+
+  -p          Pretend -- show commands that would be run.
+  -v          Verbose -- send command output to stdout.
+EOF
+}
+
 ARG_CLEAN=false
-ARG_DEV="/dev/sdc"
+ARG_DEV="/dev/sdd"
 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
@@ -47,7 +75,7 @@ run() {
                piperet
                eend $? || exit $?
        else
-               einfo "$*"
+               echo "$*"
        fi
        set -e
 }
@@ -59,7 +87,7 @@ rm -f "${IMAGES}"/log.*
 
 einfo "Log root: ${IMAGES}/log."
 
-run ./update_chroot
+run ./update_chroot --toolchain_boards=${BOARD}
 
 if ${ARG_CLEAN} || [[ ! -d ${BUILD} ]] ; then
        run sudo rm -rf "${BUILD}"
@@ -73,14 +101,16 @@ fi
 run ./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="./build_image --board=${BOARD} --noenable_rootfs_verification $(tfe ${ARG_TEST} --test) dev"
+BUILD_IMG="./build_image --board=${BOARD} --noenable_rootfs_verification $(tfe ${ARG_TEST} test) dev"
 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 &
@@ -89,18 +119,23 @@ fi
 cd "${IMAGES}"
 rm -rf $(ls -td1R `find -mindepth 1 -maxdepth 1 -type d` | sed -e 1d -e 2d)
 
+d="~/trunk/src/scripts"
+BUILD_IMG="${d}/${BUILD_IMG#./}"
 cat <<EOF
 
 ### LIVE
 ${IMG_TO_USB}
 
 ### KVM
-./image_to_vm.sh --board=${BOARD} --from=../build/images/${BOARD}/latest
-kvm -m 1024 -vga std -net nic,model=virtio -net user,hostfwd=tcp::9222-:22 -hda ~/chromiumos/src/build/images/${BOARD}/latest/chromiumos_qemu_image.bin
+${d}/image_to_vm.sh --board=${BOARD} --from=../build/images/${BOARD}/latest
+${d}/image_to_vm.sh --board=${BOARD} --from=../build/images/${BOARD}/latest --test_image
+~/chromiumos/src/scripts/bin/cros_start_vm --no_graphics --image_path=\${HOME}/chromiumos/src/build/images/${BOARD}/latest/chromiumos_qemu_image.bin
+qemu-system-x86_64 -enable-kvm -m 1024 -vga std -net nic,model=virtio -net user,hostfwd=tcp::9222-:22 -hda ~/chromiumos/src/build/images/${BOARD}/latest/chromiumos_qemu_image.bin
+http://dev.chromium.org/chromium-os/testing/running-smoke-suite-on-a-vm-image
 
 ### RECOVERY
-./mod_image_for_recovery.sh --board=${BOARD}
-${IMG_TO_USB} --image_name=recovery_image.bin
+${d}/mod_image_for_recovery.sh --board=${BOARD}
+${IMG_TO_USB%/dev}/recovery
 
 ### FACTORY
 ${BUILD_IMG} --factory_install