diff options
-rw-r--r-- | meta/classes/reproducible_build.bbclass | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass index ea643f2860..278eeedc74 100644 --- a/meta/classes/reproducible_build.bbclass +++ b/meta/classes/reproducible_build.bbclass | |||
@@ -80,17 +80,16 @@ python create_source_date_epoch_stamp() { | |||
80 | import oe.reproducible | 80 | import oe.reproducible |
81 | 81 | ||
82 | epochfile = d.getVar('SDE_FILE') | 82 | epochfile = d.getVar('SDE_FILE') |
83 | # If it exists we need to regenerate as the sources may have changed | 83 | tmp_file = "%s.new" % epochfile |
84 | if os.path.isfile(epochfile): | ||
85 | bb.debug(1, "Deleting existing SOURCE_DATE_EPOCH from: %s" % epochfile) | ||
86 | os.remove(epochfile) | ||
87 | 84 | ||
88 | source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) | 85 | source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) |
89 | 86 | ||
90 | bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) | 87 | bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) |
91 | bb.utils.mkdirhier(d.getVar('SDE_DIR')) | 88 | bb.utils.mkdirhier(d.getVar('SDE_DIR')) |
92 | with open(epochfile, 'w') as f: | 89 | with open(tmp_file, 'w') as f: |
93 | f.write(str(source_date_epoch)) | 90 | f.write(str(source_date_epoch)) |
91 | |||
92 | os.rename(tmp_file, epochfile) | ||
94 | } | 93 | } |
95 | 94 | ||
96 | def get_source_date_epoch_value(d): | 95 | def get_source_date_epoch_value(d): |
@@ -100,7 +99,7 @@ def get_source_date_epoch_value(d): | |||
100 | 99 | ||
101 | epochfile = d.getVar('SDE_FILE') | 100 | epochfile = d.getVar('SDE_FILE') |
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)) | 118 | d.setVar('__CACHED_SOURCE_DATE_EPOCH', str(source_date_epoch)) |