aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkgs/populate/src/populate.rs24
-rw-r--r--pkgs/populate/tests/scenarios.nix28
2 files changed, 35 insertions, 17 deletions
diff --git a/pkgs/populate/src/populate.rs b/pkgs/populate/src/populate.rs
index 6c4fd42..86639ac 100644
--- a/pkgs/populate/src/populate.rs
+++ b/pkgs/populate/src/populate.rs
@@ -380,6 +380,12 @@ impl Kind for File {
}
}
+/// The fixed modification time of what pipe sources make, for touch -t in
+/// UTC: 2000-01-01, a time rsync can keep. It stores times beyond its
+/// range wrapped, e.g. the year 3000 as 2446, so they would differ on every
+/// run, and the file count as changed.
+const PIPE_TIME: &str = "200001010000";
+
/// What a command on the deploying machine prints.
struct Pipe;
@@ -397,8 +403,9 @@ impl Kind for Pipe {
)?;
run::status(
Command::new("touch")
+ .env("TZ", "UTC0")
.arg("-t")
- .arg("300001010000")
+ .arg(PIPE_TIME)
.arg(&out),
)?;
// With the fixed modification time, only checksums tell outputs of
@@ -432,15 +439,12 @@ fn deliver_directory(d: &Delivery) -> Result<Outcome> {
))?;
// The fixed time of pipe's output, so the same contents don't change
// anything at the target path, and only checksums tell them apart.
- run::status(Command::new("find").arg(out.as_ref()).args([
- "-exec",
- "touch",
- "-h",
- "-t",
- "300001010000",
- "{}",
- "+",
- ]))?;
+ run::status(
+ Command::new("find")
+ .env("TZ", "UTC0")
+ .arg(out.as_ref())
+ .args(["-exec", "touch", "-h", "-t", PIPE_TIME, "{}", "+"]),
+ )?;
let config = Config {
use_checksum: true,
..Config::default()
diff --git a/pkgs/populate/tests/scenarios.nix b/pkgs/populate/tests/scenarios.nix
index dac8e6b..0f1051c 100644
--- a/pkgs/populate/tests/scenarios.nix
+++ b/pkgs/populate/tests/scenarios.nix
@@ -461,13 +461,21 @@ in
};
});
- pipe = matrix "pipe" {} (_: _: {
- phases = twice {
- sources.x.pipe = "/fixtures/pipe";
- check = ''
- expect_eq x "$(cat "$T"/x)" piped
- '';
- };
+ pipe = matrix "pipe" {} (_: _: let
+ check = ''
+ expect_eq x "$(cat "$T"/x)" piped
+ '';
+ in {
+ phases = [
+ { sources.x.pipe = "/fixtures/pipe"; inherit check; }
+ # The same output again changes nothing, its time neither.
+ {
+ sources.x.pipe = "/fixtures/pipe";
+ check = check + ''
+ expect_eq changed "$(record changed)" false
+ '';
+ }
+ ];
})
# A directory the command makes: delivered with the modes it has, and
# mirrored, when what the command makes changes.
@@ -500,6 +508,12 @@ in
test ! -e "$T"/x/stray || fail "stray not removed"
'';
}
+ {
+ inherit sources;
+ check = secret "two" + ''
+ expect_eq changed "$(record changed)" false
+ '';
+ }
];
})) targetKinds;
[cgit] Unable to lock slot /tmp/cgit/5f200000.lock: Permission denied (13)