diff --git a/lorax/0006-Use-SOURCE_DATE_EPOCH-for-metadata-timestamps.patch b/lorax/0006-Use-SOURCE_DATE_EPOCH-for-metadata-timestamps.patch new file mode 100644 index 0000000..07c48b9 --- /dev/null +++ b/lorax/0006-Use-SOURCE_DATE_EPOCH-for-metadata-timestamps.patch @@ -0,0 +1,102 @@ +From c90eb097d7006378155e06a3d1e8148d61da90c5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= + +Date: Thu, 4 Oct 2018 18:16:34 +0200 +Subject: [PATCH 2/4] Use SOURCE_DATE_EPOCH for metadata timestamps +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Organization: Invisible Things Lab +Cc: Marek Marczykowski-Górecki + +This include .buildinfo, .treeinfo and .discinfo. + +Signed-off-by: Marek Marczykowski-Górecki +--- + src/pylorax/buildstamp.py | 7 ++++++- + src/pylorax/discinfo.py | 8 +++++++- + src/pylorax/treeinfo.py | 8 +++++++- + 3 files changed, 20 insertions(+), 3 deletions(-) + +diff --git a/src/pylorax/buildstamp.py b/src/pylorax/buildstamp.py +index 4219944..4376784 100644 +--- a/src/pylorax/buildstamp.py ++++ b/src/pylorax/buildstamp.py +@@ -23,6 +23,7 @@ import logging + logger = logging.getLogger("pylorax.buildstamp") + + import datetime ++import os + + + class BuildStamp(object): +@@ -33,7 +34,11 @@ class BuildStamp(object): + self.bugurl = bugurl + self.isfinal = isfinal + +- now = datetime.datetime.now() ++ if 'SOURCE_DATE_EPOCH' in os.environ: ++ now = datetime.datetime.utcfromtimestamp( ++ int(os.environ['SOURCE_DATE_EPOCH'])) ++ else: ++ now = datetime.datetime.now() + now = now.strftime("%Y%m%d%H%M") + self.uuid = "{0}.{1}".format(now, buildarch) + +diff --git a/src/pylorax/discinfo.py b/src/pylorax/discinfo.py +index 9dad83b..311bae3 100644 +--- a/src/pylorax/discinfo.py ++++ b/src/pylorax/discinfo.py +@@ -22,6 +22,7 @@ + import logging + logger = logging.getLogger("pylorax.discinfo") + ++import os + import time + + +@@ -32,8 +33,13 @@ class DiscInfo(object): + self.basearch = basearch + + def write(self, outfile): ++ if 'SOURCE_DATE_EPOCH' in os.environ: ++ timestamp = int(os.environ['SOURCE_DATE_EPOCH']) ++ else: ++ timestamp = time.time() ++ + logger.info("writing .discinfo file") + with open(outfile, "w") as fobj: +- fobj.write("{0:f}\n".format(time.time())) ++ fobj.write("{0:f}\n".format(timestamp)) + fobj.write("{0.release}\n".format(self)) + fobj.write("{0.basearch}\n".format(self)) +diff --git a/src/pylorax/treeinfo.py b/src/pylorax/treeinfo.py +index 4c84006..cc1ad3f 100644 +--- a/src/pylorax/treeinfo.py ++++ b/src/pylorax/treeinfo.py +@@ -23,6 +23,7 @@ import logging + logger = logging.getLogger("pylorax.treeinfo") + + import configparser ++import os + import time + + +@@ -33,8 +34,13 @@ class TreeInfo(object): + + self.c = configparser.ConfigParser() + ++ if 'SOURCE_DATE_EPOCH' in os.environ: ++ timestamp = os.environ['SOURCE_DATE_EPOCH'] ++ else: ++ timestamp = str(time.time()) ++ + section = "general" +- data = {"timestamp": str(time.time()), ++ data = {"timestamp": timestamp, + "family": product, + "version": version, + "name": "%s-%s" % (product, version), +-- +2.17.1 + diff --git a/lorax/0007-Preserve-timestamps-when-building-fs-image.patch b/lorax/0007-Preserve-timestamps-when-building-fs-image.patch new file mode 100644 index 0000000..e7d8318 --- /dev/null +++ b/lorax/0007-Preserve-timestamps-when-building-fs-image.patch @@ -0,0 +1,34 @@ +From 3457b203feac0af5ee5c388a6c0351978dadcc1a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= + +Date: Fri, 5 Oct 2018 04:48:09 +0200 +Subject: [PATCH 3/4] Preserve timestamps when building fs image +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Organization: Invisible Things Lab +Cc: Marek Marczykowski-Górecki + +Even when FS do not support owner/modes, preserve timestamps. + +Signed-off-by: Marek Marczykowski-Górecki +--- + src/pylorax/imgutils.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py +index 25c300d..942695f 100644 +--- a/src/pylorax/imgutils.py ++++ b/src/pylorax/imgutils.py +@@ -219,7 +219,7 @@ def copytree(src, dest, preserve=True): + If preserve is False, uses cp -R (useful for modeless filesystems) + raises CalledProcessError if copy fails.''' + logger.debug("copytree %s %s", src, dest) +- cp = ["cp", "-a"] if preserve else ["cp", "-R", "-L"] ++ cp = ["cp", "-a"] if preserve else ["cp", "-R", "-L", "--preserve=timestamps"] + cp += [join(src, "."), os.path.abspath(dest)] + runcmd(cp) + +-- +2.17.1 + diff --git a/lorax/0008-Use-SOURCE_DATE_EPOCH-for-volumeid-of-efi-boot-image.patch b/lorax/0008-Use-SOURCE_DATE_EPOCH-for-volumeid-of-efi-boot-image.patch new file mode 100644 index 0000000..02c0cc2 --- /dev/null +++ b/lorax/0008-Use-SOURCE_DATE_EPOCH-for-volumeid-of-efi-boot-image.patch @@ -0,0 +1,40 @@ +From 7e29418e9a5692c1f5ff7327929cd48f543d3d80 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= + +Date: Fri, 5 Oct 2018 04:48:57 +0200 +Subject: [PATCH 4/4] Use SOURCE_DATE_EPOCH for volumeid of efi boot image +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Organization: Invisible Things Lab +Cc: Marek Marczykowski-Górecki + +By default mkfs.mksdos choose volume id based on current time. If +SOURCE_DATE_EPOCH is set, use that instead. + +Signed-off-by: Marek Marczykowski-Górecki +--- + src/pylorax/imgutils.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py +index 6cd67e0..92de296 100644 +--- a/src/pylorax/imgutils.py ++++ b/src/pylorax/imgutils.py +@@ -398,8 +398,12 @@ def mkfsimage(fstype, rootdir, outfile, size=None, mkfsargs=None, mountargs="", + # convenience functions with useful defaults + def mkdosimg(rootdir, outfile, size=None, label="", mountargs="shortname=winnt,umask=0077", graft=None): + graft = graft or {} ++ mkfsargs = ["-n", label] ++ if 'SOURCE_DATE_EPOCH' in os.environ: ++ mkfsargs.extend(["-i", ++ "{:x}".format(int(os.environ['SOURCE_DATE_EPOCH']))]) + mkfsimage("msdos", rootdir, outfile, size, mountargs=mountargs, +- mkfsargs=["-n", label], graft=graft) ++ mkfsargs=mkfsargs, graft=graft) + + def mkext4img(rootdir, outfile, size=None, label="", mountargs="", graft=None): + graft = graft or {} +-- +2.17.1 + diff --git a/lorax/lorax.spec b/lorax/lorax.spec index df978ee..cb247d7 100644 --- a/lorax/lorax.spec +++ b/lorax/lorax.spec @@ -21,6 +21,9 @@ Patch2: 0002-verify-packages-signature.patch Patch3: 0003-Update-package-verification-for-dnf-API.patch Patch4: 0004-Remove-branding-code.patch Patch5: 0005-Drop-inner-rootfs.img-layer.patch +Patch6: 0006-Use-SOURCE_DATE_EPOCH-for-metadata-timestamps.patch +Patch7: 0007-Preserve-timestamps-when-building-fs-image.patch +Patch8: 0008-Use-SOURCE_DATE_EPOCH-for-volumeid-of-efi-boot-image.patch BuildRequires: python3-devel @@ -128,6 +131,9 @@ Lorax templates for creating the boot.iso and live isos are placed in %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 %build