feat: add support for metapackages in interactive prompts and update git2 dependency features

This commit is contained in:
2026-02-25 20:09:19 -06:00
parent d9a30f5d56
commit 631ac73b3f
2 changed files with 268 additions and 210 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ ar = "0.9.0"
bzip2 = "0.6.1"
clap = { version = "4.5.60", features = ["derive"] }
flate2 = "1.1.9"
git2 = { version = "0.20.4", features = ["vendored-libgit2"] }
git2 = { version = "0.20.4", features = ["openssl-sys"] }
indicatif = "0.18.4"
nix = { version = "0.31.1", features = ["user"] }
reqwest = { version = "0.13.2", features = ["blocking", "native-tls"] }
+66 -8
View File
@@ -243,11 +243,13 @@ pub fn create_interactive() -> Result<PackageSpec> {
BuildType::Rust,
BuildType::Custom,
BuildType::Bin,
BuildType::Meta,
];
let build_type = Select::new("Build System:", build_types)
.with_help_message("Select the build system used by the package (common choices)")
.prompt()?;
let is_metapackage = matches!(build_type, BuildType::Meta);
// If the build system is Autotools, offer a convenience prompt for GNU-hosted tarballs.
let mut gnu_source_default = String::new();
@@ -268,11 +270,19 @@ pub fn create_interactive() -> Result<PackageSpec> {
}
// Ask whether to show advanced fields.
let show_advanced = Confirm::new("Show advanced options?")
.with_help_message("Includes source subdir, toolchain overrides, hooks, and build tuning")
let show_advanced = if is_metapackage {
false
} else {
Confirm::new("Show advanced options?")
.with_help_message(
"Includes source subdir, toolchain overrides, hooks, and build tuning",
)
.with_default(false)
.prompt()?;
.prompt()?
};
let mut sources = Vec::new();
if !is_metapackage {
let source_url = Text::new("Source URL:")
.with_help_message("URL to the source tarball or git repository")
.with_default(gnu_source_default.as_str())
@@ -323,8 +333,15 @@ pub fn create_interactive() -> Result<PackageSpec> {
)?;
}
let mut flags = BuildFlags::default();
sources.push(source);
} else {
crate::log_info!(
"Metapackage selected: skipping source/build prompts. Define runtime dependencies to pull in."
);
}
let mut flags = BuildFlags::default();
if !is_metapackage {
if !matches!(build_type, BuildType::Bin) {
flags.prefix = Text::new("Install prefix:")
.with_help_message("Most packages should use /usr")
@@ -389,7 +406,8 @@ pub fn create_interactive() -> Result<PackageSpec> {
"CFLAG",
"One flag per entry, e.g. -O2, -fPIC, -D_GNU_SOURCE",
)?;
flags.ldflags = prompt_repeating_list("LDFLAG", "One flag per entry, e.g. -Wl,-z,relro")?;
flags.ldflags =
prompt_repeating_list("LDFLAG", "One flag per entry, e.g. -Wl,-z,relro")?;
}
if matches!(
@@ -465,8 +483,10 @@ pub fn create_interactive() -> Result<PackageSpec> {
"Example: x86_64-unknown-linux-gnu",
)?;
if show_advanced {
flags.rustflags =
prompt_repeating_list("RUSTFLAG", "One flag per entry, e.g. -Ctarget-cpu=native")?;
flags.rustflags = prompt_repeating_list(
"RUSTFLAG",
"One flag per entry, e.g. -Ctarget-cpu=native",
)?;
flags.cargs = prompt_repeating_list(
"Extra cargo arg",
"Examples: --locked, --features, serde, --no-default-features",
@@ -495,6 +515,7 @@ pub fn create_interactive() -> Result<PackageSpec> {
flags.post_install =
prompt_repeating_list("post_install command", "Runs after install step")?;
}
}
let runtime_deps =
prompt_repeating_list("Runtime dependency", "Package name (e.g. zlib, openssl)")?;
@@ -517,7 +538,7 @@ pub fn create_interactive() -> Result<PackageSpec> {
packages: Vec::new(),
alternatives: Alternatives::default(),
manual_sources: Vec::new(),
source: vec![source],
source: sources,
build: Build { build_type, flags },
dependencies: Dependencies {
build: build_deps,
@@ -1382,6 +1403,43 @@ mod tests {
assert_eq!(test_deps[1].as_str(), Some("bats"));
}
#[test]
fn spec_to_minimal_toml_supports_metapackage_without_sources() {
let spec = PackageSpec {
package: PackageInfo {
name: "foo-meta".into(),
version: "1.0".into(),
revision: 1,
description: "Meta package".into(),
homepage: "".into(),
license: vec!["MIT".into()],
},
packages: Vec::new(),
alternatives: Alternatives::default(),
manual_sources: Vec::new(),
source: Vec::new(),
build: Build {
build_type: BuildType::Meta,
flags: BuildFlags::default(),
},
dependencies: Dependencies {
build: Vec::new(),
runtime: vec!["foo".into(), "bar".into()],
test: Vec::new(),
},
package_alternatives: Default::default(),
package_dependencies: Default::default(),
spec_dir: PathBuf::from("."),
};
let toml = spec_to_minimal_toml(&spec).unwrap();
assert!(toml.contains("type = \"meta\""));
assert!(!toml.contains("[[source]]"));
let val: toml::Value = toml::from_str(&toml).unwrap();
assert!(val.get("source").is_none());
}
#[test]
fn compute_sha256_for_local_path_and_file_url() {
use sha2::Digest as TestDigest;