Skip to content

build: add --source-date-epoch and --rewrite-timestamp flags #6208

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

Conversation

nalind
Copy link
Member

@nalind nalind commented Jun 4, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Use $SOURCE_DATE_EPOCH as the default for the --source-date-epoch flag to the "build" CLI.

When a source-date-epoch is set, we'll use it when writing new history entries, force timestamps in data written for --output to the specified timestamp, and populate a "SOURCE_DATE_EPOCH" ARG that we treat as always being set, and which we don't complain about being left unused. By default, this will not affect timestamps in newly-added layers.

Add a --rewrite-timestamp flag, which "clamps" timestamps in newly-added layers to not be later than the --source-date-epoch value if the --source-date-epoch flag is set, but has no effect otherwise.

Fix a bug in the dir_image_last_diff() helper function introduced in a57e7f4 as part of #6178.

How to verify it

New integration tests!

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`buildah build` now recognizes `--source-date-epoch` and `--rewrite-timestamp` flags, which affect the dates recorded in the new image's configuration and the timestamps on the contents of the new layers and content generated in response to the `--output` flag.

@openshift-ci openshift-ci bot added kind/feature Categorizes issue or PR as related to a new feature. approved labels Jun 4, 2025
Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. Just one non-blocking note.


if options.SourceDateEpoch != nil {
if options.Timestamp != nil {
return "", nil, errors.New("timestamp and source-date-epoch would be ambiguous if allowed together")
Copy link
Member

@Honny1 Honny1 Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be mentioned in the manpage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, thanks.

Use $SOURCE_DATE_EPOCH as the default for the --source-date-epoch flag
to the "build" CLI.

When a source-date-epoch is set, we'll use it when writing new history
entries, force timestamps in data written for --output to the specified
timestamp, and populate a "SOURCE_DATE_EPOCH" ARG that we treat as
always being set, and which we don't complain about being left unused.
By default, this will not affect timestamps in newly-added layers.

Add a --rewrite-timestamp flag, which "clamps" timestamps in newly-added
layers to not be later than the --source-date-epoch value if the
--source-date-epoch flag is set, but has no effect otherwise.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@nalind nalind force-pushed the build-source-date-epoch branch from fd8a8e8 to 865dace Compare June 5, 2025 14:23
Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Copy link
Contributor

openshift-ci bot commented Jun 5, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, nalind

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit f05fe6e into containers:main Jun 5, 2025
37 checks passed
@nalind nalind deleted the build-source-date-epoch branch June 6, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved kind/feature Categorizes issue or PR as related to a new feature. lgtm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants