2 . /etc/init.d/functions.sh || exit 1
3 die() { eerror "$*"; exit 1; }
6 BASE="/mnt/host/source"
7 d="${BASE}/src/scripts"
8 BUILD_DIR="${BASE}/src/build"
9 cd "${BASE}/src/scripts/"
11 : "${BOARD:="$(cat .default_board 2>/dev/null)"}"
12 if [[ -z ${BOARD} ]] ; then
15 IMAGES="${BASE}/src/build/images/${BOARD}"
16 BUILD="/build/${BOARD}"
20 Usage: cros-board [options]
22 Build for the board listed in \${BOARD} (current: ${BOARD}).
23 Normally only builds a dev image.
26 -t Build test packages & image
27 --autotest Build & install autotest packages.
28 --factory Build factory packages & image.
29 --nousepkg Force build from source.
33 -Y Write image to ${ARG_DEV} w/out prompting.
34 -y <dev> Write image to <dev> w/out prompting.
36 -p Pretend -- show commands that would be run.
37 -v Verbose -- send command output to stdout.
41 find_first_removable() {
45 if [[ $(cat "${d}/removable" 2>/dev/null) == "1" ]]; then
54 ARG_DEV="$(find_first_removable)"
62 while [[ $# -ne 0 ]] ; do
64 --clean) ARG_CLEAN=true;;
65 -p) ARG_PRETEND=true;;
66 -Y) ARG_DEV_USER=true;;
67 -y) shift; ARG_DEV=$1; ARG_DEV_USER=true;;
68 -v) ARG_VERBOSE=true;;
70 --nousepkg) ARG_NOPKG=true;;
71 --autotest) ARG_AUTOTEST=true;;
72 --factory) ARG_FACTORY=true;;
74 *) echo "unknown opt: $*"; exit 1;;
79 piperet() { set -- ${PIPESTATUS[@]/0}; [[ $# -eq 0 ]]; }
82 if ! ${ARG_PRETEND} ; then
84 local log="${IMAGES}"/log.${1##*/}
85 if ${ARG_VERBOSE} ; then
98 tfe() { ($1 && echo $2 || echo $3); }
101 rm -f "${IMAGES}"/log.*
103 einfo "Log root: ${IMAGES}/log."
105 run ./update_chroot --toolchain_boards=${BOARD}
107 if ${ARG_CLEAN} || [[ ! -d ${BUILD} ]] ; then
108 run sudo rm -rf "${BUILD}"
109 run setup_board --board=${BOARD} --skip-chroot-upgrade
110 if [[ $? -ne 0 ]] ; then
111 run sudo rm -rf "${BUILD}"
120 --skip-chroot-upgrade \
121 $(tfe ${ARG_AUTOTEST} --{,no-}withautotest) \
122 $(tfe ${ARG_FACTORY} --{,no-}withfactory) \
123 $(tfe ${ARG_NOPKG} --{no-,}usepkg) \
124 $(tfe ${ARG_TEST} --{,no-}withtest)
125 BUILD_IMG="build_image --board=${BOARD} --no-enable-rootfs-verification $(tfe ${ARG_TEST} test base)"
128 IMG_TO_USB="cros flash --yes usb://${ARG_DEV} xbuddy://local/${BOARD}/latest/dev"
129 if ${ARG_DEV_USER} ; then
135 rm -rf $(ls -td1R `find -mindepth 1 -maxdepth 1 -type d` | sed -e 1d -e 2d)
137 BUILD_IMG="${d}/${BUILD_IMG#./}"
144 ~/chromiumos/chromite/bin/cros_vm --board=${BOARD} --start --no-display --image-path=\${HOME}/chromiumos/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
145 #--kvm_cpu "max,vmx=on"
147 https://dev.chromium.org/chromium-os/testing/running-smoke-suite-on-a-vm-image
149 /usr/local/autotest/bin/autologin.py
151 export CROS_USER_ID_HASH=\$(ls /home/user/)
152 sudo -u chronos CROS_USER_ID_HASH="${CROS_USER_ID_HASH}" crosh
153 vmc start termina # might run twice
156 ${d}/mod_image_for_recovery.sh --board=${BOARD}
157 ${IMG_TO_USB%/dev}/recovery
160 ${BUILD_IMG} --factory_install
161 ${IMG_TO_USB} -i factory_install_shim.bin