@@ -181,3 +181,51 @@ pub(crate) async fn imgcmd_entrypoint(
181181 cmd. args ( args) ;
182182 cmd. run_capture_stderr ( )
183183}
184+
185+ /// Re-pull the currently booted image into the bootc-owned container storage.
186+ ///
187+ /// This onboards the system to unified storage for host images so that
188+ /// upgrade/switch can use the unified path automatically when the image is present.
189+ #[ context( "Setting unified storage for booted image" ) ]
190+ pub ( crate ) async fn set_unified_entrypoint ( ) -> Result < ( ) > {
191+ let sysroot = crate :: cli:: get_storage ( ) . await ?;
192+ let ostree = sysroot. get_ostree ( ) ?;
193+ let repo = & ostree. repo ( ) ;
194+
195+ // Discover the currently booted image reference
196+ let ( _booted_deployment, _deployments, host) =
197+ crate :: status:: get_status_require_booted ( ostree) ?;
198+ let imgref = host
199+ . spec
200+ . image
201+ . as_ref ( )
202+ . ok_or_else ( || anyhow:: anyhow!( "No image source specified in host spec" ) ) ?;
203+
204+ // Canonicalize for pull display only, but we want to preserve original pullspec
205+ let imgref_display = imgref. clone ( ) . canonicalize ( ) ?;
206+
207+ // Pull the image from its original source into bootc storage using LBI machinery
208+ let imgstore = sysroot. get_ensure_imgstore ( ) ?;
209+ let img_string = format ! ( "{:#}" , imgref) ;
210+ println ! (
211+ "Re-pulling booted image into bootc storage via unified path: {}" ,
212+ imgref_display
213+ ) ;
214+ imgstore
215+ . pull ( & img_string, crate :: podstorage:: PullMode :: Always )
216+ . await ?;
217+
218+ // Optionally verify we can import from containers-storage by preparing in a temp importer
219+ // without actually importing into the main repo; this is a lightweight validation.
220+ let containers_storage_imgref = crate :: spec:: ImageReference {
221+ transport : "containers-storage" . to_string ( ) ,
222+ image : imgref. image . clone ( ) ,
223+ signature : imgref. signature . clone ( ) ,
224+ } ;
225+ let ostree_imgref = ostree_ext:: container:: OstreeImageReference :: from ( containers_storage_imgref) ;
226+ let _ = ostree_ext:: container:: store:: ImageImporter :: new ( repo, & ostree_imgref, Default :: default ( ) )
227+ . await ?;
228+
229+ println ! ( "Unified storage set for current image. Future upgrade/switch will use it automatically." ) ;
230+ Ok ( ( ) )
231+ }
0 commit comments