deb: export DEB_RULES_REQUIRES_ROOT for the rules

dpkg-buildpackage normally exports the rules' root requirement from
debian/control; running the rules directly does not, and tools key
their assembly strategy on it - without it debputy refuses to
assemble packages shipping root-owned paths at all (apache2). Policy
defaults to 'binary-targets' when control does not declare it.
This commit is contained in:
2026-10-02 01:19:33 +02:00
parent bb90842ac9
commit 3038cdf5e7
+22
View File
@@ -446,6 +446,28 @@ pub async fn build(
}
}
// dpkg-buildpackage normally exports the rules' root requirement from
// debian/control; running the rules directly does not, and tools key
// their assembly strategy on it — without it debputy refuses to
// assemble packages shipping root-owned paths at all (apache2). Policy
// defaults to 'binary-targets' when control does not declare it.
let control = ctx
.command("cat")
.current_dir(package_dir_str)
.arg("debian/control")
.output()
.map_err(|e| format!("cannot read debian/control: {e}"))?;
let rules_requires_root = String::from_utf8_lossy(&control.stdout)
.lines()
.find(|line| {
line.to_ascii_lowercase()
.starts_with("rules-requires-root:")
})
.and_then(|line| line.split_once(':'))
.map(|(_, value)| value.trim().to_string())
.unwrap_or_else(|| "binary-targets".to_string());
env.insert("DEB_RULES_REQUIRES_ROOT".to_string(), rules_requires_root);
// Run the build step
log::debug!("Building (debian/rules build) package...");
enter_phase(view, Phase::Building);