Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to ostree-ext 0.13, cap-std 3 #283

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ anstream = "0.6.4"
anstyle = "1.0.4"
anyhow = "1.0"
camino = { version = "1.0.4", features = ["serde1"] }
ostree-ext = { version = "0.12.8" }
ostree-ext = { version = "0.13" }
chrono = { version = "0.4.23", features = ["serde"] }
clap = { version= "4.2", features = ["derive"] }
clap_mangen = { version = "0.2", optional = true }
cap-std-ext = "3"
cap-std-ext = "4"
hex = "^0.4"
fn-error-context = "0.2.0"
gvariant = "0.4.0"
Expand Down
5 changes: 2 additions & 3 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use anyhow::Ok;
use anyhow::{Context, Result};

use cap_std::fs::Dir;
use cap_std::fs::{Dir, MetadataExt};
use cap_std_ext::cap_std;
use cap_std_ext::dirext::CapStdExtDirExt;
use fn_error_context::context;
Expand All @@ -16,7 +16,6 @@ use ostree_ext::container::store::PrepareResult;
use ostree_ext::ostree;
use ostree_ext::ostree::Deployment;
use ostree_ext::sysroot::SysrootLock;
use rustix::fs::MetadataExt;

use crate::spec::HostSpec;
use crate::spec::ImageReference;
Expand Down Expand Up @@ -315,7 +314,7 @@ pub(crate) fn switch_origin_inplace(root: &Dir, imgref: &ImageReference) -> Resu

#[test]
fn test_switch_inplace() -> Result<()> {
use std::os::unix::fs::DirBuilderExt;
use cap_std::fs::DirBuilderExt;

let td = cap_std_ext::cap_tempfile::TempDir::new(cap_std::ambient_authority())?;
let mut builder = cap_std::fs::DirBuilder::new();
Expand Down
6 changes: 2 additions & 4 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ use anyhow::Ok;
use anyhow::{anyhow, Context, Result};
use camino::Utf8Path;
use camino::Utf8PathBuf;
use cap_std::fs::Dir;
use cap_std::fs::{Dir, MetadataExt};
use cap_std_ext::cap_std;
use cap_std_ext::prelude::CapStdExtDirExt;
use chrono::prelude::*;
use clap::ValueEnum;
use ostree_ext::oci_spec;
use rustix::fs::FileTypeExt;
use rustix::fs::MetadataExt;

use fn_error_context::context;
use ostree::gio;
Expand Down Expand Up @@ -691,8 +690,7 @@ async fn initialize_ostree_root_from_self(

let uname = rustix::system::uname();

let config = state.configuration.as_ref();
let labels = config.and_then(crate::status::labels_of_config);
let labels = crate::status::labels_of_config(&state.configuration);
let timestamp = labels
.and_then(|l| {
l.get(oci_spec::image::ANNOTATION_CREATED)
Expand Down
17 changes: 6 additions & 11 deletions lib/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,17 @@ pub(crate) fn labels_of_config(
pub(crate) fn create_imagestatus(
image: ImageReference,
manifest_digest: &str,
config: Option<&ImageConfiguration>,
config: &ImageConfiguration,
) -> ImageStatus {
let labels = config.and_then(labels_of_config);
let labels = labels_of_config(config);
let timestamp = labels
.and_then(|l| {
l.get(oci_spec::image::ANNOTATION_CREATED)
.map(|s| s.as_str())
})
.and_then(try_deserialize_timestamp);

let version = config
.and_then(ostree_container::version_for_config)
.map(ToOwned::to_owned);
let version = ostree_container::version_for_config(config).map(ToOwned::to_owned);
ImageStatus {
image,
version,
Expand All @@ -155,13 +153,10 @@ fn boot_entry_from_deployment(
let csum = deployment.csum();
let imgstate = ostree_container::store::query_image_commit(repo, &csum)?;
let cached = imgstate.cached_update.map(|cached| {
create_imagestatus(image.clone(), &cached.manifest_digest, Some(&cached.config))
create_imagestatus(image.clone(), &cached.manifest_digest, &cached.config)
});
let imagestatus = create_imagestatus(
image,
&imgstate.manifest_digest,
imgstate.configuration.as_ref(),
);
let imagestatus =
create_imagestatus(image, &imgstate.manifest_digest, &imgstate.configuration);
// We found a container-image based deployment
(Some(imagestatus), cached)
} else {
Expand Down
Loading