From patchwork Tue Jun 11 12:34:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Lele X-Patchwork-Id: 1113794 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="k6SQq4Sg"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45NTwK0sMzz9sN4 for ; Tue, 11 Jun 2019 22:34:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6130E87BDE; Tue, 11 Jun 2019 12:34:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CpkJOdFm432z; Tue, 11 Jun 2019 12:34:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 99BC687B3D; Tue, 11 Jun 2019 12:34:34 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id BB3CD1BF97C for ; Tue, 11 Jun 2019 12:34:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B810720447 for ; Tue, 11 Jun 2019 12:34:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fpwkBCdwucB1 for ; Tue, 11 Jun 2019 12:34:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by silver.osuosl.org (Postfix) with ESMTPS id B00B520031 for ; Tue, 11 Jun 2019 12:34:32 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id 196so6910804pgc.6 for ; Tue, 11 Jun 2019 05:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MPV2UGhI1Kp3ThTiooSgARDJVcscNdyhXko/sj6UzTg=; b=k6SQq4SgjgQcbklj8i/yu580OqBzmnaMG6ryUyv1kmJx51l7wnLycx3LJoOZXv+WX0 cZ5z+yu18gLPzprsQfKdI1AsgGAqitKJ7weL170SMP3kaSoZOv/RicirUdxiMXKQXDjR a1Q0mszEpjNjasyD8pONU5DroYwgxRoyowI/47AXbcfTKWPL3+jChRR2kmSp+Ztkw7fo mOexls75CqAXHeeeFQHRSrD7SYVIAUjOKXw4xQ0N3tBk2x64Oed6AHbG2nkUBhxNiflM mi//ZDTJS8bq+M0KeqdEytl7U4WTKK7R4FP5ZB9Ti91vfTR72nWlXmKaWvDNR5sc4k8o 0v1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MPV2UGhI1Kp3ThTiooSgARDJVcscNdyhXko/sj6UzTg=; b=RkzpXCnPyyHq5psP4WE5HrGHV0Tcx0p6dKQAwCl84Kbcp/mAA9IwDYNzQ0DeqDNXaE si6PnpcN+2yjElg2w7ercTEvdLsc0oucoUPFhJingLp/FstyWqdGhiMGpXEo0QAcsPn1 RxYRRkqiA/L6agcq3WkkM8GO/MGfHxPljpi84S+d71gqhL8i/mx7w0wzgM4mNbAYljWz ATjz/0nXQDwisMQ8wXi9cmTQmmeReI25rkY7nPu6L1TaFb050sCqZzMdyYeCOUW7i1f8 bGIuZXG9BH1SuBLx2X7UOCLpSwG8qt0b6GAoXEu3urO0n51OY0bF/TwEglfRl+mWVxt+ sgUw== X-Gm-Message-State: APjAAAWRRykjrX4s2UfRlHZdNrkVdRd/6lkSZBAf+rBwLpfi7FoO3agd nnuiJOKG2vK5fnDJHZ1bo+0rKrU+SO14tg== X-Google-Smtp-Source: APXvYqz/khGzKguIvBXPcU76Lo7RzRJWXC7IMkxy2dMpy92TjWSiSfU7/SD0r7aSQ7QUWlTTsXo0rw== X-Received: by 2002:a62:1dd0:: with SMTP id d199mr27583056pfd.257.1560256471420; Tue, 11 Jun 2019 05:34:31 -0700 (PDT) Received: from localhost.localdomain ([123.201.52.193]) by smtp.gmail.com with ESMTPSA id n2sm17747985pgp.27.2019.06.11.05.34.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 05:34:30 -0700 (PDT) From: Atharva Lele To: buildroot@buildroot.org Date: Tue, 11 Jun 2019 18:04:14 +0530 Message-Id: <20190611123416.11533-1-itsatharva@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 1/3] autobuild-run: initial implementation of check_reproducibility() X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Atharva Lele , yann.morin.1998@free.fr, thomas.petazzoni@bootlin.com Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" For reproducible builds, we want to find out if there are any differences between two builds having the same configuration, and to find the reason behind them. The diffoscope tool looks inside different types of files to see where the differences lie. check_reproducibility() runs diffoscope on two output directories which are expected in output/images and output/images-1. Since it uses objdump, it needs to be provided the cross-compile prefix which is derived from the TARGET_CROSS variable. Since diffoscope may not be installed, we fall back to cmp for byte-by-byte comparison. We add diffoscope to list of optional programs to avoid repeated checking of its presence. Signed-off-by: Atharva Lele Reviewed-by: Yann E. MORIN --- Changes v2 -> v3: - Use file size of reproducible_results to check reproducibility status, rather than exit status of cmp or diff (suggested by arnout) - Rename results file (diffoscope_output.txt -> reproducible_results) to avoid confusion - Change handling of diffoscope output text file using with open() - Changed commit message to have all necessary info (suggested by arnout) - Removed leftover code from when I was using an exception to handle diffoscope presense (thanks to arnout) 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 --- scripts/autobuild-run | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/autobuild-run b/scripts/autobuild-run index 190a254..ba5b337 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,43 @@ 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") + reproducible_results = os.path.join(outputdir, "results", "reproducible_results") + # 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") + + with open(reproducible_results, 'w') as diff: + if kwargs['sysinfo'].has("diffoscope"): + # 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] + log_write(log, "INFO: running diffoscope on images") + subprocess.call(["diffoscope", build_1_image, build_2_image, + "--tool-prefix-binutils", prefix], stdout=diff, stderr=log) + else: + log_write(log, "INFO: diffoscope not installed, falling back to cmp") + subprocess.call(["cmp", "-b", "build_1_image", "build_2_image"], stdout=diff, stderr=log) + + if os.stat(reproducible_results).st_size > 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"""