NetBSD-Bugs archive

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

misc/57906: [RB] bebox/powerpc: Extend`mkbootimage` to allow for $MKREPRO_TIMESTAMP usage



>Number:         57906
>Category:       misc
>Synopsis:       [RB] bebox/powerpc: Extend`mkbootimage` to allow for $MKREPRO_TIMESTAMP usage
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 07 10: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 doing CI builds with `build.sh -P`, but for bebox/powerpc, we still have a timestamp in the boot image.
>How-To-Repeat:
Build two times with `build.sh -P` on different dates and compare the release artifacts.
>Fix:
The suggested patch allows for a new parameter, `-t <epoch>`, to set the image creation time based on the repo's top commit timestamp. Makefile is changed to use this feature if `$MKREPRO_TIMESTAMP` is set:

diff --git a/distrib/bebox/floppies/bootfloppy-common/Makefile.inc b/distrib/bebox/floppies/bootfloppy-common/Makefile.inc
index 388ddd421bb9..adfdcd9f226b 100644
--- a/distrib/bebox/floppies/bootfloppy-common/Makefile.inc
+++ b/distrib/bebox/floppies/bootfloppy-common/Makefile.inc
@@ -9,8 +9,13 @@
 MDEC?=         ${DESTDIR}/usr/mdec
 BOOTLOADER?=   ${MDEC}/boot
 
+.if ${MKREPRO_TIMESTAMP:Uno} != "no"
+MKBOOTIMAGE_TIMESTAMP=-t "${MKREPRO_TIMESTAMP}"
+.endif
+
+
 ${IMAGE}:
-       ${TOOL_POWERPCMKBOOTIMAGE} -I -m ${MACHINE} -b ${BOOTLOADER} ${.TARGET}
+       ${TOOL_POWERPCMKBOOTIMAGE} -I -m ${MACHINE} -b ${BOOTLOADER} ${MKBOOTIMAGE_TIMESTAMP} ${.TARGET}
 
 KFILES=        ${IMAGE}
 
diff --git a/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c b/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c
index 1542ec3e69e8..d48443efaad3 100644
--- a/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c
+++ b/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c
@@ -127,10 +127,10 @@ usage(int extended)
        }
 #ifdef USE_SYSCTL
        fprintf(stderr, "usage: %s [-Ilsv] [-m machine] [-b bootfile] "
-           "[-k kernel] [-r rawdev] bootimage\n", getprogname());
+           "[-k kernel] [-r rawdev] [-t epoch] bootimage\n", getprogname());
 #else
        fprintf(stderr, "usage: %s [-Ilsv] -m machine [-b bootfile] "
-           "[-k kernel] [-r rawdev] bootimage\n", getprogname());
+           "[-k kernel] [-r rawdev] [-t epoch]  bootimage\n", getprogname());
 #endif
        exit(1);
 }
@@ -680,7 +680,7 @@ bebox_write_header(int bebox_fd, int elf_image_len, int kern_img_len)
 }
 
 static int
-bebox_build_image(char *kernel, char *boot, char *rawdev, char *outname)
+bebox_build_image(char *kernel, char *boot, char *rawdev, char *outname, char *repro_timestamp)
 {
        unsigned char *elf_img = NULL, *kern_img = NULL, *header_img = NULL;
        int i, ch, tmp, kgzlen, err, hsize = BEBOX_HEADER_SIZE;
@@ -822,7 +822,11 @@ bebox_build_image(char *kernel, char *boot, char *rawdev, char *outname)
        *(int32_t *)(header_img + BEBOX_FILE_SIZE_ALIGN_OFFSET) =
            (int32_t)sa_htobe32(roundup(tmp, BEBOX_FILE_BLOCK_SIZE));
 
-       gettimeofday(&tp, 0);
+       if (repro_timestamp) {
+               memset(&tp, 0x00, sizeof (tp));
+               tp.tv_sec = atol(repro_timestamp);
+       } else
+               gettimeofday(&tp, 0);
        for (offset = bebox_mtime_offset; *offset != -1; offset++)
                *(int32_t *)(header_img + *offset) =
                    (int32_t)sa_htobe32(tp.tv_sec);
@@ -848,6 +852,7 @@ main(int argc, char **argv)
        int ch, lfloppyflag=0;
        char *kernel = NULL, *boot = NULL, *rawdev = NULL, *outname = NULL;
        char *march = NULL;
+       char *repro_timestamp = NULL;
 #ifdef USE_SYSCTL
        char machine[SYS_NMLN];
        int mib[2] = { CTL_HW, HW_MACHINE };
@@ -856,7 +861,7 @@ main(int argc, char **argv)
        setprogname(argv[0]);
        kern_len = 0;
 
-       while ((ch = getopt(argc, argv, "b:Ik:lm:r:sv")) != -1)
+       while ((ch = getopt(argc, argv, "b:Ik:lm:r:st:v")) != -1)
                switch (ch) {
                case 'b':
                        boot = optarg;
@@ -880,6 +885,9 @@ main(int argc, char **argv)
                case 's':
                        saloneflag = 1;
                        break;
+               case 't':
+                       repro_timestamp = optarg;
+                       break;
                case 'v':
                        verboseflag = 1;
                        break;
@@ -928,7 +936,7 @@ main(int argc, char **argv)
        if (strcmp(march, "rs6000") == 0)
                return(rs6000_build_image(kernel, boot, rawdev, outname));
        if (strcmp(march, "bebox") == 0)
-               return(bebox_build_image(kernel, boot, rawdev, outname));
+               return(bebox_build_image(kernel, boot, rawdev, outname, repro_timestamp));
 
        usage(1);
        return(0);



Home | Main Index | Thread Index | Old Index