]> git.ipfire.org Git - thirdparty/linux.git/commit - usr/gen_init_cpio.c
gen_init_cpio: Apply mtime supplied by user to all file types
authorDmitry Safonov <dima@arista.com>
Wed, 20 Dec 2023 00:33:15 +0000 (00:33 +0000)
committerMasahiro Yamada <masahiroy@kernel.org>
Fri, 29 Dec 2023 13:25:21 +0000 (22:25 +0900)
commitf3b2306bea33b3a86ad2df4dcfab53b629e1bc84
tree86c6539435bb41d935f3bcb84eadd67ef52e5830
parent7beba04eb305393e3f8386390f25b4a9475f27f2
gen_init_cpio: Apply mtime supplied by user to all file types

Currently gen_init_cpio -d <timestamp> is applied to symlinks,
directories and special files. These files are created by
gen_init_cpio from their description. Without <timestamp> option
current time(NULL) is used. And regular files that go in initramfs
are created before cpio generation, so their mtime(s) are preserved.

This is usually not an issue as reproducible builds should rebuild
everything in the distribution, including binaries, configs and whatever
other regular files may find their way into kernel's initramfs.

On the other hand, gen_initramfs.sh usage claims:
> -d <date>      Use date for all file mtime values

Ar Arista initramfs files are managed with version control system
that preserves mtime. Those are configs, boot parameters, init scripts,
version files, platform-specific files, probably some others, too.

While it's certainly possible to work this around by copying the file
into temp directory and adjusting mtime prior to gen_init_cpio call,
I don't see why it needs workarounds.

The intended user of -d <date> option is the one that needs to create
a reproducible build, see commit a8b8017c34fe ("initramfs: Use
KBUILD_BUILD_TIMESTAMP for generated entries"). If a user wants
the build reproduction, they use -d <date>, which can be set on all
types of files, without surprising exceptions and workarounds.
Let's KISS here and just apply the time that user specified
with -d option.

Based-on-a-patch-by: Baptiste Covolato <baptiste@arista.com>
Link: https://lore.kernel.org/lkml/20181025215133.20138-1-baptiste@arista.com/
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
usr/gen_init_cpio.c