@@ -78,6 +78,9 @@ type ShellOptions struct {
7878
7979 // Whether or not to enable external network access from within the mock root the shell is executed in.
8080 EnableNetwork bool
81+
82+ // Packages to add to the mock root before starting the shell.
83+ PackagesToAdd []string
8184}
8285
8386// Constructs a [cobra.Command] for the 'mock shell' command.
@@ -97,6 +100,9 @@ func NewShellCmd() *cobra.Command {
97100
98101 cmd .Flags ().StringVarP (& options .MockConfigPath , "config" , "c" , "" , "Path to the mock .cfg file" )
99102 cmd .Flags ().BoolVar (& options .EnableNetwork , "enable-network" , false , "Enable network access in the mock root" )
103+ cmd .Flags ().StringArrayVarP (& options .PackagesToAdd , "add-package" , "p" , []string {},
104+ "Package to add to the mock root before starting the shell" ,
105+ )
100106
101107 return cmd
102108}
@@ -135,6 +141,13 @@ func RunShell(env *azldev.Env, options *ShellOptions, extraArgs []string) error
135141 runner .EnableNetwork ()
136142 }
137143
144+ if len (options .PackagesToAdd ) > 0 {
145+ err = runner .InstallPackages (env , options .PackagesToAdd )
146+ if err != nil {
147+ return fmt .Errorf ("failed to install packages in mock root (%v): %w" , options .PackagesToAdd , err )
148+ }
149+ }
150+
138151 cmd , err := runner .CmdInChroot (env , extraArgs , true /*interactive*/ )
139152 if err != nil {
140153 return fmt .Errorf ("failed to create shell command: %w" , err )
0 commit comments