Skip to content

Commit

Permalink
Store repositories in a INI-style config file
Browse files Browse the repository at this point in the history
Use justconfig to have INI-style config files with files that can
override each other to store the repositories in.
  • Loading branch information
hunger committed May 16, 2021
1 parent 50dcf12 commit aaff5cf
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 45 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 32 additions & 10 deletions gng-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,25 @@ struct Args {
config: Option<PathBuf>,

/// the directory containing the Lua runtime environment
#[clap(long, parse(from_os_str), env = "GNG_DB_DIR", value_name = "DIR")]
#[clap(
long,
parse(from_os_str),
env = "GNG_DB_DIR",
value_name = "DIR",
default_value("/var/cache/gng/packets")
)]
db_dir: PathBuf,

/// the directory containing the Lua runtime environment
#[clap(
long,
parse(from_os_str),
env = "GNG_REPO_CONFIG_DIR",
value_name = "DIR",
default_value = "/etc/gng/repositories"
)]
repository_config_dir: PathBuf,

/// the directory containing the Lua runtime environment
#[clap(long, value_name = "REPO")]
repository: Option<String>,
Expand Down Expand Up @@ -99,15 +115,21 @@ fn main() -> Result<()> {
.canonicalize() // FIXME: Just make absolute!
.wrap_err("Failed to canonicalize pkgsrc path.")?;

// let repo = match &args.repository {
// Some(rin) => db.resolve_repository(rin),
// None => db.repository_for_packet_source_path(&pkgsrc_dir),
// }
// .ok_or_else(|| {
// eyre::eyre!(
// "Could not find repository to adopt the build result into. Please make sure some repository feels responsible for the packet source directory or provide --repository."
// )
// })?;
let repo_db = gng_db::RepositoryDb::open(&args.repository_config_dir).wrap_err(format!(
"Failed to read repositories in {}.",
&args.repository_config_dir.display()
))?;

let repo = match &args.repository {
Some(rin) => repo_db.resolve_repository(rin),
None => repo_db.repository_for_packet_source_path(&pkgsrc_dir),
}
.ok_or_else(|| {
eyre::eyre!(
"Could not find repository to adopt the build result into. Please make sure some repository feels responsible for the packet source directory or provide --repository."
)
})?;
tracing::debug!("Inserting packets into repository {}.", repo);

let source_packet_info = std::rc::Rc::new(gng_build::handler::SourcePacketInfo::default());

Expand Down
1 change: 1 addition & 0 deletions gng_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repository = "https://github.com/hunger/gng"

[dependencies]
gng_shared = { path = "../gng_shared" }
justconfig = { version = "1.0" }
serde = { version = "1.0" }
serde_json = { version = "1.0" }
thiserror = { version = "1.0" }
Expand Down
Loading

0 comments on commit aaff5cf

Please sign in to comment.