mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 06:31:18 +02:00
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:
parent
b9f2d2ecbd
commit
7789d34e97
13
build_image
13
build_image
@ -41,8 +41,6 @@ DEFINE_string to "" \
|
|||||||
"The target image file or device"
|
"The target image file or device"
|
||||||
DEFINE_boolean withtest $FLAGS_FALSE \
|
DEFINE_boolean withtest $FLAGS_FALSE \
|
||||||
"Include packages required for testing and prepare image for testing"
|
"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 "" \
|
DEFINE_string arm_extra_bootargs "" \
|
||||||
"Additional command line options to pass to the ARM kernel."
|
"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"
|
sudo cp -a "$(which ldd)" "${ROOT_DEV_DIR}/usr/bin"
|
||||||
fi
|
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.
|
# Install packages required for testing.
|
||||||
if [[ $FLAGS_withtest -eq $FLAGS_TRUE ]] ; then
|
if [[ $FLAGS_withtest -eq $FLAGS_TRUE ]] ; then
|
||||||
sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \
|
sudo INSTALL_MASK="$INSTALL_MASK" emerge-${BOARD} \
|
||||||
@ -355,11 +347,6 @@ EXTRA_CUSTOMIZE_ROOTFS_FLAGS=""
|
|||||||
if [ $FLAGS_withdev -eq $FLAGS_TRUE ]; then
|
if [ $FLAGS_withdev -eq $FLAGS_TRUE ]; then
|
||||||
EXTRA_CUSTOMIZE_ROOTFS_FLAGS="--withdev"
|
EXTRA_CUSTOMIZE_ROOTFS_FLAGS="--withdev"
|
||||||
fi
|
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
|
# 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
|
# BIOS will use the kernel in the rootfs (via syslinux), Chrome OS BIOS will
|
||||||
|
@ -22,6 +22,8 @@ DEFINE_string from "" \
|
|||||||
DEFINE_string to "" "${DEFAULT_TO_HELP}"
|
DEFINE_string to "" "${DEFAULT_TO_HELP}"
|
||||||
DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y"
|
DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y"
|
||||||
DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image"
|
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} \
|
DEFINE_boolean factory ${FLAGS_FALSE} \
|
||||||
"Whether to generate a factory runin image. Implies aututest and test"
|
"Whether to generate a factory runin image. Implies aututest and test"
|
||||||
DEFINE_boolean install_autotest ${FLAGS_FALSE} \
|
DEFINE_boolean install_autotest ${FLAGS_FALSE} \
|
||||||
@ -37,6 +39,13 @@ DEFINE_string build_root "/build" \
|
|||||||
FLAGS "$@" || exit 1
|
FLAGS "$@" || exit 1
|
||||||
eval set -- "${FLAGS_ARGV}"
|
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.
|
# Require autotest for manucaturing image.
|
||||||
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
|
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
|
||||||
echo "Factory image requires --install_autotest and --test_image, setting."
|
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}
|
FLAGS_test_image=${FLAGS_TRUE}
|
||||||
fi
|
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
|
# 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.
|
# Script can be run either inside or outside the chroot.
|
||||||
if [ ${INSIDE_CHROOT} -eq 1 ]
|
if [ ${INSIDE_CHROOT} -eq 1 ]
|
||||||
@ -159,14 +175,19 @@ if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
|
|||||||
|
|
||||||
# Check for manufacturing image.
|
# Check for manufacturing image.
|
||||||
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
|
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
|
fi
|
||||||
|
|
||||||
# Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we
|
# 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
|
# really want to modify the image; the user gave their assent already with
|
||||||
# --test-image and the original image is going to be preserved.
|
# --test-image and the original image is going to be preserved.
|
||||||
"${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
|
"${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."
|
echo "Done with mod_image_for_test."
|
||||||
else
|
else
|
||||||
echo "Using cached test image."
|
echo "Using cached test image."
|
||||||
|
@ -20,6 +20,8 @@ DEFINE_string qualdb "/tmp/run_remote_tests.*" \
|
|||||||
"Location of qualified component file"
|
"Location of qualified component file"
|
||||||
DEFINE_string image "" "Location of the rootfs raw image 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 $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"
|
DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y"
|
||||||
|
|
||||||
# Parse command line
|
# Parse command line
|
||||||
@ -73,6 +75,7 @@ cleanup() {
|
|||||||
cleanup_mounts "${ROOT_FS_DIR}"
|
cleanup_mounts "${ROOT_FS_DIR}"
|
||||||
if [ -n "${ROOT_LOOP_DEV}" ]
|
if [ -n "${ROOT_LOOP_DEV}" ]
|
||||||
then
|
then
|
||||||
|
sudo umount "${ROOT_FS_DIR}/var"
|
||||||
cleanup_loop "${ROOT_LOOP_DEV}"
|
cleanup_loop "${ROOT_LOOP_DEV}"
|
||||||
fi
|
fi
|
||||||
rmdir "${ROOT_FS_DIR}"
|
rmdir "${ROOT_FS_DIR}"
|
||||||
@ -134,6 +137,7 @@ if [ -z "$STATEFUL_LOOP_DEV" ]; then
|
|||||||
fi
|
fi
|
||||||
sudo losetup -o $(( $offset * 512 )) "${STATEFUL_LOOP_DEV}" "${FLAGS_image}"
|
sudo losetup -o $(( $offset * 512 )) "${STATEFUL_LOOP_DEV}" "${FLAGS_image}"
|
||||||
sudo mount "${STATEFUL_LOOP_DEV}" "${STATEFUL_DIR}"
|
sudo mount "${STATEFUL_LOOP_DEV}" "${STATEFUL_DIR}"
|
||||||
|
sudo mount --bind "${STATEFUL_DIR}/var" "${ROOT_FS_DIR}/var"
|
||||||
STATEFUL_DIR="${STATEFUL_DIR}"
|
STATEFUL_DIR="${STATEFUL_DIR}"
|
||||||
|
|
||||||
MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts"
|
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"
|
"${MOD_FACTORY_ROOT}/factory_setup.sh"
|
||||||
fi
|
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
|
cleanup
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user