@@ -8,13 +8,12 @@ use ostree_container::OstreeImageReference;
88use  ostree_ext:: container as  ostree_container; 
99use  ostree_ext:: keyfileext:: KeyFileExt ; 
1010use  ostree_ext:: oci_spec; 
11- use  ostree_ext:: oci_spec:: image:: ImageConfiguration ; 
1211use  ostree_ext:: ostree; 
13- use  ostree_ext:: sysroot:: SysrootLock ; 
1412
1513use  crate :: cli:: OutputFormat ; 
16- use  crate :: spec:: { BootEntry ,  BootOrder ,  Host ,  HostSpec ,  HostStatus ,  HostType ,   ImageStatus } ; 
14+ use  crate :: spec:: { BootEntry ,  BootOrder ,  Host ,  HostSpec ,  HostStatus ,  HostType } ; 
1715use  crate :: spec:: { ImageReference ,  ImageSignature } ; 
16+ use  crate :: store:: { CachedImageStatus ,  ContainerImageStore ,  Storage } ; 
1817
1918impl  From < ostree_container:: SignatureSource >  for  ImageSignature  { 
2019    fn  from ( sig :  ostree_container:: SignatureSource )  -> Self  { 
@@ -115,65 +114,46 @@ pub(crate) fn labels_of_config(
115114    config. config ( ) . as_ref ( ) . and_then ( |c| c. labels ( ) . as_ref ( ) ) 
116115} 
117116
118- /// Convert between a subset of ostree-ext metadata and the exposed spec API. 
119- pub ( crate )  fn  create_imagestatus ( 
120-     image :  ImageReference , 
121-     manifest_digest :  & str , 
122-     config :  & ImageConfiguration , 
123- )  -> ImageStatus  { 
124-     let  labels = labels_of_config ( config) ; 
125-     let  timestamp = labels
126-         . and_then ( |l| { 
127-             l. get ( oci_spec:: image:: ANNOTATION_CREATED ) 
128-                 . map ( |s| s. as_str ( ) ) 
129-         } ) 
130-         . and_then ( try_deserialize_timestamp) ; 
131- 
132-     let  version = ostree_container:: version_for_config ( config) . map ( ToOwned :: to_owned) ; 
133-     ImageStatus  { 
134-         image, 
135-         version, 
136-         timestamp, 
137-         image_digest :  manifest_digest. to_owned ( ) , 
138-     } 
139- } 
140- 
141117/// Given an OSTree deployment, parse out metadata into our spec. 
142118#[ context( "Reading deployment metadata" ) ]  
143119fn  boot_entry_from_deployment ( 
144-     sysroot :  & SysrootLock , 
120+     sysroot :  & Storage , 
145121    deployment :  & ostree:: Deployment , 
146122)  -> Result < BootEntry >  { 
147-     let  repo = & sysroot. repo ( ) ; 
148-     let  ( image,  cached_update,  incompatible)  = if  let  Some ( origin)  = deployment. origin ( ) . as_ref ( )  { 
123+     let  ( 
124+         store, 
125+         CachedImageStatus  { 
126+             image, 
127+             cached_update, 
128+         } , 
129+         incompatible, 
130+     )  = if  let  Some ( origin)  = deployment. origin ( ) . as_ref ( )  { 
149131        let  incompatible = crate :: utils:: origin_has_rpmostree_stuff ( origin) ; 
150-         let  ( image ,  cached )  = if  incompatible { 
132+         let  ( store ,  cached_imagestatus )  = if  incompatible { 
151133            // If there are local changes, we can't represent it as a bootc compatible image. 
152-             ( None ,  None ) 
134+             ( None ,  CachedImageStatus :: default ( ) ) 
153135        }  else  if  let  Some ( image)  = get_image_origin ( origin) ? { 
154-             let  image = ImageReference :: from ( image) ; 
155-             let  csum = deployment. csum ( ) ; 
156-             let  imgstate = ostree_container:: store:: query_image_commit ( repo,  & csum) ?; 
157-             let  cached = imgstate. cached_update . map ( |cached| { 
158-                 create_imagestatus ( image. clone ( ) ,  & cached. manifest_digest ,  & cached. config ) 
159-             } ) ; 
160-             let  imagestatus =
161-                 create_imagestatus ( image,  & imgstate. manifest_digest ,  & imgstate. configuration ) ; 
162-             // We found a container-image based deployment 
163-             ( Some ( imagestatus) ,  cached) 
136+             let  store = deployment. store ( ) ?; 
137+             let  store = store. as_ref ( ) . unwrap_or ( & sysroot. store ) ; 
138+             let  spec = Some ( store. spec ( ) ) ; 
139+             let  status = store. imagestatus ( sysroot,  deployment,  image) ?; 
140+ 
141+             ( spec,  status) 
164142        }  else  { 
165143            // The deployment isn't using a container image 
166-             ( None ,  None ) 
144+             ( None ,  CachedImageStatus :: default ( ) ) 
167145        } ; 
168-         ( image ,  cached ,  incompatible) 
146+         ( store ,  cached_imagestatus ,  incompatible) 
169147    }  else  { 
170148        // The deployment has no origin at all (this generally shouldn't happen) 
171-         ( None ,  None ,  false ) 
149+         ( None ,  CachedImageStatus :: default ( ) ,  false ) 
172150    } ; 
151+ 
173152    let  r = BootEntry  { 
174153        image, 
175154        cached_update, 
176155        incompatible, 
156+         store, 
177157        pinned :  deployment. is_pinned ( ) , 
178158        ostree :  Some ( crate :: spec:: BootEntryOstree  { 
179159            checksum :  deployment. csum ( ) . into ( ) , 
@@ -203,7 +183,7 @@ impl BootEntry {
203183
204184/// A variant of [`get_status`] that requires a booted deployment. 
205185pub ( crate )  fn  get_status_require_booted ( 
206-     sysroot :  & SysrootLock , 
186+     sysroot :  & Storage , 
207187)  -> Result < ( ostree:: Deployment ,  Deployments ,  Host ) >  { 
208188    let  booted_deployment = sysroot. require_booted_deployment ( ) ?; 
209189    let  ( deployments,  host)  = get_status ( sysroot,  Some ( & booted_deployment) ) ?; 
@@ -214,7 +194,7 @@ pub(crate) fn get_status_require_booted(
214194/// a more native Rust structure. 
215195#[ context( "Computing status" ) ]  
216196pub ( crate )  fn  get_status ( 
217-     sysroot :  & SysrootLock , 
197+     sysroot :  & Storage , 
218198    booted_deployment :  Option < & ostree:: Deployment > , 
219199)  -> Result < ( Deployments ,  Host ) >  { 
220200    let  stateroot = booted_deployment. as_ref ( ) . map ( |d| d. osname ( ) ) ; 
@@ -311,7 +291,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
311291    let  host = if  !Utf8Path :: new ( "/run/ostree-booted" ) . try_exists ( ) ? { 
312292        Default :: default ( ) 
313293    }  else  { 
314-         let  sysroot = super :: cli:: get_locked_sysroot ( ) . await ?; 
294+         let  sysroot = super :: cli:: get_storage ( ) . await ?; 
315295        let  booted_deployment = sysroot. booted_deployment ( ) ; 
316296        let  ( _deployments,  host)  = get_status ( & sysroot,  booted_deployment. as_ref ( ) ) ?; 
317297        host
0 commit comments