예제 #1
0
func (cfg *Cfg) readDefsOnce(lpkg *pkg.LocalPackage,
	features map[string]bool) error {
	v := lpkg.SyscfgV

	lfeatures := cfg.FeaturesForLpkg(lpkg)
	for k, _ := range features {
		lfeatures[k] = true
	}

	settings := newtutil.GetStringMapFeatures(v, lfeatures, "syscfg.defs")
	if settings != nil {
		for k, v := range settings {
			vals := v.(map[interface{}]interface{})
			entry, err := readSetting(k, lpkg, vals)
			if err != nil {
				return util.FmtNewtError("Config for package %s: %s",
					lpkg.Name(), err.Error())
			}

			if _, exists := cfg.Settings[k]; exists {
				// XXX: Better error message.
				return util.FmtNewtError("setting %s redefined", k)
			}
			cfg.Settings[k] = entry
		}
	}

	return nil
}
예제 #2
0
func (cfg *Cfg) readValsOnce(lpkg *pkg.LocalPackage,
	features map[string]bool) error {
	v := lpkg.SyscfgV

	lfeatures := cfg.FeaturesForLpkg(lpkg)
	for k, _ := range features {
		lfeatures[k] = true
	}

	values := newtutil.GetStringMapFeatures(v, lfeatures, "syscfg.vals")
	for k, v := range values {
		if normalizePkgType(lpkg.Type()) == pkg.PACKAGE_TYPE_LIB {
			// A library package is overriding a setting; this is disallowed.
			// Overrides must come from a higher priority package.
			lateral := CfgLateral{
				PkgName:     lpkg.Name(),
				SettingName: k,
			}
			cfg.Laterals = append(cfg.Laterals, lateral)
		} else {
			entry, ok := cfg.Settings[k]
			if ok {
				entry.appendValue(lpkg, v)
				cfg.Settings[k] = entry
			} else {
				orphan := CfgPoint{
					Value:  stringValue(v),
					Source: lpkg,
				}
				cfg.Orphans[k] = append(cfg.Orphans[k], orphan)
			}
		}
	}

	return nil
}