Extend pkg_tar rule with stamp_mtime attribute#285
Extend pkg_tar rule with stamp_mtime attribute#285dennis3620 wants to merge 1 commit intobazelbuild:mainfrom
Conversation
… status variables
| </p> | ||
| <p> | ||
| <code> | ||
| stamp_mtime = "{STAMP_MTIME}", |
There was a problem hiding this comment.
Why is this using a different name than BUILD_TIMESTAMP?
But really, this should be a bool. Either stamp the time found in BUILD_TIMESTAMP or use the portable time.
|
Let's discuss solutions in an issue first. I would like to to have as many people as possible weigh in on what is useful.
|
|
Design and requirements gathering is tracked in #287. |
aiuto
left a comment
There was a problem hiding this comment.
I tried my own variant in #288.
It uses a similar technique, but supports --stamp directly, without having to modify the pkg_tar rule.
I prefer that because it feeds into the stamp behavior of the built-in rules like cc_binary. https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary
Let's finish discussion of what we want in #287 and then see what to implement.
| stamp_mtime_strip = ctx.attr.stamp_mtime.strip() | ||
| if not stamp_mtime_strip.startswith("{") or not stamp_mtime_strip.endswith("}"): | ||
| fail("You set stamp_mtime, but this doesn't contain a valid key variable") |
There was a problem hiding this comment.
This should just use BUILD_STAMP. We don't need the flexibility to let the user set an arbitrary variable out of the volatile status file. This adds complexity that no one asked for.
| #!/usr/bin/env bash | ||
| stamp_mtime=946684741 # 1999-12-31, 23:58:01 | ||
| cat << EOF | ||
| STAMP_MTIME ${stamp_mtime} |
|
I'm opting for the path I have taken in #288. That will works the same way as the |
This change extends the
pkg_tarrule for stamp support for files' mtime. The attributestamp_mtimecontains a "volatile" workspace status command key which allows to set dynamic mtime for files inside tar archives. The value of the key depends on the workspace status command result but only "volatile" keys are provided as input topkg_tarrule.The motivation behind this change relates to #149 and #192. Files are build with Bazel and added as tar archive to
container_imagerule (rules_docker). These files are served by nginx inside the container. This change should provide proper ETag values for nginx which relies on file's last modification date for caching.