File 0001-Drop-microsecond-resolution-for-datetime.now.patch of Package mkosi
From 74d157b1e77f862965b0b09be90c78f6792a3a51 Mon Sep 17 00:00:00 2001
From: Alberto Planas <aplanas@suse.com>
Date: Wed, 6 Aug 2025 12:58:55 +0200
Subject: [PATCH] Drop microsecond resolution for datetime.now()
The RPM INSTALLTIME attribute is an integer represetantion of the
installation time of the package, and datetime.now is a date
representation of a float timestamp. This can produce some rounding
errors is powerful build servers.
For example, if the variable `_init_timestamp` has a value XXXXX.1 but
in the same sub-second the package gets installed, the registered
installation time will be the integer representation (XXXXX), making the
comparison done for exclusion of the package to be `True`.
This patch will remove the microsecond granularity of the datetime,
converting the timestamp on its integer representation, instead of the
default float one. The comparison is still done in the datetime data
type.
Signed-off-by: Alberto Planas <aplanas@suse.com>
---
mkosi/manifest.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mkosi/manifest.py b/mkosi/manifest.py
index 90c485c2..5fd7682f 100644
--- a/mkosi/manifest.py
+++ b/mkosi/manifest.py
@@ -86,7 +86,9 @@ class Manifest:
packages: list[PackageManifest] = dataclasses.field(default_factory=list)
source_packages: dict[str, SourcePackageManifest] = dataclasses.field(default_factory=dict)
- _init_timestamp: datetime.datetime = dataclasses.field(init=False, default_factory=datetime.datetime.now)
+ _init_timestamp: datetime.datetime = dataclasses.field(
+ init=False, default_factory=lambda: datetime.datetime.now().replace(microsecond=0)
+ )
def need_source_info(self) -> bool:
return ManifestFormat.changelog in self.context.config.manifest_format
--
2.43.0