Allow factory install shim to be overlay installed

Make standalone package for factory install, so it can be overlayed on top of an existing image.
Modify mod_image_for_test to do the overlay.

Review URL: http://codereview.chromium.org/1945004
This commit is contained in:
Nick Sanders 2010-05-05 21:21:15 -07:00
parent b9f2d2ecbd
commit 7789d34e97
3 changed files with 41 additions and 15 deletions

View File

@ -41,8 +41,6 @@ DEFINE_string to "" \
"The target image file or device"
DEFINE_boolean withtest $FLAGS_FALSE \
"Include packages required for testing and prepare image for testing"
DEFINE_string factory_server "" \
"Build a factory install image pointing to given server."
DEFINE_string arm_extra_bootargs "" \
"Additional command line options to pass to the ARM kernel."
@ -337,12 +335,6 @@ if [[ $FLAGS_withdev -eq $FLAGS_TRUE ]] ; then
sudo cp -a "$(which ldd)" "${ROOT_DEV_DIR}/usr/bin"
fi
if [ -n "$FLAGS_factory_server" ]; then
sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \
--root="$ROOT_DEV_DIR" --root-deps=rdeps \
--usepkgonly chromeos-factoryinstall $EMERGE_JOBS
fi
# Install packages required for testing.
if [[ $FLAGS_withtest -eq $FLAGS_TRUE ]] ; then
sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \
@ -355,11 +347,6 @@ EXTRA_CUSTOMIZE_ROOTFS_FLAGS=""
if [ $FLAGS_withdev -eq $FLAGS_TRUE ]; then
EXTRA_CUSTOMIZE_ROOTFS_FLAGS="--withdev"
fi
if [ -n "$FLAGS_factory_server" ]; then
# Indentation off b/c of long line
EXTRA_CUSTOMIZE_ROOTFS_FLAGS="$EXTRA_CUSTOMIZE_ROOTFS_FLAGS"\
" --factory_server=$FLAGS_factory_server"
fi
# Extract the kernel from the root filesystem for use by the GPT image. Legacy
# BIOS will use the kernel in the rootfs (via syslinux), Chrome OS BIOS will

View File

@ -22,6 +22,8 @@ DEFINE_string from "" \
DEFINE_string to "" "${DEFAULT_TO_HELP}"
DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y"
DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image"
DEFINE_boolean factory_install ${FLAGS_FALSE} \
"Whether to generate a factory install shim."
DEFINE_boolean factory ${FLAGS_FALSE} \
"Whether to generate a factory runin image. Implies aututest and test"
DEFINE_boolean install_autotest ${FLAGS_FALSE} \
@ -37,6 +39,13 @@ DEFINE_string build_root "/build" \
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then
echo "Factory test image is incompatible with factory install shim."
exit 1
fi
fi
# Require autotest for manucaturing image.
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
echo "Factory image requires --install_autotest and --test_image, setting."
@ -44,6 +53,13 @@ if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
FLAGS_test_image=${FLAGS_TRUE}
fi
# Require test for for factory install shim.
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then
echo "Factory install shim requires --test_image, setting."
FLAGS_test_image=${FLAGS_TRUE}
fi
# Inside the chroot, so output to usb.img in the same dir as the other
# Script can be run either inside or outside the chroot.
if [ ${INSIDE_CHROOT} -eq 1 ]
@ -159,14 +175,19 @@ if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
# Check for manufacturing image.
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
FACTORY_ARGS="--factory"
EXTRA_ARGS="--factory"
fi
# Check for instqall shim.
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then
EXTRA_ARGS="--factory_install"
fi
# Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we
# really want to modify the image; the user gave their assent already with
# --test-image and the original image is going to be preserved.
"${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
"${FLAGS_from}/chromiumos_test_image.bin" ${FACTORY_ARGS} --yes
"${FLAGS_from}/chromiumos_test_image.bin" ${EXTRA_ARGS} --yes
echo "Done with mod_image_for_test."
else
echo "Using cached test image."

View File

@ -20,6 +20,8 @@ DEFINE_string qualdb "/tmp/run_remote_tests.*" \
"Location of qualified component file"
DEFINE_string image "" "Location of the rootfs raw image file"
DEFINE_boolean factory $FLAGS_FALSE "Modify the image for manufacturing testing"
DEFINE_boolean factory_install $FLAGS_FALSE \
"Modify the image for factory install shim"
DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y"
# Parse command line
@ -73,6 +75,7 @@ cleanup() {
cleanup_mounts "${ROOT_FS_DIR}"
if [ -n "${ROOT_LOOP_DEV}" ]
then
sudo umount "${ROOT_FS_DIR}/var"
cleanup_loop "${ROOT_LOOP_DEV}"
fi
rmdir "${ROOT_FS_DIR}"
@ -134,6 +137,7 @@ if [ -z "$STATEFUL_LOOP_DEV" ]; then
fi
sudo losetup -o $(( $offset * 512 )) "${STATEFUL_LOOP_DEV}" "${FLAGS_image}"
sudo mount "${STATEFUL_LOOP_DEV}" "${STATEFUL_DIR}"
sudo mount --bind "${STATEFUL_DIR}/var" "${ROOT_FS_DIR}/var"
STATEFUL_DIR="${STATEFUL_DIR}"
MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts"
@ -149,6 +153,20 @@ if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
"${MOD_FACTORY_ROOT}/factory_setup.sh"
fi
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
# Run factory setup script to modify the image.
sudo emerge-${FLAGS_board} --root=$ROOT_FS_DIR --usepkgonly \
--root-deps=rdeps chromeos-factoryinstall
# Set factory server if necessary.
if [ "${FACTORY_SERVER}" != "" ]; then
sudo sed -i \
"s/CHROMEOS_AUSERVER=.*$/CHROMEOS_AUSERVER=\
http:\/\/${FACTORY_SERVER}:8080\/update/" \
${ROOT_FS_DIR}/etc/lsb-release
fi
fi
cleanup
trap - EXIT