Improved workspace/repository checks

main
Michal 2 years ago
parent 8970931ff1
commit 5b87866922
No known key found for this signature in database
GPG Key ID: A6A1A4DCB22279B9

@ -1,15 +1,15 @@
[base]
mode = "repository"
mode = "workspace"
smart_pull = true
[mode.repository]
name = "test"
build_on_update = true
name = ""
build_on_update = false
[mode.repository.signing]
enabled = true
enabled = false
key = ""
on_gen = true
on_gen = false
[mode.workspace]
@ -18,26 +18,10 @@ name = [
"1::amethyst",
"1::jade!",
"2::notop-git",
"3::slippy-rb"
"3::appendage",
]
urls = [
"https://github.com/crystal-linux/%repo%",
"https://aur.archlinux.org/%repo%",
"https://github.com/jnats/%repo%"
]
# In this example, Malachite will create a repository called "test", with 4 packages
# These packages will be expanded based on the index number they have (index_number::package)
# To demonstrate, the ones in this config will expand to the following:
#
# https://github.com/crystal-linux/ame
# https://github.com/crystal-linux/jade
# https://aur.archlinux.org/notop-git
# https://github.com/jnats/slippy-rb
#
# The "name" option specifies the name of the pacman repository.
# The "sign" option specifies whether the built packages should be signed, which is recommended for all pacman repositories.
# When in repository mode, malachite only pulls the PKGBUILD file from the git repository (all we need to build the packages from src)
#
# Additionally, packages are built in the order of priority, so packages with a higher priority (denoted by "!"s appended to the name) will be built first.
# In this case, jade has a higher priority than amethyst, so it will be built first.
"https://github.com/not-my-segfault/%repo%"
]

@ -23,15 +23,19 @@ fn main() {
}
let args: Args = Args::parse();
let exclude = &args.exclude;
let verbose = args.verbose;
log!(verbose, "Args: {:?}", args);
log!(verbose, "Exclude: {:?}", exclude);
log!(verbose, "Verbose: You guess. :)");
let config = read_cfg(verbose);
log!(verbose, "Config: {:?}", config);
if Path::exists("../.git".as_ref()) {
log!(verbose, "Detected parent git repository");
info!("Parent directory is a git directory, pulling latest mlc.toml. It is advised you run mlc pull/update in all malachite directories");
let config = read_cfg(verbose);
let dir = env::current_dir().unwrap();
env::set_current_dir("../").unwrap();
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
@ -72,21 +76,30 @@ fn main() {
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
}
let repository = config.base.mode == "repository";
log!(verbose, "Repository Mode: {:?}", repository);
match args.subcommand.unwrap_or(Operation::Clone) {
Operation::Clone => operations::clone(verbose),
Operation::Build {
packages, no_regen, ..
} => operations::build(packages, exclude.to_vec(), no_regen, verbose),
} => {
if !repository {
crash!(
AppExitCode::BuildInWorkspace,
"Cannot build packages in workspace mode"
)
}
operations::build(packages, exclude.to_vec(), no_regen, verbose)
}
Operation::Pull { packages, .. } => operations::pull(packages, exclude.to_vec(), verbose),
Operation::RepoGen => {
let config = read_cfg(verbose);
if config.base.mode != "repository" {
if !repository {
crash!(
AppExitCode::BuildInWorkspace,
"Cannot build packages in workspace mode"
)
}
info!("Generating repository: {}", config.mode.repository.name);
repository::generate(verbose);
}
Operation::Config => operations::config(verbose),

@ -2,7 +2,7 @@ use std::path::Path;
use std::process::Command;
use std::{env, fs};
use crate::{crash, internal::AppExitCode, log, workspace::read_cfg};
use crate::{crash, info, internal::AppExitCode, log, workspace::read_cfg};
pub fn generate(verbose: bool) {
// Read config struct from mlc.toml
@ -13,6 +13,8 @@ pub fn generate(verbose: bool) {
let name = config.mode.repository.name;
log!(verbose, "Name: {}", name);
info!("Generating repository: {}", name);
// If repository exists, delete it
if Path::exists(name.as_ref()) {
log!(verbose, "Deleting {}", name);

Loading…
Cancel
Save