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);