NetBSD Problem Report #57911

From www@netbsd.org  Thu Feb  8 18:49:31 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 274161A9238
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  8 Feb 2024 18:49:31 +0000 (UTC)
Message-Id: <20240208184929.6F9DB1A9239@mollari.NetBSD.org>
Date: Thu,  8 Feb 2024 18:49:29 +0000 (UTC)
From: jbglaw@lug-owl.de
Reply-To: jbglaw@lug-owl.de
To: gnats-bugs@NetBSD.org
Subject: [RB] hppa/hppa mkboot.c: Allow to set repro timestamp (and use it)
X-Send-Pr-Version: www-1.0

>Number:         57911
>Category:       misc
>Synopsis:       [RB] hppa/hppa mkboot.c: Allow to set repro timestamp (and use it)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 08 18:50:00 +0000 2024
>Last-Modified:  Thu Feb 08 19:25:01 +0000 2024
>Originator:     Jan-Benedict Glaw
>Release:        current
>Organization:
>Environment:
>Description:
Using CI builds, I found out that the hppa port cannot be build reproducible.
>How-To-Repeat:
Build twice, compare build artifacts.
>Fix:
diff --git a/distrib/hppa/kernel/Makefile b/distrib/hppa/kernel/Makefile
index f3ba00dc2965..210f766f6d1f 100644
--- a/distrib/hppa/kernel/Makefile
+++ b/distrib/hppa/kernel/Makefile
@@ -13,8 +13,12 @@ MDSET_RELEASEDIR=    binary/kernel

 LIF=   netinstall.lif

+.if ${MKREPRO_TIMESTAMP:Uno} != "no"
+MKBOOT_TIMESTAMP=-t "${MKREPRO_TIMESTAMP}"
+.endif
+
 MDSET_POST = \
-       ${MKBOOT} ${DESTDIR}/usr/mdec/boot ${.TARGET} ${LIF}
+       ${MKBOOT} ${MKBOOT_TIMESTAMP} ${DESTDIR}/usr/mdec/boot ${.TARGET} ${LIF}

 .include "${DISTRIBDIR}/common/Makefile.mdset"

diff --git a/distrib/hppa/sysnbsd/Makefile b/distrib/hppa/sysnbsd/Makefile
index 7c9f6c281d62..640536a911b9 100644
--- a/distrib/hppa/sysnbsd/Makefile
+++ b/distrib/hppa/sysnbsd/Makefile
@@ -10,8 +10,12 @@ MKBOOT = ${TOOLDIR}/bin/${_TOOL_PREFIX}hppa-mkboot
 KERN=  ${KERNOBJDIR}/GENERIC/netbsd
 LIF=   SYSNBSD

-release: check_RELEASEDIR 
-       ${MKBOOT} ${DESTDIR}/usr/mdec/boot ${KERN} ${.OBJDIR}/${LIF}
+.if ${MKREPRO_TIMESTAMP:Uno} != "no"
+MKBOOT_TIMESTAMP=-t "${MKREPRO_TIMESTAMP}"
+.endif
+
+release: check_RELEASEDIR
+       ${MKBOOT} ${MKBOOT_TIMESTAMP} ${DESTDIR}/usr/mdec/boot ${KERN} ${.OBJDIR}/${LIF}
        ${RELEASE_INSTALL} ${.OBJDIR}/${LIF} \
            ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation

diff --git a/sys/arch/hppa/stand/mkboot/mkboot.c b/sys/arch/hppa/stand/mkboot/mkboot.c
index 0ed22d455235..07232dccb582 100644
--- a/sys/arch/hppa/stand/mkboot/mkboot.c
+++ b/sys/arch/hppa/stand/mkboot/mkboot.c
@@ -115,6 +115,7 @@ int cksum(int, int *, int);
 char *to_file;
 int loadpoint, verbose;
 u_long entry;
+time_t repro_epoch = 0;

 /*
  * Old Format:
@@ -140,7 +141,7 @@ main(int argc, char **argv)
        struct hppa_lifvol *lifv = (struct hppa_lifvol *)buf;
        struct hppa_lifdir *lifd = (struct hppa_lifdir *)(buf + HPPA_LIF_DIRSTART);

-       while ((c = getopt(argc, argv, "vl:")) != -1) {
+       while ((c = getopt(argc, argv, "vl:t:")) != -1) {
                switch (c) {
                case 'v':
                        verbose++;
@@ -148,6 +149,9 @@ main(int argc, char **argv)
                case 'l':
                        sscanf(optarg, "0x%x", &loadpoint);
                        break;
+               case 't':
+                       repro_epoch = atol(optarg);
+                       break;
                default:
                        usage();
                }
@@ -374,7 +378,7 @@ void __dead
 usage(void)
 {
        fprintf(stderr,
-               "usage: %s [-v] [-l loadpoint] prog1 {progN} outfile\n",
+               "usage: %s [-v] [-l loadpoint] [-t epoch] prog1 {progN} outfile\n",
                getprogname());
        exit(1);
 }
@@ -411,8 +415,12 @@ bcddate(char *file, char *toc)
        struct stat statb;
        struct tm *tm;

-       stat(file, &statb);
-       tm = localtime(&statb.st_ctime);
+       if (repro_epoch)
+               tm = gmtime(&repro_epoch);
+       else {
+               stat(file, &statb);
+               tm = localtime(&statb.st_ctime);
+       }
        tm->tm_year %= 100;
        *toc = (tm->tm_year / 10) << 4;
        *toc++ |= tm->tm_year % 10;
diff --git a/distrib/hppa/cdroms/Makefile.cdrom b/distrib/hppa/cdroms/Makefile.cdrom
index dc6a842dc169..ff5a3aaabc3c 100644
--- a/distrib/hppa/cdroms/Makefile.cdrom
+++ b/distrib/hppa/cdroms/Makefile.cdrom
@@ -6,6 +6,10 @@ CDMAKEFSOPTIONS=       generic-bootimage=cdrom/${BOOTFILE}
 CDINSTKERNEL=          ../../kernel
 CDKERNELS=             netbsd-RAMDISK  netbsd  # from ../instkernel

+.if ${MKREPRO_TIMESTAMP:Uno} != "no"
+MKBOOT_TIMESTAMP=-t "${MKREPRO_TIMESTAMP}"
+.endif
+
 prepare_md_post:
        ${RM} -f cdrom/${BOOTFILE}
-       ${TOOL_HPPAMKBOOT} ${DESTDIR}/usr/mdec/cdboot cdrom/${BOOTFILE}
+       ${TOOL_HPPAMKBOOT} ${MKBOOT_TIMESTAMP} ${DESTDIR}/usr/mdec/cdboot cdrom/${BOOTFILE}

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57911 CVS commit: src
Date: Thu, 8 Feb 2024 14:24:43 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Thu Feb  8 19:24:43 UTC 2024

 Modified Files:
 	src/distrib/hppa/sysnbsd: Makefile
 	src/sys/arch/hppa/stand/mkboot: mkboot.c

 Log Message:
 PR/57911: Jan-Benedict Glaw: Allow to set repro timestamp (and use it)


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/distrib/hppa/sysnbsd/Makefile
 cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/stand/mkboot/mkboot.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.