func (m *Mirror) Create() (err error) { keyPath := filepath.Join(m.Root, "sign.key") m.Signing, err = utils.Exists(keyPath) if err != nil { return } if m.Signing { err = signing.ImportKey(keyPath) if err != nil { return } err = signing.CreateRedhatConf() if err != nil { return } } switch constants.DistroPack[m.Distro] { case "pacman": err = m.createPacman() case "debian": err = m.createDebian() case "redhat": err = m.createRedhat() default: err = &UnknownType{ errors.Newf("mirror: Unknown type '%s'", m.Distro), } } return }
func (p *RedhatProject) Prep() (err error) { buildDir, err := p.getBuildDir() if err != nil { return } keyPath := filepath.Join(p.Path, "..", "sign.key") exists, err := utils.Exists(keyPath) if err != nil { return } if exists { err = utils.CopyFile("", keyPath, buildDir, true) if err != nil { return } } err = utils.RsyncExt(p.Path, buildDir, ".rpm") if err != nil { return } return }
func (p *Project) Init() (err error) { p.MirrorRoot = filepath.Join(p.Root, "mirror") p.BuildRoot = filepath.Join(p.Root, "mirror.tmp") p.confPath = filepath.Join(p.Root, "pacur.json") exists, err := utils.Exists(p.confPath) if err != nil { return } if exists { dataByt, e := utils.ReadFile(p.confPath) if e != nil { err = e return } data := conf{} err = json.Unmarshal(dataByt, &data) if err != nil { err = &ParseError{ errors.Wrapf(err, "project: Failed to parse project conf '%s'", p.confPath), } return } p.Name = data.Name } else { p.Name = "pacur" } return }
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 }
func (p *Project) InitProject() (err error) { exists, err := utils.Exists(p.confPath) if err != nil { return } if !exists { err = utils.CreateWrite(p.confPath, `{\n "name": "pacur"\n}\n`) if err != nil { return } } return }
func (s *Source) getUrl() (err error) { exists, err := utils.Exists(s.Path) if err != nil { return } if !exists { err = utils.HttpGet(s.Source, s.Path) if err != nil { return } } return }