Skip to content
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

Set the mtime fields in the tarball correctly #61

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ serde = { version = "1.0.164", features = ["derive"] }
serde_json = "1.0.97"
gix = { version = "0.46.0", features = ["async-network-client", "serde"] }
gix-ref = { version = "0.30.0", features = ["serde"] }
tar = { version = "0.4.38", features = ["xattr"] }
#tar = { version = "0.4.38", features = ["xattr"] }
tar = { git = "https://github.com/DeterminateSystems/tar-rs.git", branch = "force-mtime", features = ["xattr"] }
Copy link
Member

Choose a reason for hiding this comment

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

Are we planning to try to upstream this? Otherwise, we'll need to keep this in sync somehow (I don't know how active the upstream is but...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's pretty ad hoc. Something more general (e.g. a filter to massage the FS metadata in arbitrary ways) might be more acceptable to upstream.

Upstream is not moving super fast: https://github.com/alexcrichton/tar-rs/tags so I don't think it's a lot of effort to rebase from time to time. It's not like the tar format is changing a lot...

Copy link
Member

Choose a reason for hiding this comment

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

Let's send a PR anyway and see what they say. We can keep pulling from our fork in the meantime.

Copy link
Member

Choose a reason for hiding this comment

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

(That is done in alexcrichton/tar-rs#337)

flate2 = "1.0.26"
tempfile = "3.6.0"
ring = "0.16.20"
Expand Down
13 changes: 12 additions & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,18 @@ async fn push_new_release(
span.record("source", tracing::field::display(source.clone().display()));
tracing::debug!("Found source");

let flake_tarball = get_flake_tarball(&source)
let last_modified = if let Some(last_modified) = flake_metadata.get("lastModified") {
last_modified.as_u64().ok_or_else(|| {
eyre!("`nix flake metadata --json` does not have a integer `lastModified` field")
})?
} else {
return Err(eyre!(
"`nix flake metadata` did not return a `lastModified` attribute"
));
};
tracing::debug!("lastModified = {}", last_modified);

let flake_tarball = get_flake_tarball(&source, last_modified)
.await
.wrap_err("Making release tarball")?;

Expand Down
6 changes: 5 additions & 1 deletion src/flake_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ const FLAKE_URL_PLACEHOLDER_UUID: &str = "c9026fc0-ced9-48e0-aa3c-fc86c4c86df1";
directory = %directory.display(),
)
)]
pub(crate) async fn get_flake_tarball(directory: &Path) -> color_eyre::Result<Vec<u8>> {
pub(crate) async fn get_flake_tarball(
directory: &Path,
last_modified: u64,
) -> color_eyre::Result<Vec<u8>> {
let mut tarball_builder = tar::Builder::new(vec![]);
tarball_builder.follow_symlinks(false);
tarball_builder.force_mtime(last_modified);

tracing::trace!("Creating tarball");
// `tar` works according to the current directory (yay)
Expand Down