1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
use std::path::Path;
use anyhow::Result;
use crate::package_installer::{AptConfig, PackageRequest};
use crate::{ImageSpec, Stage};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BuildPlan {
spec: ImageSpec,
}
impl BuildPlan {
pub fn compile(spec: ImageSpec) -> Result<Self> {
spec.validate()?;
Ok(Self { spec })
}
pub fn spec(&self) -> &ImageSpec {
&self.spec
}
pub fn stages(&self) -> &'static [Stage] {
&Stage::ORDERED
}
pub fn dependencies(&self, stage: Stage) -> &'static [Stage] {
stage.dependencies()
}
/// Compile package-installation inputs from the validated immutable spec.
/// This keeps ALT's external resolver behind the typed adapter boundary.
pub fn package_request(
&self,
workdir: impl AsRef<Path>,
apt_config: impl AsRef<Path>,
) -> Result<PackageRequest> {
PackageRequest::new(
workdir,
AptConfig::new(apt_config)?,
self.spec.packages.base.iter().cloned(),
self.spec
.packages
.selectors
.iter()
.map(|selector| selector.as_str().to_owned()),
)
}
}
|