mirror of
https://github.com/clearlinux/mixer-tools.git
synced 2026-09-05 13:11:31 +00:00
Initialize local yum repo
Newer versions of DNF require that yum repos are initialized, so Mixer must initialize the local repo, even when it's empty. Fixes #731 Signed-off-by: John Akre <john.w.akre@intel.com>
This commit is contained in:
@@ -126,6 +126,10 @@ func (b *Builder) CheckManifestCorrectness(fromVer, toVer, downloadRetries, tabl
|
||||
os.Stdout = stdOut
|
||||
}()
|
||||
|
||||
if err := b.NewDNFConfIfNeeded(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Load initial repo map
|
||||
if err := b.ListRepos(); err != nil {
|
||||
return err
|
||||
|
||||
+25
-7
@@ -22,6 +22,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -130,6 +131,17 @@ func (b *Builder) NewDNFConfIfNeeded() error {
|
||||
return errors.Wrapf(err, "Failed to write to dnf file: %s", b.Config.Builder.DNFConf)
|
||||
}
|
||||
}
|
||||
|
||||
if b.Config.Mixer.LocalRepoDir != "" {
|
||||
localRepo := path.Join(b.Config.Mixer.LocalRepoDir, "repodata")
|
||||
if _, err := os.Stat(localRepo); os.IsNotExist(err) {
|
||||
if err = b.createLocalRepo(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -412,13 +424,7 @@ func (b *Builder) AddRPMList(rpms []string) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmd := exec.Command("createrepo_c", ".")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Dir = b.Config.Mixer.LocalRepoDir
|
||||
|
||||
return cmd.Run()
|
||||
return b.createLocalRepo()
|
||||
}
|
||||
|
||||
// checkRPM returns nil if path contains a valid RPM file.
|
||||
@@ -433,3 +439,15 @@ func checkRPM(path string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Builder) createLocalRepo() error {
|
||||
if _, err := os.Stat(b.Config.Mixer.LocalRepoDir); err != nil {
|
||||
return err
|
||||
}
|
||||
cmd := exec.Command("createrepo_c", ".")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Dir = b.Config.Mixer.LocalRepoDir
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user