[zypp-commit] r10729 - in /trunk/libzypp/zypp: RepoManager.cc parser/RepoindexFileReader.cc
Author: jkupec Date: Sat Aug 2 19:26:44 2008 New Revision: 10729 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10729&view=rev Log: - support an optional url attribute in repoindex.xml's <repo> Modified: trunk/libzypp/zypp/RepoManager.cc trunk/libzypp/zypp/parser/RepoindexFileReader.cc Modified: trunk/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=10729&r1=10728&r2=10729&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.cc (original) +++ trunk/libzypp/zypp/RepoManager.cc Sat Aug 2 19:26:44 2008 @@ -1464,11 +1464,12 @@ mediamanager.release( mid ); mediamanager.close( mid ); - // set base url for all collected repositories - for_( it, collector.repos.begin(), collector.repos.end()) + // set service alias and base url for all collected repositories + for_( it, collector.repos.begin(), collector.repos.end() ) { - //repoUrl = it->baseUrlsBegin(); - it->setBaseUrl( service.url() ); + // if the repo url was not set by the repoindex parser, set service's url + if ( it->baseUrlsEmpty() ) + it->setBaseUrl( service.url() ); it->setService( service.alias() ); } Modified: trunk/libzypp/zypp/parser/RepoindexFileReader.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/RepoindexFileReader.cc?rev=10729&r1=10728&r2=10729&view=diff ============================================================================== --- trunk/libzypp/zypp/parser/RepoindexFileReader.cc (original) +++ trunk/libzypp/zypp/parser/RepoindexFileReader.cc Sat Aug 2 19:26:44 2008 @@ -18,9 +18,11 @@ #include "zypp/Pathname.h" #include "zypp/parser/xml/Reader.h" +#include "zypp/parser/ParseException.h" #include "zypp/parser/RepoindexFileReader.h" + #undef ZYPP_BASE_LOGGER_LOGGROUP #define ZYPP_BASE_LOGGER_LOGGROUP "parser" @@ -94,14 +96,44 @@ // xpath: /repoindex/data (+) if ( reader_r->name() == "repo" ) { + XmlString s; RepoInfo info; + + // url and/or path + string url_s; + s = reader_r->getAttribute("url"); + if (s.get()) + url_s = s.asString(); + string path_s; + s = reader_r->getAttribute("path"); + if (s.get()) + path_s = s.asString(); + + if (url_s.empty() && path_s.empty()) + throw ParseException(_("One or both of 'url' or 'path' attributes is required.")); //! \todo FIXME this hardcodes the "/repo/" fragment - should not be if we want it to be usable by others! - info.setPath(Pathname(string("/repo/")+reader_r->getAttribute("path").asString())); + else if (url_s.empty()) + info.setPath(Pathname(string("/repo/") + path_s)); + else if (path_s.empty()) + info.setBaseUrl(Url(url_s)); + else + info.setBaseUrl(Url(url_s + "/repo/" + path_s)); + + // required alias info.setAlias(reader_r->getAttribute("alias").asString()); - info.setType(repo::RepoType::RPMMD_e); //TODO hardwired rpmmd??? - XmlString s = reader_r->getAttribute("name"); - if (s.get()) // name available so store it + + // optional type + s = reader_r->getAttribute("type"); + if (s.get()) + info.setType(repo::RepoType(s.asString())); + + // optional name + s = reader_r->getAttribute("name"); + if (s.get()) info.setName(s.asString()); + + DBG << info << endl; + // ignore the rest _callback(info); return true; -- 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