You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.1 KiB
103 lines
3.1 KiB
From c90eb097d7006378155e06a3d1e8148d61da90c5 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
|
|
<marmarek@invisiblethingslab.com>
|
|
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 <marmarek@invisiblethingslab.com>
|
|
|
|
This include .buildinfo, .treeinfo and .discinfo.
|
|
|
|
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
|
|
---
|
|
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
|
|
|