image_types: Ensure tar archives are reproducible
PATCH 1/2 image_types: Ensure tar archives are reproducible
The tar output seems to vary depending on the version of tar used and distro configuration. Be explict about the output format to avoid this and be determinstic.
--- meta/classes/image_types.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/image_types.bbclass +1 -1
@@ -110,7 +110,7 @@ IMAGE_CMD_squashfs-lz4 = "mksquashfs ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAM IMAGE_CMD_TAR ?= "tar" # ignore return code 1 "file changed as we read it" as other tasks(e.g. do_image_wic) may be hardlinking rootfs -IMAGE_CMD_tar = "${IMAGE_CMD_TAR} --sort=name --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.tar -C ${IMAGE_ROOTFS} . || [ $? -eq 1 ]" +IMAGE_CMD_tar = "${IMAGE_CMD_TAR} --sort=name --format=gnu --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.tar -C ${IMAGE_ROOTFS} . || [ $? -eq 1 ]" do_image_cpio[cleandirs] += "${WORKDIR}/cpio_append" IMAGE_CMD_cpio () {
Signature · 1 line
2.27.0
PATCH 2/2 qemu.inc: Should depend on qemu-system-native, not qemu-native
This looks like it was from before the recipe was split, we'd expect the system qemu mode for running the images so the dependency should be updated.
--- meta/conf/machine/include/qemu.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/machine/include/qemu.inc +1 -1
@@ -21,7 +21,7 @@ RDEPENDS_${KERNEL_PACKAGE_NAME}-base = "" # Use a common kernel recipe for all QEMU machines PREFERRED_PROVIDER_virtual/kernel ??= "linux-yocto" -EXTRA_IMAGEDEPENDS += "qemu-native qemu-helper-native" +EXTRA_IMAGEDEPENDS += "qemu-system-native qemu-helper-native" # Provide the nfs server kernel module for all qemu images KERNEL_FEATURES_append_pn-linux-yocto = " features/nfsd/nfsd-enable.scc"
Signature · 1 line
2.27.0
Quoted 5 lines · Richard Purdie
The tar output seems to vary depending on the version of tar used and distro
configuration. Be explict about the output format to avoid this and be determinstic.
Is it the tar format selection which isn't deterministic or something else when the format isn't set to gnu?
I'm asking because gnu format isn't compatible with --xattrs used e.g. here:
https://github.com/advancedtelematic/meta-updater/blob/d3a832f66e8802cb45536ff278d5c77f946d341d/classes/image_types_ostree.bbclass#L16
causing do_image_tar failing with:
| tar: --xattrs can be used only on POSIX archives | Try 'tar --help' or 'tar --usage' for more information.
I've already tested that --format=posix here would fix meta-updater, but not sure if it's still as deterministic as --format=gnu. Do you remember which distros were producing different output?
Thanks
Quoted 32 lines
Signed-off-by Richard Purdie <[email protected]>--- meta/classes/image_types.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta/classes/image_types.bbclass +0
-0@@ -110,7 +110,7 @@ IMAGE_CMD_squashfs-lz4 = "mksquashfs ${IMAGE_ROOTFS}${IMGDEPLOYDIR}/${IMAGE_NAM
IMAGE_CMD_TAR?= "tar"# ignore return code 1 "file changed as we read it" as other tasks(e.g. do_image_wic) may be hardlinking rootfs -IMAGE_CMD_tar = "${IMAGE_CMD_TAR} --sort=name --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.tar -C ${IMAGE_ROOTFS} . || [ $? -eq 1 ]"meta/classes/image_types.bbclass +1
-3+IMAGE_CMD_tar = "${IMAGE_CMD_TAR} --sort=name --format=gnu --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.tar -C ${IMAGE_ROOTFS} . || [ $? -eq 1 ]" do_image_cpio[cleandirs] += "${WORKDIR}/cpio_append" IMAGE_CMD_cpio () { --2.27.0
Quoted 11 lines · Martin Jansa
Quoted 6 lines · Richard Purdie
The tar output seems to vary depending on the version of tar used and distro
configuration. Be explict about the output format to avoid this and be
determinstic.Is it the tar format selection which isn't deterministic or something else when the format isn't set to gnu?
Different versions of tar seemed to be picking different output formats, I therefore picked one. I looked at which output format reproducible builds were recommending.
Quoted 6 lines
I'm asking because gnu format isn't compatible with --xattrs used e.g. here:
https://github.com/advancedtelematic/meta-updater/blob/d3a832f66e8802cb45536ff278d5c77f946d341d/classes/image_types_ostree.bbclass#L16
causingdo_image_tarfailing with:
Quoted 6 lines
| tar: --xattrs can be used only on POSIX archives | Try 'tar --help' or 'tar --usage' for more information.
I've already tested that --format=posix here would fix meta-updater, but not sure if it's still as deterministic as --format=gnu. Do you remember which distros were producing different output?
I think it was centos7 differing to ubuntu 18.04
Cheers,
Richard