Use SOURCE_DATE_EPOCH for metadata timestamps
This include .buildinfo, .treeinfo and .discinfo.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
(cherry picked from commit 876ec52215
)
This commit is contained in:
parent
ab1effb98d
commit
376eda543c
@ -23,6 +23,7 @@ import logging
|
|||||||
logger = logging.getLogger("pylorax.buildstamp")
|
logger = logging.getLogger("pylorax.buildstamp")
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class BuildStamp(object):
|
class BuildStamp(object):
|
||||||
@ -34,6 +35,10 @@ class BuildStamp(object):
|
|||||||
self.isfinal = isfinal
|
self.isfinal = isfinal
|
||||||
self.variant = variant
|
self.variant = variant
|
||||||
|
|
||||||
|
if 'SOURCE_DATE_EPOCH' in os.environ:
|
||||||
|
now = datetime.datetime.utcfromtimestamp(
|
||||||
|
int(os.environ['SOURCE_DATE_EPOCH']))
|
||||||
|
else:
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
now = now.strftime("%Y%m%d%H%M")
|
now = now.strftime("%Y%m%d%H%M")
|
||||||
self.uuid = "{0}.{1}".format(now, buildarch)
|
self.uuid = "{0}.{1}".format(now, buildarch)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger("pylorax.discinfo")
|
logger = logging.getLogger("pylorax.discinfo")
|
||||||
|
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
@ -32,8 +33,13 @@ class DiscInfo(object):
|
|||||||
self.basearch = basearch
|
self.basearch = basearch
|
||||||
|
|
||||||
def write(self, outfile):
|
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")
|
logger.info("writing .discinfo file")
|
||||||
with open(outfile, "w") as fobj:
|
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.release}\n".format(self))
|
||||||
fobj.write("{0.basearch}\n".format(self))
|
fobj.write("{0.basearch}\n".format(self))
|
||||||
|
@ -23,6 +23,7 @@ import logging
|
|||||||
logger = logging.getLogger("pylorax.treeinfo")
|
logger = logging.getLogger("pylorax.treeinfo")
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
@ -33,8 +34,13 @@ class TreeInfo(object):
|
|||||||
|
|
||||||
self.c = configparser.ConfigParser()
|
self.c = configparser.ConfigParser()
|
||||||
|
|
||||||
|
if 'SOURCE_DATE_EPOCH' in os.environ:
|
||||||
|
timestamp = os.environ['SOURCE_DATE_EPOCH']
|
||||||
|
else:
|
||||||
|
timestamp = str(time.time())
|
||||||
|
|
||||||
section = "general"
|
section = "general"
|
||||||
data = {"timestamp": str(time.time()),
|
data = {"timestamp": timestamp,
|
||||||
"family": product,
|
"family": product,
|
||||||
"version": version,
|
"version": version,
|
||||||
"name": "%s-%s" % (product, version),
|
"name": "%s-%s" % (product, version),
|
||||||
|
Loading…
Reference in New Issue
Block a user