@@ -415,15 +415,23 @@ func cmdBuild(cmd *cobra.Command, args []string) error {
415415 if err != nil {
416416 return err
417417 }
418+ runInVm , err := cmd .Flags ().GetBool ("in-vm" )
419+ if err != nil {
420+ return err
421+ }
418422 // XXX: check env here, i.e. if user is root and osbuild is installed
419423
420424 // Setup osbuild environment if running in a container
421425 if setup .IsContainer () {
422- if err := setup .EnsureEnvironment (cacheDir , false ); err != nil {
426+ if err := setup .EnsureEnvironment (cacheDir , runInVm ); err != nil {
423427 return fmt .Errorf ("entrypoint setup failed: %w" , err )
424428 }
425429 }
426430
431+ if runInVm && ! setup .IsContainer () {
432+ return fmt .Errorf ("running in VM outside container is not supported yet" )
433+ }
434+
427435 pbar , err := progressFromCmd (cmd )
428436 if err != nil {
429437 return err
@@ -475,6 +483,9 @@ func cmdBuild(cmd *cobra.Command, args []string) error {
475483 WriteBuildlog : withBuildlog ,
476484 Metrics : withMetrics ,
477485 }
486+ if runInVm {
487+ buildOpts .InVm = []string {"image" }
488+ }
478489 pbar .SetPulseMsgf ("Image building step" )
479490 imagePath , err := buildImage (pbar , res , mf .Bytes (), buildOpts )
480491 if err != nil {
@@ -663,6 +674,7 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.
663674 buildCmd .Flags ().String ("progress" , "auto" , "type of progress bar to use (e.g. verbose,term)" )
664675 buildCmd .Flags ().Bool ("with-metrics" , false , `print timing information at the end of the build` )
665676 buildCmd .Flags ().String ("output-name" , "" , "set specific output basename" )
677+ buildCmd .Flags ().Bool ("in-vm" , false , `run the osbuild pipeline in a virtual machine` )
666678 rootCmd .AddCommand (buildCmd )
667679 buildCmd .Flags ().AddFlagSet (uploadCmd .Flags ())
668680 // add after the rest of the uploadCmd flag set is added to avoid
@@ -681,6 +693,7 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.
681693 }
682694 describeImgCmd .Flags ().String ("arch" , "" , `use the different architecture` )
683695 describeImgCmd .Flags ().String ("distro" , "" , `build manifest for a different distroname (e.g. centos-9)` )
696+ describeImgCmd .Flags ().Bool ("in-vm" , false , `run container in a virtual machine` )
684697
685698 rootCmd .AddCommand (describeImgCmd )
686699
0 commit comments