From: Martin Vidner Date: Wed, 15 Nov 2006 13:41:09 +0000 (+0000) Subject: service-add: added options --type (especially for Plandir, #174369), X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb20345206d871c6453151fa94235f407d45d3bc;p=platform%2Fupstream%2Fzypper.git service-add: added options --type (especially for Plandir, #174369), --disabled and --no-refresh. --- diff --git a/VERSION b/VERSION index ed4c14c..8e987c0 100644 --- a/VERSION +++ b/VERSION @@ -10,5 +10,5 @@ dnl phase) dnl ================================================== m4_define([ZYPPER_MAJOR], [0]) m4_define([ZYPPER_MINOR], [6]) -m4_define([ZYPPER_PATCH], [9]) +m4_define([ZYPPER_PATCH], [10]) dnl ================================================== diff --git a/doc/zypper.8 b/doc/zypper.8 index 4ca4e52..575ef1a 100644 --- a/doc/zypper.8 +++ b/doc/zypper.8 @@ -186,6 +186,15 @@ Add a new service (installation source). .TP \fI\-r, -\-repo\fR Read URI and alias from a file +.TP +\fI\-t, \-\-type\fR +Type of repository (YaST, YUM, or Plaindir). +.TP +\fI\-d, \-\-disabled\fR +Add the service as disabled. +.TP +\fI\-n, \-\-no\-refresh\fR +Do not automatically refresh the metadata. .TP .B service-delete (sd) diff --git a/package/zypper.changes b/package/zypper.changes index 8b5a2eb..72ac4df 100644 --- a/package/zypper.changes +++ b/package/zypper.changes @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Wed Nov 15 14:40:11 CET 2006 - mvidner@suse.cz + +- service-add: added options --type (especially for Plaindir, + #174369), --disabled, and --no-refresh. +- 0.6.10 + +------------------------------------------------------------------- Mon Nov 13 15:47:50 CET 2006 - mvidner@suse.cz - Fixed service-rename leaving the old name around. @@ -30,6 +37,7 @@ Thu Nov 9 16:21:33 CET 2006 - mvidner@suse.cz (for example install -t was thinking -t stood for --terse). - If "install"ing more resolvables at a time, don't commit one by one. - 0.6.6 + ------------------------------------------------------------------- Wed Nov 8 20:08:30 CET 2006 - jkupec@suse.cz diff --git a/src/zmart-sources.cc b/src/zmart-sources.cc index 99d8be7..d8385d6 100644 --- a/src/zmart-sources.cc +++ b/src/zmart-sources.cc @@ -227,7 +227,8 @@ std::string timestamp () return outstr; } -void add_source_by_url( const zypp::Url &url, std::string alias ) +void add_source_by_url( const zypp::Url &url, const string &alias, + const string &type, bool enabled, bool refresh ) { cerr_vv << "Constructing SourceManager" << endl; SourceManager_Ptr manager = SourceManager::sourceManager(); @@ -239,22 +240,29 @@ void add_source_by_url( const zypp::Url &url, std::string alias ) Pathname path; Pathname cache; bool is_base = false; - if (alias.empty ()) - alias = timestamp(); + string myalias = alias.empty() ? timestamp() : alias; // more products? // try cerr_vv << "Creating source" << endl; - Source_Ref source = SourceFactory().createFrom( url, path, alias, cache, is_base ); + Source_Ref source; + if (type.empty()) { + source = SourceFactory().createFrom( url, path, myalias, cache, is_base ); + } + else { + source = SourceFactory().createFrom( type, + url, path, myalias, cache, is_base, + refresh ); + } cerr_vv << "Adding source" << endl; SourceManager::SourceId sourceId = manager->addSource( source ); - //if (enableSource) + if (enabled) source.enable(); - //else - // source.disable(); + else + source.disable(); - //source.setAutorefresh (autoRefresh); + source.setAutorefresh (refresh); sourceIds.push_back( sourceId ); cout << "Added Installation Sources:" << endl; diff --git a/src/zmart-sources.h b/src/zmart-sources.h index 71744f0..7f65f4b 100644 --- a/src/zmart-sources.h +++ b/src/zmart-sources.h @@ -17,7 +17,9 @@ void cond_init_system_sources(); void init_system_sources(); void include_source_by_url( const zypp::Url &url ); bool parse_repo_file (const std::string& file, std::string& url, std::string& alias); -void add_source_by_url( const zypp::Url &url, std::string alias ); +void add_source_by_url( const zypp::Url &url, const std::string &alias, + const std::string &type = "", + bool enabled = true, bool refresh = true ); void remove_source( const std::string& anystring ); void rename_source( const std::string& anystring, const std::string& newalias ); void list_system_sources(); @@ -41,4 +43,7 @@ private: }; #endif - +// Local Variables: +// mode: c++ +// c-basic-offset: 2 +// End: diff --git a/src/zypper.cc b/src/zypper.cc index 6dbb07a..28dff72 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -230,6 +230,7 @@ int one_command(const string& command, int argc, char **argv) } else if (command == "service-add" || command == "sa") { static struct option service_add_options[] = { + {"type", required_argument, 0, 't'}, {"disabled", no_argument, 0, 'd'}, {"no-refresh", no_argument, 0, 'n'}, {"repo", required_argument, 0, 'r'}, @@ -244,6 +245,9 @@ int one_command(const string& command, int argc, char **argv) " Command options:\n" "\t--repo,-r \tRead the URL and alias from a file\n" "\t\t\t\t(even remote)\n" + "\t--type,-t \tType of repository (YaST, YUM, or Plaindir)\n" + "\t--disabled,-d\t\tAdd the service as disabled\n" + "\t--no-refresh,-n\t\tDo not automatically refresh the metadata\n" ; } else if (command == "service-list" || command == "sl") { @@ -532,11 +536,13 @@ int one_command(const string& command, int argc, char **argv) else if (command == "service-add" || command == "sa") { - if (copts.count("disabled")) { - cerr_v << "FAKE Disabled" << endl; - } - if (copts.count("no-refresh")) { - cerr_v << "FAKE No Refresh" << endl; + // TODO: repect values in .repo, have these as overrides + bool enabled = ! copts.count("disabled"); + bool refresh = ! copts.count("no-refresh"); + + string type = copts.count("type")? copts["type"].front() : ""; + if (type != "" && type != "YaST" && type != "YUM" && type != "Plaindir") { + cerr << "Warning, unknown metadata type " << type << endl; } string repoalias, repourl; @@ -573,7 +579,7 @@ int one_command(const string& command, int argc, char **argv) try { // also stores it - add_source_by_url(url, alias); + add_source_by_url(url, alias, type, enabled, refresh); } catch ( const Exception & excpt_r ) {