From b791de076aaa4df60d7560c5381aa13a48ac692f Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 21 Mar 2023 09:57:01 +1300 Subject: [PATCH] Add checksum generation support DIB_CHECKSUM is set by the disk-image-create --checksum flag, and for other images results in checksum files being generated for the image[1]. This change ensures checksum files are generated for built ramdisk/kernel as well. [1] https://opendev.org/openstack/diskimage-builder/src/branch/master/diskimage_builder/lib/common-functions#L68 Change-Id: I6128fbad5d9db2ea6469f196f3ee13b6fab76837 (cherry picked from commit 59d79f6ccd45e55ca72d7c971a74eb202702ce4e) --- dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create | 6 ++++++ dib/ironic-ramdisk-base/environment.d/10-checksum.bash | 1 + 2 files changed, 7 insertions(+) create mode 100644 dib/ironic-ramdisk-base/environment.d/10-checksum.bash diff --git a/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create b/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create index cd45aec..e538839 100755 --- a/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create +++ b/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create @@ -86,5 +86,11 @@ fi select_boot_kernel_initrd $TARGET_ROOT sudo cp $BOOTDIR/$KERNEL ${IMAGE_PATH}.kernel sudo chown $USER: ${IMAGE_PATH}.kernel +if [ "$DIB_CHECKSUM" == "1" ]; then + pushd $(dirname ${IMAGE_PATH}) + md5sum ${IMAGE_NAME}.initramfs ${IMAGE_NAME}.kernel > ${IMAGE_NAME}.md5 + sha256sum ${IMAGE_NAME}.initramfs ${IMAGE_NAME}.kernel > ${IMAGE_NAME}.sha256 + popd +fi # Output image sizes for debugging sudo ls -lh ${IMAGE_PATH}.* diff --git a/dib/ironic-ramdisk-base/environment.d/10-checksum.bash b/dib/ironic-ramdisk-base/environment.d/10-checksum.bash new file mode 100644 index 0000000..ea13dac --- /dev/null +++ b/dib/ironic-ramdisk-base/environment.d/10-checksum.bash @@ -0,0 +1 @@ +export DIB_CHECKSUM=${DIB_CHECKSUM:-0} \ No newline at end of file