Improved workspace/repository checks

main
Michal 2 years ago
parent a1276fb7d8
commit e5997de8da

@ -1,15 +1,15 @@
[base] [base]
mode = "repository" mode = "workspace"
smart_pull = true smart_pull = true
[mode.repository] [mode.repository]
name = "test" name = ""
build_on_update = true build_on_update = false
[mode.repository.signing] [mode.repository.signing]
enabled = true enabled = false
key = "" key = ""
on_gen = true on_gen = false
[mode.workspace] [mode.workspace]
@ -18,26 +18,10 @@ name = [
"1::amethyst", "1::amethyst",
"1::jade!", "1::jade!",
"2::notop-git", "2::notop-git",
"3::slippy-rb" "3::appendage",
] ]
urls = [ urls = [
"https://github.com/crystal-linux/%repo%", "https://github.com/crystal-linux/%repo%",
"https://aur.archlinux.org/%repo%", "https://aur.archlinux.org/%repo%",
"https://github.com/jnats/%repo%" "https://github.com/not-my-segfault/%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.

@ -23,15 +23,19 @@ fn main() {
} }
let args: Args = Args::parse(); let args: Args = Args::parse();
let exclude = &args.exclude; let exclude = &args.exclude;
let verbose = args.verbose; 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()) { 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"); 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(); let dir = env::current_dir().unwrap();
env::set_current_dir("../").unwrap(); env::set_current_dir("../").unwrap();
log!(verbose, "Current dir: {:?}", env::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()); 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) { match args.subcommand.unwrap_or(Operation::Clone) {
Operation::Clone => operations::clone(verbose), Operation::Clone => operations::clone(verbose),
Operation::Build { Operation::Build {
packages, no_regen, .. 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::Pull { packages, .. } => operations::pull(packages, exclude.to_vec(), verbose),
Operation::RepoGen => { Operation::RepoGen => {
let config = read_cfg(verbose); if !repository {
if config.base.mode != "repository" {
crash!( crash!(
AppExitCode::BuildInWorkspace, AppExitCode::BuildInWorkspace,
"Cannot build packages in workspace mode" "Cannot build packages in workspace mode"
) )
} }
info!("Generating repository: {}", config.mode.repository.name);
repository::generate(verbose); repository::generate(verbose);
} }
Operation::Config => operations::config(verbose), Operation::Config => operations::config(verbose),

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

Loading…
Cancel
Save