Skip to content

Commit fd86d1d

Browse files
committed
install: Factor out helper to create aleph version
Prep for the anaconda install completion work. Signed-off-by: Colin Walters <[email protected]>
1 parent 7c8121a commit fd86d1d

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

lib/src/install.rs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,32 @@ impl FromStr for MountSpec {
495495
}
496496
}
497497

498+
impl InstallAleph {
499+
#[context("Creating aleph data")]
500+
pub(crate) fn new(
501+
src_imageref: &ostree_container::OstreeImageReference,
502+
imgstate: &ostree_container::store::LayeredImageState,
503+
selinux_state: &SELinuxFinalState,
504+
) -> Result<Self> {
505+
let uname = rustix::system::uname();
506+
let labels = crate::status::labels_of_config(&imgstate.configuration);
507+
let timestamp = labels
508+
.and_then(|l| {
509+
l.get(oci_spec::image::ANNOTATION_CREATED)
510+
.map(|s| s.as_str())
511+
})
512+
.and_then(crate::status::try_deserialize_timestamp);
513+
let r = InstallAleph {
514+
image: src_imageref.imgref.name.clone(),
515+
version: imgstate.version().as_ref().map(|s| s.to_string()),
516+
timestamp,
517+
kernel: uname.release().to_str()?.to_string(),
518+
selinux: selinux_state.to_aleph().to_string(),
519+
};
520+
Ok(r)
521+
}
522+
}
523+
498524
impl SourceInfo {
499525
// Inspect container information and convert it to an ostree image reference
500526
// that pulls from containers-storage.
@@ -842,23 +868,7 @@ async fn install_container(
842868
osconfig::inject_root_ssh_authorized_keys(&root, sepolicy, contents)?;
843869
}
844870

845-
let uname = rustix::system::uname();
846-
847-
let labels = crate::status::labels_of_config(&imgstate.configuration);
848-
let timestamp = labels
849-
.and_then(|l| {
850-
l.get(oci_spec::image::ANNOTATION_CREATED)
851-
.map(|s| s.as_str())
852-
})
853-
.and_then(crate::status::try_deserialize_timestamp);
854-
let aleph = InstallAleph {
855-
image: src_imageref.imgref.name.clone(),
856-
version: imgstate.version().as_ref().map(|s| s.to_string()),
857-
timestamp,
858-
kernel: uname.release().to_str()?.to_string(),
859-
selinux: state.selinux_state.to_aleph().to_string(),
860-
};
861-
871+
let aleph = InstallAleph::new(&src_imageref, &imgstate, &state.selinux_state)?;
862872
Ok((deployment, aleph))
863873
}
864874

0 commit comments

Comments
 (0)