summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/reproducible_build.bbclass13
1 files changed, 6 insertions, 7 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 43cf9dc894..62655c2a5b 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -77,17 +77,16 @@ python create_source_date_epoch_stamp() {
77 import oe.reproducible 77 import oe.reproducible
78 78
79 epochfile = d.getVar('SDE_FILE') 79 epochfile = d.getVar('SDE_FILE')
80 # If it exists we need to regenerate as the sources may have changed 80 tmp_file = "%s.new" % epochfile
81 if os.path.isfile(epochfile):
82 bb.debug(1, "Deleting existing SOURCE_DATE_EPOCH from: %s" % epochfile)
83 os.remove(epochfile)
84 81
85 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) 82 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
86 83
87 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) 84 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
88 bb.utils.mkdirhier(d.getVar('SDE_DIR')) 85 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
89 with open(epochfile, 'w') as f: 86 with open(tmp_file, 'w') as f:
90 f.write(str(source_date_epoch)) 87 f.write(str(source_date_epoch))
88
89 os.rename(tmp_file, epochfile)
91} 90}
92 91
93def get_source_date_epoch_value(d): 92def get_source_date_epoch_value(d):
@@ -100,7 +99,7 @@ def get_source_date_epoch_value(d):
100 bb.debug(1, "Epoch file changed from %s to %s" % (efile, epochfile)) 99 bb.debug(1, "Epoch file changed from %s to %s" % (efile, epochfile))
101 100
102 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) 101 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
103 if os.path.isfile(epochfile): 102 try:
104 with open(epochfile, 'r') as f: 103 with open(epochfile, 'r') as f:
105 s = f.read() 104 s = f.read()
106 try: 105 try:
@@ -113,7 +112,7 @@ def get_source_date_epoch_value(d):
113 bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK" % s) 112 bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK" % s)
114 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) 113 source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
115 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) 114 bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
116 else: 115 except FileNotFoundError:
117 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch)) 116 bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch))
118 117
119 d.setVar('__CACHED_SOURCE_DATE_EPOCH', (str(source_date_epoch), epochfile)) 118 d.setVar('__CACHED_SOURCE_DATE_EPOCH', (str(source_date_epoch), epochfile))