Skip to content

Commit c3b5fc8

Browse files
authored
Merge pull request #283 from cgwalters/bump-ostree-ext
Port to ostree-ext 0.13, cap-std 3
2 parents f9c37ae + f3ded38 commit c3b5fc8

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

lib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ anstream = "0.6.4"
1515
anstyle = "1.0.4"
1616
anyhow = "1.0"
1717
camino = { version = "1.0.4", features = ["serde1"] }
18-
ostree-ext = { version = "0.12.8" }
18+
ostree-ext = { version = "0.13" }
1919
chrono = { version = "0.4.23", features = ["serde"] }
2020
clap = { version= "4.2", features = ["derive"] }
2121
clap_mangen = { version = "0.2", optional = true }
22-
cap-std-ext = "3"
22+
cap-std-ext = "4"
2323
hex = "^0.4"
2424
fn-error-context = "0.2.0"
2525
gvariant = "0.4.0"

lib/src/deploy.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use anyhow::Ok;
66
use anyhow::{Context, Result};
77

8-
use cap_std::fs::Dir;
8+
use cap_std::fs::{Dir, MetadataExt};
99
use cap_std_ext::cap_std;
1010
use cap_std_ext::dirext::CapStdExtDirExt;
1111
use fn_error_context::context;
@@ -16,7 +16,6 @@ use ostree_ext::container::store::PrepareResult;
1616
use ostree_ext::ostree;
1717
use ostree_ext::ostree::Deployment;
1818
use ostree_ext::sysroot::SysrootLock;
19-
use rustix::fs::MetadataExt;
2019

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

316315
#[test]
317316
fn test_switch_inplace() -> Result<()> {
318-
use std::os::unix::fs::DirBuilderExt;
317+
use cap_std::fs::DirBuilderExt;
319318

320319
let td = cap_std_ext::cap_tempfile::TempDir::new(cap_std::ambient_authority())?;
321320
let mut builder = cap_std::fs::DirBuilder::new();

lib/src/install.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ use anyhow::Ok;
2020
use anyhow::{anyhow, Context, Result};
2121
use camino::Utf8Path;
2222
use camino::Utf8PathBuf;
23-
use cap_std::fs::Dir;
23+
use cap_std::fs::{Dir, MetadataExt};
2424
use cap_std_ext::cap_std;
2525
use cap_std_ext::prelude::CapStdExtDirExt;
2626
use chrono::prelude::*;
2727
use clap::ValueEnum;
2828
use ostree_ext::oci_spec;
2929
use rustix::fs::FileTypeExt;
30-
use rustix::fs::MetadataExt;
3130

3231
use fn_error_context::context;
3332
use ostree::gio;
@@ -691,8 +690,7 @@ async fn initialize_ostree_root_from_self(
691690

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

694-
let config = state.configuration.as_ref();
695-
let labels = config.and_then(crate::status::labels_of_config);
693+
let labels = crate::status::labels_of_config(&state.configuration);
696694
let timestamp = labels
697695
.and_then(|l| {
698696
l.get(oci_spec::image::ANNOTATION_CREATED)

lib/src/status.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,17 @@ pub(crate) fn labels_of_config(
117117
pub(crate) fn create_imagestatus(
118118
image: ImageReference,
119119
manifest_digest: &str,
120-
config: Option<&ImageConfiguration>,
120+
config: &ImageConfiguration,
121121
) -> ImageStatus {
122-
let labels = config.and_then(labels_of_config);
122+
let labels = labels_of_config(config);
123123
let timestamp = labels
124124
.and_then(|l| {
125125
l.get(oci_spec::image::ANNOTATION_CREATED)
126126
.map(|s| s.as_str())
127127
})
128128
.and_then(try_deserialize_timestamp);
129129

130-
let version = config
131-
.and_then(ostree_container::version_for_config)
132-
.map(ToOwned::to_owned);
130+
let version = ostree_container::version_for_config(config).map(ToOwned::to_owned);
133131
ImageStatus {
134132
image,
135133
version,
@@ -155,13 +153,10 @@ fn boot_entry_from_deployment(
155153
let csum = deployment.csum();
156154
let imgstate = ostree_container::store::query_image_commit(repo, &csum)?;
157155
let cached = imgstate.cached_update.map(|cached| {
158-
create_imagestatus(image.clone(), &cached.manifest_digest, Some(&cached.config))
156+
create_imagestatus(image.clone(), &cached.manifest_digest, &cached.config)
159157
});
160-
let imagestatus = create_imagestatus(
161-
image,
162-
&imgstate.manifest_digest,
163-
imgstate.configuration.as_ref(),
164-
);
158+
let imagestatus =
159+
create_imagestatus(image, &imgstate.manifest_digest, &imgstate.configuration);
165160
// We found a container-image based deployment
166161
(Some(imagestatus), cached)
167162
} else {

0 commit comments

Comments
 (0)