diff options
Diffstat (limited to 'meta/classes/reproducible_build.bbclass')
-rw-r--r-- | meta/classes/reproducible_build.bbclass | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass index 2f3bd90b07..9e806c0b75 100644 --- a/meta/classes/reproducible_build.bbclass +++ b/meta/classes/reproducible_build.bbclass | |||
@@ -37,10 +37,13 @@ | |||
37 | BUILD_REPRODUCIBLE_BINARIES ??= '1' | 37 | BUILD_REPRODUCIBLE_BINARIES ??= '1' |
38 | inherit ${@oe.utils.ifelse(d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1', 'reproducible_build_simple', '')} | 38 | inherit ${@oe.utils.ifelse(d.getVar('BUILD_REPRODUCIBLE_BINARIES') == '1', 'reproducible_build_simple', '')} |
39 | 39 | ||
40 | SDE_DIR ="${WORKDIR}/source-date-epoch" | 40 | SDE_DIR = "${WORKDIR}/source-date-epoch" |
41 | SDE_FILE = "${SDE_DIR}/__source_date_epoch.txt" | 41 | SDE_FILE = "${SDE_DIR}/__source_date_epoch.txt" |
42 | SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch" | 42 | SDE_DEPLOYDIR = "${WORKDIR}/deploy-source-date-epoch" |
43 | 43 | ||
44 | # A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE | ||
45 | export SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400" | ||
46 | |||
44 | SSTATETASKS += "do_deploy_source_date_epoch" | 47 | SSTATETASKS += "do_deploy_source_date_epoch" |
45 | 48 | ||
46 | do_deploy_source_date_epoch () { | 49 | do_deploy_source_date_epoch () { |
@@ -81,6 +84,10 @@ python create_source_date_epoch_stamp() { | |||
81 | 84 | ||
82 | 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')) |
83 | 86 | ||
87 | if source_date_epoch == 0 : | ||
88 | bb.debug(1, "source_date_epoch is 0, using SOURCE_DATE_EPOCH_FALLBACK instead.") | ||
89 | source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) | ||
90 | |||
84 | bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) | 91 | bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) |
85 | bb.utils.mkdirhier(d.getVar('SDE_DIR')) | 92 | bb.utils.mkdirhier(d.getVar('SDE_DIR')) |
86 | with open(epochfile, 'w') as f: | 93 | with open(epochfile, 'w') as f: |
@@ -93,15 +100,19 @@ def get_source_date_epoch_value(d): | |||
93 | return cached | 100 | return cached |
94 | 101 | ||
95 | epochfile = d.getVar('SDE_FILE') | 102 | epochfile = d.getVar('SDE_FILE') |
96 | source_date_epoch = 0 | 103 | source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) |
97 | if os.path.isfile(epochfile): | 104 | if os.path.isfile(epochfile): |
98 | with open(epochfile, 'r') as f: | 105 | with open(epochfile, 'r') as f: |
99 | s = f.read() | 106 | s = f.read() |
100 | try: | 107 | try: |
101 | source_date_epoch = int(s) | 108 | source_date_epoch = int(s) |
109 | # workaround for old sstate with SDE_FILE content being 0 - use SOURCE_DATE_EPOCH_FALLBACK | ||
110 | if source_date_epoch == 0 : | ||
111 | source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) | ||
112 | bb.warn("SOURCE_DATE_EPOCH value from sstate '%s' is deprecated/invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK '%s'" % (s, source_date_epoch)) | ||
102 | except ValueError: | 113 | except ValueError: |
103 | bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to 0" % s) | 114 | bb.warn("SOURCE_DATE_EPOCH value '%s' is invalid. Reverting to SOURCE_DATE_EPOCH_FALLBACK" % s) |
104 | source_date_epoch = 0 | 115 | source_date_epoch = int(d.getVar('SOURCE_DATE_EPOCH_FALLBACK')) |
105 | bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) | 116 | bb.debug(1, "SOURCE_DATE_EPOCH: %d" % source_date_epoch) |
106 | else: | 117 | else: |
107 | bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch)) | 118 | bb.debug(1, "Cannot find %s. SOURCE_DATE_EPOCH will default to %d" % (epochfile, source_date_epoch)) |