Skip to content

Commit

Permalink
feat(image): add flag to skip default packages when creating image co…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
jacdavi authored and activeshadow committed Jan 4, 2024
1 parent afb3cd0 commit 59a6721
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/go/api/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func SetDefaults(img *v1.Image) error {

img.Scripts = make(map[string]string)

img.Packages = append(img.Packages, PACKAGES_DEFAULT...)
if !img.SkipDefaultPackages {
img.Packages = append(img.Packages, PACKAGES_DEFAULT...)
}

switch img.Variant {
case "minbase":
Expand Down
2 changes: 2 additions & 0 deletions src/go/cmd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func newImageCreateCmd() *cobra.Command {
img.DebAppend = MustGetString(cmd.Flags(), "debootstrap-append")
img.IncludeMiniccc = MustGetBool(cmd.Flags(), "include-miniccc")
img.IncludeProtonuke = MustGetBool(cmd.Flags(), "include-protonuke")
img.SkipDefaultPackages = MustGetBool(cmd.Flags(), "skip-default-pkgs")

if overlays := MustGetString(cmd.Flags(), "overlays"); overlays != "" {
img.Overlays = strings.Split(overlays, ",")
Expand Down Expand Up @@ -159,6 +160,7 @@ func newImageCreateCmd() *cobra.Command {
cmd.Flags().BoolP("compress", "c", false, "Compress image after creation (does not apply to raw image)")
cmd.Flags().BoolP("ramdisk", "R", false, "Create a kernel/initrd pair in addition to a disk image")
cmd.Flags().StringP("overlays", "O", "", "List of overlay names (include full path; separated by comma)")
cmd.Flags().Bool("skip-default-pkgs", false, "Skip default packages typically included in all builds")
cmd.Flags().StringP("packages", "P", "", "List of packages to include in addition to those provided by variant (separated by comma)")
cmd.Flags().StringP("scripts", "T", "", "List of scripts to include in addition to the defaults (include full path; separated by comma)")
cmd.Flags().StringP("debootstrap-append", "d", "", `Additional arguments to debootstrap "(default: --components=main,restricted,universe,multiverse)"`)
Expand Down
25 changes: 13 additions & 12 deletions src/go/types/version/v1/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ const (
)

type Image struct {
Variant string `json:"variant" yaml:"variant"`
Release string `json:"release" yaml:"release"`
Format Format `json:"format" yaml:"format"`
Ramdisk bool `json:"ramdisk" yaml:"ramdisk"`
Compress bool `json:"compress" yaml:"compress"`
Size string `json:"size" yaml:"size"`
Mirror string `json:"mirror" yaml:"mirror"`
DebAppend string `json:"deb_append" yaml:"deb_append" structs:"deb_append" mapstructure:"deb_append"`
Packages []string `json:"packages" yaml:"packages"`
Overlays []string `json:"overlays" yaml:"overlays"`
Scripts map[string]string `json:"scripts" yaml:"scripts"`
ScriptOrder []string `json:"script_order" yaml:"script_order" structs:"script_order" mapstructure:"script_order"`
Variant string `json:"variant" yaml:"variant"`
Release string `json:"release" yaml:"release"`
Format Format `json:"format" yaml:"format"`
Ramdisk bool `json:"ramdisk" yaml:"ramdisk"`
Compress bool `json:"compress" yaml:"compress"`
Size string `json:"size" yaml:"size"`
Mirror string `json:"mirror" yaml:"mirror"`
DebAppend string `json:"deb_append" yaml:"deb_append" structs:"deb_append" mapstructure:"deb_append"`
SkipDefaultPackages bool `json:"skip_default_packages" yaml:"skip_default_packages"`
Packages []string `json:"packages" yaml:"packages"`
Overlays []string `json:"overlays" yaml:"overlays"`
Scripts map[string]string `json:"scripts" yaml:"scripts"`
ScriptOrder []string `json:"script_order" yaml:"script_order" structs:"script_order" mapstructure:"script_order"`

IncludeMiniccc bool `json:"include_miniccc" yaml:"include_miniccc" structs:"include_miniccc" mapstructure:"include_miniccc"`
IncludeProtonuke bool `json:"include_protonuke" yaml:"include_protonuke" structs:"include_protonuke" mapstructure:"include_protonuke"`
Expand Down

0 comments on commit 59a6721

Please sign in to comment.