NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

misc/57911: [RB] hppa/hppa mkboot.c: Allow to set repro timestamp (and use it)



>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
>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}



Home | Main Index | Thread Index | Old Index