NetBSD Problem Report #57906
From www@netbsd.org Wed Feb 7 10:08:07 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 EA66E1A9238
for <gnats-bugs@gnats.NetBSD.org>; Wed, 7 Feb 2024 10:08:06 +0000 (UTC)
Message-Id: <20240207100805.6BE361A9239@mollari.NetBSD.org>
Date: Wed, 7 Feb 2024 10:08:05 +0000 (UTC)
From: jbglaw@lug-owl.de
Reply-To: jbglaw@lug-owl.de
To: gnats-bugs@NetBSD.org
Subject: [RB] bebox/powerpc: Extend`mkbootimage` to allow for $MKREPRO_TIMESTAMP usage
X-Send-Pr-Version: www-1.0
>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
>Last-Modified: Thu Feb 08 18:00:01 +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);
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57906 CVS commit: src
Date: Thu, 8 Feb 2024 12:57:54 -0500
Module Name: src
Committed By: christos
Date: Thu Feb 8 17:57:54 UTC 2024
Modified Files:
src/distrib/bebox/floppies/bootfloppy-common: Makefile.inc
src/sys/arch/powerpc/stand/mkbootimage: mkbootimage.c
Log Message:
PR/57906: Jan-Benedict Glaw: Extend`mkbootimage` to allow for
$MKREPRO_TIMESTAMP usage
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/distrib/bebox/floppies/bootfloppy-common/Makefile.inc
cvs rdiff -u -r1.19 -r1.20 \
src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(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.