fix(build_library): Skip modifying non-existent partitions.

To make it possible to plop a CoreOS install into a simple
single-filesystem image for use as a container some things like
configuring bootloaders need to be skipped.
This commit is contained in:
Michael Marineau 2014-05-16 20:52:21 -07:00
parent ee6b9ee1f9
commit 54f774d931
2 changed files with 19 additions and 8 deletions

View File

@ -151,17 +151,22 @@ finish_image() {
--group="${update_group}" \
--board="${BOARD}"
${BUILD_LIBRARY_DIR}/configure_bootloaders.sh \
--arch=${ARCH} \
--disk_layout="${disk_layout}" \
--boot_dir="${root_fs_dir}"/usr/boot \
--esp_dir="${root_fs_dir}"/boot/efi \
--boot_args="${FLAGS_boot_args}"
# Only configure bootloaders if there is a boot partition
if mountpoint -q "${root_fs_dir}"/boot/efi; then
${BUILD_LIBRARY_DIR}/configure_bootloaders.sh \
--arch=${ARCH} \
--disk_layout="${disk_layout}" \
--boot_dir="${root_fs_dir}"/usr/boot \
--esp_dir="${root_fs_dir}"/boot/efi \
--boot_args="${FLAGS_boot_args}"
fi
# Zero all fs free space to make it more compressible so auto-update
# payloads become smaller, not fatal since it won't work on linux < 3.2
sudo fstrim "${root_fs_dir}" || true
sudo fstrim "${root_fs_dir}/usr" || true
if mountpoint -q "${root_fs_dir}/usr"; then
sudo fstrim "${root_fs_dir}/usr" || true
fi
cleanup_mounts "${root_fs_dir}"
trap - EXIT

View File

@ -63,10 +63,16 @@ EOF
sudo rm ${root_fs_dir}/etc/xinetd.d/rsyncd
sudo rmdir ${root_fs_dir}/etc/xinetd.d
# Only try to disable rw on /usr if there is a /usr partition
local disable_read_write=${FLAGS_enable_rootfs_verification}
if ! mountpoint -q "${root_fs_dir}/usr"; then
disable_read_write=${FLAGS_FALSE}
fi
finish_image "${disk_layout}" "${root_fs_dir}" "${update_group}"
# Make the filesystem un-mountable as read-write.
if [ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]; then
if [[ ${disable_read_write} -eq ${FLAGS_TRUE} ]]; then
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${disk_layout}" \
tune --disable2fs_rw "${BUILD_DIR}/${image_name}" "USR-A"
fi