Example #1
0
File: utils.go Project: pacur/pacur
func getTargets(path string) (targets []string, err error) {
	pac, err := parse.File("", "", path)
	if err != nil {
		return
	}

	err = pac.Compile()
	if err != nil {
		return
	}

	tarSet := set.NewSet()
	for _, target := range pac.Targets {
		tarSet.Add(target)
	}

	for _, release := range constants.Releases {
		distro := strings.Split(release, "-")[0]

		if tarSet.Contains("!"+release) || tarSet.Contains("!"+distro) {
			continue
		}

		if tarSet.Contains(release) || tarSet.Contains(distro) {
			targets = append(targets, release)
		}
	}

	return
}
Example #2
0
File: build.go Project: pacur/pacur
func Build() (err error) {
	split := strings.Split(flag.Arg(1), "-")
	distro := split[0]
	release := ""
	if len(split) > 1 {
		release = split[1]
	}

	pac, err := parse.File(distro, release, "/pacur")
	if err != nil {
		return
	}

	err = pac.Compile()
	if err != nil {
		return
	}

	pcker, err := packer.GetPacker(pac, distro, release)
	if err != nil {
		return
	}

	err = pcker.Prep()
	if err != nil {
		return
	}

	builder := builder.Builder{
		Pack: pac,
	}
	err = builder.Build()
	if err != nil {
		return
	}

	err = pcker.Build()
	if err != nil {
		return
	}

	return
}