From d561c6ac5612e6bf44247ea1c703c15923db22ac Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Tue, 10 Dec 2024 15:56:43 +0100 Subject: [PATCH] fix two reproducible build issues Fixed two reproducible builds issues found by Bernhard Wiedemann. Signed-off-by: Marcus Meissner --- ssg/build_yaml.py | 6 +++++- utils/create_scap_delta_tailoring.py | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ssg/build_yaml.py b/ssg/build_yaml.py index 1bd4e9d4835..ed991fcbb3b 100644 --- a/ssg/build_yaml.py +++ b/ssg/build_yaml.py @@ -8,6 +8,7 @@ from copy import deepcopy import datetime +import time import json import os import os.path @@ -741,7 +742,10 @@ def _create_benchmark_xml_skeleton(self, env_yaml): root.set('xml:lang', 'en-US') status = ET.SubElement(root, '{%s}status' % XCCDF12_NS) - status.set('date', datetime.date.today().strftime("%Y-%m-%d")) + status.set( + 'date', + time.strftime("%Y-%m-%d", + time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))))) status.text = self.status add_sub_element(root, "title", XCCDF12_NS, self.title) diff --git a/utils/create_scap_delta_tailoring.py b/utils/create_scap_delta_tailoring.py index 6ccca8fc8c0..ee85a57bc01 100755 --- a/utils/create_scap_delta_tailoring.py +++ b/utils/create_scap_delta_tailoring.py @@ -2,6 +2,7 @@ import argparse import datetime +import time import json import os import re @@ -165,10 +166,8 @@ def setup_tailoring_profile(profile_id, profile_root): def _get_datetime(): - try: - return datetime.datetime.now(datetime.UTC).isoformat() - except AttributeError: - return datetime.datetime.utcnow().isoformat() + return datetime.datetime.fromtimestamp( + int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))).isoformat() def create_tailoring(args):