2 .
/etc
/init.d
/functions.sh ||
exit 1
3 die
() { eerror
"$*"; exit 1; }
6 BASE
="/mnt/host/source"
7 BUILD_DIR
="${BASE}/src/build"
8 cd "${BASE}/src/scripts/"
10 : "${BOARD:="$(cat .default_board 2>/dev/null)"}"
11 if [[ -z ${BOARD} ]] ; then
14 IMAGES
="${BASE}/src/build/images/${BOARD}"
15 BUILD
="/build/${BOARD}"
19 Usage: cros-board [options]
21 Build for the board listed in \${BOARD} (current: ${BOARD}).
22 Normally only builds a dev image.
25 -t Build test packages & image
26 --autotest Build & install autotest packages.
27 --factory Build factory packages & image.
28 --nousepkg Force build from source.
32 -Y Write image to ${ARG_DEV} w/out prompting.
33 -y <dev> Write image to <dev> w/out prompting.
35 -p Pretend -- show commands that would be run.
36 -v Verbose -- send command output to stdout.
40 find_first_removable
() {
44 if [[ $
(cat "${d}/removable" 2>/dev
/null
) == "1" ]]; then
53 ARG_DEV
="$(find_first_removable)"
61 while [[ $# -ne 0 ]] ; do
63 --clean) ARG_CLEAN
=true
;;
64 -p) ARG_PRETEND
=true
;;
65 -Y) ARG_DEV_USER
=true
;;
66 -y) shift; ARG_DEV
=$1; ARG_DEV_USER
=true
;;
67 -v) ARG_VERBOSE
=true
;;
69 --nousepkg) ARG_NOPKG
=true
;;
70 --autotest) ARG_AUTOTEST
=true
;;
71 --factory) ARG_FACTORY
=true
;;
73 *) echo "unknown opt: $*"; exit 1;;
78 piperet
() { set -- ${PIPESTATUS[@]/0}; [[ $# -eq 0 ]]; }
81 if ! ${ARG_PRETEND} ; then
83 local log
="${IMAGES}"/log.
${1##*/}
84 if ${ARG_VERBOSE} ; then
97 tfe
() { ($1 && echo $2 ||
echo $3); }
100 rm -f "${IMAGES}"/log.
*
102 einfo
"Log root: ${IMAGES}/log."
106 if ${ARG_CLEAN} ||
[[ ! -d ${BUILD} ]] ; then
107 run sudo
rm -rf "${BUILD}"
108 run setup_board
--board=${BOARD} --skip-chroot-upgrade
109 if [[ $?
-ne 0 ]] ; then
110 run sudo
rm -rf "${BUILD}"
115 run cros build-packages \
119 --skip-chroot-upgrade \
120 $
(tfe
${ARG_AUTOTEST} --{,no-
}withautotest
) \
121 $
(tfe
${ARG_FACTORY} --{,no-
}withfactory
) \
122 $
(tfe
${ARG_NOPKG} --{no-
,}usepkg
) \
123 $
(tfe
${ARG_TEST} --{,no-
}withtest
)
124 BUILD_IMG
="cros build-image --board=${BOARD} --no-enable-rootfs-verification $(tfe ${ARG_TEST} test base)"
127 IMG_TO_USB
="cros flash --yes usb://${ARG_DEV} xbuddy://local/${BOARD}/latest/dev"
128 if ${ARG_DEV_USER} ; then
134 rm -rf $
(ls -td1R `find -mindepth 1 -maxdepth 1 -type d` |
sed -e 1d
-e 2d
)
142 cros vm --board=${BOARD} --start --no-display --image-path=\${HOME}/chromiumos/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
144 /usr/local/autotest/bin/autologin.py
146 export CROS_USER_ID_HASH=\$(ls /home/user/)
147 sudo -u chronos CROS_USER_ID_HASH="${CROS_USER_ID_HASH}" crosh
148 vmc start termina # might run twice
151 ~/chromiumos/src/scripts/mod_image_for_recovery.sh --board=${BOARD}
152 ${IMG_TO_USB%/dev}/recovery
155 ${BUILD_IMG} --factory_install
156 ${IMG_TO_USB} -i factory_install_shim.bin