From 3038cdf5e7a8987b62ef80297b56ce69b8aa661d Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Fri, 2 Oct 2026 01:19:33 +0200 Subject: [PATCH] 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. --- src/deb/local.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/deb/local.rs b/src/deb/local.rs index 138f053..92dd992 100644 --- a/src/deb/local.rs +++ b/src/deb/local.rs @@ -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);