mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 23:21:17 +02:00
Standardize invocations of emerge in build_image.
Also includes a style nit fix: don't quote arguments to numeric comparison test operators. BUG=chromium-os:13582 TEST=setup_board --force && build_packages && build_image; boot the result Review URL: http://codereview.chromium.org/6801027 Change-Id: I689ca9697a05cf93a789fde1242fb2fa50f21612
This commit is contained in:
parent
dd5e04a875
commit
eb5246f8d9
63
build_image
63
build_image
@ -143,17 +143,17 @@ check_blacklist
|
|||||||
# TODO(vlaviano): Validate command line flags. Check for conflicting flags and
|
# TODO(vlaviano): Validate command line flags. Check for conflicting flags and
|
||||||
# reconcile them if possible. Exit with an error message otherwise.
|
# reconcile them if possible. Exit with an error message otherwise.
|
||||||
|
|
||||||
INSTALL_MASK=""
|
export INSTALL_MASK=""
|
||||||
if [ "${FLAGS_installmask}" -eq "${FLAGS_TRUE}" ] ; then
|
if [ ${FLAGS_installmask} -eq ${FLAGS_TRUE} ] ; then
|
||||||
INSTALL_MASK="${DEFAULT_INSTALL_MASK}"
|
INSTALL_MASK="${DEFAULT_INSTALL_MASK}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reduce the size of factory install shim.
|
# Reduce the size of factory install shim.
|
||||||
if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then
|
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
|
||||||
# Disable --withdev flag when --factory_install is set to True. Otherwise, the
|
# Disable --withdev flag when --factory_install is set to True. Otherwise, the
|
||||||
# dev image produced will be based on install shim, rather than a pristine
|
# dev image produced will be based on install shim, rather than a pristine
|
||||||
# image
|
# image
|
||||||
if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then
|
if [ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]; then
|
||||||
info "Incompatible flags: --withdev and --factory_install cannot both be \
|
info "Incompatible flags: --withdev and --factory_install cannot both be \
|
||||||
set to True. Resetting --withdev to False."
|
set to True. Resetting --withdev to False."
|
||||||
FLAGS_withdev=${FLAGS_FALSE}
|
FLAGS_withdev=${FLAGS_FALSE}
|
||||||
@ -169,14 +169,14 @@ set to True. Resetting --withdev to False."
|
|||||||
FLAGS_statefulfs_size=140
|
FLAGS_statefulfs_size=140
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad))" -gt \
|
if [ $((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) -gt \
|
||||||
"${FLAGS_rootfs_partition_size}" ] ; then
|
${FLAGS_rootfs_partition_size} ] ; then
|
||||||
die "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MiB) is \
|
die "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MiB) is \
|
||||||
bigger than partition (${FLAGS_rootfs_partition_size} MiB)."
|
bigger than partition (${FLAGS_rootfs_partition_size} MiB)."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EMERGE_BOARD_CMD="emerge-${FLAGS_board}"
|
EMERGE_BOARD_CMD="emerge-${FLAGS_board}"
|
||||||
if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then
|
if [ ${FLAGS_fast} -eq ${FLAGS_TRUE} ]; then
|
||||||
echo "Using alternate emerge"
|
echo "Using alternate emerge"
|
||||||
EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge"
|
EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge"
|
||||||
EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}"
|
EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}"
|
||||||
@ -189,21 +189,24 @@ OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/"
|
|||||||
|
|
||||||
# Configure extra USE or packages for this type of build.
|
# Configure extra USE or packages for this type of build.
|
||||||
EXTRA_PACKAGES=""
|
EXTRA_PACKAGES=""
|
||||||
EXTRA_USE=""
|
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then
|
||||||
if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] ; then
|
|
||||||
# Factory install needs to have the kernel initrmafs enabled,
|
# Factory install needs to have the kernel initrmafs enabled,
|
||||||
# and the factory installer added.
|
# and the factory installer added.
|
||||||
EXTRA_PACKAGES="${EXTRA_PACKAGES} chromeos-base/chromeos-factoryinstall"
|
EXTRA_PACKAGES="${EXTRA_PACKAGES} chromeos-base/chromeos-factoryinstall"
|
||||||
EXTRA_USE="${EXTRA_USE} initramfs"
|
export USE="${USE} initramfs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
emerge_to_image() {
|
||||||
|
sudo -E ${EMERGE_BOARD_CMD} --root-deps=rdeps --usepkgonly \
|
||||||
|
"$@" ${EMERGE_JOBS}
|
||||||
|
}
|
||||||
|
|
||||||
# Freshen kernel with correct USE flags. This is a noop if we have
|
# Freshen kernel with correct USE flags. This is a noop if we have
|
||||||
# the right kernel prebuilt. Factory install uses USE="initramfs".
|
# the right kernel prebuilt. Factory install uses USE="initramfs".
|
||||||
# We don't allow building from source with the image as a target,
|
# We don't allow building from source with the image as a target,
|
||||||
# and it's not possible to store prebuilts for the same package
|
# and it's not possible to store prebuilts for the same package
|
||||||
# with different use flags.
|
# with different use flags.
|
||||||
USE="${EXTRA_USE} ${USE}" emerge-${FLAGS_board} \
|
sudo -E ${EMERGE_BOARD_CMD} -uDNv -g virtual/kernel
|
||||||
-uNDvg --binpkg-respect-use=y virtual/kernel
|
|
||||||
|
|
||||||
# Use canonical path since some tools (e.g. mount) do not like symlinks.
|
# Use canonical path since some tools (e.g. mount) do not like symlinks.
|
||||||
# Append build attempt to output directory.
|
# Append build attempt to output directory.
|
||||||
@ -216,11 +219,11 @@ OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}"
|
|||||||
# different name.
|
# different name.
|
||||||
DEVELOPER_IMAGE_NAME=
|
DEVELOPER_IMAGE_NAME=
|
||||||
PRISTINE_IMAGE_NAME=chromiumos_image.bin
|
PRISTINE_IMAGE_NAME=chromiumos_image.bin
|
||||||
if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then
|
if [ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]; then
|
||||||
PRISTINE_IMAGE_NAME=chromiumos_base_image.bin
|
PRISTINE_IMAGE_NAME=chromiumos_base_image.bin
|
||||||
DEVELOPER_IMAGE_NAME=chromiumos_image.bin
|
DEVELOPER_IMAGE_NAME=chromiumos_image.bin
|
||||||
# Rename pristine image for factory install shim
|
# Rename pristine image for factory install shim
|
||||||
elif [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then
|
elif [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
|
||||||
PRISTINE_IMAGE_NAME=factory_install_shim.bin
|
PRISTINE_IMAGE_NAME=factory_install_shim.bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -416,15 +419,11 @@ update_dev_packages() {
|
|||||||
root_dev_dir="${ROOT_FS_DIR}/usr/local"
|
root_dev_dir="${ROOT_FS_DIR}/usr/local"
|
||||||
|
|
||||||
# Install developer packages described in chromeos-dev.
|
# Install developer packages described in chromeos-dev.
|
||||||
sudo -E USE="${USE} ${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" \
|
emerge_to_image --root="${root_dev_dir}" -uDNv chromeos-dev
|
||||||
${EMERGE_BOARD_CMD} --root="${root_dev_dir}" --root-deps=rdeps \
|
|
||||||
--usepkgonly -uDNv chromeos-dev ${EMERGE_JOBS}
|
|
||||||
|
|
||||||
if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then
|
if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then
|
||||||
# Clean out unused packages
|
# Clean out unused packages
|
||||||
sudo -E USE="${USE} ${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" \
|
emerge_to_image --root="${ROOT_FS_DIR}" --depclean
|
||||||
${EMERGE_BOARD_CMD} --root="${ROOT_FS_DIR}" --root-deps=rdeps \
|
|
||||||
--usepkgonly --depclean ${EMERGE_JOBS}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the bare necessary files so that the "emerge" command works
|
# Install the bare necessary files so that the "emerge" command works
|
||||||
@ -504,14 +503,10 @@ update_base_packages() {
|
|||||||
-s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}"
|
-s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}"
|
||||||
|
|
||||||
# Emerge updated packages, exactly like when creating base image
|
# Emerge updated packages, exactly like when creating base image
|
||||||
sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \
|
emerge_to_image --root="${ROOT_FS_DIR}" -uDNv chromeos ${EXTRA_PACKAGES}
|
||||||
--root="${ROOT_FS_DIR}" --root-deps=rdeps \
|
|
||||||
--usepkgonly -uDNv chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS}
|
|
||||||
|
|
||||||
# Clean out unused packages
|
# Clean out unused packages
|
||||||
sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \
|
emerge_to_image --root="${ROOT_FS_DIR}" --depclean
|
||||||
--root="${ROOT_FS_DIR}" --root-deps=rdeps \
|
|
||||||
--usepkgonly --depclean ${EMERGE_JOBS}
|
|
||||||
|
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \
|
${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \
|
||||||
@ -636,9 +631,7 @@ create_base_image() {
|
|||||||
# runtime packages for chrome os. This builds up a chrome os image from
|
# runtime packages for chrome os. This builds up a chrome os image from
|
||||||
# binary packages with runtime dependencies only. We use INSTALL_MASK to
|
# binary packages with runtime dependencies only. We use INSTALL_MASK to
|
||||||
# trim the image size as much as possible.
|
# trim the image size as much as possible.
|
||||||
sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \
|
emerge_to_image --root="${ROOT_FS_DIR}" chromeos ${EXTRA_PACKAGES}
|
||||||
--root="${ROOT_FS_DIR}" --root-deps=rdeps \
|
|
||||||
--usepkgonly chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS}
|
|
||||||
|
|
||||||
# Set /etc/lsb-release on the image.
|
# Set /etc/lsb-release on the image.
|
||||||
"${OVERLAY_CHROMEOS_DIR}/scripts/cros_set_lsb_release" \
|
"${OVERLAY_CHROMEOS_DIR}/scripts/cros_set_lsb_release" \
|
||||||
@ -736,7 +729,7 @@ if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Perform an eclean to remove packages which are not installed
|
# Perform an eclean to remove packages which are not installed
|
||||||
if [[ "${FLAGS_eclean}" -eq "${FLAGS_TRUE}" ]]; then
|
if [[ ${FLAGS_eclean} -eq ${FLAGS_TRUE} ]]; then
|
||||||
eclean-${FLAGS_board} -d packages
|
eclean-${FLAGS_board} -d packages
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -752,7 +745,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
USE_DEV_KEYS=
|
USE_DEV_KEYS=
|
||||||
if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then
|
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
|
||||||
USE_DEV_KEYS="--use_dev_keys"
|
USE_DEV_KEYS="--use_dev_keys"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -766,9 +759,9 @@ ${SCRIPTS_DIR}/bin/cros_make_image_bootable "${OUTPUT_DIR}" \
|
|||||||
# should unconditionally test an image after crosbug12352 is fixed
|
# should unconditionally test an image after crosbug12352 is fixed
|
||||||
if [[ "${ARCH}" = "x86" ]] ||
|
if [[ "${ARCH}" = "x86" ]] ||
|
||||||
[[ "${ARCH}" = "arm" &&
|
[[ "${ARCH}" = "arm" &&
|
||||||
"${FLAGS_crosbug12352_arm_kernel_signing}" -eq "${FLAGS_TRUE}" ]]; then
|
${FLAGS_crosbug12352_arm_kernel_signing} -eq ${FLAGS_TRUE} ]]; then
|
||||||
BOOT_FLAG=
|
BOOT_FLAG=
|
||||||
if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then
|
if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
|
||||||
BOOT_FLAG="-b 1" # BOOT_FLAG_DEVELOPER value defined in load_kernel_fw.h
|
BOOT_FLAG="-b 1" # BOOT_FLAG_DEVELOPER value defined in load_kernel_fw.h
|
||||||
info "--factory_install set, pass BOOT_FLAG_DEVELOPER flag to \
|
info "--factory_install set, pass BOOT_FLAG_DEVELOPER flag to \
|
||||||
load_kernel_test"
|
load_kernel_test"
|
||||||
@ -780,7 +773,7 @@ load_kernel_test"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a developer image based on the chromium os base image.
|
# Create a developer image based on the chromium os base image.
|
||||||
if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ] ; then
|
if [ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ] ; then
|
||||||
if [[ ! -f ${DEVELOPER_IMG} ]] ; then
|
if [[ ! -f ${DEVELOPER_IMG} ]] ; then
|
||||||
echo "Creating developer image from base image ${PRISTINE_IMAGE_NAME}"
|
echo "Creating developer image from base image ${PRISTINE_IMAGE_NAME}"
|
||||||
cp ${PRISTINE_IMG} ${DEVELOPER_IMG}
|
cp ${PRISTINE_IMG} ${DEVELOPER_IMG}
|
||||||
@ -805,7 +798,7 @@ ln -s $(basename ${OUTPUT_DIR}) ${FLAGS_output_root}/${FLAGS_board}/latest
|
|||||||
|
|
||||||
echo "Done. Image created in ${OUTPUT_DIR}"
|
echo "Done. Image created in ${OUTPUT_DIR}"
|
||||||
echo "Chromium OS image created as ${PRISTINE_IMAGE_NAME}"
|
echo "Chromium OS image created as ${PRISTINE_IMAGE_NAME}"
|
||||||
if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then
|
if [ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]; then
|
||||||
echo "Developer image created as ${DEVELOPER_IMAGE_NAME}"
|
echo "Developer image created as ${DEVELOPER_IMAGE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user