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 (p *Project) Repo(filter string) (err error) {
	_ = utils.RemoveAll(p.BuildRoot)
	_ = utils.RemoveAll(p.MirrorRoot)

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

	err = p.iterPackages(filter, func(target, path string) (err error) {
		proj, err := p.getProject(target, path)
		if err != nil {
			return
		}

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

		return
	})
	if err != nil {
		return
	}

	for _, release := range constants.Releases {
		path := filepath.Join(p.BuildRoot, release)

		exists, e := utils.Exists(path)
		if e != nil {
			err = e
			return
		}

		if exists {
			proj, e := p.getProject(release, path)
			if e != nil {
				err = e
				return
			}

			err = proj.Create()
			if err != nil {
				return
			}
		}
	}

	err = utils.RemoveAll(p.BuildRoot)
	if err != nil {
		return
	}

	return
}
Example #3
0
func (p *RedhatProject) getBuildDir() (path string, err error) {
	path = filepath.Join(p.BuildRoot, p.Distro+"-"+p.Release)

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

	return
}
Example #4
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 #5
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
}