diff options
author | Juro Bystricky <juro.bystricky@intel.com> | 2018-04-13 15:47:44 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-04-18 18:57:06 +0100 |
commit | b8ce7d0800dc63db2786e2761b7ac97f7b59cd06 (patch) | |
tree | 7d1c2a018365a79af3be165c8cc6133657043279 /meta/classes/rootfs-postcommands.bbclass | |
parent | 53078a00ceab5d6aaa61c77fcb73f0d4aa788e00 (diff) | |
download | poky-b8ce7d0800dc63db2786e2761b7ac97f7b59cd06.tar.gz |
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]
(From OE-Core rev: 11e45082ad00b9c172e59bf6b2a76dd613773f5a)
Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/rootfs-postcommands.bbclass')
-rw-r--r-- | meta/classes/rootfs-postcommands.bbclass | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass index a4e627fef8..5522209534 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}" | |||
56 | SORT_PASSWD_POSTPROCESS_COMMAND ??= " sort_passwd; " | 56 | SORT_PASSWD_POSTPROCESS_COMMAND ??= " sort_passwd; " |
57 | python () { | 57 | python () { |
58 | d.appendVar('ROOTFS_POSTPROCESS_COMMAND', '${SORT_PASSWD_POSTPROCESS_COMMAND}') | 58 | d.appendVar('ROOTFS_POSTPROCESS_COMMAND', '${SORT_PASSWD_POSTPROCESS_COMMAND}') |
59 | d.appendVar('ROOTFS_POSTPROCESS_COMMAND', 'rootfs_reproducible;') | ||
59 | } | 60 | } |
60 | 61 | ||
61 | systemd_create_users () { | 62 | systemd_create_users () { |
@@ -256,10 +257,17 @@ python write_image_manifest () { | |||
256 | os.symlink(os.path.basename(manifest_name), manifest_link) | 257 | os.symlink(os.path.basename(manifest_name), manifest_link) |
257 | } | 258 | } |
258 | 259 | ||
259 | # Can be use to create /etc/timestamp during image construction to give a reasonably | 260 | # Can be used to create /etc/timestamp during image construction to give a reasonably |
260 | # sane default time setting | 261 | # sane default time setting |
261 | rootfs_update_timestamp () { | 262 | rootfs_update_timestamp () { |
262 | date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp | 263 | if [ "${REPRODUCIBLE_TIMESTAMP_ROOTFS}" != "" ]; then |
264 | # Convert UTC into %4Y%2m%2d%2H%2M%2S | ||
265 | sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S` | ||
266 | else | ||
267 | sformatted=`date -u +%4Y%2m%2d%2H%2M%2S` | ||
268 | fi | ||
269 | echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp | ||
270 | bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted" | ||
263 | } | 271 | } |
264 | 272 | ||
265 | # Prevent X from being started | 273 | # Prevent X from being started |
@@ -328,3 +336,16 @@ python rootfs_log_check_recommends() { | |||
328 | if 'unsatisfied recommendation for' in line: | 336 | if 'unsatisfied recommendation for' in line: |
329 | bb.warn('[log_check] %s: %s' % (d.getVar('PN'), line)) | 337 | bb.warn('[log_check] %s: %s' % (d.getVar('PN'), line)) |
330 | } | 338 | } |
339 | |||
340 | # Perform any additional adjustments needed to make rootf binary reproducible | ||
341 | rootfs_reproducible () { | ||
342 | if [ "${REPRODUCIBLE_TIMESTAMP_ROOTFS}" != "" ]; then | ||
343 | # Convert UTC into %4Y%2m%2d%2H%2M%2S | ||
344 | sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S` | ||
345 | echo $sformatted > ${IMAGE_ROOTFS}/etc/version | ||
346 | bbnote "rootfs_reproducible: set /etc/version to $sformatted" | ||
347 | |||
348 | find ${IMAGE_ROOTFS}/etc/gconf -name '%gconf.xml' -print0 | xargs -0r \ | ||
349 | sed -i -e 's@\bmtime="[0-9][0-9]*"@mtime="'${REPRODUCIBLE_TIMESTAMP_ROOTFS}'"@g' | ||
350 | fi | ||
351 | } | ||