From f4829fd86007587c5531cd90a285630d6e1d583c Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Mon, 30 Jan 2023 13:25:48 +0100 Subject: [PATCH] build_library: Add generation of image contents with different details Timestamp and user/group information are out, in are device ID and inode number. That way, the file can be used for accounting size differences of files/image. --- build_library/build_image_util.sh | 36 +++++++++++++++++++++++++---- build_library/dev_container_util.sh | 4 +++- build_library/prod_image_util.sh | 3 +++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 409693268b..40fb4e3eda 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -244,12 +244,36 @@ systemd_enable() { write_contents() { info "Writing ${2##*/}" pushd "$1" >/dev/null + # %M - file permissions + # %n - number of hard links to file + # %u - file's user name + # %g - file's group name + # %s - size in bytes + # %Tx - modification time (Y - year, m - month, d - day, H - hours, M - minutes) + # %P - file's path + # %l - symlink target (empty if not a symlink) sudo TZ=UTC find -printf \ '%M %2n %-7u %-7g %7s %TY-%Tm-%Td %TH:%TM ./%P -> %l\n' \ | sed -e 's/ -> $//' > "$2" popd >/dev/null } +# Generate a listing that can be used by other tools to analyze +# image/file size changes. +write_contents_with_technical_details() { + info "Writing ${2##*/}" + pushd "$1" >/dev/null + # %M - file permissions + # %D - ID of a device where file resides + # %i - inode number + # %n - number of hard links to file + # %s - size in bytes + # %P - file's path + sudo find -printf \ + '%M %D %i %n %s ./%P\n' > "$2" + popd >/dev/null +} + # "equery list" a potentially uninstalled board package query_available_package() { local pkg="$1" @@ -624,11 +648,12 @@ finish_image() { local disk_layout="$2" local root_fs_dir="$3" local image_contents="$4" - local image_kernel="$5" - local pcr_policy="$6" - local image_grub="$7" - local image_shim="$8" - local image_kconfig="$9" + local image_contents_wtd="$5" + local image_kernel="$6" + local pcr_policy="$7" + local image_grub="$8" + local image_shim="$9" + local image_kconfig="${10}" local install_grub=0 local disk_img="${BUILD_DIR}/${image_name}" @@ -731,6 +756,7 @@ EOF fi write_contents "${root_fs_dir}" "${BUILD_DIR}/${image_contents}" + write_contents_with_technical_details "${root_fs_dir}" "${BUILD_DIR}/${image_contents_wtd}" # 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 diff --git a/build_library/dev_container_util.sh b/build_library/dev_container_util.sh index 7fa195b443..8710b304fd 100755 --- a/build_library/dev_container_util.sh +++ b/build_library/dev_container_util.sh @@ -77,6 +77,7 @@ create_dev_container() { info "Building developer image ${image_name}" local root_fs_dir="${BUILD_DIR}/rootfs" local image_contents="${image_name%.bin}_contents.txt" + local image_contents_wtd="${image_name%.bin}_contents_wtd.txt" local image_packages="${image_name%.bin}_packages.txt" local image_licenses="${image_name%.bin}_licenses.json" @@ -104,7 +105,7 @@ create_dev_container() { # The remount services are provided by coreos-base/coreos-init systemd_enable "${root_fs_dir}" "multi-user.target" "remount-usr.service" - finish_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${image_contents}" + finish_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${image_contents}" "${image_contents_wtd}" declare -a files_to_evaluate declare -a compressed_images @@ -115,6 +116,7 @@ create_dev_container() { upload_image -d "${BUILD_DIR}/${image_name}.DIGESTS" \ "${BUILD_DIR}/${image_contents}" \ + "${BUILD_DIR}/${image_contents_wtd}" \ "${BUILD_DIR}/${image_packages}" \ "${BUILD_DIR}/${image_licenses}" \ "${compressed_images[@]}" \ diff --git a/build_library/prod_image_util.sh b/build_library/prod_image_util.sh index 77502402bb..8f5d514f4b 100755 --- a/build_library/prod_image_util.sh +++ b/build_library/prod_image_util.sh @@ -65,6 +65,7 @@ create_prod_image() { info "Building production image ${image_name}" local root_fs_dir="${BUILD_DIR}/rootfs" local image_contents="${image_name%.bin}_contents.txt" + local image_contents_wtd="${image_name%.bin}_contents_wtd.txt" local image_packages="${image_name%.bin}_packages.txt" local image_sbom="${image_name%.bin}_sbom.json" local image_licenses="${image_name%.bin}_licenses.json" @@ -131,6 +132,7 @@ EOF "${disk_layout}" \ "${root_fs_dir}" \ "${image_contents}" \ + "${image_contents_wtd}" \ "${image_kernel}" \ "${image_pcr_policy}" \ "${image_grub}" \ @@ -140,6 +142,7 @@ EOF # Upload local to_upload=( "${BUILD_DIR}/${image_contents}" + "${BUILD_DIR}/${image_contents_wtd}" "${BUILD_DIR}/${image_packages}" "${BUILD_DIR}/${image_sbom}" "${BUILD_DIR}/${image_licenses}"