feat: add support for Mercurial (hg) source handling in mod.rs

- Implemented `split_hg_url` to parse Mercurial URLs and revisions.
- Added `checkout_hg` function to clone Mercurial repositories.
- Integrated Mercurial handling into the `prepare_one` function to support resuming builds.
- Added tests for `split_hg_url` to ensure correct parsing of URLs and revisions.

---

feat: introduce legacy STARBUILD conversion support in starbuild.rs

- Created `ConvertedStarbuild` and `ParsedStarbuild` structs to manage conversion data.
- Implemented `convert_starbuild_file` to parse STARBUILD files and generate package specifications.
- Added functions to handle parsing of various STARBUILD constructs, including dependencies and build phases.
- Developed a build script generator for STARBUILD, supporting custom install functions.
- Included tests to validate conversion of single and multi-output STARBUILD files.
This commit is contained in:
2026-03-23 15:13:07 -05:00
parent 19da5b960c
commit fd7873995a
10 changed files with 1653 additions and 9 deletions
+58 -2
View File
@@ -1,6 +1,7 @@
use crate::cli::{
BuildArgs, Cli, Commands, ConfigArgs, InfoArgs, InstallArgs, InternalCommands, ListArgs,
OwnsArgs, RemoveArgs, RepoArgs, RepoCommands, RepoKindArg, SearchArgs, SignArgs, UpdateArgs,
BuildArgs, Cli, Commands, ConfigArgs, ConvertArgs, InfoArgs, InstallArgs, InternalCommands,
ListArgs, OwnsArgs, RemoveArgs, RepoArgs, RepoCommands, RepoKindArg, SearchArgs, SignArgs,
UpdateArgs,
};
use crate::{
builder, cli_assets, config, cross, db, deps, index, install, locking, package, planner,
@@ -63,6 +64,7 @@ fn command_rootfs(command: &Commands) -> Option<&Path> {
Commands::Repo(args) => Some(repo_command_rootfs(&args.command)),
Commands::Config(args) => Some(&args.rootfs_args.rootfs),
Commands::Check(_)
| Commands::Convert(_)
| Commands::GenerateArtifacts(_)
| Commands::MakeSpec(_)
| Commands::Internal(_) => None,
@@ -76,6 +78,7 @@ fn command_assume_yes(command: &Commands) -> bool {
Commands::Build(args) => args.prompt_args.yes,
Commands::Update(args) => args.prompt_args.yes,
Commands::Check(_)
| Commands::Convert(_)
| Commands::Info(_)
| Commands::Search(_)
| Commands::Owns(_)
@@ -4669,6 +4672,7 @@ pub fn run(cli: Cli) -> Result<()> {
| Commands::Repo(_)
| Commands::Config(_)
| Commands::GenerateArtifacts(_)
| Commands::Convert(_)
| Commands::MakeSpec(_)
| Commands::Internal(_) => false,
};
@@ -5901,6 +5905,58 @@ pub fn run(cli: Cli) -> Result<()> {
output_path.display()
));
}
Commands::Convert(ConvertArgs { input, output }) => {
let converted = package::convert_starbuild_file(&input, output.as_deref())?;
let mut outputs = vec![converted.output_path.clone()];
if let Some(build_script_path) = &converted.build_script_path {
outputs.push(build_script_path.clone());
}
let existing: Vec<_> = outputs
.iter()
.filter(|path| path.exists())
.map(|path| path.display().to_string())
.collect();
if !existing.is_empty() {
ui::warn(format!(
"Generated files already exist: {}",
existing.join(", ")
));
if !ui::prompt_yes_no("Overwrite them?", false)? {
anyhow::bail!("Aborted");
}
}
fs::write(&converted.output_path, converted.toml)
.with_context(|| format!("Failed to write {}", converted.output_path.display()))?;
if let (Some(build_script), Some(build_script_path)) =
(converted.build_script, converted.build_script_path)
{
fs::write(&build_script_path, build_script)
.with_context(|| format!("Failed to write {}", build_script_path.display()))?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let mut perms = fs::metadata(&build_script_path)
.with_context(|| format!("Failed to stat {}", build_script_path.display()))?
.permissions();
perms.set_mode(0o755);
fs::set_permissions(&build_script_path, perms).with_context(|| {
format!("Failed to chmod {}", build_script_path.display())
})?;
}
ui::success(format!(
"Converted STARBUILD into {} and {}",
converted.output_path.display(),
build_script_path.display()
));
} else {
ui::success(format!(
"Converted STARBUILD into {}",
converted.output_path.display()
));
}
}
Commands::Internal(args) => {
let command = args.command;
run_internal_command(command)?;