summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-11-01 23:16:41 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-11-01 23:33:45 +0100
commitf6e4529dba0adbf1736687686a0d70e674830a21 (patch)
tree6e77a6f70a9f8568ae627dd0fa8c890923b15cc5
parent54578efb4fe92e26a25bc9329c07ac0a8dc33deb (diff)
downloadrebel-f6e4529dba0adbf1736687686a0d70e674830a21.tar
rebel-f6e4529dba0adbf1736687686a0d70e674830a21.zip
context: get rootfs hash from pin map
-rw-r--r--crates/driver/src/context.rs29
-rw-r--r--crates/driver/src/main.rs3
2 files changed, 29 insertions, 3 deletions
diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs
index b77655f..1c8c0bd 100644
--- a/crates/driver/src/context.rs
+++ b/crates/driver/src/context.rs
@@ -13,6 +13,7 @@ use regex::Regex;
use common::{
error::{self, Contextualizable},
+ string_hash::ArchiveHash,
types::TaskID,
};
@@ -136,11 +137,12 @@ pub struct Context {
platforms: HashMap<String, Arg>,
globals: TaskArgs,
tasks: HashMap<TaskID, TaskDef>,
+ rootfs: (ArchiveHash, String),
rootfs_tasks: HashMap<TaskID, TaskDef>,
}
impl Context {
- pub fn new(tasks: HashMap<TaskID, TaskDef>, _pins: Pins) -> Self {
+ pub fn new(tasks: HashMap<TaskID, TaskDef>, pins: Pins) -> error::Result<Self> {
let platforms: HashMap<_, _> = [
arg(
"build",
@@ -171,14 +173,33 @@ impl Context {
arg("destdir", paths::TASK_DESTDIR.to_string()),
arg("sysroot", paths::TASK_SYSROOT.to_string()),
]);
+ let rootfs = Context::handle_pins(pins)?;
let rootfs_tasks = Context::rootfs_tasks();
- Context {
+ Ok(Context {
platforms,
globals,
tasks,
+ rootfs,
rootfs_tasks,
+ })
+ }
+
+ fn handle_pins(pins: Pins) -> error::Result<(ArchiveHash, String)> {
+ let mut rootfs = None;
+
+ for (name, pin) in pins {
+ if pin.is_rootfs {
+ if rootfs.is_some() {
+ return Err(error::Error::new("Multiple is-rootfs pins"));
+ }
+ let hash = pin.hash.context("is-rootfs pin without hash")?;
+
+ rootfs = Some((hash, name));
+ }
}
+
+ rootfs.context("No is-rootfs pins")
}
fn rootfs_tasks() -> HashMap<TaskID, TaskDef> {
@@ -227,6 +248,10 @@ impl Context {
ret
}
+ pub fn get_rootfs(&self) -> &(ArchiveHash, String) {
+ &self.rootfs
+ }
+
fn rootfs_task<'ctx>(&'ctx self, id: &'ctx TaskID, args: &TaskArgs) -> Option<&TaskDef> {
let build = self.globals.get("build").unwrap();
if args.get("host") != Some(build) {
diff --git a/crates/driver/src/main.rs b/crates/driver/src/main.rs
index 2763dfa..fe9204a 100644
--- a/crates/driver/src/main.rs
+++ b/crates/driver/src/main.rs
@@ -32,7 +32,8 @@ fn main() {
let ctx = context::Context::new(
recipe::read_recipes("examples/recipes").unwrap(),
pin::read_pins("examples/pins.yml").unwrap(),
- );
+ )
+ .unwrap();
let mut rsv = resolve::Resolver::new(&ctx);