From 59a6721003ff199c7507747ce2e6ffb005508df1 Mon Sep 17 00:00:00 2001 From: jacdavi <86626873+jacdavi@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:05:06 -0700 Subject: [PATCH] feat(image): add flag to skip default packages when creating image config --- src/go/api/image/image.go | 4 +++- src/go/cmd/image.go | 2 ++ src/go/types/version/v1/image.go | 25 +++++++++++++------------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/go/api/image/image.go b/src/go/api/image/image.go index 8208efbc..e4c03673 100644 --- a/src/go/api/image/image.go +++ b/src/go/api/image/image.go @@ -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": diff --git a/src/go/cmd/image.go b/src/go/cmd/image.go index 37215e4e..38f048b6 100644 --- a/src/go/cmd/image.go +++ b/src/go/cmd/image.go @@ -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, ",") @@ -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)"`) diff --git a/src/go/types/version/v1/image.go b/src/go/types/version/v1/image.go index 6a60c925..0358bb3c 100644 --- a/src/go/types/version/v1/image.go +++ b/src/go/types/version/v1/image.go @@ -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"`