Author: jkupec
Date: Mon Jul 9 12:29:54 2007
New Revision: 5928
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5928&view=rev
Log:
modifyrepo command added (service-modify in help for now)
Modified:
trunk/zypper/doc/zypper.8
trunk/zypper/src/zypper-command.cc
trunk/zypper/src/zypper-command.h
trunk/zypper/src/zypper-sources.cc
trunk/zypper/src/zypper-sources.h
trunk/zypper/src/zypper.cc
Modified: trunk/zypper/doc/zypper.8
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=5928&r1=5927&r2=5928&view=diff
==============================================================================
--- trunk/zypper/doc/zypper.8 (original)
+++ trunk/zypper/doc/zypper.8 Mon Jul 9 12:29:54 2007
@@ -189,7 +189,7 @@
.B service-add (sa) <URI> <alias>
Add a new service (installation source).
.TP
-\fI\-r, -\-repo\fR
+\fI\-r, \-\-repo\fR
Read URI and alias from a file
.TP
\fI\-t, \-\-type\fR <TYPE>
@@ -218,6 +218,22 @@
Rename a service (installation source).
.TP
+.B service-modify (sm) <options> <alias>
+Modify a service (installation source).
+.TP
+\fI\-e, \-\-enable\fR
+Enable the service.
+.TP
+\fI\-d, \-\-disable\fR
+Disable the service.
+.TP
+\fI\-a, \-\-enable-autorefresh\fR
+Enable auto-refresh for the service.
+.TP
+\fI \-\-disable\-autorefresh\fR
+Disable auto-refresh for the service.
+
+.TP
.B refresh (ref)
Refresh all installation sources found in system.
.IP
Modified: trunk/zypper/src/zypper-command.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.cc?rev=5928&r1=5927&r2=5928&view=diff
==============================================================================
--- trunk/zypper/src/zypper-command.cc (original)
+++ trunk/zypper/src/zypper-command.cc Mon Jul 9 12:29:54 2007
@@ -19,6 +19,7 @@
const ZypperCommand ZypperCommand::ADD_REPO(ZypperCommand::ADD_REPO_e);
const ZypperCommand ZypperCommand::REMOVE_REPO(ZypperCommand::REMOVE_REPO_e);
const ZypperCommand ZypperCommand::RENAME_REPO(ZypperCommand::RENAME_REPO_e);
+const ZypperCommand ZypperCommand::MODIFY_REPO(ZypperCommand::MODIFY_REPO_e);
const ZypperCommand ZypperCommand::LIST_REPOS(ZypperCommand::LIST_REPOS_e);
const ZypperCommand ZypperCommand::REFRESH(ZypperCommand::REFRESH_e);
@@ -51,9 +52,10 @@
if (_table.empty())
{
// initialize it
- _table["addrepo"] = _table["service-add"] = _table["sa"] = ZypperCommand::ADD_REPO_e;
- _table["rmrepo"] = _table["service-delete"] = _table["sd"] = ZypperCommand::REMOVE_REPO_e;
- _table["renamerepo"]= _table["rr"] = _table["service-rename"] = _table["sr"] = ZypperCommand::RENAME_REPO_e;
+ _table["addrepo"] = _table["ar"] = _table["service-add"] = _table["sa"] = ZypperCommand::ADD_REPO_e;
+ _table["removerepo"] = _table["rr"] = _table["service-delete"] = _table["sd"] = ZypperCommand::REMOVE_REPO_e;
+ _table["renamerepo"]= _table["nr"] = _table["service-rename"] = _table["sr"] = ZypperCommand::RENAME_REPO_e;
+ _table["modifyrepo"]= _table["mr"] = _table["service-modify"] = _table["sm"] = ZypperCommand::MODIFY_REPO_e;
_table["listrepos"] = _table["lr"] = _table["service-list"] = _table["sl"] = ZypperCommand::LIST_REPOS_e;
_table["refresh"] = _table["ref"] = ZypperCommand::REFRESH_e;
Modified: trunk/zypper/src/zypper-command.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.h?rev=5928&r1=5927&r2=5928&view=diff
==============================================================================
--- trunk/zypper/src/zypper-command.h (original)
+++ trunk/zypper/src/zypper-command.h Mon Jul 9 12:29:54 2007
@@ -13,6 +13,7 @@
static const ZypperCommand ADD_REPO;
static const ZypperCommand REMOVE_REPO;
static const ZypperCommand RENAME_REPO;
+ static const ZypperCommand MODIFY_REPO;
static const ZypperCommand LIST_REPOS;
static const ZypperCommand REFRESH;
@@ -44,6 +45,7 @@
ADD_REPO_e,
REMOVE_REPO_e,
RENAME_REPO_e,
+ MODIFY_REPO_e,
LIST_REPOS_e,
REFRESH_e,
Modified: trunk/zypper/src/zypper-sources.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-sources.cc?rev=5928&r1=5927&r2=5928&view=diff
==============================================================================
--- trunk/zypper/src/zypper-sources.cc (original)
+++ trunk/zypper/src/zypper-sources.cc Mon Jul 9 12:29:54 2007
@@ -417,16 +417,97 @@
void rename_repo(const std::string & alias, const std::string & newalias)
{
RepoManager manager;
-
- RepoInfo repo(manager.getRepositoryInfo(alias));
- repo.setAlias(newalias);
-
+
try
{
+ RepoInfo repo(manager.getRepositoryInfo(alias));
+ repo.setAlias(newalias);
manager.modifyRepository(alias, repo);
cout_n << format(_("Repository %s renamed to %s")) % alias % repo.alias() << endl;
- MIL << format(_("Repository %s renamed to %s")) % alias % repo.alias() << endl;
+ MIL << format("Repository %s renamed to %s") % alias % repo.alias() << endl;
+ }
+ catch (const RepoNotFoundException & ex)
+ {
+ cerr << format(_("Repository %s not found.")) % alias << endl;
+ ERR << "Repo " << alias << " not found" << endl;
+ }
+ catch (const Exception & ex)
+ {
+ cerr << _("Error while modifying the repository:") << endl;
+ cerr << ex.asUserString();
+ cerr << format(_("Leaving repository %s unchanged.")) % alias << endl;
+
+ ERR << "Error while modifying the repository:" << ex.asUserString() << endl;
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+void modify_repo(const string & alias, const parsed_opts & copts)
+{
+ // tell whether currenlty processed options are contradicting each other
+ bool contradiction = false;
+ // TranslatorExplanation speaking of two mutually contradicting command line options
+ string msg_contradition =
+ _("%s used together with %s, which contradict each other."
+ " This property will be left unchanged.");
+
+ // enable/disable repo
+ tribool enable = indeterminate;
+ if (copts.count("enable"))
+ enable = true;
+ if (copts.count("disable"))
+ {
+ if (enable)
+ {
+ cerr << format(msg_contradition) % "--enable" % "--disable" << endl;
+
+ enable = indeterminate;
+ }
+ else
+ enable = false;
+ }
+ DBG << "enable = " << enable << endl;
+
+ // autorefresh
+ tribool autoref = indeterminate;
+ if (copts.count("enable-autorefresh"))
+ autoref = true;
+ if (copts.count("disable-autorefresh"))
+ {
+ if (autoref)
+ {
+ cerr << format(msg_contradition)
+ % "--enable-autorefresh" % "--disable-autorefresh" << endl;
+
+ autoref = indeterminate;
+ }
+ else
+ autoref = false;
+ }
+ DBG << "autoref = " << autoref << endl;
+
+ try
+ {
+ RepoManager manager;
+ RepoInfo repo(manager.getRepositoryInfo(alias));
+
+ if (!indeterminate(enable))
+ repo.setEnabled(enable);
+
+ if (!indeterminate(autoref))
+ repo.setAutorefresh(autoref);
+
+ manager.modifyRepository(alias, repo);
+
+ cout_n << format(_("Repository %s has been sucessfully modified.")) % alias << endl;
+ MIL << format("Repository %s modified:") % alias << repo << endl;
+ }
+ catch (const RepoNotFoundException & ex)
+ {
+ cerr << format(_("Repository %s not found.")) % alias << endl;
+ ERR << "Repo " << alias << " not found" << endl;
}
catch (const Exception & ex)
{
Modified: trunk/zypper/src/zypper-sources.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-sources.h?rev=5928&r1=5927&r2=5928&view=diff
==============================================================================
--- trunk/zypper/src/zypper-sources.h (original)
+++ trunk/zypper/src/zypper-sources.h Mon Jul 9 12:29:54 2007
@@ -5,6 +5,8 @@
#include "zypp/Url.h"
+#include "zypper-getopt.h"
+
/**
* Reads known enabled repositories and stores them in gData.
* This command also refreshes repos with auto-refresh enabled.
@@ -73,6 +75,12 @@
*/
void rename_repo(const std::string & alias, const std::string & newalias);
+
+/**
+ *
+ */
+void modify_repo(const std::string & alias, const parsed_opts & copts);
+
//void include_source_by_url( const zypp::Url &url ); // OLD
#endif
Modified: trunk/zypper/src/zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=5928&r1=5927&r2=5928&view=diff
==============================================================================
--- trunk/zypper/src/zypper.cc (original)
+++ trunk/zypper/src/zypper.cc Mon Jul 9 12:29:54 2007
@@ -96,6 +96,7 @@
"\tservice-add, sa\t\tAdd a new service\n"
"\tservice-delete, sd\tDelete a service\n"
"\tservice-rename, sr\tRename a service\n"
+ "\tservice-modify, sm\tModify a service\n"
"\trefresh, ref\t\tRefresh all installation sources\n"
"\tpatch-check, pchk\tCheck for patches\n"
"\tpatches, pch\t\tList patches\n"
@@ -340,7 +341,7 @@
"This command has no additional options.\n"
);
}
- else if (command == ZypperCommand::NONE) {//command_str == "service-rename" || command_str == "sr") {
+ else if (command == ZypperCommand::RENAME_REPO) {
static struct option service_rename_options[] = {
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
@@ -349,11 +350,32 @@
specific_help = _(
"service-rename [options] <alias> <new-alias>\n"
"\n"
- "Assign new alias to the service specified by URI or current alias."
+ "Assign new alias to the service specified by alias."
"\n"
"This command has no additional options.\n"
);
}
+ else if (command == ZypperCommand::MODIFY_REPO) {
+ static struct option service_modify_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {"disable", no_argument, 0, 'd'},
+ {"enable", no_argument, 0, 'e'},
+ {"enable-autorefresh", no_argument, 0, 'a'},
+ {"disable-autorefresh", no_argument, 0, 0},
+ {0, 0, 0, 0}
+ };
+ specific_options = service_modify_options;
+ specific_help = _(
+ "service-modify (sm) <options> <alias>\n"
+ "\n"
+ "Modify properties of a service specified by alias."
+ "\n"
+ "\t--disable,-d\t\tDisable the service (but don't remove it)\n"
+ "\t--enable,-e\t\tEnable a disabled service\n"
+ "\t--enable-autorefresh,-a\tEnable auto-refresh of the service\n"
+ "\t--disable-autorefresh\tDisable auto-refresh of the service\n"
+ );
+ }
else if (command == ZypperCommand::REFRESH) {
static struct option refresh_options[] = {
{"help", no_argument, 0, 'h'},
@@ -746,6 +768,29 @@
return ZYPPER_EXIT_OK;
}
+ // --------------------------( service modify )-----------------------------
+
+ else if (command == ZypperCommand::MODIFY_REPO)
+ {
+ if (ghelp || arguments.size() < 1)
+ {
+ if (ghelp)
+ {
+ cout << specific_help;
+ return ZYPPER_EXIT_OK;
+ }
+ else
+ {
+ cerr << _("Alias is a required argument.") << endl;
+ ERR << "Na alias argument given." << endl;
+ cout_n << specific_help;
+ return ZYPPER_EXIT_ERR_INVALID_ARGS;
+ }
+ }
+
+ modify_repo(arguments[0], copts);
+ }
+
// --------------------------( refresh )------------------------------------
else if (command == ZypperCommand::REFRESH)
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org