Esempio n. 1
0
func main() {
	log.Printf("Loading local and remote indexes.\n")

	c, _ := repo.LoadConfig("/home/tag/tmp/repo")
	i, e := c.LoadIndex("unstable")

	if e != nil {
		panic(e)
	}

	log.Printf("%d binary package names found and loaded\n", len(*i))

	repRepo := reprepro.NewRepo("/home/tag/tmp/repo")
	needsBuild, err := repRepo.BuildNeeding("unstable", "any")

	if err != nil {
		panic(err)
	}

	log.Printf("Computing build candidates\n")

	for _, status := range repo.ComputeBuildStatus(*repRepo, *i, needsBuild) {
		log.Printf("%s - %s (%s)\n", status.Package.Location, status.Buildable, status.Why)
	}
}
Esempio n. 2
0
func (c *CoordinatorRemote) GetBuildNeeding(
	buildNeedingRequest BuildNeedingRequest,
	ret *[]reprepro.BuildNeedingPackage,
) error {
	repos := c.Config.Repos
	if repos == "" {
		return fmt.Errorf("Error; I don't know where repos live. Set Repos: config flag")
	}
	repo := reprepro.NewRepo(path.Join(repos, path.Clean(buildNeedingRequest.Repo)))

	var pkg *string
	if buildNeedingRequest.Package != "" {
		pkg = &buildNeedingRequest.Package
	}

	buildNeeding, err := repo.BuildNeeding(
		buildNeedingRequest.Suite,
		buildNeedingRequest.Arch,
		pkg,
	)
	if err != nil {
		return err
	}
	*ret = buildNeeding
	return nil
}
Esempio n. 3
0
File: main.go Progetto: paultag/nmr
func main() {
	arch := os.Args[1]
	repoRoot := os.Args[2]
	params := os.Args[3:]

	repreproRepo := reprepro.NewRepo(repoRoot)
	log, err := repreproRepo.ParseLogEntry(params)
	if err != nil {
		panic(err)
	}

	arches := log.Changes.Architectures
	// insane hack here. ignore me.
	fmt.Printf("Got: %s %s\n", log.Action, log.Changes.Architectures)
	if log.Action != "accepted" || arches[0].CPU != "source" || len(arches) != 1 {
		fmt.Printf("Ignoring: %s %s\n", log.Action, log.Changes.Architectures)
		return
	}

	// Right, let's run a build.
	dsc, err := log.Changes.GetDSC()
	if err != nil {
		panic(err)
	}

	complete, err := Tempdir()
	if err != nil {
		panic(err)
	}
	defer complete()

	ftbfs, err := BuildPackage(dsc.Filename, arch, log.Suite, repoRoot, true)
	fmt.Printf("FTBFS: %s", ftbfs)
	fmt.Printf("Error: %s", err)
}
Esempio n. 4
0
File: build.go Progetto: paultag/nmr
func IsArchAllArch(repoRoot, arch string) bool {
	repreproRepo := reprepro.NewRepo(repoRoot)
	config, err := repo.LoadConfig(repreproRepo.Basedir)
	if err != nil {
		return false
	}
	return arch == config.Global.ArchIndepBuildArch
}
Esempio n. 5
0
File: build.go Progetto: paultag/nmr
func SbuildCommand(
	chroot,
	suite,
	arch,
	dscFile,
	repoRoot string,
	verbose bool,
) (*exec.Cmd, error) {
	repreproRepo := reprepro.NewRepo(repoRoot)
	config, err := repo.LoadConfig(repreproRepo.Basedir)
	if err != nil {
		return nil, err
	}

	suiteConfig, err := repo.LoadDistributions(repreproRepo.Basedir)
	if err != nil {
		return nil, err
	}

	distConfig, err := config.GetDistConfig(suite)
	if err != nil {
		return nil, err
	}

	suiteDistConfig, err := suiteConfig.GetDistConfig(suite)
	if err != nil {
		return nil, err
	}

	build := sbuild.NewSbuild(suite, suite)

	if verbose {
		build.Verbose()
	}

	if arch == config.Global.ArchIndepBuildArch {
		build.AddFlag("--arch-all")
	} else {
		build.AddFlag("--no-arch-all")
	}

	// build.AddArgument("build-dep-resolver", "aptitude")
	build.AddArgument("chroot-setup-commands",
		fmt.Sprintf("apt-key add /schroot/%s.asc", suiteDistConfig.SignWith))

	build.AddArgument("extra-repository",
		fmt.Sprintf("deb %s %s main",
			config.Global.PublicArchiveRoot,
			distConfig.Upstream.Dist))

	cmd, err := build.BuildCommand(dscFile)

	if verbose {
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
	}
	return cmd, err
}
Esempio n. 6
0
File: build.go Progetto: paultag/nmr
func GetIncoming(repoRoot, dist string) (string, error) {
	repreproRepo := reprepro.NewRepo(repoRoot)
	config, err := repo.LoadConfig(repreproRepo.Basedir)
	if err != nil {
		return "", err
	}

	distConfig, err := config.GetDistConfig(dist)
	if err != nil {
		return "", err
	}
	return distConfig.Incoming, nil
}
Esempio n. 7
0
File: build.go Progetto: paultag/nmr
func GetBuildNeeding(repoRoot, suite, arch string) []repo.BuildStatus {
	repreproRepo := reprepro.NewRepo(repoRoot)

	config, err := repo.LoadConfig(repreproRepo.Basedir)
	i, err := config.LoadIndex(suite)

	if err != nil {
		return []repo.BuildStatus{}
	}

	needsBuild, err := repreproRepo.BuildNeeding(suite, arch)
	if err != nil {
		return []repo.BuildStatus{}
	}

	return repo.ComputeBuildStatus(*repreproRepo, *i, needsBuild)
}
Esempio n. 8
0
func Process(changesPath string) {
	repoRoot := path.Clean(path.Join(path.Dir(changesPath), ".."))
	pwd, err := os.Getwd()
	if err != nil {
		log.Printf("%s\n", err)
		return
	}
	gnuPGHome := path.Join(pwd, "..", "private", repoRoot, ".gnupg")
	repo := reprepro.NewRepo(
		repoRoot,
		"--component=main",
		fmt.Sprintf("--gnupghome=%s", gnuPGHome),
	)

	changes, err := control.ParseChangesFile(changesPath)
	if err != nil {
		log.Printf("Error: %s\n", err)
	}

	err = repo.Include(changes.Distribution, changesPath)
	if err != nil {
		go Mail([]string{conf.Administrator}, "rejected", &Upload{
			Changes: *changes,
			Repo:    *repo,
			Reason:  err.Error(),
		})

		log.Printf("Error: %s\n", err)
		changes.Remove()
		log.Printf("Removed %s and associated files\n", changesPath)
		return
	}

	log.Printf("Included %s into %s", changes.Source, repo.Basedir)
	go Mail([]string{conf.Administrator}, "accepted", &Upload{
		Changes: *changes,
		Repo:    *repo,
	})
	changes.Remove()
}