summaryrefslogtreecommitdiffstats
path: root/meta/classes/reproducible_build.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/reproducible_build.bbclass')
-rw-r--r--meta/classes/reproducible_build.bbclass96
1 files changed, 0 insertions, 96 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
deleted file mode 100644
index f38be1a765..0000000000
--- a/meta/classes/reproducible_build.bbclass
+++ /dev/null
@@ -1,96 +0,0 @@
1# reproducible_build.bbclass
2#
3# Sets the default SOURCE_DATE_EPOCH in each component's build environment.
4# The format is number of seconds since the system epoch.
5#
6# Upstream components (generally) respect this environment variable,
7# using it in place of the "current" date and time.
8# See https://reproducible-builds.org/specs/source-date-epoch/
9#
10# The default value of SOURCE_DATE_EPOCH comes from the function
11# get_source_date_epoch_value which reads from the SDE_FILE, or if the file
12# is not available (or set to 0) will use the fallback of
13# SOURCE_DATE_EPOCH_FALLBACK.
14#
15# The SDE_FILE is normally constructed from the function
16# create_source_date_epoch_stamp which is typically added as a postfuncs to
17# the do_unpack task. If a recipe does NOT have do_unpack, it should be added
18# to a task that runs after the source is available and before the
19# do_deploy_source_date_epoch task is executed.
20#
21# If a recipe wishes to override the default behavior it should set it's own
22# SOURCE_DATE_EPOCH or override the do_deploy_source_date_epoch_stamp task
23# with recipe-specific functionality to write the appropriate
24# SOURCE_DATE_EPOCH into the SDE_FILE.
25#
26# SOURCE_DATE_EPOCH is intended to be a reproducible value. This value should
27# be reproducible for anyone who builds the same revision from the same
28# sources.
29#
30# There are 4 ways the create_source_date_epoch_stamp function determines what
31# becomes SOURCE_DATE_EPOCH:
32#
33# 1. Use the value from __source_date_epoch.txt file if this file exists.
34# This file was most likely created in the previous build by one of the
35# following methods 2,3,4.
36# Alternatively, it can be provided by a recipe via SRC_URI.
37#
38# If the file does not exist:
39#
40# 2. If there is a git checkout, use the last git commit timestamp.
41# Git does not preserve file timestamps on checkout.
42#
43# 3. Use the mtime of "known" files such as NEWS, CHANGLELOG, ...
44# This works for well-kept repositories distributed via tarball.
45#
46# 4. Use the modification time of the youngest file in the source tree, if
47# there is one.
48# This will be the newest file from the distribution tarball, if any.
49#
50# 5. Fall back to a fixed timestamp (SOURCE_DATE_EPOCH_FALLBACK).
51#
52# Once the value is determined, it is stored in the recipe's SDE_FILE.
53
54
55SSTATETASKS += "do_deploy_source_date_epoch"
56
57do_deploy_source_date_epoch () {
58 mkdir -p ${SDE_DEPLOYDIR}
59 if [ -e ${SDE_FILE} ]; then
60 echo "Deploying SDE from ${SDE_FILE} -> ${SDE_DEPLOYDIR}."
61 cp -p ${SDE_FILE} ${SDE_DEPLOYDIR}/__source_date_epoch.txt
62 else
63 echo "${SDE_FILE} not found!"
64 fi
65}
66
67python do_deploy_source_date_epoch_setscene () {
68 sstate_setscene(d)
69 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
70 sde_file = os.path.join(d.getVar('SDE_DEPLOYDIR'), '__source_date_epoch.txt')
71 if os.path.exists(sde_file):
72 target = d.getVar('SDE_FILE')
73 bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target))
74 bb.utils.rename(sde_file, target)
75 else:
76 bb.debug(1, "%s not found!" % sde_file)
77}
78
79do_deploy_source_date_epoch[dirs] = "${SDE_DEPLOYDIR}"
80do_deploy_source_date_epoch[sstate-plaindirs] = "${SDE_DEPLOYDIR}"
81addtask do_deploy_source_date_epoch_setscene
82addtask do_deploy_source_date_epoch before do_configure after do_patch
83
84python create_source_date_epoch_stamp() {
85 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
86 oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d)
87}
88
89EPOCHTASK = "do_deploy_source_date_epoch"
90
91# Generate the stamp after do_unpack runs
92do_unpack[postfuncs] += "create_source_date_epoch_stamp"
93
94def get_source_date_epoch_value(d):
95 return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
96