From cf1eb4a47737aed8b869c91abf35b4df197a6b4e Mon Sep 17 00:00:00 2001 From: jan Michal Date: Fri, 11 Feb 2022 00:53:48 +0000 Subject: [PATCH] attempt to fix #3 --- src/operations/build.rs | 20 ++++++++++++++++---- src/repository/mod.rs | 6 +++--- src/repository/package.rs | 8 +++++--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/operations/build.rs b/src/operations/build.rs index d68878a..0f7e18a 100644 --- a/src/operations/build.rs +++ b/src/operations/build.rs @@ -1,5 +1,5 @@ use crate::repository::generate; -use crate::{crash, repository, workspace}; +use crate::{crash, info, repository, workspace}; use clap::ArgMatches; pub fn build(matches: &ArgMatches) { @@ -41,11 +41,16 @@ pub fn build(matches: &ArgMatches) { } } + let mut errored: Vec = vec![]; + for pkg in packages { if !repos.contains(&pkg) { crash(format!("Package {} not found in repos in mlc.toml", pkg), 3); } else { - repository::build(pkg); + let code = repository::build(&pkg); + if code != 0 { + errored.push(pkg); + } } } @@ -55,7 +60,10 @@ pub fn build(matches: &ArgMatches) { .is_present("all") { for pkg in repos { - repository::build(pkg); + let code = repository::build(&pkg); + if code != 0 { + errored.push(pkg); + } } generate(); } @@ -67,4 +75,8 @@ pub fn build(matches: &ArgMatches) { { repository::generate(); } -} + + if !errored.is_empty() { + info(format!("The following packages build jobs returned a non-zero exit code: {}", errored.join(" "))) + } +} \ No newline at end of file diff --git a/src/repository/mod.rs b/src/repository/mod.rs index cadf498..70f9daf 100755 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -2,8 +2,8 @@ mod config; mod package; mod repo; -pub fn build(pkg: String) { - package::build(pkg); +pub fn build(pkg: &str) -> i32 { + package::build(pkg) } pub fn generate() { @@ -12,4 +12,4 @@ pub fn generate() { pub fn create_config() { config::create_config(); -} +} \ No newline at end of file diff --git a/src/repository/package.rs b/src/repository/package.rs index 57fe203..2ed0d46 100755 --- a/src/repository/package.rs +++ b/src/repository/package.rs @@ -3,7 +3,7 @@ use std::path::Path; use std::process::Command; use std::{env, fs}; -pub fn build(pkg: String) { +pub fn build(pkg: &str) -> i32 { let dir = env::current_dir().unwrap(); if !Path::exists("out".as_ref()) { fs::create_dir_all("out").unwrap(); @@ -14,7 +14,7 @@ pub fn build(pkg: String) { env::set_current_dir(pkg).unwrap(); - Command::new("makepkg") + let a = Command::new("makepkg") .args(&["-sf", "--skippgpcheck", "--sign", "--noconfirm"]) .spawn() .unwrap() @@ -29,4 +29,6 @@ pub fn build(pkg: String) { .unwrap(); env::set_current_dir(dir).unwrap(); -} + + a.code().unwrap() +} \ No newline at end of file