summaryrefslogtreecommitdiffstats
path: root/crates/driver/src/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/driver/src/context.rs')
-rw-r--r--crates/driver/src/context.rs29
1 files changed, 27 insertions, 2 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) {