Skip to content

Commit

Permalink
fix: correctly check installed release packages
Browse files Browse the repository at this point in the history
  • Loading branch information
femnad committed Dec 16, 2023
1 parent 46301d8 commit 8e4dd9d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
14 changes: 8 additions & 6 deletions entity/dnfrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ func (i installer) runMaybeSudo(cmd string) error {
}

type DnfRepo struct {
RepoName string `yaml:"name"`
Packages []string `yaml:"packages"`
Repo string `yaml:"repo"`
Url []string `yaml:"url"`
When string `yaml:"when"`
}

Expand Down Expand Up @@ -57,8 +59,8 @@ func (DnfRepo) HasPostProc() bool {
return false
}

func (DnfRepo) Name() string {
return ""
func (d DnfRepo) Name() string {
return d.RepoName
}

func (d DnfRepo) RunWhen() string {
Expand Down Expand Up @@ -94,15 +96,15 @@ func (i installer) configManagerInstall(repo string) error {
return i.runMaybeSudo(cmd)
}

func (i installer) releasePackagesInstall(packages []string, osId string) error {
packageList := strings.Join(packages, " ")
func (i installer) releasePackagesInstall(url []string, osId string) error {
packageList := strings.Join(url, " ")
cmd := fmt.Sprintf("rpm -E %%%s", osId)
out, err := marecmd.RunFormatError(marecmd.Input{Command: cmd})
if err != nil {
return err
}

packageList = settings.Expand(packageList, map[string]string{"version_id": out.Stdout})
packageList = settings.Expand(packageList, map[string]string{"version_id": strings.TrimSpace(out.Stdout)})
cmd = fmt.Sprintf("dnf install -y %s", packageList)
return i.runMaybeSudo(cmd)
}
Expand All @@ -123,7 +125,7 @@ func (d DnfRepo) Install() error {
if err != nil {
return err
}
return i.releasePackagesInstall(d.Packages, osId)
return i.releasePackagesInstall(d.Url, osId)
}

return fmt.Errorf("unable to determine install method for repo %+v", d)
Expand Down
3 changes: 2 additions & 1 deletion precheck/unless/unless.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func shouldSkip(unlessable Unlessable, s settings.Settings) bool {
out, err = run.Cmd(s, marecmd.Input{Command: unlessCmd, Shell: unless.Shell})

if unless.ExitCode != 0 {
internal.Log.Debugf("Command %s exited with code: %d, skip when: %d", unlessCmd, out.Code, unless.ExitCode)
internal.Log.Debugf("Command %s exited with code: %d, skip when: %d", unlessCmd, out.Code,
unless.ExitCode)
return out.Code == unless.ExitCode
}

Expand Down
2 changes: 2 additions & 0 deletions provision/osrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func addRepos(config base.Config) error {
continue
}

internal.Log.Debugf("Adding repo %s", repo.Name())

err := repo.Install()
if err == nil && repo.UpdateCmd() != "" {
updateCmds.Add(repo.UpdateCmd())
Expand Down

0 comments on commit 8e4dd9d

Please sign in to comment.