mirror of
https://github.com/clearlinux/mixer-tools.git
synced 2026-09-03 20:21:32 +00:00
Add set-priority to the repo command
The set-priority repo command updates the priority value for the specified repo in the DNF config file. This command uses the following format: mixer repo set-priority <repo> <priority> Fixes #691 Signed-off-by: John Akre <john.w.akre@intel.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
@@ -220,6 +221,18 @@ func (b *Builder) SetExcludesRepo(repo, pkgs string) error {
|
||||
return b.setRepoVal(repo, "excludepkgs", pkgs)
|
||||
}
|
||||
|
||||
// SetPriorityRepo sets the priority for the repo
|
||||
func (b *Builder) SetPriorityRepo(repo, priority string) error {
|
||||
p, err := strconv.Atoi(priority)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if p < 1 || p > 99 {
|
||||
return errors.Errorf("repo priority %d must be between 1 and 99", p)
|
||||
}
|
||||
return b.setRepoVal(repo, "priority", priority)
|
||||
}
|
||||
|
||||
// WriteRepoURLOverrides writes a copy of the DNF conf file
|
||||
// with overridden baseurl values for the specified repos to
|
||||
// a tmp config file.
|
||||
|
||||
@@ -84,6 +84,13 @@ Remove the repo \fIname\fP from the DNF configuration file used by mixer.
|
||||
.UNINDENT
|
||||
.UNINDENT
|
||||
.sp
|
||||
\fBset\-priority {name} {priority}\fP
|
||||
.INDENT 0.0
|
||||
.INDENT 3.5
|
||||
Sets the priority for repo \fIname\fP to the provided \fIpriority\fP\&.
|
||||
.UNINDENT
|
||||
.UNINDENT
|
||||
.sp
|
||||
\fBset\-url {name} {url}\fP
|
||||
.INDENT 0.0
|
||||
.INDENT 3.5
|
||||
|
||||
@@ -60,6 +60,10 @@ SUBCOMMANDS
|
||||
|
||||
Remove the repo `name` from the DNF configuration file used by mixer.
|
||||
|
||||
``set-priority {name} {priority}``
|
||||
|
||||
Sets the priority for repo `name` to the provided `priority`.
|
||||
|
||||
``set-url {name} {url}``
|
||||
|
||||
Sets the URL for repo `name` to the provided `url`. If `name` does not exist
|
||||
|
||||
@@ -81,6 +81,15 @@ to use when building bundles by excluding the unwanted ones. Globbing is support
|
||||
Run: runExcludesRepo,
|
||||
}
|
||||
|
||||
var setPriorityRepoCmd = &cobra.Command{
|
||||
Use: "set-priority <repo> <priority>",
|
||||
Short: "Set priority of repo in DNF conf file",
|
||||
Long: `Set repo <repo> with <priority> to the DNF conf file used by mixer. The <priority> must be a
|
||||
number between 1 and 99.`,
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: runPriorityRepo,
|
||||
}
|
||||
|
||||
var repoCmds = []*cobra.Command{
|
||||
addRepoCmd,
|
||||
removeRepoCmd,
|
||||
@@ -88,6 +97,7 @@ var repoCmds = []*cobra.Command{
|
||||
initRepoCmd,
|
||||
setURLRepoCmd,
|
||||
setExcludesRepoCmd,
|
||||
setPriorityRepoCmd,
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -111,6 +121,19 @@ func runExcludesRepo(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Excluded packages from repo %s:\n%s\n", args[0], strings.Join(args[1:], "\n"))
|
||||
}
|
||||
|
||||
func runPriorityRepo(cmd *cobra.Command, args []string) {
|
||||
b, err := builder.NewFromConfig(configFile)
|
||||
if err != nil {
|
||||
fail(err)
|
||||
}
|
||||
|
||||
err = b.SetPriorityRepo(args[0], args[1])
|
||||
if err != nil {
|
||||
fail(err)
|
||||
}
|
||||
fmt.Printf("Setting repo %s with priority %s\n", args[0], args[1])
|
||||
}
|
||||
|
||||
func runAddRepo(cmd *cobra.Command, args []string) {
|
||||
b, err := builder.NewFromConfig(configFile)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user