From: Atharva Lele <itsatharva@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 1/3] autobuild-run: initial implementation of check_reproducibility()
Date: Fri, 7 Jun 2019 12:16:55 +0530 [thread overview]
Message-ID: <20190607064657.3571-1-itsatharva@gmail.com> (raw)
Find out differences in built images, if any
Add diffoscope to list of optional programs
Signed-off-by: Atharva Lele <itsatharva@gmail.com>
---
Changes v1 -> v2:
- move diffoscope output to results dir (suggested by arnout)
- fix make printvars call
- Add diffoscope to DEFAULT_OPTIONAL_PROGS
Signed-off-by: Atharva Lele <itsatharva@gmail.com>
---
scripts/autobuild-run | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/scripts/autobuild-run b/scripts/autobuild-run
index ef2f2a5..5d76583 100755
--- a/scripts/autobuild-run
+++ b/scripts/autobuild-run
@@ -204,7 +204,7 @@ def get_branch():
class SystemInfo:
DEFAULT_NEEDED_PROGS = ["make", "git", "gcc"]
- DEFAULT_OPTIONAL_PROGS = ["bzr", "java", "javac", "jar"]
+ DEFAULT_OPTIONAL_PROGS = ["bzr", "diffoscope", "java", "javac", "jar"]
def __init__(self):
self.needed_progs = list(self.__class__.DEFAULT_NEEDED_PROGS)
@@ -394,6 +394,45 @@ def stop_on_build_hang(monitor_thread_hung_build_flag,
break
monitor_thread_stop_flag.wait(30)
+def check_reproducibility(**kwargs):
+ """Check reproducibility of builds
+
+ Use diffoscope on the built images, if diffoscope is not
+ installed, fallback to cmp
+ """
+
+ log = kwargs['log']
+ idir = "instance-%d" % kwargs['instance']
+ outputdir = os.path.join(idir, "output")
+ srcdir = os.path.join(idir, "buildroot")
+ diffoscope_output = os.path.join(outputdir, "results", "diffoscope-results.txt")
+ # Using only tar images for now
+ build_1_image = os.path.join(outputdir, "images-1", "rootfs.tar")
+ build_2_image = os.path.join(outputdir, "images", "rootfs.tar")
+
+ # Prefix to point diffoscope towards cross-tools
+ prefix = subprocess.check_output(["make", "O=%s" % outputdir, "-C", srcdir, "printvars", "VARS=TARGET_CROSS"])
+ # Remove TARGET_CROSS= and \n from the string
+ prefix = prefix[13:-1]
+
+ if kwargs['sysinfo'].has("diffoscope"):
+ log_write(log, "INFO: running diffoscope on images")
+ ret = subprocess.call(["diffoscope", build_1_image, build_2_image,
+ "--tool-prefix-binutils", prefix,
+ "--text", diffoscope_output])
+ else:
+ if e.errno == errno.ENOENT:
+ log_write(log, "INFO: diffoscope not installed, falling back to cmp")
+ ret = subprocess.call(["cmp", "build_1_image", "build_2_image", "-b", ">", diffoscope_output])
+
+ if ret != 0:
+ log_write(log, "INFO: Build is non-reproducible.")
+ return -1
+
+ # rootfs images match byte-for-byte -> reproducible image
+ log_write(log, "INFO: Build is reproducible!")
+ return 0
+
def do_build(**kwargs):
"""Run the build itself"""
--
2.20.1
next reply other threads:[~2019-06-07 6:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-07 6:46 Atharva Lele [this message]
2019-06-07 6:46 ` [Buildroot] [PATCH v2 2/3] autobuild-run: initial implementation of do_reproducible_build() Atharva Lele
2019-06-07 8:33 ` Thomas Petazzoni
2019-06-07 8:39 ` Arnout Vandecappelle
2019-06-07 8:44 ` Thomas Petazzoni
2019-06-07 8:40 ` Atharva Lele
2019-06-08 11:40 ` Arnout Vandecappelle
2019-06-07 6:46 ` [Buildroot] [PATCH v2 3/3] autobuild-run: do reproducible builds tests if BR2_REPRODUCIBLE=y Atharva Lele
2019-06-08 11:46 ` Arnout Vandecappelle
2019-06-08 11:37 ` [Buildroot] [PATCH v2 1/3] autobuild-run: initial implementation of check_reproducibility() Arnout Vandecappelle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190607064657.3571-1-itsatharva@gmail.com \
--to=itsatharva@gmail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox