Esempio n. 1
0
func (ag *AptGet) setPackages(args haiconf.CommandArgs) error {
	pl, _ := haiconf.CheckStringList("Packages", args)

	if len(pl) > 0 {
		ag.Packages = stringutils.RemoveDuplicates(pl)
		return nil
	}

	pfs, _ := haiconf.CheckAbsolutePath("PackagesFromSource", args)
	if pfs != "" {
		buff, err := ioutil.ReadFile(pfs)
		if err != nil {
			return err
		}

		nlSplit := func(r rune) bool {
			if r == '\n' {
				return true
			}
			return false
		}

		pkgs := strings.FieldsFunc(string(buff), nlSplit)
		ag.Packages = stringutils.RemoveDuplicates(pkgs)

		return nil
	}

	msg := "You must provide a value for either Packages or PackagesFromSource"
	return haiconf.NewArgError(msg, args)
}
Esempio n. 2
0
func (ag *AptGet) setExtraOptions(args haiconf.CommandArgs) error {
	xtraOpts, _ := haiconf.CheckStringList("ExtraOptions", args)
	l := len(xtraOpts)

	if l > 0 {
		ag.ExtraOptions = stringutils.RemoveDuplicates(xtraOpts)
	}

	return nil
}