Bug 11178 - Use SOURCE_DATE_EPOCH
Summary: Use SOURCE_DATE_EPOCH
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.4
Hardware: x86 Multiple
: Medium+ enhancement
Target Milestone: 2.5 M3
Assignee: Juro Bystricky
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks: 12421
  Show dependency tree
 
Reported: 2017-03-17 15:12 UTC by Joshua Lock
Modified: 2018-03-27 09:50 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments
patch to define a variable to select/de-select binary reproducible builds (1.16 KB, patch)
2017-04-21 22:12 UTC, Juro Bystricky
no flags Details | Diff
patch to set environment variables, SOURCE_DATE_EPOCH (5.63 KB, patch)
2017-04-21 22:14 UTC, Juro Bystricky
no flags Details | Diff
simple script to get some statistics (same/different/totals) (1.21 KB, application/x-shellscript)
2017-04-21 22:15 UTC, Juro Bystricky
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Lock 2017-03-17 15:12:11 UTC
As part of our effort to provide reproducible build output we should adopt the SOURCE_DATE_EPOCH spec.

Export an appropriately set SOURCE_DATE_EPOCH[1][2] environment variable to the environment builds are performed in. 

We'll need to ensure we're using appropriate versions of upstream that support SOURCE_DATE_EPOCH and integrating relevant patches from Debian[3] where those aren't already upstream. Separate issues may need to be filed for this piece.

1. https://reproducible-builds.org/specs/source-date-epoch/
2. https://reproducible-builds.org/docs/timestamps/
3. https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal#Reading_the_variable
Comment 1 Juro Bystricky 2017-03-22 22:15:57 UTC
There is some preliminary work (bottom):
https://bugzilla.yoctoproject.org/show_bug.cgi?id=5866
Comment 2 Joshua Lock 2017-04-03 09:41:48 UTC
Some of the related patches for reproducibility and SOURCE_DATE_EPOCH enabling are being collected in the distrpatches github organisation:
https://github.com/distropatches

specifically the reproducible-builds repository:
https://github.com/distropatches/reproducible-builds
Comment 3 Juro Bystricky 2017-04-03 16:24:12 UTC
nice link, seems like we could re-use some of those patches in Yocto recipes.
Comment 4 Juro Bystricky 2017-04-12 22:28:04 UTC
Basically, we need to be able to set SOURCE_DATE_EPOCH per each recipe.
The date should be set to the latest date in the set of files used by the recipe.
(This - in theory - should be Changelog, but that is not guaranteed, so different routes need to be taken based on context, i.e. date of the top commit in a git repo etc.)
Comment 5 Juro Bystricky 2017-04-21 22:10:49 UTC
I attached some initial patches to set SOURCE_DATE_EPOCH. The value for this variable is obtained after source code for a recipe has been unpacked, but before it is patched. If the code comes from a GIT repo, we get the timestamp from the top commit. (This usually corresponds to the mktime of "changelog".) Otherwise we go through all files and get the timestamp from the youngest one. We create a timestamp for each recipe. The timestamp is stored in the file    'src_date_epoch.txt'. Later on, each task reads this file and sets SOURCE_DATE_EPOCH based on the value found in the file.

This works surprisingly well for .DEB packages. Building core-image-minimal in two different build folders and performing comparison results in:

Same:  3617 
Different:  249 
Total: 3866

I attached the patches and the comparison shell script "repro-stats.sh"
The script is located/called from the "poky" folder, i.e.:

$ ./repro-stats.sh build-one build-two deb

The other packages (.RPM, IPK) are not as successful, you can see the disappointing results:
 
$ ./repro-stats.sh build-one build-two ipk
$ ./repro-stats.sh build-one build-two rpm
Comment 6 Juro Bystricky 2017-04-21 22:12:36 UTC
Created attachment 3744 [details]
patch to define a variable to select/de-select binary reproducible builds
Comment 7 Juro Bystricky 2017-04-21 22:14:01 UTC
Created attachment 3745 [details]
patch to set environment variables, SOURCE_DATE_EPOCH
Comment 8 Juro Bystricky 2017-04-21 22:15:08 UTC
Created attachment 3746 [details]
simple script to get some statistics (same/different/totals)
Comment 9 Juro Bystricky 2017-04-21 22:16:19 UTC
Probably worth mentioning: in local.conf:

PACKAGE_CLASSES = "package_rpm package_deb package_ipk"
BUILD_REPRODUCIBLE_BINARIES="1"
Comment 10 Juro Bystricky 2017-08-30 23:30:56 UTC
Sent patch to the ML:
https://patchwork.openembedded.org/patch/143060/

Moving to 2.5 M1, a slightly better version is being tested.