NetBSD-Bugs archive

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

misc/57909: [RB] hp300/m68k mkboot: Don't include (build) timestamp when doing a reproducible build



>Number:         57909
>Category:       misc
>Synopsis:       [RB] hp300/m68k mkboot: Don't include (build) timestamp when doing a reproducible build
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 08 15:10:00 +0000 2024
>Originator:     Jan-Benedict Glaw
>Release:        current
>Organization:
>Environment:
Linux lili 5.16.0-4-amd64 #1 SMP PREEMPT Debian 5.16.12-1 (2022-03-08) x86_64 GNU/Linux
>Description:
I'm running lots of CI builds and started to actually also test reproducibility. For hp300/m68k, I noticed that build artifacts contain a timestamp.
>How-To-Repeat:
Build twice for hp300/m68k with `build.sh [...] -P` and compare artifacts.
>Fix:
diff --git a/sys/arch/hp300/stand/Makefile.buildboot b/sys/arch/hp300/stand/Makefile.buildboot
index 1f528d5d3f96..2ff61444b7e4 100644
--- a/sys/arch/hp300/stand/Makefile.buildboot
+++ b/sys/arch/hp300/stand/Makefile.buildboot
@@ -29,9 +29,13 @@ LIBC=
 LIBCRTBEGIN=
 LIBCRTEND=
 
+.if ${MKREPRO_TIMESTAMP:Uno} != "no"
+HP300MKBOOT_TIMESTAMP=-t "${MKREPRO_TIMESTAMP}"
+.endif
+
 ${PROG}: ${PROGAOUT}
        ${OBJCOPY} --output-target=binary ${PROGAOUT} ${PROGAOUT}.bin
-       ${TOOL_HP300MKBOOT} -l 0x${RELOC} ${PROGAOUT}.bin ${PROG}
+       ${TOOL_HP300MKBOOT} -l 0x${RELOC} ${HP300MKBOOT_TIMESTAMP} ${PROGAOUT}.bin ${PROG}
        rm -f ${PROGAOUT}.bin
 
 .include "${S}/conf/newvers_stand.mk"
diff --git a/sys/arch/hp300/stand/mkboot/mkboot.c b/sys/arch/hp300/stand/mkboot/mkboot.c
index 5f7bd7fecc1f..914d094c0f49 100644
--- a/sys/arch/hp300/stand/mkboot/mkboot.c
+++ b/sys/arch/hp300/stand/mkboot/mkboot.c
@@ -83,6 +83,7 @@ int   loadpoint;
 struct  load ld;
 struct lifvol lifv;
 struct lifdir lifd[LIF_NUMDIR];
+time_t repro_epoch = 0;
 
 int     main(int, char **);
 void    bcddate(char *, char *);
@@ -127,6 +128,15 @@ main(int argc, char **argv)
                argv++;
                argc--;
        }
+       if (!strcmp(argv[0], "-t")) {
+               argv++;
+               argc--;
+               if (argc == 0)
+                       usage();
+               repro_epoch = atol(argv[0]);
+               argv++;
+               argc--;
+       }
        if (!lpflag || argc == 0)
                usage();
        n1 = argv[0];
@@ -251,7 +261,7 @@ usage(void)
 {
 
        fprintf(stderr,
-               "usage:  mkboot -l loadpoint prog1 [ prog2 ] outfile\n");
+               "usage:  mkboot -l loadpoint [-t epoch] prog1 [ prog2 ] outfile\n");
        exit(1);
 }
 
@@ -284,8 +294,12 @@ bcddate(char *name, char *toc)
        struct stat statb;
        struct tm *tm;
 
-       stat(name, &statb);
-       tm = localtime(&statb.st_ctime);
+       if (repro_epoch)
+               tm = gmtime(&repro_epoch);
+       else {
+               stat(name, &statb);
+               tm = localtime(&statb.st_ctime);
+       }
        *toc = ((tm->tm_mon+1) / 10) << 4;
        *toc++ |= (tm->tm_mon+1) % 10;
        *toc = (tm->tm_mday / 10) << 4;



Home | Main Index | Thread Index | Old Index