summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-10-30 00:29:20 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-11-01 23:17:47 +0100
commit54578efb4fe92e26a25bc9329c07ac0a8dc33deb (patch)
tree0f8d56256010eec337f21d4c514fc7123c362674
parentfddeb158b550a938358ee8251741514b362c68b6 (diff)
downloadrebel-54578efb4fe92e26a25bc9329c07ac0a8dc33deb.tar
rebel-54578efb4fe92e26a25bc9329c07ac0a8dc33deb.zip
driver: read pins from YAML file
-rw-r--r--.gitignore1
-rw-r--r--crates/driver/src/context.rs4
-rw-r--r--crates/driver/src/main.rs6
-rw-r--r--crates/driver/src/pin.rs39
4 files changed, 47 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index ea8c4bf..ff9dbb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/target
+/examples/*.yml
diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs
index a7ea302..b77655f 100644
--- a/crates/driver/src/context.rs
+++ b/crates/driver/src/context.rs
@@ -16,7 +16,7 @@ use common::{
types::TaskID,
};
-use crate::{args::*, paths, task::*};
+use crate::{args::*, paths, pin::Pins, task::*};
#[derive(Debug, Clone, Copy)]
pub enum ErrorKind<'ctx> {
@@ -140,7 +140,7 @@ pub struct Context {
}
impl Context {
- pub fn new(tasks: HashMap<TaskID, TaskDef>) -> Self {
+ pub fn new(tasks: HashMap<TaskID, TaskDef>, _pins: Pins) -> Self {
let platforms: HashMap<_, _> = [
arg(
"build",
diff --git a/crates/driver/src/main.rs b/crates/driver/src/main.rs
index b9a6173..2763dfa 100644
--- a/crates/driver/src/main.rs
+++ b/crates/driver/src/main.rs
@@ -2,6 +2,7 @@ mod args;
mod context;
mod driver;
mod paths;
+mod pin;
mod recipe;
mod resolve;
mod task;
@@ -28,7 +29,10 @@ fn main() {
let runner = unsafe { Runner::new(&runner::Options { jobs: opts.jobs }) }.unwrap();
- let ctx = context::Context::new(recipe::read_recipes("examples/recipes").unwrap());
+ let ctx = context::Context::new(
+ recipe::read_recipes("examples/recipes").unwrap(),
+ pin::read_pins("examples/pins.yml").unwrap(),
+ );
let mut rsv = resolve::Resolver::new(&ctx);
diff --git a/crates/driver/src/pin.rs b/crates/driver/src/pin.rs
new file mode 100644
index 0000000..26e445c
--- /dev/null
+++ b/crates/driver/src/pin.rs
@@ -0,0 +1,39 @@
+use std::{collections::HashMap, fs::File, path::Path};
+
+use serde::{Deserialize, Serialize};
+
+use common::{error::*, string_hash::*};
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub struct Args {
+ pub host: Option<String>,
+ pub target: Option<String>,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub struct Provides {
+ pub recipe: String,
+ pub task: String,
+ pub output: Vec<String>,
+ pub args: Args,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "kebab-case")]
+pub struct Pin {
+ pub hash: Option<ArchiveHash>,
+ #[serde(default)]
+ pub provides: Vec<Provides>,
+ #[serde(default)]
+ pub is_rootfs: bool,
+}
+
+pub type Pins = HashMap<String, Pin>;
+
+pub fn read_pins<P: AsRef<Path>>(path: P) -> Result<Pins> {
+ let f = File::open(path)?;
+ let pins: Pins = serde_yaml::from_reader(f)
+ .map_err(Error::new)
+ .context("YAML error")?;
+ Ok(pins)
+}