summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuro Bystricky <juro.bystricky@intel.com>2017-04-25 10:39:21 -0700
committerMartin Jansa <Martin.Jansa@gmail.com>2017-08-17 04:12:29 +0200
commit7807e980a50c73d1c62913add266777d197e96fb (patch)
tree68a4b295e125dceacf4d5f6f5519166b79e19464
parent4b4875fb93a6d72ce2140268056e04796a812f76 (diff)
downloadopenembedded-core-contrib-7807e980a50c73d1c62913add266777d197e96fb.tar.gz
openembedded-core-contrib-7807e980a50c73d1c62913add266777d197e96fb.tar.bz2
openembedded-core-contrib-7807e980a50c73d1c62913add266777d197e96fb.zip
rootfs-postcommands.bbclass: support binary reproducibility
Conditionally support binary reproducibility of rootfs images. If BUILD_REPRODUCIBLE_BINARIES = 1 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. If the variable is not specified, the timestamp value is derived from the top git commit. [YOCTO#11176] Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
-rw-r--r--meta/classes/rootfs-postcommands.bbclass27
1 files changed, 24 insertions, 3 deletions
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index 78f7c55933..46cb530187 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -48,6 +48,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 () {
@@ -245,10 +246,12 @@ 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 [ "$BUILD_REPRODUCIBLE_BINARIES" = "0" ]; then
+ date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
+ fi
}
# Prevent X from being started
@@ -288,7 +291,6 @@ rootfs_sysroot_relativelinks () {
sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}
}
-
# Generated test data json file
python write_image_test_data() {
from oe.data import export2json
@@ -304,3 +306,22 @@ python write_image_test_data() {
os.remove(testdata_link)
os.symlink(os.path.basename(testdata), testdata_link)
}
+
+# Perform any additional adjustments needed to make rootf binary reproducible
+rootfs_reproducible () {
+ if [ "$BUILD_REPRODUCIBLE_BINARIES" = "1" ]; then
+ if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
+ REPRODUCIBLE_TIMESTAMP_ROOTFS=`git log -1 --pretty=%ct`
+ fi
+
+ # 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"
+ echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
+ bbnote "rootfs_reproducible: set /etc/timestamp 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
+}