Implemented package priorities

main
Michal 2 years ago
parent ef7007bffc
commit 6397055196

@ -1,4 +1,4 @@
use crate::internal::structs::ErroredPackage;
use crate::internal::structs::{ErroredPackage, Repo};
use crate::internal::AppExitCode;
use crate::{crash, info, repository, workspace};
@ -8,10 +8,10 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
let all = packages.is_empty();
// Get list of repos and subtract exclude
let mut repos: Vec<String> = config.repo.iter().map(|x| x.name.clone()).collect();
let mut repos: Vec<Repo> = config.repo;
if !exclude.is_empty() {
for ex in exclude {
repos.retain(|x| *x != ex);
repos.retain(|x| *x.name != ex);
}
}
@ -19,16 +19,21 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
let mut errored: Vec<ErroredPackage> = vec![];
if !packages.is_empty() && !all {
for pkg in &packages {
if !repos.contains(pkg) {
// If repo is not in config, crash
if !repos.iter().map(|x| x.name.clone()).any(|x| x == *pkg) {
crash!(
AppExitCode::PkgNotFound,
"Package repo {} not found in in mlc.toml",
pkg
);
} else {
// Otherwise, build
let code = repository::build(pkg, config.sign);
if code != 0 {
let error = ErroredPackage { name: pkg.to_string(), code };
let error = ErroredPackage {
name: pkg.to_string(),
code,
};
errored.push(error);
}
}
@ -37,10 +42,15 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
// If all is specified, attempt to build a package from all repos
if all {
// Sort by package priority
repos.sort_by(|a, b| b.priority.cmp(&a.priority));
for pkg in repos {
let code = repository::build(&pkg, config.sign);
let code = repository::build(&pkg.name, config.sign);
if code != 0 {
let error = ErroredPackage { name: pkg, code };
let error = ErroredPackage {
name: pkg.name,
code,
};
errored.push(error);
}
}

@ -1,4 +1,4 @@
use crate::{internal::AppExitCode, crash};
use crate::{crash, internal::AppExitCode};
use std::env;
use std::process::Command;
@ -34,11 +34,7 @@ pub fn pull(packages: Vec<String>, exclude: Vec<String>) {
.collect::<Vec<String>>();
// Set repos_applicable for next function
let mut repos_applicable = if all {
repos
} else {
packages
};
let mut repos_applicable = if all { repos } else { packages };
// Subtract exclude from repos_applicable
if !exclude.is_empty() {

@ -29,7 +29,12 @@ pub fn build(pkg: &str, sign: bool) -> i32 {
// Build each package
let a = Command::new("makepkg")
.args(&["-sf", "--skippgpcheck", if sign { "--sign" } else {"--nosign"}, "--noconfirm"])
.args(&[
"-sf",
"--skippgpcheck",
if sign { "--sign" } else { "--nosign" },
"--noconfirm",
])
.spawn()
.unwrap()
.wait()

@ -37,10 +37,7 @@ pub fn generate() {
Command::new("bash")
.args(&[
"-c",
&format!(
"GLOBIGNORE=\"*.sig\" repo-add {}.tar.gz *.pkg.tar.*",
db
),
&format!("GLOBIGNORE=\"*.sig\" repo-add {}.tar.gz *.pkg.tar.*", db),
])
.spawn()
.unwrap()

Loading…
Cancel
Save