[zypp-commit] r9311 - in /trunk/zypper: doc/zypper.8 src/zypper-repos.cc src/zypper.cc
Author: jkupec Date: Sun Mar 30 22:09:41 2008 New Revision: 9311 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9311&view=rev Log: - --priority option added to the modifyrepo command to set repository priority (bnc #369827) Modified: trunk/zypper/doc/zypper.8 trunk/zypper/src/zypper-repos.cc trunk/zypper/src/zypper.cc Modified: trunk/zypper/doc/zypper.8 URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=9311&r1=9310&r2=9311&view=diff ============================================================================== --- trunk/zypper/doc/zypper.8 (original) +++ trunk/zypper/doc/zypper.8 Sun Mar 30 22:09:41 2008 @@ -424,6 +424,12 @@ .TP \fI\-n, \-\-no\-refresh\fR Disable auto-refresh for the repository. +.TP +.I \-p, \-\-priority <1-99> +Set priority of the repository. Priority of 1 is the highest, 99 is the lowest +and the default. Packages from repositories with higher priority will be +preferred even in case there is a higher installable version of available +in the repository with a lower priority. .TP .B refresh (ref) [alias|#] ... Modified: trunk/zypper/src/zypper-repos.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-repos.cc?rev=9311&r1=9310&r2=9311&view=diff ============================================================================== --- trunk/zypper/src/zypper-repos.cc (original) +++ trunk/zypper/src/zypper-repos.cc Sun Mar 30 22:09:41 2008 @@ -19,7 +19,6 @@ #include "zypper-main.h" #include "zypper-getopt.h" #include "zypper-tabulator.h" -//#include "zypper-callbacks.h" #include "zypper-utils.h" #include "zypper-repos.h" @@ -1421,6 +1420,7 @@ RepoInfo repo(manager.getRepositoryInfo(alias)); bool chnaged_enabled = false; bool changed_autoref = false; + bool changed_prio = false; if (!indeterminate(enable)) { @@ -1435,9 +1435,36 @@ changed_autoref = true; repo.setAutorefresh(autoref); } + + int prio = 0; + parsed_opts::const_iterator tmp1; + if ((tmp1 = zypper.cOpts().find("priority")) != zypper.cOpts().end()) + { + //! \todo use some preset priorities (high, medium, low, ...) + + string prio_str = *tmp1->second.begin(); + safe_lexical_cast(prio_str, prio); // try to make an int out of the string + if (prio < 1 || prio > 99) + { + zypper.out().error(boost::str(format( + _("Invalid priority '%s'. Use an integer number between 1 (highest priority) and 99 (lowest priority).")) + % prio_str)); + zypper.setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS); + return; + } + if (prio == (int) repo.priority()) + zypper.out().info(boost::str(format( + _("Repository '%s' priority has been left unchanged (%d)")) + % alias % prio)); + else + { + repo.setPriority(prio); + changed_prio = true; + } + } - if (chnaged_enabled || changed_autoref) + if (chnaged_enabled || changed_autoref || changed_prio) { manager.modifyRepository(alias, repo); @@ -1460,6 +1487,12 @@ zypper.out().info(boost::str(format( _("Autorefresh has been disabled for repository '%s'.")) % alias)); } + + if (changed_prio) + { + zypper.out().info(boost::str(format( + _("Repository '%s' priority has been set to %d.")) % alias % prio)); + } } else { Modified: trunk/zypper/src/zypper.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=9311&r1=9310&r2=9311&view=diff ============================================================================== --- trunk/zypper/src/zypper.cc (original) +++ trunk/zypper/src/zypper.cc Sun Mar 30 22:09:41 2008 @@ -955,6 +955,7 @@ {"enable-autorefresh", no_argument, 0, 'a'}, // backward compatibility {"no-refresh", no_argument, 0, 'n'}, {"disable-autorefresh", no_argument, 0, 0 }, // backward compatibility + {"priority", required_argument, 0, 'p'}, {0, 0, 0, 0} }; specific_options = service_modify_options; @@ -968,6 +969,7 @@ "-e, --enable Enable a disabled repository\n" "-r, --refresh Enable auto-refresh of the repository\n" "-n, --no-refresh Disable auto-refresh of the repository\n" + "-p, --priority <1-99> Set priority of the repository. Seem the manual page for details.\n" ); break; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
jkupec@svn.opensuse.org