Skip to contentSkip to conversation

opkg-utils: respect SOURCE_DATE_EPOCH when building ipkgs

PATCH New Ross Burton 1 participant 1 message Sep 17, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opkg-utils: respect SOURCE_DATE_EPOCH when building ipkgs

Backport a patch from upstream to respect SOURCE_DATE_EPOCH when building ipkgs, to ensure reproducible archives.

---
 ...ld-clamp-mtimes-to-SOURCE_DATE_EPOCH.patch | 44 +++++++++++++++++++
 .../opkg-utils/opkg-utils_0.4.1.bb            |  1 +
 2 files changed, 45 insertions(+)
 create mode 100644 meta/recipes-devtools/opkg-utils/opkg-utils/0001-opkg-build-clamp-mtimes-to-SOURCE_DATE_EPOCH.patch
meta/recipes-devtools/opkg-utils/opkg-utils/0001-opkg-build-clamp-mtimes-to-SOURCE_DATE_EPOCH.patch new file +44 -0
new file mode 100644
index 00000000000..a181169d476
@@ -0,0 +1,44 @@
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <[email protected]>
+
+From 59da5577bf8df441c6ca958e50fcb83228702764 Mon Sep 17 00:00:00 2001
+From: Alejandro del Castillo <[email protected]>
+Date: Thu, 12 Sep 2019 10:24:58 -0500
+Subject: [PATCH] opkg-build: clamp mtimes to SOURCE_DATE_EPOCH
+
+For reproducible builds, clamp mtimes bigger than SOURCE_DATE_EPOCH to
+SOURCE_DATE_EPOCH (build generated files, usually).
+
+Fixes bugzilla 13450
+
+Signed-off-by: Alejandro del Castillo <[email protected]>
+Signed-off-by: Ross Burton <[email protected]>
+---
+ opkg-build | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/opkg-build b/opkg-build
+index dcd2d68..2517a2b 100755
+--- a/opkg-build
++++ b/opkg-build
+@@ -297,9 +297,16 @@ mkdir $tmp_dir
+ 
+ build_date="${SOURCE_DATE_EPOCH:-$(date +%s)}"
+ 
++mtime_args=""
++# --clamp-mtime requires tar > 1.28. Only use it if SOURCE_DATE_EPOCH is set, to avoid having a generic case dependency on tar > 1.28.
++# this setting will make sure files generated at build time have consistent mtimes, for reproducible builds.
++if [ ! -z "$SOURCE_DATE_EPOCH"  ]; then
++    mtime_args="--mtime=@$build_date --clamp-mtime"
++fi
++
+ ( cd $pkg_dir/$CONTROL && find . -type f > $tmp_dir/control_list )
+ ( cd $pkg_dir && find . -path ./$CONTROL -prune -o -print > $tmp_dir/file_list )
+-( cd $pkg_dir && tar $ogargs $tsortargs --no-recursion -c $tarformat -T $tmp_dir/file_list | $compressor $compressorargs > $tmp_dir/data.tar.$cext )
++( cd $pkg_dir && tar $ogargs $tsortargs --no-recursion $mtime_args -c $tarformat -T $tmp_dir/file_list | $compressor $compressorargs > $tmp_dir/data.tar.$cext )
+ ( cd $pkg_dir/$CONTROL && tar $ogargs $tsortargs --no-recursion --mtime=@$build_date -c $tarformat -T $tmp_dir/control_list | gzip $zipargs > $tmp_dir/control.tar.gz )
+ rm $tmp_dir/file_list
+ rm $tmp_dir/control_list
+-- 
+2.20.1
+
meta/recipes-devtools/opkg-utils/opkg-utils_0.4.1.bb +1 -0
index 4be7b16d8a2..cf1e4670c65 100644
@@ -9,6 +9,7 @@ PROVIDES += "${@bb.utils.contains('PACKAGECONFIG', 'update-alternatives', 'virtu
 
 SRC_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/${BPN}/snapshot/${BPN}-${PV}.tar.gz \
            file://0001-Switch-all-scripts-to-use-Python-3.x.patch \
+           file://0001-opkg-build-clamp-mtimes-to-SOURCE_DATE_EPOCH.patch \
 "
 UPSTREAM_CHECK_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/refs/"
 
Signature · 1 line
2.20.1