@@ -199,6 +199,31 @@ pub(crate) enum ContainerOpts {
199199 Lint ,
200200}
201201
202+ /// Subcommands which operate on images.
203+ #[ derive( Debug , clap:: Subcommand , PartialEq , Eq ) ]
204+ pub ( crate ) enum ImageCmdOpts {
205+ /// Wrapper for `podman image list` in bootc storage.
206+ List {
207+ #[ clap( allow_hyphen_values = true ) ]
208+ args : Vec < OsString > ,
209+ } ,
210+ /// Wrapper for `podman image build` in bootc storage.
211+ Build {
212+ #[ clap( allow_hyphen_values = true ) ]
213+ args : Vec < OsString > ,
214+ } ,
215+ /// Wrapper for `podman image pull` in bootc storage.
216+ Pull {
217+ #[ clap( allow_hyphen_values = true ) ]
218+ args : Vec < OsString > ,
219+ } ,
220+ /// Wrapper for `podman image push` in bootc storage.
221+ Push {
222+ #[ clap( allow_hyphen_values = true ) ]
223+ args : Vec < OsString > ,
224+ } ,
225+ }
226+
202227/// Subcommands which operate on images.
203228#[ derive( Debug , clap:: Subcommand , PartialEq , Eq ) ]
204229pub ( crate ) enum ImageOpts {
@@ -232,6 +257,16 @@ pub(crate) enum ImageOpts {
232257 /// this will make the image accessible via e.g. `podman run localhost/bootc` and for builds.
233258 target : Option < String > ,
234259 } ,
260+ /// Copy a container image from the default `containers-storage:` to the bootc-owned container storage.
261+ PullFromDefaultStorage {
262+ /// The image to pull
263+ image : String ,
264+ } ,
265+ /// List fetched images stored in the bootc storage.
266+ ///
267+ /// Note that these are distinct from images stored via e.g. `podman`.
268+ #[ clap( subcommand) ]
269+ Cmd ( ImageCmdOpts ) ,
235270}
236271
237272/// Hidden, internal only options
@@ -430,10 +465,12 @@ pub(crate) async fn get_locked_sysroot() -> Result<ostree_ext::sysroot::SysrootL
430465 Ok ( sysroot)
431466}
432467
468+ /// Load global storage state, expecting that we're booted into a bootc system.
433469#[ context( "Initializing storage" ) ]
434470pub ( crate ) async fn get_storage ( ) -> Result < crate :: store:: Storage > {
471+ let global_run = Dir :: open_ambient_dir ( "/run" , cap_std:: ambient_authority ( ) ) ?;
435472 let sysroot = get_locked_sysroot ( ) . await ?;
436- crate :: store:: Storage :: new ( sysroot)
473+ crate :: store:: Storage :: new ( sysroot, & global_run )
437474}
438475
439476#[ context( "Querying root privilege" ) ]
@@ -798,6 +835,27 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
798835 ImageOpts :: CopyToStorage { source, target } => {
799836 crate :: image:: push_entrypoint ( source. as_deref ( ) , target. as_deref ( ) ) . await
800837 }
838+ ImageOpts :: PullFromDefaultStorage { image } => {
839+ let sysroot = get_storage ( ) . await ?;
840+ sysroot. imgstore . pull_from_host_storage ( & image) . await
841+ }
842+ ImageOpts :: Cmd ( opt) => {
843+ let sysroot = get_storage ( ) . await ?;
844+ match opt {
845+ ImageCmdOpts :: List { args } => {
846+ crate :: image:: imgcmd_entrypoint ( & sysroot. imgstore , "list" , & args) . await
847+ }
848+ ImageCmdOpts :: Build { args } => {
849+ crate :: image:: imgcmd_entrypoint ( & sysroot. imgstore , "build" , & args) . await
850+ }
851+ ImageCmdOpts :: Pull { args } => {
852+ crate :: image:: imgcmd_entrypoint ( & sysroot. imgstore , "pull" , & args) . await
853+ }
854+ ImageCmdOpts :: Push { args } => {
855+ crate :: image:: imgcmd_entrypoint ( & sysroot. imgstore , "push" , & args) . await
856+ }
857+ }
858+ }
801859 } ,
802860 #[ cfg( feature = "install" ) ]
803861 Opt :: Install ( opts) => match opts {
0 commit comments