mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-11-06 12:37:44 +08:00
Make repo call repo_builder instead
This commit is contained in:
parent
45d6bf5007
commit
835c25e92d
2
repo.sh
2
repo.sh
@ -23,5 +23,3 @@ do
|
||||
done
|
||||
|
||||
repo cook $COOK_OPT $recipes
|
||||
|
||||
repo_builder "$ROOT/repo/$TARGET" $recipes
|
||||
|
||||
@ -4,7 +4,7 @@ use cookbook::WALK_DEPTH;
|
||||
use cookbook::config::{CookConfig, get_config, init_config};
|
||||
use cookbook::cook::cook_build::build;
|
||||
use cookbook::cook::fetch::{fetch, fetch_offline};
|
||||
use cookbook::cook::fs::create_target_dir;
|
||||
use cookbook::cook::fs::{create_target_dir, run_command};
|
||||
use cookbook::cook::package::package;
|
||||
use cookbook::cook::pty::{PtyOut, UnixSlavePty, setup_pty};
|
||||
use cookbook::cook::tree::{display_tree_entry, format_size};
|
||||
@ -173,7 +173,7 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
|
||||
let (config, command, recipe_names) = parse_args(args)?;
|
||||
if command == CliCommand::Cook && config.cook.tui {
|
||||
if let Some((name, e)) = run_tui_cook(config, recipe_names)? {
|
||||
if let Some((name, e)) = run_tui_cook(config.clone(), recipe_names.clone())? {
|
||||
let _ = stderr().write(e.as_bytes());
|
||||
let _ = stderr().write(b"\n\n");
|
||||
eprintln!(
|
||||
@ -194,7 +194,7 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
style::Reset,
|
||||
);
|
||||
}
|
||||
return Ok(());
|
||||
return publish_packages(&recipe_names, &config.repo_dir);
|
||||
}
|
||||
if command == CliCommand::Tree {
|
||||
return handle_tree(&recipe_names, &config);
|
||||
@ -236,6 +236,10 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
if command == CliCommand::Cook {
|
||||
return publish_packages(&recipe_names, &config.repo_dir);
|
||||
}
|
||||
|
||||
if verbose {
|
||||
println!(
|
||||
"\nCommand '{}' completed for {} recipes.",
|
||||
@ -267,6 +271,22 @@ fn repo_inner(
|
||||
})
|
||||
}
|
||||
|
||||
fn publish_packages(recipe_names: &Vec<CookRecipe>, repo_path: &PathBuf) -> anyhow::Result<()> {
|
||||
let repo_bin = env::current_exe()?.parent().unwrap().join("repo_builder");
|
||||
let mut command = Command::new(repo_bin);
|
||||
command
|
||||
.arg(repo_path)
|
||||
.args(recipe_names.iter().filter_map(|n| {
|
||||
if !n.is_deps {
|
||||
Some(n.name.as_str())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}));
|
||||
|
||||
run_command(command, &None).map_err(|e| anyhow!(e))
|
||||
}
|
||||
|
||||
fn parse_args(args: Vec<String>) -> anyhow::Result<(CliConfig, CliCommand, Vec<CookRecipe>)> {
|
||||
let mut config = CliConfig::new()?;
|
||||
let mut command: Option<String> = None;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use anyhow::anyhow;
|
||||
use cookbook::WALK_DEPTH;
|
||||
use pkg::{Package, PackageName, recipes};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
@ -25,6 +26,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let repo_dir = args
|
||||
.next()
|
||||
.expect("Usage: repo_builder <REPO_DIR> <recipe1> <recipe2> ...");
|
||||
Ok(publish_packages(args.collect(), repo_dir)?)
|
||||
}
|
||||
|
||||
// TODO: Make this callable from repo bin
|
||||
fn publish_packages(recipe_list: Vec<String>, repo_dir: String) -> anyhow::Result<()> {
|
||||
let repo_path = Path::new(&repo_dir);
|
||||
if !repo_path.is_dir() {
|
||||
fs::create_dir_all(repo_path)?;
|
||||
@ -36,7 +42,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// The following adds the package dependencies of the recipes to the repo as
|
||||
// well.
|
||||
let recipe_list = Package::new_recursive(
|
||||
&args.map(PackageName::new).collect::<Result<Vec<_>, _>>()?,
|
||||
&recipe_list
|
||||
.iter()
|
||||
.map(PackageName::new)
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
WALK_DEPTH,
|
||||
)?
|
||||
.into_iter()
|
||||
@ -111,7 +120,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.status()?
|
||||
.success()
|
||||
.then_some(())
|
||||
.ok_or("appstreamcli failed")?;
|
||||
.ok_or(anyhow!("appstreamcli failed"))?;
|
||||
|
||||
Command::new("pkgar")
|
||||
.arg("create")
|
||||
@ -123,7 +132,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.status()?
|
||||
.success()
|
||||
.then_some(())
|
||||
.ok_or("pkgar create failed")?;
|
||||
.ok_or(anyhow!("pkgar create failed"))?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user