Example #1
0
func (m *Mirror) createPacman() (err error) {
	outDir := filepath.Join(m.Root, "pacman")

	err = utils.MkdirAll(outDir)
	if err != nil {
		return
	}

	err = utils.RsyncExt(m.Root, outDir, ".pkg.tar.xz")
	if err != nil {
		return
	}

	if m.Signing {
		err = signing.SignPacman(outDir)
		if err != nil {
			return
		}
	}

	pkgs, err := utils.FindExt(outDir, ".pkg.tar.xz")
	for _, pkg := range pkgs {
		err = utils.Exec(outDir, "repo-add",
			fmt.Sprintf("%s.db.tar.gz", m.Name), pkg)
		if err != nil {
			return
		}
	}

	return
}
Example #2
0
func SignRedhat(dir string) (err error) {
	err = CreateRedhatConf()
	if err != nil {
		return
	}

	pkgs, err := utils.FindExt(dir, ".rpm")
	if err != nil {
		return
	}

	for _, pkg := range pkgs {
		err = utils.Exec("", "expect",
			"-c", "spawn rpm --resign "+pkg,
			"-c", `expect "Enter pass phrase:"`,
			"-c", `send "\r"`,
			"-c", "wait",
			"-c", "interact")
		if err != nil {
			return
		}
	}

	return
}
Example #3
0
File: utils.go Project: pacur/pacur
func runScript(path, dir string) (err error) {
	err = utils.Exec(dir, "sh", path)
	if err != nil {
		return
	}

	return
}
Example #4
0
func (r *Redhat) rpmBuild() (err error) {
	err = utils.Exec(r.specsDir, "rpmbuild", "--define",
		"_topdir "+r.redhatDir, "-ba", r.Pack.PkgName+".spec")
	if err != nil {
		return
	}

	return
}
Example #5
0
func (p *Pacman) pacmanBuild() (err error) {
	err = utils.Chmod(p.pacmanDir, 0777)
	if err != nil {
		return
	}

	err = utils.Exec(p.pacmanDir, "sudo", "-u", "nobody", "makepkg")
	if err != nil {
		return
	}

	return
}
Example #6
0
func (g *GenKey) Generate() (err error) {
	confPath, err := g.createConf()
	if err != nil {
		return
	}
	defer utils.Remove(confPath)

	err = utils.Exec(g.Root, "gpg", "--batch", "--gen-key", confPath)
	if err != nil {
		return
	}

	return
}
Example #7
0
func (d *Debian) getDepends() (err error) {
	if len(d.Pack.MakeDepends) == 0 {
		return
	}

	err = utils.Exec("", "apt-get", "--assume-yes", "update")
	if err != nil {
		return
	}

	args := []string{
		"--assume-yes",
		"install",
	}
	args = append(args, d.Pack.MakeDepends...)

	err = utils.Exec("", "apt-get", args...)
	if err != nil {
		return
	}

	return
}
Example #8
0
func (p *Pacman) getDepends() (err error) {
	if len(p.Pack.MakeDepends) == 0 {
		return
	}

	err = utils.Exec("", "pacman", "-Sy")
	if err != nil {
		return
	}

	args := []string{
		"-S",
		"--noconfirm",
	}
	args = append(args, p.Pack.Depends...)
	args = append(args, p.Pack.MakeDepends...)

	err = utils.Exec("", "pacman", args...)
	if err != nil {
		return
	}

	return
}
Example #9
0
func (p *Project) Build(filter string) (err error) {
	err = p.iterPackages(filter, func(target, path string) (err error) {
		err = utils.Exec("", "docker", "run", "--rm", "-t", "-v",
			path+":/pacur", constants.DockerOrg+target)
		if err != nil {
			return
		}

		return
	})
	if err != nil {
		return
	}

	return
}
Example #10
0
func (r *Redhat) getDepends() (err error) {
	if len(r.Pack.MakeDepends) == 0 {
		return
	}

	args := []string{
		"-y",
		"install",
	}
	args = append(args, r.Pack.MakeDepends...)

	err = utils.Exec("", "yum", args...)
	if err != nil {
		return
	}

	return
}
Example #11
0
func (p *RedhatProject) Create() (err error) {
	buildDir, err := p.getBuildDir()
	if err != nil {
		return
	}

	err = utils.Exec("", "docker", "run", "--rm", "-t", "-v",
		buildDir+":/pacur", constants.DockerOrg+p.Distro+"-"+p.Release,
		"create", p.Distro+"-"+p.Release, p.Name)
	if err != nil {
		return
	}

	err = utils.Rsync(filepath.Join(buildDir, "yum"),
		filepath.Join(p.MirrorRoot, "yum"))
	if err != nil {
		return
	}

	return
}
Example #12
0
func (d *Debian) dpkgDeb() (err error) {
	err = utils.Exec("", "dpkg-deb", "-b", d.Pack.PackageDir)
	if err != nil {
		return
	}

	_, dir := filepath.Split(filepath.Clean(d.Pack.PackageDir))
	path := filepath.Join(d.Pack.Root, dir+".deb")
	newPath := filepath.Join(d.Pack.Home,
		fmt.Sprintf("%s_%s-0%s%s.%s_%s.deb",
			d.Pack.PkgName, d.Pack.PkgVer, d.Pack.Distro, d.Pack.PkgRel,
			d.Pack.Release, d.Pack.Arch))

	os.Remove(newPath)

	err = utils.CopyFile("", path, newPath, false)
	if err != nil {
		return
	}

	return
}
Example #13
0
func (m *Mirror) createRedhat() (err error) {
	outDir := filepath.Join(m.Root, "yum", m.Distro, m.Release)

	err = utils.MkdirAll(outDir)
	if err != nil {
		return
	}

	match, ok := constants.ReleasesMatch[m.Distro+"-"+m.Release]
	if !ok {
		err = &BuildError{
			errors.Newf("mirror: Failed to find match for '%s'",
				m.Distro+"-"+m.Release),
		}
		return
	}

	err = utils.RsyncMatch(m.Root, outDir, match)
	if err != nil {
		return
	}

	if m.Signing {
		err = signing.SignRedhat(outDir)
		if err != nil {
			return
		}
	}

	err = utils.Exec(outDir, "createrepo", ".")
	if err != nil {
		return
	}

	return
}
Example #14
0
func SignPacman(dir string) (err error) {
	pkgs, err := utils.FindExt(dir, ".pkg.tar.xz")
	if err != nil {
		return
	}

	name, err := GetName()
	if err != nil {
		return
	}

	for _, pkg := range pkgs {
		err = utils.Exec(dir, "gpg",
			"--detach-sign",
			"-u", name,
			"--no-armor",
			pkg)
		if err != nil {
			return
		}
	}

	return
}
Example #15
0
func (m *Mirror) createDebian() (err error) {
	outDir := filepath.Join(m.Root, "apt")
	confDir := filepath.Join(m.Root, "conf")
	confPath := filepath.Join(confDir, "distributions")

	err = utils.MkdirAll(confDir)
	if err != nil {
		return
	}

	data := "Codename: " + m.Release + "\n" +
		"Components: main\nArchitectures: i386 amd64\n"

	if m.Signing {
		id, e := signing.GetId()
		if e != nil {
			err = e
			return
		}

		data += fmt.Sprintf("SignWith: %s\n", id)

		err = utils.CreateWrite(filepath.Join(confDir, "options"),
			"ask-passphrase\n")
		if err != nil {
			return
		}
	}

	err = utils.CreateWrite(confPath, data)
	if err != nil {
		return
	}

	err = utils.MkdirAll(outDir)
	if err != nil {
		return
	}

	match, ok := constants.ReleasesMatch[m.Distro+"-"+m.Release]
	if !ok {
		err = &BuildError{
			errors.Newf("mirror: Failed to find match for '%s'",
				m.Distro+"-"+m.Release),
		}
		return
	}

	debs, err := utils.FindMatch(m.Root, match)
	if err != nil {
		return
	}

	for _, deb := range debs {
		err = utils.Exec(m.Root, "reprepro", "--outdir", outDir,
			"includedeb", m.Release, deb)
		if err != nil {
			return
		}
	}

	return
}
Example #16
0
func ImportKey(path string) (err error) {
	utils.Exec("", "gpg", "--batch", "--allow-secret-key-import",
		"--import", path)
	// TODO err handle already imported
	return
}