From 7fe977104acd2f85aad6aced418e0c80a04302fd Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Tue, 12 Jul 2022 09:50:36 +0200 Subject: [PATCH] build_library: Try to clean up unused stuff There is some cruft left after grub hashes generation. After the contents are zipped into archive, they don't need to be around any more. Try to remove the rootfs directory after unmounting the image. disk_util can recreate it again if there is a need for it. Remove the build directory used for generating ACI images - it's not needed after successful installation. --- build_library/build_image_util.sh | 2 ++ build_library/vm_image_util.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 54b027558d..9981548711 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -31,6 +31,7 @@ set_build_symlinks() { cleanup_mounts() { info "Cleaning up mounts" "${BUILD_LIBRARY_DIR}/disk_util" umount "$1" || true + rmdir "${1}" || true } delete_prompt() { @@ -763,5 +764,6 @@ EOF pushd "${BUILD_DIR}" >/dev/null zip --quiet -r -9 "${BUILD_DIR}/${pcr_policy}" pcrs popd >/dev/null + rm -rf "${BUILD_DIR}/pcrs" fi } diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 9017e466bf..945f6170ec 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -512,6 +512,8 @@ install_oem_aci() { "${aci_path}" \ "${VM_TMP_ROOT}/usr/share/oem/flatcar-oem-${oem_aci}.aci" || die "Could not install ${oem_aci} OEM ACI" + # Remove aci_dir if building ACI and installing it succeeded + rm -rf "${aci_dir}" } # Any other tweaks required?