Skip to content

Allow SOURCE_DATE_EPOCH to override file timestamps #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2017

Conversation

bmwiedemann
Copy link
Contributor

@bmwiedemann bmwiedemann commented Feb 1, 2017

Limit the maximum date to SOURCE_DATE_EPOCH, if defined
similar to the tar --clamp-mtime option

based on a patch by Nicolas Vigier <boklm at torproject.org>

together with previously merged
#143
b8a54d6 from @boklm
2258825

This allows rpmbuild to produce bit-by-bit identical rpms on different hosts when setting rpmmacros to

%_buildhost reproducible
%source_date_epoch_from_changelog Y
%clamp_mtime_to_source_date_epoch Y

macro is needed, because not everyone might want it, as it is known to affect python packages that include .pyc files which reference the original timestamp. Those will still work but re-compile on demand.

@ffesti
Copy link
Contributor

ffesti commented Feb 2, 2017

I am not too keen on the use of global variable(s) here. May be we can renew loading the environ variable for each build and store it in the spec or package variable instead.
While it may not matter much in practise I'd rather not like to add more technical debt there.

Other than that the patch looks good from a code POV.

I wonder how we want to address the Python .pyc file issue (and probably others). Not that this is a prerequisite for getting this patch in. We could try to leverage the file attribute mechanism or have a list of REs matching the FILECLASS tag. Resulting files could be given an mtime of SOURCE_DATE_EPOCH+1

@bmwiedemann
Copy link
Contributor Author

bmwiedemann commented Feb 2, 2017 via email

@toabctl
Copy link

toabctl commented Feb 2, 2017

I was thinking that it would be better to do it like Debian and generate
those in %post
which also reduces the size of rpms and allows it to be noarch

Yes that would be good. Here is the relevant debian policy for that: https://www.debian.org/doc/packaging-manuals/python-policy/ch-module_packages.html#s-byte_compilation

@Conan-Kudo
Copy link
Member

Conan-Kudo commented Feb 3, 2017

@toabctl I'm not particularly a fan of the late byte-compilation technique Debian uses, and I'd rather not propagate that down to everyone. For one thing, we're trying to reduce the number of scripts run outside of the realm of the package manager, not increase it. Having even fewer files known by the package manager is just crazy and stupid.

However, @bmwiedemann's idea of getting the .py files set to $SOURCE_DATE_EPOCH to embed that in .pyc files is interesting.

@fweimer
Copy link
Contributor

fweimer commented Feb 7, 2017

@bmwiedemann wrote:

The alternative approach would be to change the macro generating them and first touch source .py files to set their date to $SOURCE_DATE_EPOCH so that this gets embedded in .pyc headers

I doubt that RPM can do this without delayed script execution because the bytecode generator is not necessarily installed when the %post runs.

Limit the maximum date to SOURCE_DATE_EPOCH or use origtime if not defined
similar to the tar --clamp-mtime option

based on a patch by Nicolas Vigier <boklm at torproject.org>
@bmwiedemann
Copy link
Contributor Author

@ffesti I restructured the code to get rid of the ugly 'static' globals.

@Conan-Kudo
Copy link
Member

@fweimer Wouldn't that happen during the package build, rather than at runtime? It seems like that's a package build-time action.

@fweimer
Copy link
Contributor

fweimer commented Feb 8, 2017

@Conan-Kudo:

Wouldn't that happen during the package build, rather than at runtime? It seems like that's a package build-time action.

I quoted the wrong part (Github doesn't seem to support automated quoting). I was actually referring to this:

I was thinking that it would be better to do it like Debian and generate those in %post which also reduces the size of rpms and allows it to be noarch

@Conan-Kudo
Copy link
Member

@fweimer I see, that makes much more sense.

@ffesti ffesti merged commit 8d84878 into rpm-software-management:master Feb 16, 2017
@ffesti
Copy link
Contributor

ffesti commented Feb 16, 2017

Thanks for the patch!

@bmwiedemann
Copy link
Contributor Author

on the semi-offtopic python .pyc timestamp issue see: python/cpython#296

nacl pushed a commit to nacl/rules_pkg that referenced this pull request Mar 24, 2021
…ng in make_rpm.py

This change makes experimental/rpm.bzl support setting [`SOURCE_DATE_EPOCH`] when
packaging rpms, sourced either directly inline Bazel or from a rule, as in the
existing `pkg_rpm` rule.  The code is largely identical.

Additionally, it was discovered that `SOURCE_DATE_EPOCH` only affects the RPM's
build time (not the files) unless you explicitly tell it otherwise.  This seems
to be the `%clamp_mtime_to_source_date_epoch` macro, first added in [this PR].
It is now set automatically in RPMs when `SOURCE_DATE_EPOCH` is set in both
`pkg_rpm` rules.

Tests are also provided for `experimental/rpm.bzl` only.  Tests for the
existing/legacy `pkg_rpm` rule can be added if so desired.

Additionally:

- Command debugging in `make_rpm.py` was expanded to include printing out the
  environment.

- The test helper routines were made even more generic -- now users can specify
  the exact CSV manifest formats they want.  This is used to check for mtimes for
  this particular use case which are otherwise not checked.

- Documentation fixes where noted.  Some of the TODOs will be tagged with
  tickets when opportune (soon).

[`SOURCE_DATE_EPOCH`]: https://reproducible-builds.org/docs/source-date-epoch/
[this PR]: rpm-software-management/rpm#144
nacl pushed a commit to bazelbuild/rules_pkg that referenced this pull request Apr 26, 2021
…ng in make_rpm.py (#322)

This change makes experimental/rpm.bzl support setting [`SOURCE_DATE_EPOCH`] when
packaging rpms, sourced either directly inline Bazel or from a rule, as in the
existing `pkg_rpm` rule.  The code is largely identical.

Additionally, it was discovered that `SOURCE_DATE_EPOCH` only affects the RPM's
build time (not the files) unless you explicitly tell it otherwise.  This seems
to be the `%clamp_mtime_to_source_date_epoch` macro, first added in [this PR].
It is now set automatically in RPMs when `SOURCE_DATE_EPOCH` is set in both
`pkg_rpm` rules.

Tests are also provided for `experimental/rpm.bzl` only.  Tests for the
existing/legacy `pkg_rpm` rule can be added if so desired.

Additionally:

- Command debugging in `make_rpm.py` was expanded to include printing out the
  environment.

- The test helper routines were made even more generic -- now users can specify
  the exact CSV manifest formats they want.  This is used to check for mtimes for
  this particular use case which are otherwise not checked.

- Documentation fixes where observed.  Some of the TODOs will be tagged with
  tickets when opportune (soon).

[`SOURCE_DATE_EPOCH`]: https://reproducible-builds.org/docs/source-date-epoch/
[this PR]: rpm-software-management/rpm#144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants