summaryrefslogtreecommitdiff
path: root/poky/meta/classes/reproducible_build.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'poky/meta/classes/reproducible_build.bbclass')
-rw-r--r--poky/meta/classes/reproducible_build.bbclass18
1 files changed, 10 insertions, 8 deletions
diff --git a/poky/meta/classes/reproducible_build.bbclass b/poky/meta/classes/reproducible_build.bbclass
index f06e00d70..278eeedc7 100644
--- a/poky/meta/classes/reproducible_build.bbclass
+++ b/poky/meta/classes/reproducible_build.bbclass
@@ -41,6 +41,9 @@ SDE_DIR = "${WORKDIR}/source-date-epoch"
SDE_FILE = "${SDE_DIR}/__source_date_epoch.txt"
SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch"
+# Enable compiler warning when the __TIME__, __DATE__ and __TIMESTAMP__ macros are used.
+TARGET_CC_ARCH_append_class-target = " -Wdate-time"
+
# A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE
export SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400"
@@ -63,7 +66,7 @@ python do_deploy_source_date_epoch_setscene () {
if os.path.exists(sde_file):
target = d.getVar('SDE_FILE')
bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target))
- os.rename(sde_file, target)
+ bb.utils.rename(sde_file, target)
else:
bb.debug(1, "%s not found!" % sde_file)
}
@@ -77,17 +80,16 @@ python create_source_date_epoch_stamp() {
import oe.reproducible
epochfile = d.getVar('SDE_FILE')
- # If it exists we need to regenerate as the sources may have changed
- if os.path.isfile(epochfile):
- bb.debug(1, "Deleting existing SOURCE_DATE_EPOCH from: %s" % epochfile)
- os.remove(epochfile)
+ tmp_file = "%s.new" % epochfile
source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
bb.utils.mkdirhier(d.getVar('SDE_DIR'))
- with open(epochfile, 'w') as f:
+ with open(tmp_file, 'w') as f:
f.write(str(source_date_epoch))
+
+ os.rename(tmp_file, epochfile)
}
def get_source_date_epoch_value(d):
@@ -97,7 +99,7 @@ def get_source_date_epoch_value(d):
epochfile = d.getVar('SDE_FILE')
source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
- if os.path.isfile(epochfile):
+ try:
with open(epochfile, 'r') as f:
s = f.read()
try:
@@ -110,7 +112,7 @@ def get_source_date_epoch_value(d):
bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK" % s)
source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK'))
bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch)
- else:
+ except FileNotFoundError:
bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch))
d.setVar('__CACHED_SOURCE_DATE_EPOCH', str(source_date_epoch))