Fixed issues presented in @axtloss 's testing

main
Michal 2 years ago
parent a333562859
commit 4467f08ac8

@ -16,9 +16,11 @@ repos = [
"crs:malachite/development:0a5bdc9", # Note, in this example, these two "crs:malachite/development:0a5bdc9", # Note, in this example, these two
"mic:apod:v.1.1.2", # will fail to build. "mic:apod:v.1.1.2", # will fail to build.
"pkg:pfetch!", "pkg:pfetch!",
"nms:rpass" # This too
] ]
[repositories.urls] [repositories.urls]
crs = "https://github.com/crystal-linux/{}" crs = "https://github.com/crystal-linux/{}"
pkg = "https://github.com/crystal-linux/pkgbuild.{}" pkg = "https://github.com/crystal-linux/pkgbuild.{}"
mic = "https://git.tar.black/michal/{}" mic = "https://git.tar.black/michal/{}"
nms = "https://github.com/not-my-segfault/{}"

@ -38,8 +38,8 @@ pub struct ConfigModeRepository {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct ConfigModeRepositorySigning { pub struct ConfigModeRepositorySigning {
pub enabled: bool, pub enabled: bool,
pub key: String, pub key: Option<String>,
pub on_gen: bool, pub on_gen: Option<bool>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

@ -10,19 +10,19 @@ pub fn build(packages: &[String], exclude: Vec<String>, no_regen: bool, verbose:
let all = packages.is_empty(); let all = packages.is_empty();
log!(verbose, "All: {:?}", all); log!(verbose, "All: {:?}", all);
// Read signing
let signing = config.mode.repository.as_ref().unwrap().signing.enabled;
// Read on_gen
let on_gen = config.mode.repository.as_ref().unwrap().signing.on_gen;
// Parse whether to sign on build or not // Parse whether to sign on build or not
let sign = if config.mode.repository.as_ref().unwrap().signing.enabled let sign = if signing && on_gen.is_some() && on_gen.unwrap() {
&& config.mode.repository.as_ref().unwrap().signing.on_gen
{
false false
} else { } else {
config.mode.repository.as_ref().unwrap().signing.enabled signing
}; };
log!( log!(verbose, "Signing: {:?}", sign);
verbose,
"Signing: {:?}",
config.mode.repository.unwrap().signing
);
// Get list of repos and subtract exclude // Get list of repos and subtract exclude
let mut repos: Vec<Repo> = config.repositories; let mut repos: Vec<Repo> = config.repositories;
@ -130,5 +130,11 @@ pub fn build(packages: &[String], exclude: Vec<String>, no_regen: bool, verbose:
"The following packages build jobs returned a non-zero exit code: \n {}", "The following packages build jobs returned a non-zero exit code: \n {}",
error_strings.join("\n ") error_strings.join("\n ")
); );
info!("Please check `man 8 makepkg` for more information");
// Check if code 63 appeared at all
if errored.iter().any(|x| x.code == 63) {
log!(verbose, "Code 63 found");
info!("Note: Code 63 is an internal Malachite exit code, and specifies that no PKGBUILD was found.");
}
} }
} }

@ -138,8 +138,38 @@ pub fn pull(packages: Vec<String>, exclude: &[String], verbose: bool, no_regen:
crash!(AppExitCode::NoPkgs, "No packages specified"); crash!(AppExitCode::NoPkgs, "No packages specified");
} }
// Pull! // Sort repos_applicable by priority
repos_applicable.sort_by(|a, b| {
config
.repositories
.iter()
.find(|x| x.name == *a)
.unwrap()
.priority
.cmp(
&config
.repositories
.iter()
.find(|x| x.name == *b)
.unwrap()
.priority,
)
});
log!(verbose, "Pulling {:?}", repos_applicable); log!(verbose, "Pulling {:?}", repos_applicable);
// If the directories specified in repos_applicable do not exist, crash
for repo in &repos_applicable {
if !std::path::Path::new(repo).exists() {
crash!(
AppExitCode::NoPkgs,
"Package {} does not exist, have you run `mlc clone/init`?",
repo
);
}
}
// Pull!
do_the_pulling( do_the_pulling(
repos_applicable, repos_applicable,
verbose, verbose,

@ -32,6 +32,13 @@ pub fn build(pkg: &str, sign: bool, verbose: bool) -> i32 {
env::set_current_dir(pkg).unwrap(); env::set_current_dir(pkg).unwrap();
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap()); log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
// If PKGBUILD is not found, return 63 and break
if !Path::exists("PKGBUILD".as_ref()) {
env::set_current_dir(&dir).unwrap();
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
return 63;
}
// Build each package // Build each package
let a = Command::new("makepkg") let a = Command::new("makepkg")
.args(&[ .args(&[

@ -40,7 +40,22 @@ pub fn generate(verbose: bool) {
// Sign all package files in repository if signing and on_gen are true // Sign all package files in repository if signing and on_gen are true
if config.mode.repository.as_ref().unwrap().signing.enabled if config.mode.repository.as_ref().unwrap().signing.enabled
&& config.mode.repository.as_ref().unwrap().signing.on_gen && config
.mode
.repository
.as_ref()
.unwrap()
.signing
.on_gen
.is_some()
&& config
.mode
.repository
.as_ref()
.unwrap()
.signing
.on_gen
.unwrap()
{ {
// Get a list of all .tar.* files in repository // Get a list of all .tar.* files in repository
let files = fs::read_dir(".").unwrap(); let files = fs::read_dir(".").unwrap();
@ -48,18 +63,49 @@ pub fn generate(verbose: bool) {
// Get file name // Get file name
let file = file.unwrap(); let file = file.unwrap();
let path = file.path(); let path = file.path();
let sign_command = if config
.mode
.repository
.as_ref()
.unwrap()
.signing
.key
.is_some()
&& !config
.mode
.repository
.as_ref()
.unwrap()
.signing
.key
.as_ref()
.unwrap()
.is_empty()
{
format!(
"gpg --default-key {} --detach-sign {}",
config
.mode
.repository
.as_ref()
.unwrap()
.signing
.key
.as_ref()
.unwrap(),
path.to_str().unwrap()
)
} else {
format!("gpg --detach-sign {}", path.to_str().unwrap())
};
// If extension is either .zst or .xz, sign it // If extension is either .zst or .xz, sign it
if path.extension().unwrap() == "zst" || path.extension().unwrap() == "xz" { if path.extension().unwrap() == "zst" || path.extension().unwrap() == "xz" {
log!(verbose, "Signing {}", path.display()); log!(verbose, "Signing {}", path.display());
Command::new("bash") Command::new("bash")
.args(&[ .arg("-c")
"-c", .args(&[&sign_command])
&format!(
"gpg --default-key {} --detach-sign {}",
config.mode.repository.as_ref().unwrap().signing.key,
file.file_name().to_str().unwrap()
),
])
.spawn() .spawn()
.unwrap() .unwrap()
.wait() .wait()

Loading…
Cancel
Save