aboutsummaryrefslogtreecommitdiff
path: root/meta/classes
diff options
context:
space:
mode:
authorJuro Bystricky <juro.bystricky@intel.com>2018-04-13 15:47:44 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-04-18 18:48:20 +0100
commit11e45082ad00b9c172e59bf6b2a76dd613773f5a (patch)
tree56485febfc1c535a760aed171490f1b18e5c7520 /meta/classes
parent882ae0dcce2d96a7c286fc23b22b07972d3d8f93 (diff)
downloadopenembedded-core-11e45082ad00b9c172e59bf6b2a76dd613773f5a.zip
openembedded-core-11e45082ad00b9c172e59bf6b2a76dd613773f5a.tar.gz
openembedded-core-11e45082ad00b9c172e59bf6b2a76dd613773f5a.tar.bz2
rootfs-postcommands.bbclass: improve binary reproducibility
Conditionally support binary reproducibility of rootfs images. If REPRODUCIBLE_TIMESTAMP_ROOTFS is specified then: 1. set /etc/timestamp to a reproducible value 2. set /etc/version to a reproducible value 3. set /etc/gconf: set mtime in all %gconf.xml to reproducible values The reproducible value is taken from the variable REPRODUCIBLE_TIMESTAMP_ROOTFS. [YOCTO #11176] [YOCTO #12422] Signed-off-by: Juro Bystricky <juro.bystricky@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/rootfs-postcommands.bbclass25
1 files changed, 23 insertions, 2 deletions
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index a4e627f..5522209 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -56,6 +56,7 @@ ROOTFS_POSTPROCESS_COMMAND_append_qemuall = "${SSH_DISABLE_DNS_LOOKUP}"
SORT_PASSWD_POSTPROCESS_COMMAND ??= " sort_passwd; "
python () {
d.appendVar('ROOTFS_POSTPROCESS_COMMAND', '${SORT_PASSWD_POSTPROCESS_COMMAND}')
+ d.appendVar('ROOTFS_POSTPROCESS_COMMAND', 'rootfs_reproducible;')
}
systemd_create_users () {
@@ -256,10 +257,17 @@ python write_image_manifest () {
os.symlink(os.path.basename(manifest_name), manifest_link)
}
-# Can be use to create /etc/timestamp during image construction to give a reasonably
+# Can be used to create /etc/timestamp during image construction to give a reasonably
# sane default time setting
rootfs_update_timestamp () {
- date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
+ if [ "${REPRODUCIBLE_TIMESTAMP_ROOTFS}" != "" ]; then
+ # Convert UTC into %4Y%2m%2d%2H%2M%2S
+ sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S`
+ else
+ sformatted=`date -u +%4Y%2m%2d%2H%2M%2S`
+ fi
+ echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
+ bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted"
}
# Prevent X from being started
@@ -328,3 +336,16 @@ python rootfs_log_check_recommends() {
if 'unsatisfied recommendation for' in line:
bb.warn('[log_check] %s: %s' % (d.getVar('PN'), line))
}
+
+# Perform any additional adjustments needed to make rootf binary reproducible
+rootfs_reproducible () {
+ if [ "${REPRODUCIBLE_TIMESTAMP_ROOTFS}" != "" ]; then
+ # Convert UTC into %4Y%2m%2d%2H%2M%2S
+ sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S`
+ echo $sformatted > ${IMAGE_ROOTFS}/etc/version
+ bbnote "rootfs_reproducible: set /etc/version to $sformatted"
+
+ find ${IMAGE_ROOTFS}/etc/gconf -name '%gconf.xml' -print0 | xargs -0r \
+ sed -i -e 's@\bmtime="[0-9][0-9]*"@mtime="'${REPRODUCIBLE_TIMESTAMP_ROOTFS}'"@g'
+ fi
+}