mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Marek <mmarek@suse.cz>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 08/34] initramfs: Use KBUILD_BUILD_TIMESTAMP for generated entries
Date: Tue,  5 Apr 2011 16:58:55 +0200	[thread overview]
Message-ID: <1302015561-21047-9-git-send-email-mmarek@suse.cz> (raw)
In-Reply-To: <1302015561-21047-1-git-send-email-mmarek@suse.cz>

gen_init_cpio uses the current time for symlinks, special files and
directories. Make it possible to override this with the
KBUILD_BUILD_TIMESTAMP variable for reproducible builds.

Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 scripts/gen_initramfs_list.sh |    4 ++++
 usr/gen_init_cpio.c           |   17 +++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 4a43fe1..18cde32 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -283,6 +283,10 @@ while [ $# -gt 0 ]; do
 	esac
 done
 
+if test -n "$KBUILD_BUILD_TIMESTAMP"; then
+	export CPIO_TIMESTAMP=$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s)
+fi
+
 # If output_file is set we will generate cpio archive and compress it
 # we are carefull to delete tmp files
 if [ ! -z ${output_file} ]; then
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index 7f06884..11f604d 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -22,6 +22,7 @@
 
 static unsigned int offset;
 static unsigned int ino = 721;
+static time_t default_mtime;
 
 struct file_handler {
 	const char *type;
@@ -102,7 +103,6 @@ static int cpio_mkslink(const char *name, const char *target,
 			 unsigned int mode, uid_t uid, gid_t gid)
 {
 	char s[256];
-	time_t mtime = time(NULL);
 
 	if (name[0] == '/')
 		name++;
@@ -114,7 +114,7 @@ static int cpio_mkslink(const char *name, const char *target,
 		(long) uid,		/* uid */
 		(long) gid,		/* gid */
 		1,			/* nlink */
-		(long) mtime,		/* mtime */
+		(long) default_mtime,	/* mtime */
 		(unsigned)strlen(target)+1, /* filesize */
 		3,			/* major */
 		1,			/* minor */
@@ -152,7 +152,6 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,
 		       uid_t uid, gid_t gid)
 {
 	char s[256];
-	time_t mtime = time(NULL);
 
 	if (name[0] == '/')
 		name++;
@@ -164,7 +163,7 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,
 		(long) uid,		/* uid */
 		(long) gid,		/* gid */
 		2,			/* nlink */
-		(long) mtime,		/* mtime */
+		(long) default_mtime,	/* mtime */
 		0,			/* filesize */
 		3,			/* major */
 		1,			/* minor */
@@ -242,7 +241,6 @@ static int cpio_mknod(const char *name, unsigned int mode,
 		       unsigned int maj, unsigned int min)
 {
 	char s[256];
-	time_t mtime = time(NULL);
 
 	if (dev_type == 'b')
 		mode |= S_IFBLK;
@@ -259,7 +257,7 @@ static int cpio_mknod(const char *name, unsigned int mode,
 		(long) uid,		/* uid */
 		(long) gid,		/* gid */
 		1,			/* nlink */
-		(long) mtime,		/* mtime */
+		(long) default_mtime,	/* mtime */
 		0,			/* filesize */
 		3,			/* major */
 		1,			/* minor */
@@ -529,6 +527,7 @@ int main (int argc, char *argv[])
 	char *args, *type;
 	int ec = 0;
 	int line_nr = 0;
+	const char *env;
 
 	if (2 != argc) {
 		usage(argv[0]);
@@ -544,6 +543,12 @@ int main (int argc, char *argv[])
 		exit(1);
 	}
 
+	env = getenv("CPIO_TIMESTAMP");
+	if (env)
+		default_mtime = atol(env);
+	if (!default_mtime)
+		default_mtime = time(NULL);
+
 	while (fgets(line, LINE_SIZE, cpio_list)) {
 		int type_idx;
 		size_t slen = strlen(line);
-- 
1.7.4.1


  parent reply	other threads:[~2011-04-05 15:06 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1302015561-21047-1-git-send-email-mmarek@suse.cz>
2011-04-05 14:58 ` [PATCH 01/34] kconfig: Do not record timestamp in auto.conf and autoconf.h Michal Marek
2011-04-05 18:57   ` Arnaud Lacombe
2011-04-06  7:37     ` Michal Marek
2011-04-06 16:25       ` Arnaud Lacombe
2011-04-06 20:39         ` Michal Marek
2011-04-18 13:04   ` Michal Marek
2011-04-05 14:58 ` [PATCH 02/34] kbuild: Call gzip with -n Michal Marek
2011-04-18 13:05   ` Michal Marek
2011-04-05 14:58 ` [PATCH 03/34] powerpc: " Michal Marek
2011-04-05 14:58 ` [PATCH 04/34] kbuild: Use the deterministic mode of ar Michal Marek
2011-04-18 13:05   ` Michal Marek
2011-04-05 14:58 ` [PATCH 05/34] powerpc: " Michal Marek
2011-04-05 14:58 ` [PATCH 06/34] kbuild: Drop unused LINUX_COMPILE_TIME and LINUX_COMPILE_DOMAIN macros Michal Marek
2011-04-18 13:05   ` Michal Marek
2011-04-05 14:58 ` [PATCH 07/34] kbuild: Allow to override LINUX_COMPILE_BY and LINUX_COMPILE_HOST macros Michal Marek
2011-04-05 15:52   ` Jack Stone
2011-04-05 18:09     ` Michal Marek
2011-04-11 15:04     ` [PATCH v2] " Michal Marek
2011-04-12  3:25       ` Valdis.Kletnieks
2011-04-12  9:01         ` Michal Marek
2011-04-18 13:05           ` Michal Marek
2011-04-05 14:58 ` Michal Marek [this message]
2011-04-05 17:31   ` [08/34] initramfs: Use KBUILD_BUILD_TIMESTAMP for generated entries Milton Miller
2011-04-05 18:12     ` Michal Marek
2011-04-11 15:06     ` [PATCH v2] " Michal Marek
2011-04-18 13:06       ` Michal Marek
2011-04-05 14:58 ` [PATCH 09/34] x86: Allow to override the ROOT_DEV variable Michal Marek
2011-04-05 15:30   ` H. Peter Anvin
2011-04-06  7:47     ` Michal Marek
2011-04-11 15:08       ` Michal Marek
2011-04-12  3:25         ` Valdis.Kletnieks
2011-04-12  7:11           ` Paul Bolle
2011-04-12  3:39         ` H. Peter Anvin
2011-04-12  5:01         ` Paul Bolle
2011-04-12  9:57           ` Michal Marek
2011-04-12 10:40             ` Paul Bolle
2011-04-12 11:30         ` [PATCH v2] x86: Do not set the root_dev field in bzImage Michal Marek
2011-05-11 15:22           ` Michal Marek
2011-05-25 20:32             ` Michal Marek
2011-05-25 20:49           ` [tip:x86/build] x86, build: " tip-bot for Michal Marek
2011-04-05 14:58 ` [PATCH 10/34] cyclades: Drop __TIME__ usage Michal Marek
2011-04-18 22:17   ` Michal Marek
2011-04-05 14:58 ` [PATCH 11/34] nozomi: " Michal Marek
2011-04-05 14:58 ` [PATCH 12/34] isdn/diva: " Michal Marek
2011-04-05 15:10   ` Armin Schindler
2011-04-05 15:37     ` Ben Hutchings
2011-04-05 16:07       ` Armin Schindler
2011-04-05 20:01         ` Sam Ravnborg
2011-04-05 19:17     ` Valdis.Kletnieks
2011-04-06  8:06       ` Michal Marek
2011-05-25 20:38     ` Michal Marek
2011-05-26  8:15       ` Armin Schindler
2011-05-26  8:29         ` Michal Marek
2011-04-05 14:59 ` [PATCH 13/34] media/radio-maxiradio: " Michal Marek
2011-04-18 22:18   ` Michal Marek
2011-04-05 14:59 ` [PATCH 14/34] media/cx231xx: " Michal Marek
2011-04-18 22:18   ` Michal Marek
2011-04-05 14:59 ` [PATCH 15/34] baycom: " Michal Marek
     [not found]   ` <1302015780.4124.53.camel@xbox360.hq.axsem.com>
2011-05-25 15:23     ` Michal Marek
2011-04-05 14:59 ` [PATCH 16/34] nand/denali: " Michal Marek
2011-04-05 15:02   ` Artem Bityutskiy
2011-04-05 15:10     ` Michal Marek
2011-04-05 15:15   ` Artem Bityutskiy
2011-04-05 14:59 ` [PATCH 17/34] hdlcdrv: " Michal Marek
     [not found]   ` <1302015790.4124.54.camel@xbox360.hq.axsem.com>
2011-05-25 15:24     ` Michal Marek
2011-04-05 14:59 ` [PATCH 18/34] wan/pc300: " Michal Marek
2011-05-25 20:43   ` Michal Marek
2011-05-25 20:44     ` David Miller
2011-04-05 14:59 ` [PATCH 19/34] rt2x00: " Michal Marek
2011-04-05 15:28   ` Gertjan van Wingerde
2011-04-05 18:37   ` Ivo Van Doorn
2011-04-05 14:59 ` [PATCH 20/34] parport: " Michal Marek
2011-04-05 20:00   ` Arnaud Giersch
2011-05-25 20:44     ` Michal Marek
2011-04-05 14:59 ` [PATCH 21/34] aacraid: " Michal Marek
2011-04-18 22:20   ` Michal Marek
2011-04-05 14:59 ` [PATCH 22/34] scsi/in2000: " Michal Marek
2011-04-18 22:20   ` Michal Marek
2011-04-05 14:59 ` [PATCH 23/34] scsi/wd33c93: " Michal Marek
2011-04-18 22:20   ` Michal Marek
2011-04-05 14:59 ` [PATCH 24/34] usb/u132-hcd: " Michal Marek
2011-04-05 14:59 ` [PATCH 25/34] usb/ftdi-elan: " Michal Marek
2011-04-05 17:50   ` Matthew Dharm
2011-04-05 18:13     ` Greg KH
2011-04-05 14:59 ` [PATCH 26/34] dlm: " Michal Marek
2011-05-25 20:47   ` Michal Marek
2011-05-25 20:47     ` David Teigland
2011-04-05 14:59 ` [PATCH 27/34] gfs2: " Michal Marek
2011-05-25 20:48   ` Michal Marek
2011-05-26  8:43     ` Steven Whitehouse
2011-05-26  9:08       ` Michal Marek
2011-04-05 14:59 ` [PATCH 28/34] atm: " Michal Marek
2011-05-25 20:49   ` Michal Marek
2011-05-25 21:39     ` David Miller
2011-04-05 14:59 ` [PATCH 29/34] tipc: " Michal Marek
2011-04-05 22:25   ` Paul Gortmaker
2011-04-05 14:59 ` [PATCH 30/34] rio: Drop __DATE__ usage Michal Marek
2011-04-18 22:21   ` Michal Marek
2011-04-05 14:59 ` [PATCH 31/34] edac: " Michal Marek
2011-04-18 22:21   ` Michal Marek
2011-04-05 14:59 ` [PATCH 32/34] pmcraid: " Michal Marek
2011-04-18 22:21   ` Michal Marek
2011-04-05 14:59 ` [PATCH 33/34] usb/lh7a40x_udc: " Michal Marek
2011-04-05 16:25   ` Russell King - ARM Linux
2011-04-06  8:23     ` Michal Marek
2011-04-05 14:59 ` [PATCH 34/34] checkpatch: Warn about usage of __DATE__, __TIME__ and __TIMESTAMP__ Michal Marek
2011-05-26 11:39   ` Michal Marek
2011-05-26 12:42   ` Andy Whitcroft
     [not found] ` <20110405154918.GA31337@suse.de>
     [not found]   ` <1302031447.2608.41.camel@koala>
     [not found]     ` <20110406085712.GA16597@elte.hu>
2011-04-06  9:04       ` [PATCH 00/34] Make kernel build deterministic Artem Bityutskiy
2011-05-05 15:22 ` [PATCH v2] powerpc: Use the deterministic mode of ar Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302015561-21047-9-git-send-email-mmarek@suse.cz \
    --to=mmarek@suse.cz \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®