Implement package replacement feature across the codebase

- Introduced a new `replaces` field in various structs to support package replacements.
- Updated database schema to include a `replaces` table and corresponding queries.
- Modified the package index to handle replacements and ensure they take precedence over exact package names.
- Enhanced the `create_source_repo_index` function to include replacement entries in the index.
- Updated tests to validate the new replacement functionality, including parsing and metadata generation.
- Refactored relevant functions and structures to accommodate the new `replaces` feature in package specifications and alternatives.
This commit is contained in:
2026-03-16 22:47:35 -05:00
parent 82f3b625ee
commit 2bc9e7a525
14 changed files with 1108 additions and 140 deletions
+11 -7
View File
@@ -890,19 +890,23 @@ mod tests {
#[test]
fn test_effective_rustflags_applies_replace_rules() {
let mut flags = BuildFlags::default();
flags.rustflags = vec!["-C".into(), "debuginfo=2".into()];
flags.replace_rustflags = vec!["debuginfo=2=>opt-level=2".into()];
let flags = BuildFlags {
rustflags: vec!["-C".into(), "debuginfo=2".into()],
replace_rustflags: vec!["debuginfo=2=>opt-level=2".into()],
..BuildFlags::default()
};
assert_eq!(effective_rustflags(&flags), vec!["-C", "opt-level=2"]);
}
#[test]
fn test_effective_rustflags_appends_rustltoflags_when_enabled() {
let mut flags = BuildFlags::default();
flags.rustflags = vec!["-C".into(), "opt-level=3".into()];
flags.rustltoflags = vec!["-Clinker-plugin-lto".into(), "-Cembed-bitcode=yes".into()];
flags.use_lto = true;
let flags = BuildFlags {
rustflags: vec!["-C".into(), "opt-level=3".into()],
rustltoflags: vec!["-Clinker-plugin-lto".into(), "-Cembed-bitcode=yes".into()],
use_lto: true,
..BuildFlags::default()
};
assert_eq!(
effective_rustflags(&flags),