[PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp

Gang Yan posted 1 patch 2 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20251013101946.248420-1-yangang@kylinos.cn
usr/gen_initramfs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp
Posted by Gang Yan 2 weeks, 3 days ago
There exists a compilation error in the latest version of
mptcp-upstream-virtme-docker:latest:
'''
	ERROR: Timestamp out of range for cpio format
	make[4]: *** [<KERNEL_SRC>/usr/Makefile:76:
'''

The reason is the output of 'date -d0' is 'Sat Jan 1 00:00:00 UTC 0000'.
After using 'date -u', the output is correct.

Reported-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
 usr/gen_initramfs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
index 7eba2fddf0ef..8eb43f76d521 100755
--- a/usr/gen_initramfs.sh
+++ b/usr/gen_initramfs.sh
@@ -222,7 +222,7 @@ while [ $# -gt 0 ]; do
 			shift
 			;;
 		"-d")	# date for file mtimes
-			timestamp="$(date -d"$1" +%s || :)"
+			timestamp="$(date -u +%s || :)"
 			if test -n "$timestamp"; then
 				timestamp="-t $timestamp"
 			fi
-- 
2.43.0
Re: [PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp
Posted by MPTCP CI 2 weeks, 3 days ago
Hi Gang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Unstable: 2 failed test(s): packetdrill_fastclose selftest_simult_flows 🔴
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Script error! ❓
- KVM Validation: btf-debug (only bpftest_all): Script error! ❓
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/18463151285

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/ca9d5aad6b72
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1010664


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Re: [PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp
Posted by Matthieu Baerts 2 weeks, 3 days ago
Hi Gang,

13 Oct 2025 13:50:42 MPTCP CI <wpasupplicant.patchew@gmail.com>:

> Hi Gang,
>
> Thank you for your modifications, that's great!
>
> Our CI did some validations and here is its report:
>
> - KVM Validation: normal (except selftest_mptcp_join): Unstable: 2 failed test(s): packetdrill_fastclose selftest_simult_flows 🔴
> - KVM Validation: normal (only selftest_mptcp_join): Success! ✅
> - KVM Validation: debug (except selftest_mptcp_join): Success! ✅
> - KVM Validation: debug (only selftest_mptcp_join): Success! ✅
> - KVM Validation: btf-normal (only bpftest_all): Script error! ❓
> - KVM Validation: btf-debug (only bpftest_all): Script error! ❓

FYI, this issue has also been fixed in our tree, but just after you sent
your patch:

https://git.kernel.org/bpf/bpf/c/de7342228b73

Cheers,
Matt
Re: [PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp
Posted by Matthieu Baerts 2 weeks, 3 days ago
Hi Gang,

On 13/10/2025 12:19, Gang Yan wrote:
> There exists a compilation error in the latest version of
> mptcp-upstream-virtme-docker:latest:
> '''
> 	ERROR: Timestamp out of range for cpio format
> 	make[4]: *** [<KERNEL_SRC>/usr/Makefile:76:
> '''
> 
> The reason is the output of 'date -d0' is 'Sat Jan 1 00:00:00 UTC 0000'.
> After using 'date -u', the output is correct.

Thank you for having looked at this. I already sent a fix in
mptcp-upstream-virtme-docker:


https://github.com/multipath-tcp/mptcp-upstream-virtme-docker/commit/52aa674

The issue is in fact in Rust CoreUtils:

  https://github.com/uutils/coreutils/issues/8898


Then, I don't think we need to modify the kernel source. Here are a few
workarounds:

- Use date's GNU version: ln -sf gnudate /usr/bin/date

- Do not generate the initramfs if not needed: -d CONFIG_BLK_DEV_INITRD

- Set KBUILD_BUILD_TIMESTAMP to "-1"

WDYT?

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp
Posted by GangYan 2 weeks, 3 days ago
> On Mon, Oct 13, 2025 at 12:28:08PM +0200, Matthieu Baerts wrote:
> Hi Gang,
> 
> On 13/10/2025 12:19, Gang Yan wrote:
> > There exists a compilation error in the latest version of
> > mptcp-upstream-virtme-docker:latest:
> > '''
> > 	ERROR: Timestamp out of range for cpio format
> > 	make[4]: *** [<KERNEL_SRC>/usr/Makefile:76:
> > '''
> > 
> > The reason is the output of 'date -d0' is 'Sat Jan 1 00:00:00 UTC 0000'.
> > After using 'date -u', the output is correct.
> 
> Thank you for having looked at this. I already sent a fix in
> mptcp-upstream-virtme-docker:
> 
> 
> https://github.com/multipath-tcp/mptcp-upstream-virtme-docker/commit/52aa674
> 
This fix works well in my enviroment.

Thanks,
Gang
> The issue is in fact in Rust CoreUtils:
> 
>   https://github.com/uutils/coreutils/issues/8898
> 
> 
> Then, I don't think we need to modify the kernel source. Here are a few
> workarounds:
> 
> - Use date's GNU version: ln -sf gnudate /usr/bin/date
> 
> - Do not generate the initramfs if not needed: -d CONFIG_BLK_DEV_INITRD
> 
> - Set KBUILD_BUILD_TIMESTAMP to "-1"
> 
> WDYT?
> 
> Cheers,
> Matt
> -- 
> Sponsored by the NGI0 Core fund.
> 
>
Re: [PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp
Posted by GangYan 2 weeks, 3 days ago
On Mon, Oct 13, 2025 at 12:28:08PM +0200, Matthieu Baerts wrote:
> Hi Gang,
> 
> On 13/10/2025 12:19, Gang Yan wrote:
> > There exists a compilation error in the latest version of
> > mptcp-upstream-virtme-docker:latest:
> > '''
> > 	ERROR: Timestamp out of range for cpio format
> > 	make[4]: *** [<KERNEL_SRC>/usr/Makefile:76:
> > '''
> > 
> > The reason is the output of 'date -d0' is 'Sat Jan 1 00:00:00 UTC 0000'.
> > After using 'date -u', the output is correct.
> 
> Thank you for having looked at this. I already sent a fix in
> mptcp-upstream-virtme-docker:
> 
> 
> https://github.com/multipath-tcp/mptcp-upstream-virtme-docker/commit/52aa674
> 
> The issue is in fact in Rust CoreUtils:
> 
>   https://github.com/uutils/coreutils/issues/8898
>
Thanks for this information.
> 
> Then, I don't think we need to modify the kernel source. Here are a few
> workarounds:
Sure!
> 
> - Use date's GNU version: ln -sf gnudate /usr/bin/date
> 
> - Do not generate the initramfs if not needed: -d CONFIG_BLK_DEV_INITRD
> 
> - Set KBUILD_BUILD_TIMESTAMP to "-1"
> 
> WDYT?
Still, I have another question: Is the compilation error too strict when
failing to retrieve the date? Would throwing a simple error be enough by
default? Or would it be better to provide a default value when the date
cannot be obtained, ensuring the compilation can be completed?

WDYT? It's just a normal discussion.

Thanks,
Gang
> 
> Cheers,
> Matt
> -- 
> Sponsored by the NGI0 Core fund.
> 
>
Re: [PATCH] gen_initramfs.sh: use 'date -u' to get Timestamp
Posted by Matthieu Baerts 2 weeks, 3 days ago
Hi Gang,

On 13/10/2025 15:22, GangYan wrote:
> Still, I have another question: Is the compilation error too strict when
> failing to retrieve the date? Would throwing a simple error be enough by
> default? Or would it be better to provide a default value when the date
> cannot be obtained, ensuring the compilation can be completed?

Maybe, I don't know. This gen_initramfs.sh already checks that 'date'
returned something, and if not, it doesn't try to set the option. Maybe
an extra check could be added to make sure the timestamp is positive?

  if test -n "$timestamp" && test "$timestamp" -ge 0; then

But because it is not linked to MPTCP, do you mind checking this with
the maintainers of this file, please?

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.