build: resolve the default build profiles from the distro data
This commit is contained in:
+16
-8
@@ -135,15 +135,15 @@ pub fn vendor_from_origins_content(content: &str) -> Option<String> {
|
||||
|
||||
/// Default build profiles applied by vendor hooks.
|
||||
///
|
||||
/// The Ubuntu vendor module activates `derivative.ubuntu noudeb` by default;
|
||||
/// Debian applies none. This mirrors what `Dpkg::BuildProfiles` resolves when
|
||||
/// `DEB_BUILD_PROFILES` is unset.
|
||||
/// The distro data carries them (`build_profiles` of the vendor's
|
||||
/// distribution in `data/distro_info.yml` — the Ubuntu vendor activates
|
||||
/// `derivative.ubuntu noudeb`, Debian applies none), mirroring what
|
||||
/// `Dpkg::BuildProfiles` resolves when `DEB_BUILD_PROFILES` is unset. The
|
||||
/// vendor is matched case-insensitively against the distro data keys
|
||||
/// (dpkg's `Vendor:` field keeps its original casing); a vendor with no
|
||||
/// distro entry gets no profiles.
|
||||
pub fn default_build_profiles(vendor: &str) -> Vec<String> {
|
||||
if vendor.eq_ignore_ascii_case("ubuntu") {
|
||||
vec!["derivative.ubuntu".to_string(), "noudeb".to_string()]
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
crate::distro_info::get_build_profiles(&vendor.to_lowercase()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Resolve the active build profiles: explicit `-P` profiles take precedence,
|
||||
@@ -378,6 +378,14 @@ mod tests {
|
||||
default_build_profiles("ubuntu"),
|
||||
vec!["derivative.ubuntu".to_string(), "noudeb".to_string()]
|
||||
);
|
||||
// dpkg's Vendor field keeps its original casing; the distro data
|
||||
// keys are lowercase.
|
||||
assert_eq!(
|
||||
default_build_profiles("Ubuntu"),
|
||||
vec!["derivative.ubuntu".to_string(), "noudeb".to_string()]
|
||||
);
|
||||
// A vendor without a distro entry gets no profiles.
|
||||
assert!(default_build_profiles("some-derivative").is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user