]> code.ossystems Code Review - openembedded-core.git/commitdiff
classes/kernel: Generate reproducible kernel module tarball
authorJoshua Watt <JPEWhacker@gmail.com>
Tue, 12 May 2020 21:19:24 +0000 (16:19 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 May 2020 13:13:50 +0000 (14:13 +0100)
If reproducible binaries are requested, generate the kernel modules
tarball in a reproducible way. Namely, sort the tarball contents, clamp
the mtime to the source date epoch, compress the archive with a
consistent compression level (9), and don't include the name and
timestamp in the compressed file.

[YOCTO #12719]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/kernel.bbclass

index a724645466a5237d85b8db0f96b39e2c05692823..6846d6040df6ac4380468cfa83d924b6b7f91736 100644 (file)
@@ -691,7 +691,13 @@ kernel_do_deploy() {
 
        if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
                mkdir -p ${D}${root_prefix}/lib
-               tar -cvzf $deployDir/modules-${MODULE_TARBALL_NAME}.tgz -C ${D}${root_prefix} lib
+               if [ -n "${SOURCE_DATE_EPOCH}" ]; then
+                       TAR_ARGS="--sort=name --clamp-mtime --mtime=@${SOURCE_DATE_EPOCH}"
+               else
+                       TAR_ARGS=""
+               fi
+               tar $TAR_ARGS -cv -C ${D}${root_prefix} lib | gzip -9n > $deployDir/modules-${MODULE_TARBALL_NAME}.tgz
+
                ln -sf modules-${MODULE_TARBALL_NAME}.tgz $deployDir/modules-${MODULE_TARBALL_LINK_NAME}.tgz
        fi