summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2023-02-03 20:42:35 -0500
committerGitHub <noreply@github.com>2023-02-03 20:42:35 -0500
commit9981e4d1ea6ac0992ff21be5514d4230dc77548b (patch)
treed45a0696337881689c1e7adaaad22a5a4f664ec4
parent5b2eee7eed72b4894909c5eecbf014ea0b5ad995 (diff)
parentc2531885d136707cbbc6f19df2b16504c3a0d22f (diff)
downloadrust-installer-9981e4d1ea6ac0992ff21be5514d4230dc77548b.tar.gz
Merge pull request #120 from jonhoo/deterministic-manifest
Write out manifest.in entries deterministically
-rw-r--r--src/generator.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/generator.rs b/src/generator.rs
index 6a4cb9b..1e4d00b 100644
--- a/src/generator.rs
+++ b/src/generator.rs
@@ -3,6 +3,7 @@ use super::Tarballer;
use crate::compression::CompressionFormats;
use crate::util::*;
use anyhow::{bail, format_err, Context, Result};
+use std::collections::BTreeSet;
use std::io::Write;
use std::path::Path;
@@ -121,13 +122,14 @@ impl Generator {
/// Copies the `src` directory recursively to `dst`, writing `manifest.in` too.
fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> {
- let manifest = create_new_file(dst.join("manifest.in"))?;
+ let mut manifest = create_new_file(dst.join("manifest.in"))?;
let bulk_dirs: Vec<_> = bulk_dirs
.split(',')
.filter(|s| !s.is_empty())
.map(Path::new)
.collect();
+ let mut paths = BTreeSet::new();
copy_with_callback(src, dst, |path, file_type| {
// We need paths to be compatible with both Unix and Windows.
if path
@@ -157,14 +159,20 @@ fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> {
if file_type.is_dir() {
// Only manifest directories that are explicitly bulk.
if bulk_dirs.contains(&path) {
- writeln!(&manifest, "dir:{}", string)?;
+ paths.insert(format!("dir:{}\n", string));
}
} else {
// Only manifest files that aren't under bulk directories.
if !bulk_dirs.iter().any(|d| path.starts_with(d)) {
- writeln!(&manifest, "file:{}", string)?;
+ paths.insert(format!("file:{}\n", string));
}
}
Ok(())
- })
+ })?;
+
+ for path in paths {
+ manifest.write_all(path.as_bytes())?;
+ }
+
+ Ok(())
}