From 32ef7422b883e73b90f2b7511975cfda6fc0ba17 Mon Sep 17 00:00:00 2001 From: "Kevin C. Wells" Date: Fri, 25 May 2018 19:52:58 +0000 Subject: [PATCH] Mixer init always add defaults, unless new flag Previously 'mixer init' would add four default bundles to your mixbundles list, unless it already existed. This resulted in confusing behavior. Some users resorted to creating an empty mixbundles list before running 'mixer init' in order to avoid these bundles. Others had a mixbundles list already, but expected the bundles to be added anyway. This patch changes the behavior to *always* add the four default bundles, even if the mixbundles list already exists, unless a new '--no-default-bundles' flag is passed. This does not affect the behavior of '--all-local' or '--all-upstream'. Signed-off-by: Kevin C. Wells --- builder/builder.go | 14 +++++++------- mixer/cmd/root.go | 4 +++- mixin/package.go | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/builder/builder.go b/builder/builder.go index 2ef5149..86d5860 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -194,7 +194,7 @@ mix-bundles/` // InitMix will initialise a new swupd-client consumable "mix" with the given // based Clear Linux version and specified mix version. -func (b *Builder) InitMix(upstreamVer string, mixVer string, allLocal bool, allUpstream bool, upstreamURL string, git bool) error { +func (b *Builder) InitMix(upstreamVer string, mixVer string, allLocal bool, allUpstream bool, noDefaults bool, upstreamURL string, git bool) error { // Set up local dirs if err := b.initDirs(); err != nil { return err @@ -253,12 +253,12 @@ func (b *Builder) InitMix(upstreamVer string, mixVer string, allLocal bool, allU } // Initialize the Mix Bundles List - if _, err := os.Stat(filepath.Join(b.Config.Builder.VersionPath, b.MixBundlesFile)); os.IsNotExist(err) { - // Add default bundles (or all) - defaultBundles := []string{"os-core", "os-core-update", "bootloader", "kernel-native"} - if err := b.AddBundles(defaultBundles, allLocal, allUpstream, false); err != nil { - return err - } + var bundles []string + if !noDefaults { + bundles = []string{"os-core", "os-core-update", "bootloader", "kernel-native"} + } + if err := b.AddBundles(bundles, allLocal, allUpstream, false); err != nil { + return err } // Get upstream bundles diff --git a/mixer/cmd/root.go b/mixer/cmd/root.go index 981f571..66d82a1 100644 --- a/mixer/cmd/root.go +++ b/mixer/cmd/root.go @@ -87,6 +87,7 @@ var rootCmdFlags = struct { type initCmdFlags struct { allLocal bool allUpstream bool + noDefaults bool clearVer string mixver int localRPMs bool @@ -119,7 +120,7 @@ var initCmd = &cobra.Command{ if err := b.LoadBuilderConf(config); err != nil { fail(err) } - err := b.InitMix(initFlags.clearVer, strconv.Itoa(initFlags.mixver), initFlags.allLocal, initFlags.allUpstream, initFlags.upstreamURL, initFlags.git) + err := b.InitMix(initFlags.clearVer, strconv.Itoa(initFlags.mixver), initFlags.allLocal, initFlags.allUpstream, initFlags.noDefaults, initFlags.upstreamURL, initFlags.git) if err != nil { fail(err) } @@ -157,6 +158,7 @@ func init() { initCmd.Flags().BoolVar(&initFlags.allLocal, "all-local", false, "Initialize mix with all local bundles automatically included") initCmd.Flags().BoolVar(&initFlags.allUpstream, "all-upstream", false, "Initialize mix with all upstream bundles automatically included") + initCmd.Flags().BoolVar(&initFlags.noDefaults, "no-default-bundles", false, "Skip adding default bundles to the mix") initCmd.Flags().StringVar(&initFlags.clearVer, "clear-version", "latest", "Supply the Clear version to compose the mix from") initCmd.Flags().StringVar(&initFlags.clearVer, "upstream-version", "latest", "Alias to --clear-version") initCmd.Flags().IntVar(&initFlags.mixver, "mix-version", 10, "Supply the Mix version to build") diff --git a/mixin/package.go b/mixin/package.go index e75fd2c..e076e89 100644 --- a/mixin/package.go +++ b/mixin/package.go @@ -103,7 +103,7 @@ func addPackage(pkg string, build bool) (string, error) { return "", err } err = b.InitMix(fmt.Sprintf("%d", ver), fmt.Sprintf("%d", mixVer), - false, false, "https://download.clearlinux.org", false) + false, false, true, "https://download.clearlinux.org", false) if err != nil { return "", err }