]>
git.wh0rd.org - home.git/blob - .bin/cros-board
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.
34 -Y Write image to ${ARG_DEV} w/out prompting.
35 -y <dev> Write image to <dev> w/out prompting.
37 -p Pretend -- show commands that would be run.
38 -v Verbose -- send command output to stdout.
42 find_first_removable
() {
46 if [[ $
(cat "${d}/removable" 2>/dev
/null
) == "1" ]]; then
55 ARG_DEV
="$(find_first_removable)"
64 while [[ $# -ne 0 ]] ; do
66 --clean) ARG_CLEAN
=true
;;
67 -p) ARG_PRETEND
=true
;;
68 -Y) ARG_DEV_USER
=true
;;
69 -y) shift; ARG_DEV
=$1; ARG_DEV_USER
=true
;;
70 -v) ARG_VERBOSE
=true
;;
72 --nousepkg) ARG_NOPKG
=true
;;
73 --autotest) ARG_AUTOTEST
=true
;;
74 --factory) ARG_FACTORY
=true
;;
77 *) echo "unknown opt: $*"; exit 1;;
82 piperet
() { set -- ${PIPESTATUS[@]/0}; [[ $# -eq 0 ]]; }
85 if ! ${ARG_PRETEND} ; then
87 local log
="${IMAGES}"/log.
${1##*/}
88 if ${ARG_VERBOSE} ; then
101 tfe
() { ($1 && echo $2 ||
echo $3); }
104 rm -f "${IMAGES}"/log.
*
106 einfo
"Log root: ${IMAGES}/log."
108 run .
/update_chroot
--toolchain_boards=${BOARD}
110 if ${ARG_CLEAN} ||
[[ ! -d ${BUILD} ]] ; then
111 run sudo
rm -rf "${BUILD}"
112 run setup_board
--board=${BOARD} --skip-chroot-upgrade
113 if [[ $?
-ne 0 ]] ; then
114 run sudo
rm -rf "${BUILD}"
119 run .
/build_packages \
123 --skip-chroot-upgrade \
125 $
(tfe
${ARG_AUTOTEST} --{,no
}withautotest
) \
126 $
(tfe
${ARG_FACTORY} --{,no
}withfactory
) \
127 $
(tfe
${ARG_NOPKG} --{no
,}usepkg
) \
128 $
(tfe
${ARG_TEST} --{,no
}withtest
)
129 BUILD_IMG
="./build_image --board=${BOARD} --noenable_rootfs_verification $(tfe ${ARG_TEST} test base)"
132 IMG_TO_USB
="cros flash --yes usb://${ARG_DEV} xbuddy://local/${BOARD}/latest/dev"
133 if ${ARG_DEV_USER} ; then
138 IMG_TO_VM
=( ${d}/image_to_vm.sh --board=${BOARD} --from=${BUILD_DIR}/images/${BOARD}/latest
--test_image )
140 run
"${IMG_TO_VM[@]}"
144 rm -rf $
(ls -td1R `find -mindepth 1 -maxdepth 1 -type d` |
sed -e 1d
-e 2d
)
146 BUILD_IMG
="${d}/${BUILD_IMG#./}"
154 ~/chromiumos/chromite/bin/cros_vm --start --no-display --image-path=\${HOME}/chromiumos/src/build/images/${BOARD}/latest/chromiumos_qemu_image.bin
155 #--kvm_cpu "max,vmx=on"
157 https://dev.chromium.org/chromium-os/testing/running-smoke-suite-on-a-vm-image
159 /usr/local/autotest/bin/autologin.py
161 export CROS_USER_ID_HASH=\$(ls /home/user/)
162 sudo -u chronos CROS_USER_ID_HASH="${CROS_USER_ID_HASH}" crosh
163 vmc start termina # might run twice
166 ${d}/mod_image_for_recovery.sh --board=${BOARD}
167 ${IMG_TO_USB%/dev}/recovery
170 ${BUILD_IMG} --factory_install
171 ${IMG_TO_USB} -i factory_install_shim.bin