Skip to contentSkip to conversation

opkg-utils: Fix reproducibility issues in opkg-build

PATCH In review Richard Purdie 2 participants 7 messages Feb 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 opkg-utils: Fix reproducibility issues in opkg-build

There is a sorting problem with opkg-build where the ipk generated is depending upon the order of files on disk. The reason is the --sort option to tar only influences the orders of files tar reads, not those passed by the -T option.

Add in a sort call to resolve this issue. To ensure consistent sorting we also need to force to a specific locale (C) else the results are still not deterministic.

---
 .../opkg-utils/fix-reproducibility.patch      | 32 +++++++++++++++++++
 .../opkg-utils/opkg-utils_0.4.2.bb            |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 meta/recipes-devtools/opkg-utils/opkg-utils/fix-reproducibility.patch
meta/recipes-devtools/opkg-utils/opkg-utils/fix-reproducibility.patch new file +32 -0
new file mode 100644
index 00000000000..945979bc8a7
@@ -0,0 +1,32 @@
+Fix reproducibility issues in opkg-build
+
+There is a sorting problem with opkg-build where the ipk generated is depending
+upon the order of files on disk. The reason is the --sort option to tar only
+influences the orders of files tar reads, not those passed by the -T option.
+
+Add in a sort call to resolve this issue. To ensure consistent sorting we
+also need to force to a specific locale (C) else the results are still not
+deterministic.
+
+RP 2020/2/5
+
+Upstream-Status: Submitted [https://groups.google.com/forum/#!topic/opkg-devel/YttZ73NLrYQ]
+Signed-off-by: Richard Purdie <[email protected]>
+
+Index: opkg-utils-0.4.2/opkg-build
+===================================================================
+--- opkg-utils-0.4.2.orig/opkg-build
++++ opkg-utils-0.4.2/opkg-build
+@@ -305,8 +305,10 @@ 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 -path . -o -print  > $tmp_dir/file_list )
++export LANG=C
++export LC_ALL=C
++( cd $pkg_dir/$CONTROL && find . -type f | sort > $tmp_dir/control_list )
++( cd $pkg_dir && find . -path ./$CONTROL -prune -o -path . -o -print  | sort > $tmp_dir/file_list )
+ ( 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
meta/recipes-devtools/opkg-utils/opkg-utils_0.4.2.bb +1 -0
index 8e7ef00b087..eda73db6a4b 100644
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
 PROVIDES += "${@bb.utils.contains('PACKAGECONFIG', 'update-alternatives', 'virtual/update-alternatives', '', d)}"
 
 SRC_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/${BPN}/snapshot/${BPN}-${PV}.tar.gz \ 
+           file://fix-reproducibility.patch \
 "
 UPSTREAM_CHECK_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/refs/"
 
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/6 oeqa/reproducible: Improve test output and ensure deb+ipk compared

Adding newline characters between the packages in the failure output massively improves readability.

Also ensure to output ipk failures when there are deb failures by calling self.fail() at the end, else sometimes only partial differences are returned.

---
 meta/lib/oeqa/selftest/cases/reproducible.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/reproducible.py +7 -2
index 04dc46f38a0..f6433c9a02b 100644
@@ -185,6 +185,8 @@ class ReproducibleTests(OESelftestTestCase):
         # NOTE: The temp directories from the reproducible build are purposely
         # kept after the build so it can be diffed for debugging.
 
+        fails = []
+
         for c in self.package_classes:
             with self.subTest(package_class=c):
                 package_class = 'package_' + c
@@ -208,8 +210,11 @@ class ReproducibleTests(OESelftestTestCase):
                         self.copy_file(d.test, '/'.join([save_dir, d.test]))
 
                 if result.missing or result.different:
-                    self.fail("The following %s packages are missing or different: %s" %
-                            (c, ' '.join(r.test for r in (result.missing + result.different))))
+                    fails.append("The following %s packages are missing or different: %s" %
+                            (c, '\n'.join(r.test for r in (result.missing + result.different))))
+
+        if fails:
+            self.fail('\n'.join(fails))
 
         # Clean up empty directories
         if self.save_results:
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 2/6] oeqa/reproducible: Improve test output and ensure deb+ipk compared

Quoted 23 lines · Richard Purdie

Adding newline characters between the packages in the failure output massively improves readability.

Also ensure to output ipk failures when there are deb failures by calling self.fail() at the end, else sometimes only partial differences are returned.

---
 meta/lib/oeqa/selftest/cases/reproducible.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/cases/reproducible.py +0 -0
index 04dc46f38a0..f6433c9a02b 100644
@@ -185,6 +185,8 @@ class ReproducibleTests(OESelftestTestCase):
         # NOTE: The temp directories from the reproducible build are

purposely

         # kept after the build so it can be diffed for debugging.

meta/lib/oeqa/selftest/cases/reproducible.py class ReproducibleTests(OESelftestTestCase): · line 191

Quoted 4 lines
meta/lib/oeqa/selftest/cases/reproducible.py +2 -0
+        fails = []
+
         for c in self.package_classes:
             with self.subTest(package_class=c):

It too bad subtests are broken. If we can't handle failed subtests, we can remove this line that creates the subtest in the first place.

package_class = 'package_' + c

Quoted 28 lines
meta/lib/oeqa/selftest/cases/reproducible.py +0 -1
@@ -208,8 +210,11 @@ class ReproducibleTests(OESelftestTestCase):
                         self.copy_file(d.test, '/'.join([save_dir,
 d.test]))
 
                 if result.missing or result.different:
-                    self.fail("The following %s packages are missing or

different: %s" %

meta/lib/oeqa/selftest/cases/reproducible.py +2 -1
-                            (c, ' '.join(r.test for r in (result.missing
+ result.different))))
+                    fails.append("The following %s packages are missing

or different: %s" %

meta/lib/oeqa/selftest/cases/reproducible.py +5 -1
+                            (c, '\n'.join(r.test for r in (result.missing
+ result.different))))
+
+        if fails:
+            self.fail('\n'.join(fails))
 
         # Clean up empty directories
         if self.save_results:
--

2.20.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#3 lore raw

PATCH 3/6 mc: Set zipinfo presence determinstically

In reply to Richard Purdie

This value was floating causing differences in generated files. Set it determinstically.

---
 meta/recipes-extended/mc/mc_4.8.23.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-extended/mc/mc_4.8.23.bb +1 -0
index 95fa1dae78d..d8c8f8643e1 100644
@@ -29,6 +29,7 @@ EXTRA_OECONF = "--with-screen=ncurses --without-gpm-mouse --without-x --disable-
 CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
 CACHED_CONFIGUREVARS += "ac_cv_path_PYTHON='/usr/bin/env python'"
 CACHED_CONFIGUREVARS += "ac_cv_path_GREP='/usr/bin/env grep'"
+CACHED_CONFIGUREVARS += "mc_cv_have_zipinfo=yes"
 
 do_install_append () {
 	sed -i -e '1s,#!.*perl,#!${bindir}/env perl,' ${D}${libexecdir}/mc/extfs.d/*
Signature · 1 line
2.20.1
#4 lore raw

PATCH 4/6 mc: Fix manpage date indeterminism

In reply to Richard Purdie

The man page date can vary depending upon the host perl, e.g. in Russian some versions print 'июня', others 'Июнь' or Polish 'czerwca' or 'czerwiec'. Rather than depend upon perl-native to fix this, just remove the date from the manpages.

---
 .../recipes-extended/mc/files/nomandate.patch | 21 +++++++++++++++++++
 meta/recipes-extended/mc/mc_4.8.23.bb         |  1 +
 2 files changed, 22 insertions(+)
 create mode 100644 meta/recipes-extended/mc/files/nomandate.patch
meta/recipes-extended/mc/files/nomandate.patch new file +21 -0
new file mode 100644
index 00000000000..48bd73b1102
@@ -0,0 +1,21 @@
+The man page date can vary depending upon the host perl, e.g. in Russian
+some versions print 'июня', others 'Июнь' or Polish 'czerwca' or 'czerwiec'.
+Rather than depend upon perl-native to fix this, just remove the date from 
+the manpages.
+
+RP 2020/2/4
+
+Upstream-Status: Inappropriate [OE specficic reproducibility workaround]
+Signed-off-by: Richard Purdie <[email protected]>
+
+Index: mc-4.8.23/doc/man/date-of-man-include.am
+===================================================================
+--- mc-4.8.23.orig/doc/man/date-of-man-include.am
++++ mc-4.8.23/doc/man/date-of-man-include.am
+@@ -1,5 +1,5 @@
+ SED_PARAMETERS = \
+-	-e "s/%DATE_OF_MAN_PAGE%/$${MAN_DATE}/g" \
++	-e "s/%DATE_OF_MAN_PAGE%//g" \
+ 	-e "s/%DISTR_VERSION%/@DISTR_VERSION@/g" \
+ 	-e "s{%prefix%{@prefix@{g" \
+ 	-e "s{%sysconfdir%{@sysconfdir@{g" \
meta/recipes-extended/mc/mc_4.8.23.bb +1 -0
index d8c8f8643e1..ead348b92e7 100644
@@ -11,6 +11,7 @@ SRC_URI = "http://www.midnight-commander.org/downloads/${BPN}-${PV}.tar.bz2 \
            file://0001-mc-replace-perl-w-with-use-warnings.patch \
            file://0001-Add-option-to-control-configure-args.patch \
            file://0001-Ticket-3629-configure.ac-drop-bundled-gettext.patch \
+           file://nomandate.patch \
            "
 SRC_URI[md5sum] = "152927ac29cf0e61d7d019f261bb7d89"
 SRC_URI[sha256sum] = "238c4552545dcf3065359bd50753abbb150c1b22ec5a36eaa02c82808293267d"
Signature · 1 line
2.20.1
#5 lore raw

PATCH 5/6 patch: Extend to native/nativesdk and depend upon

In reply to Richard Purdie

There is a bug in patch 2.7.3 and earlier where index lines in patches can change file modes when they shouldn't:
http://git.savannah.gnu.org/cgit/patch.git/patch/?id=82b800c9552a088a241457948219d25ce0a407a4

This leaks into debug sources in particular (e.g. tcp-wrappers where source files are read-only). Add the dependency to target recipes to avoid this problem until we can rely on 2.7.4 or later.

We could try and remove all index lines from patch files but it will be a losing battle. We could try and identify all the recipes which change modes on files in patches but again, its a losing battle.

Instead, compromise and have patch-native as a dependency for target recipes. We use patch-replacement-native since patch-native is in ASSUME_PROVIDED.

Also add nativesdk-patch to buildtools-tarball.

[YOCTO #13777]

---
 meta/classes/patch.bbclass                   | 7 +++++++
 meta/recipes-core/meta/buildtools-tarball.bb | 1 +
 meta/recipes-devtools/patch/patch_2.7.6.bb   | 3 +++
 3 files changed, 11 insertions(+)
meta/classes/patch.bbclass +7 -0
index cd241f1c848..25ec089ae12 100644
@@ -5,6 +5,13 @@ QUILTRCFILE ?= "${STAGING_ETCDIR_NATIVE}/quiltrc"
 
 PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
 
+# There is a bug in patch 2.7.3 and earlier where index lines
+# in patches can change file modes when they shouldn't:
+# http://git.savannah.gnu.org/cgit/patch.git/patch/?id=82b800c9552a088a241457948219d25ce0a407a4
+# This leaks into debug sources in particular. Add the dependency
+# to target recipes to avoid this problem until we can rely on 2.7.4 or later.
+PATCHDEPENDENCY_append_class-target = " patch-replacement-native:do_populate_sysroot"
+
 PATCH_GIT_USER_NAME ?= "OpenEmbedded"
 PATCH_GIT_USER_EMAIL ?= "oe.patch@oe"
 
meta/recipes-core/meta/buildtools-tarball.bb +1 -0
index 95ebda7fa15..aa55cde84a9 100644
@@ -25,6 +25,7 @@ TOOLCHAIN_HOST_TASK ?= "\
     nativesdk-texinfo \
     nativesdk-libnss-nis \
     nativesdk-rpcsvc-proto \
+    nativesdk-patch \
     "
 
 MULTIMACH_TARGET_SYS = "${SDK_ARCH}-nativesdk${SDK_VENDOR}-${SDK_OS}"
meta/recipes-devtools/patch/patch_2.7.6.bb +3 -0
index 5d7f55f8dc3..b5897b357ae 100644
@@ -22,3 +22,6 @@ acpaths = "-I ${S}/m4 "
 PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'xattr', d)}"
 PACKAGECONFIG[xattr] = "--enable-xattr,--disable-xattr,attr,"
 
+PROVIDES_append_class-native = " patch-replacement-native"
+
+BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.20.1
#6 lore raw

PATCH 6/6 xserver-xorg: Fix reproducibility issue

In reply to Richard Purdie

The host kernel version was being encoded into the Xorg binary. Set an appropriate configure option to avoid this and be deterministic.

---
 meta/recipes-graphics/xorg-xserver/xserver-xorg.inc | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-graphics/xorg-xserver/xserver-xorg.inc +1 -0
index a0ae65c785d..14ba6bfee6c 100644
@@ -117,6 +117,7 @@ EXTRA_OECONF += "--with-fop=no \
                  --sysconfdir=/etc/X11 \
                  --localstatedir=/var \
                  --with-xkb-output=/var/lib/xkb \
+                 --with-os-name=Linux \
 "
 
 OPENGL_PKGCONFIGS = "dri glx glamor dri3 xshmfence"
Signature · 1 line
2.20.1