deb: run the user probes through sh with stderr dropped

A missing build user is the expected state in every fresh ephemeral
chroot: without the redirect the id failures leak into the build log
as errors on every run.
This commit is contained in:
2026-10-02 12:26:46 +02:00
parent 7b47a3b32c
commit 672d17136b
+10 -12
View File
@@ -107,12 +107,15 @@ fn ensure_build_user(
workroot: &Path, workroot: &Path,
ccache_dir: Option<&str>, ccache_dir: Option<&str>,
) -> Result<(String, String), Box<dyn Error>> { ) -> Result<(String, String), Box<dyn Error>> {
let probe = ctx // Through sh with the stderr dropped: a missing user is the expected
.command("id") // state in a fresh chroot, not a message the build log needs.
.arg("-u") let id_of = |ctx: &Arc<Context>, what: &str| {
.arg(BUILD_USER) ctx.command("sh")
.output() .arg("-c")
.map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?; .arg(format!("id {what} {BUILD_USER} 2>/dev/null"))
.output()
};
let probe = id_of(ctx, "-u").map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?;
let fresh = !probe.status.success(); let fresh = !probe.status.success();
if fresh { if fresh {
create_build_user(ctx)?; create_build_user(ctx)?;
@@ -120,12 +123,7 @@ fn ensure_build_user(
let mut ids = (String::new(), String::new()); let mut ids = (String::new(), String::new());
for (flag, slot) in [("-u", 0), ("-g", 1)] { for (flag, slot) in [("-u", 0), ("-g", 1)] {
let output = ctx let output = id_of(ctx, flag).map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?;
.command("id")
.arg(flag)
.arg(BUILD_USER)
.output()
.map_err(|e| format!("cannot look up {BUILD_USER}: {e}"))?;
if !output.status.success() { if !output.status.success() {
return Err(format!("cannot resolve the ids of '{BUILD_USER}'").into()); return Err(format!("cannot resolve the ids of '{BUILD_USER}'").into());
} }