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 <kevin.c.wells@intel.com>
This commit is contained in:
Kevin C. Wells
2018-05-29 12:40:37 -07:00
committed by tmarcu
parent e0d0107e75
commit 32ef7422b8
3 changed files with 11 additions and 9 deletions
+7 -7
View File
@@ -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
+3 -1
View File
@@ -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")
+1 -1
View File
@@ -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
}