feat: add support for renamed package updates and ABI-breaking flags
- Introduced `real_name` field in `InstalledPackageRecord` and `PackageInfo` to handle renamed packages. - Added `abi_breaking` field to manage versioned shared libraries during renamed updates. - Updated database schema to include `real_name` and `abi_breaking` columns. - Enhanced package registration logic to support replacement of renamed packages while retaining specified files and directories. - Modified various functions and tests to accommodate the new fields and ensure backward compatibility. - Updated TOML serialization to include `real_name` and `abi_breaking` in package metadata.
This commit is contained in:
@@ -138,6 +138,12 @@ impl Packager {
|
||||
"version".to_string(),
|
||||
toml::Value::String(self.spec.package.version.clone()),
|
||||
);
|
||||
if let Some(real_name) = &self.spec.package.real_name {
|
||||
map.insert(
|
||||
"real_name".to_string(),
|
||||
toml::Value::String(real_name.clone()),
|
||||
);
|
||||
}
|
||||
map.insert(
|
||||
"revision".to_string(),
|
||||
toml::Value::Integer(self.spec.package.revision as i64),
|
||||
@@ -150,6 +156,10 @@ impl Packager {
|
||||
"homepage".to_string(),
|
||||
toml::Value::String(self.spec.package.homepage.clone()),
|
||||
);
|
||||
map.insert(
|
||||
"abi_breaking".to_string(),
|
||||
toml::Value::Boolean(self.spec.package.abi_breaking),
|
||||
);
|
||||
map.insert(
|
||||
"license".to_string(),
|
||||
license_value(&self.spec.package.license),
|
||||
@@ -294,10 +304,12 @@ mod tests {
|
||||
PackageSpec {
|
||||
package: PackageInfo {
|
||||
name: "test".into(),
|
||||
real_name: None,
|
||||
version: "1.0".into(),
|
||||
revision: 1,
|
||||
description: "d".into(),
|
||||
homepage: "h".into(),
|
||||
abi_breaking: false,
|
||||
license: vec!["MIT".into()],
|
||||
},
|
||||
packages: Vec::new(),
|
||||
@@ -455,6 +467,26 @@ mod tests {
|
||||
assert_eq!(arr[1].as_str(), Some("Apache-2.0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_generate_metadata_toml_includes_real_name_and_abi_breaking() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let dest = tmp.path();
|
||||
|
||||
let mut packager = mk_packager(dest.to_path_buf());
|
||||
packager.spec.package.real_name = Some("icu".into());
|
||||
packager.spec.package.abi_breaking = true;
|
||||
packager.generate_metadata_toml().unwrap();
|
||||
|
||||
let meta_path = dest.join(".metadata.toml");
|
||||
let content = fs::read_to_string(meta_path).unwrap();
|
||||
let val: toml::Value = toml::from_str(&content).unwrap();
|
||||
assert_eq!(val.get("real_name").and_then(|v| v.as_str()), Some("icu"));
|
||||
assert_eq!(
|
||||
val.get("abi_breaking").and_then(|v| v.as_bool()),
|
||||
Some(true)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_generate_metadata_toml_includes_keep_paths() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user