Implemented package priorities

main
Michal 2 years ago
parent c2dc3189f1
commit 085b460739
No known key found for this signature in database
GPG Key ID: A6A1A4DCB22279B9

@ -1,4 +1,4 @@
use crate::internal::structs::ErroredPackage; use crate::internal::structs::{ErroredPackage, Repo};
use crate::internal::AppExitCode; use crate::internal::AppExitCode;
use crate::{crash, info, repository, workspace}; 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(); let all = packages.is_empty();
// Get list of repos and subtract exclude // 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() { if !exclude.is_empty() {
for ex in exclude { 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![]; let mut errored: Vec<ErroredPackage> = vec![];
if !packages.is_empty() && !all { if !packages.is_empty() && !all {
for pkg in &packages { 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!( crash!(
AppExitCode::PkgNotFound, AppExitCode::PkgNotFound,
"Package repo {} not found in in mlc.toml", "Package repo {} not found in in mlc.toml",
pkg pkg
); );
} else { } else {
// Otherwise, build
let code = repository::build(pkg, config.sign); let code = repository::build(pkg, config.sign);
if code != 0 { if code != 0 {
let error = ErroredPackage { name: pkg.to_string(), code }; let error = ErroredPackage {
name: pkg.to_string(),
code,
};
errored.push(error); 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 is specified, attempt to build a package from all repos
if all { if all {
// Sort by package priority
repos.sort_by(|a, b| b.priority.cmp(&a.priority));
for pkg in repos { for pkg in repos {
let code = repository::build(&pkg, config.sign); let code = repository::build(&pkg.name, config.sign);
if code != 0 { if code != 0 {
let error = ErroredPackage { name: pkg, code }; let error = ErroredPackage {
name: pkg.name,
code,
};
errored.push(error); errored.push(error);
} }
} }

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

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

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

Loading…
Cancel
Save