1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoManager.cc
17 #include "zypp/base/InputStream.h"
18 #include "zypp/base/Logger.h"
19 #include "zypp/base/Gettext.h"
20 #include "zypp/base/Function.h"
21 #include "zypp/PathInfo.h"
22 #include "zypp/TmpPath.h"
24 #include "zypp/repo/RepoException.h"
25 #include "zypp/RepoManager.h"
27 #include "zypp/cache/CacheStore.h"
28 #include "zypp/repo/cached/RepoImpl.h"
29 #include "zypp/media/MediaManager.h"
30 #include "zypp/MediaSetAccess.h"
32 #include "zypp/parser/RepoFileReader.h"
33 #include "zypp/repo/yum/Downloader.h"
34 #include "zypp/parser/yum/RepoParser.h"
35 #include "zypp/parser/plaindir/RepoParser.h"
36 #include "zypp/repo/susetags/Downloader.h"
37 #include "zypp/parser/susetags/RepoParser.h"
39 #include "zypp/ZYppCallbacks.h"
43 using namespace zypp::repo;
44 using namespace zypp::filesystem;
46 using namespace zypp::repo;
48 ///////////////////////////////////////////////////////////////////
50 { /////////////////////////////////////////////////////////////////
52 ///////////////////////////////////////////////////////////////////
54 // CLASS NAME : RepoManagerOptions
56 ///////////////////////////////////////////////////////////////////
58 RepoManagerOptions::RepoManagerOptions()
60 repoCachePath = ZConfig::instance().defaultRepoCachePath();
61 repoRawCachePath = ZConfig::instance().defaultRepoMetadataPath();
62 knownReposPath = ZConfig::instance().defaultKnownReposPath();
65 ////////////////////////////////////////////////////////////////////////////
68 * \short Simple callback to collect the results
70 * Classes like RepoFileParser call the callback
71 * once per each repo in a file.
73 * Passing this functor as callback, you can collect
74 * all resuls at the end, without dealing with async
89 bool collect( const RepoInfo &repo )
91 //MIL << "here in collector: " << repo.alias() << endl;
92 repos.push_back(repo);
93 //MIL << "added: " << repo.alias() << endl;
100 ////////////////////////////////////////////////////////////////////////////
103 * Reads RepoInfo's from a repo file.
105 * \param file pathname of the file to read.
107 static std::list<RepoInfo> repositories_in_file( const Pathname & file )
109 MIL << "repo file: " << file << endl;
110 RepoCollector collector;
111 parser::RepoFileReader parser( file, bind( &RepoCollector::collect, &collector, _1 ) );
112 return collector.repos;
115 ////////////////////////////////////////////////////////////////////////////
117 std::list<RepoInfo> readRepoFile(const Url & repo_file)
119 // no interface to download a specific file, using workaround:
120 //! \todo add MediaManager::provideFile(Url file_url) to easily access any file URLs? (no need for media access id or media_nr)
122 Pathname path(url.getPathName());
123 url.setPathName ("/");
124 MediaSetAccess access(url);
125 Pathname local = access.provideFile(path);
127 DBG << "reading repo file " << repo_file << ", local path: " << local << endl;
129 return repositories_in_file(local);
132 ////////////////////////////////////////////////////////////////////////////
135 * \short List of RepoInfo's from a directory
137 * Goes trough every file in a directory and adds all
138 * RepoInfo's contained in that file.
140 * \param dir pathname of the directory to read.
142 static std::list<RepoInfo> repositories_in_dir( const Pathname &dir )
144 MIL << "directory " << dir << endl;
145 list<RepoInfo> repos;
146 list<Pathname> entries;
147 if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
148 ZYPP_THROW(Exception("failed to read directory"));
150 for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
152 list<RepoInfo> tmp = repositories_in_file( *it );
153 repos.insert( repos.end(), tmp.begin(), tmp.end() );
155 //std::copy( collector.repos.begin(), collector.repos.end(), std::back_inserter(repos));
156 //MIL << "ok" << endl;
161 ////////////////////////////////////////////////////////////////////////////
163 static void assert_alias( const RepoInfo &info )
165 if (info.alias().empty())
166 ZYPP_THROW(RepoNoAliasException());
169 ////////////////////////////////////////////////////////////////////////////
171 static void assert_urls( const RepoInfo &info )
173 if (info.baseUrls().empty())
174 ZYPP_THROW(RepoNoUrlException());
177 ////////////////////////////////////////////////////////////////////////////
180 * \short Calculates the raw cache path for a repository
182 static Pathname rawcache_path_for_repoinfo( const RepoManagerOptions &opt, const RepoInfo &info )
185 return opt.repoRawCachePath + info.alias();
188 ///////////////////////////////////////////////////////////////////
190 // CLASS NAME : RepoManager::Impl
192 ///////////////////////////////////////////////////////////////////
195 * \short RepoManager implementation.
197 struct RepoManager::Impl
199 Impl( const RepoManagerOptions &opt )
210 RepoManagerOptions options;
213 /** Offer default Impl. */
214 static shared_ptr<Impl> nullimpl()
216 static shared_ptr<Impl> _nullimpl( new Impl );
221 friend Impl * rwcowClone<Impl>( const Impl * rhs );
222 /** clone for RWCOW_pointer */
224 { return new Impl( *this ); }
226 ///////////////////////////////////////////////////////////////////
228 /** \relates RepoManager::Impl Stream output */
229 inline std::ostream & operator<<( std::ostream & str, const RepoManager::Impl & obj )
231 return str << "RepoManager::Impl";
234 ///////////////////////////////////////////////////////////////////
236 // CLASS NAME : RepoManager
238 ///////////////////////////////////////////////////////////////////
240 RepoManager::RepoManager( const RepoManagerOptions &opt )
241 : _pimpl( new Impl(opt) )
244 ////////////////////////////////////////////////////////////////////////////
246 RepoManager::~RepoManager()
249 ////////////////////////////////////////////////////////////////////////////
251 std::list<RepoInfo> RepoManager::knownRepositories() const
255 if ( PathInfo(_pimpl->options.knownReposPath).isExist() )
257 RepoInfoList repos = repositories_in_dir(_pimpl->options.knownReposPath);
258 for ( RepoInfoList::iterator it = repos.begin();
262 // set the metadata path for the repo
263 Pathname metadata_path = rawcache_path_for_repoinfo(_pimpl->options, (*it));
264 (*it).setMetadataPath(metadata_path);
269 return std::list<RepoInfo>();
274 ////////////////////////////////////////////////////////////////////////////
276 RepoStatus RepoManager::metadataStatus( const RepoInfo &info ) const
278 Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info );
279 RepoType repokind = info.type();
282 switch ( repokind.toEnum() )
284 case RepoType::NONE_e:
285 // unknown, probe the local metadata
286 repokind = probe(rawpath.asUrl());
292 switch ( repokind.toEnum() )
294 case RepoType::RPMMD_e :
296 status = RepoStatus( rawpath + "/repodata/repomd.xml");
300 case RepoType::YAST2_e :
302 status = RepoStatus( rawpath + "/content");
306 case RepoType::RPMPLAINDIR_e :
308 if ( PathInfo(Pathname(rawpath + "/cookie")).isExist() )
309 status = RepoStatus( rawpath + "/cookie");
313 case RepoType::NONE_e :
314 // Return default RepoStatus in case of RepoType::NONE
315 // indicating it should be created?
316 // ZYPP_THROW(RepoUnknownTypeException());
322 void RepoManager::refreshMetadata( const RepoInfo &info,
323 RawMetadataRefreshPolicy policy,
324 const ProgressData::ReceiverFnc & progress )
329 RepoStatus oldstatus;
330 RepoStatus newstatus;
331 // try urls one by one
332 for ( RepoInfo::urls_const_iterator it = info.baseUrlsBegin(); it != info.baseUrlsEnd(); ++it )
338 repo::RepoType repokind = info.type();
340 // if the type is unknown, try probing.
341 switch ( repokind.toEnum() )
343 case RepoType::NONE_e:
345 repokind = probe(*it);
351 Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info );
352 filesystem::assert_dir(rawpath);
353 oldstatus = metadataStatus(info);
355 // create temp dir as sibling of rawpath
356 filesystem::TmpDir tmpdir( filesystem::TmpDir::makeSibling( rawpath ) );
358 if ( ( repokind.toEnum() == RepoType::RPMMD_e ) ||
359 ( repokind.toEnum() == RepoType::YAST2_e ) )
361 MediaSetAccess media(url);
362 shared_ptr<repo::Downloader> downloader_ptr;
364 if ( repokind.toEnum() == RepoType::RPMMD_e )
365 downloader_ptr.reset(new yum::Downloader(info.path()));
367 downloader_ptr.reset( new susetags::Downloader(info.path()));
370 * Given a downloader, sets the other repos raw metadata
371 * path as cache paths for the fetcher, so if another
372 * repo has the same file, it will not download it
373 * but copy it from the other repository
375 std::list<RepoInfo> repos = knownRepositories();
376 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
380 downloader_ptr->addCachePath(rawcache_path_for_repoinfo( _pimpl->options, *it ));
383 RepoStatus newstatus = downloader_ptr->status(media);
384 bool refresh = false;
385 if ( oldstatus.checksum() == newstatus.checksum() )
387 MIL << "repo has not changed" << endl;
388 if ( policy == RefreshForced )
390 MIL << "refresh set to forced" << endl;
399 downloader_ptr->download( media, tmpdir.path());
404 else if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e )
406 RepoStatus newstatus = parser::plaindir::dirStatus(url.getPathName());
407 bool refresh = false;
408 if ( oldstatus.checksum() == newstatus.checksum() )
410 MIL << "repo has not changed" << endl;
411 if ( policy == RefreshForced )
413 MIL << "refresh set to forced" << endl;
424 std::ofstream file(( tmpdir.path() + "/cookie").c_str());
426 ZYPP_THROW (Exception( "Can't open " + tmpdir.path().asString() + "/cookie" ) );
429 file << newstatus.checksum() << endl;
439 ZYPP_THROW(RepoUnknownTypeException());
442 // ok we have the metadata, now exchange
444 TmpDir oldmetadata( TmpDir::makeSibling( rawpath ) );
445 filesystem::rename( rawpath, oldmetadata.path() );
446 // move the just downloaded there
447 filesystem::rename( tmpdir.path(), rawpath );
451 catch ( const Exception &e )
454 ERR << "Trying another url..." << endl;
457 ERR << "No more urls..." << endl;
458 ZYPP_THROW(RepoException("Cant refresh metadata"));
461 ////////////////////////////////////////////////////////////////////////////
463 void RepoManager::cleanMetadata( const RepoInfo &info,
464 const ProgressData::ReceiverFnc & progress )
466 filesystem::recursive_rmdir(rawcache_path_for_repoinfo(_pimpl->options, info));
469 void RepoManager::buildCache( const RepoInfo &info,
470 CacheBuildPolicy policy,
471 const ProgressData::ReceiverFnc & progressrcv )
473 ProgressData progress(100);
474 callback::SendReport<ProgressReport> report;
475 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
476 progress.name(str::form(_("Building repository '%s' cache"), info.alias().c_str()));
480 Pathname rawpath = rawcache_path_for_repoinfo(_pimpl->options, info);
482 cache::CacheStore store(_pimpl->options.repoCachePath);
484 RepoStatus raw_metadata_status = metadataStatus(info);
485 if ( raw_metadata_status.empty() )
487 ZYPP_THROW(RepoMetadataException(info));
490 if ( store.isCached( info.alias() ) )
492 MIL << info.alias() << " is already cached." << endl;
493 data::RecordId id = store.lookupRepository(info.alias());
494 RepoStatus cache_status = store.repositoryStatus(id);
496 if ( cache_status.checksum() == raw_metadata_status.checksum() )
498 MIL << info.alias() << " cache is up to date with metadata." << endl;
499 if ( policy == BuildIfNeeded ) {
504 MIL << info.alias() << " cache rebuild is forced" << endl;
507 MIL << info.alias() << " cleaning cache..." << endl;
508 store.cleanRepository(id);
511 MIL << info.alias() << " building cache..." << endl;
512 data::RecordId id = store.lookupOrAppendRepository(info.alias());
514 repo::RepoType repokind = info.type();
516 // if the type is unknown, try probing.
517 switch ( repokind.toEnum() )
519 case RepoType::NONE_e:
520 // unknown, probe the local metadata
521 repokind = probe(rawpath.asUrl());
527 CombinedProgressData subprogrcv( progress, 100);
529 switch ( repokind.toEnum() )
531 case RepoType::RPMMD_e :
533 parser::yum::RepoParser parser(id, store, parser::yum::RepoParserOpts(), subprogrcv);
534 parser.parse(rawpath);
538 case RepoType::YAST2_e :
540 parser::susetags::RepoParser parser(id, store, subprogrcv);
541 parser.parse(rawpath);
545 case RepoType::RPMPLAINDIR_e :
547 InputStream is(rawpath + "cookie");
549 getline( is.stream(), buffer);
551 parser::plaindir::RepoParser parser(id, store, subprogrcv);
552 parser.parse(url.getPathName());
556 ZYPP_THROW(RepoUnknownTypeException());
559 // update timestamp and checksum
560 store.updateRepositoryStatus(id, raw_metadata_status);
562 MIL << "Commit cache.." << endl;
567 ////////////////////////////////////////////////////////////////////////////
569 repo::RepoType RepoManager::probe( const Url &url ) const
571 if ( url.getScheme() == "dir" && ! PathInfo( url.getPathName() ).isDir() )
573 // Handle non existing local directory in advance, as
574 // MediaSetAccess does not support it.
575 return repo::RepoType::NONE;
578 MediaSetAccess access(url);
579 if ( access.doesFileExist("/repodata/repomd.xml") )
580 return repo::RepoType::RPMMD;
581 if ( access.doesFileExist("/content") )
582 return repo::RepoType::YAST2;
584 // if it is a local url of type dir
585 if ( (! media::MediaManager::downloads(url)) && ( url.getScheme() == "dir" ) )
587 Pathname path = Pathname(url.getPathName());
588 if ( PathInfo(path).isDir() )
590 // allow empty dirs for now
591 return repo::RepoType::RPMPLAINDIR;
595 return repo::RepoType::NONE;
598 ////////////////////////////////////////////////////////////////////////////
600 void RepoManager::cleanCache( const RepoInfo &info,
601 const ProgressData::ReceiverFnc & progressrcv )
603 ProgressData progress(100);
604 callback::SendReport<ProgressReport> report;
605 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
606 progress.name(str::form(_("Cleaning repository '%s' cache"), info.alias().c_str()));
609 cache::CacheStore store(_pimpl->options.repoCachePath);
611 data::RecordId id = store.lookupRepository(info.alias());
612 store.cleanRepository(id);
616 ////////////////////////////////////////////////////////////////////////////
618 bool RepoManager::isCached( const RepoInfo &info ) const
620 cache::CacheStore store(_pimpl->options.repoCachePath);
621 return store.isCached(info.alias());
624 RepoStatus RepoManager::cacheStatus( const RepoInfo &info ) const
626 cache::CacheStore store(_pimpl->options.repoCachePath);
627 data::RecordId id = store.lookupRepository(info.alias());
628 RepoStatus cache_status = store.repositoryStatus(id);
632 Repository RepoManager::createFromCache( const RepoInfo &info,
633 const ProgressData::ReceiverFnc & progressrcv )
635 callback::SendReport<ProgressReport> report;
636 ProgressData progress;
637 progress.sendTo(ProgressReportAdaptor( progressrcv, report ));
638 //progress.sendTo( progressrcv );
639 progress.name(str::form(_("Reading repository '%s' cache"), info.alias().c_str()));
641 cache::CacheStore store(_pimpl->options.repoCachePath);
643 if ( ! store.isCached( info.alias() ) )
644 ZYPP_THROW(RepoNotCachedException());
646 MIL << "Repository " << info.alias() << " is cached" << endl;
648 data::RecordId id = store.lookupRepository(info.alias());
650 repo::cached::RepoOptions opts( info, _pimpl->options.repoCachePath, id );
651 opts.readingResolvablesProgress = progressrcv;
652 repo::cached::RepoImpl::Ptr repoimpl =
653 new repo::cached::RepoImpl( opts );
655 repoimpl->resolvables();
656 // read the resolvables from cache
657 return Repository(repoimpl);
660 ////////////////////////////////////////////////////////////////////////////
663 * Generate a non existing filename in a directory, using a base
664 * name. For example if a directory contains 3 files
670 * If you try to generate a unique filename for this directory,
671 * based on "ruu" you will get "ruu", but if you use the base
672 * "foo" you will get "foo_1"
674 * \param dir Directory where the file needs to be unique
675 * \param basefilename string to base the filename on.
677 static Pathname generate_non_existing_name( const Pathname &dir,
678 const std::string &basefilename )
680 string final_filename = basefilename;
682 while ( PathInfo(dir + final_filename).isExist() )
684 final_filename = basefilename + "_" + str::numstring(counter);
687 return dir + Pathname(final_filename);
690 ////////////////////////////////////////////////////////////////////////////
693 * \short Generate a related filename from a repo info
695 * From a repo info, it will try to use the alias as a filename
696 * escaping it if necessary. Other fallbacks can be added to
697 * this function in case there is no way to use the alias
699 static std::string generate_filename( const RepoInfo &info )
703 std::string filename = info.alias();
704 // replace slashes with underscores
705 size_t pos = filename.find(fnd);
706 while(pos!=string::npos)
708 filename.replace(pos,fnd.length(),rep);
709 pos = filename.find(fnd,pos+rep.length());
711 filename = Pathname(filename).extend(".repo").asString();
712 MIL << "generating filename for repo [" << info.alias() << "] : '" << filename << "'" << endl;
717 ////////////////////////////////////////////////////////////////////////////
719 void RepoManager::addRepository( const RepoInfo &info,
720 const ProgressData::ReceiverFnc & progressrcv )
724 ProgressData progress(100);
725 callback::SendReport<ProgressReport> report;
726 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
727 progress.name(str::form(_("Adding repository '%s'"), info.alias().c_str()));
730 std::list<RepoInfo> repos = knownRepositories();
731 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
735 if ( info.alias() == (*it).alias() )
736 ZYPP_THROW(RepoAlreadyExistsException(info.alias()));
741 // assert the directory exists
742 filesystem::assert_dir(_pimpl->options.knownReposPath);
744 Pathname repofile = generate_non_existing_name(_pimpl->options.knownReposPath,
745 generate_filename(info));
746 // now we have a filename that does not exists
747 MIL << "Saving repo in " << repofile << endl;
749 std::ofstream file(repofile.c_str());
751 ZYPP_THROW (Exception( "Can't open " + repofile.asString() ) );
754 info.dumpRepoOn(file);
756 MIL << "done" << endl;
759 void RepoManager::addRepositories( const Url &url,
760 const ProgressData::ReceiverFnc & progressrcv )
762 std::list<RepoInfo> knownrepos = knownRepositories();
763 std::list<RepoInfo> repos = readRepoFile(url);
764 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
768 // look if the alias is in the known repos.
769 for ( std::list<RepoInfo>::const_iterator kit = knownrepos.begin();
770 kit != knownrepos.end();
773 if ( (*it).alias() == (*kit).alias() )
775 ERR << "To be added repo " << (*it).alias() << " conflicts with existing repo " << (*kit).alias() << endl;
776 ZYPP_THROW(RepoAlreadyExistsException((*it).alias()));
781 string filename = Pathname(url.getPathName()).basename();
783 if ( filename == Pathname() )
784 ZYPP_THROW(RepoException("Invalid repo file name at " + url.asString() ));
786 // assert the directory exists
787 filesystem::assert_dir(_pimpl->options.knownReposPath);
789 Pathname repofile = generate_non_existing_name(_pimpl->options.knownReposPath, filename);
790 // now we have a filename that does not exists
791 MIL << "Saving " << repos.size() << " repo" << ( repos.size() ? "s" : "" ) << " in " << repofile << endl;
793 std::ofstream file(repofile.c_str());
795 ZYPP_THROW (Exception( "Can't open " + repofile.asString() ) );
798 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
802 MIL << "Saving " << (*it).alias() << endl;
803 (*it).dumpRepoOn(file);
805 MIL << "done" << endl;
808 ////////////////////////////////////////////////////////////////////////////
810 void RepoManager::removeRepository( const RepoInfo & info,
811 const ProgressData::ReceiverFnc & progressrcv)
813 MIL << "Going to delete repo " << info.alias() << endl;
815 std::list<RepoInfo> repos = knownRepositories();
816 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
820 // they can be the same only if the provided is empty, that means
821 // the provided repo has no alias
823 if ( (!info.alias().empty()) && ( info.alias() != (*it).alias() ) )
828 // we have a matcing repository, now we need to know
829 // where it does come from.
830 RepoInfo todelete = *it;
831 if (todelete.filepath().empty())
833 ZYPP_THROW(RepoException("Can't figure where the repo is stored"));
837 // figure how many repos are there in the file:
838 std::list<RepoInfo> filerepos = repositories_in_file(todelete.filepath());
839 if ( (filerepos.size() == 1) && ( filerepos.front().alias() == todelete.alias() ) )
841 // easy, only this one, just delete the file
842 if ( filesystem::unlink(todelete.filepath()) != 0 )
844 ZYPP_THROW(RepoException("Can't delete " + todelete.filepath().asString()));
846 MIL << todelete.alias() << " sucessfully deleted." << endl;
850 // there are more repos in the same file
851 // write them back except the deleted one.
853 //std::ofstream file(tmp.path().c_str());
855 // assert the directory exists
856 filesystem::assert_dir(todelete.filepath().dirname());
858 std::ofstream file(todelete.filepath().c_str());
860 //ZYPP_THROW (Exception( "Can't open " + tmp.path().asString() ) );
861 ZYPP_THROW (Exception( "Can't open " + todelete.filepath().asString() ) );
863 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
864 fit != filerepos.end();
867 if ( (*fit).alias() != todelete.alias() )
868 (*fit).dumpRepoOn(file);
872 // now delete it from cache
873 cache::CacheStore store(_pimpl->options.repoCachePath);
875 if ( store.isCached( todelete.alias() ) ) {
876 MIL << "repository was cached. cleaning cache" << endl;
877 store.cleanRepository(todelete.alias());
881 MIL << todelete.alias() << " sucessfully deleted." << endl;
883 } // else filepath is empty
886 // should not be reached on a sucess workflow
887 ZYPP_THROW(RepoNotFoundException(info));
890 ////////////////////////////////////////////////////////////////////////////
892 void RepoManager::modifyRepository( const std::string &alias,
893 const RepoInfo & newinfo,
894 const ProgressData::ReceiverFnc & progressrcv )
896 RepoInfo toedit = getRepositoryInfo(alias);
898 if (toedit.filepath().empty())
900 ZYPP_THROW(RepoException("Can't figure where the repo is stored"));
904 // figure how many repos are there in the file:
905 std::list<RepoInfo> filerepos = repositories_in_file(toedit.filepath());
907 // there are more repos in the same file
908 // write them back except the deleted one.
910 //std::ofstream file(tmp.path().c_str());
912 // assert the directory exists
913 filesystem::assert_dir(toedit.filepath().dirname());
915 std::ofstream file(toedit.filepath().c_str());
917 //ZYPP_THROW (Exception( "Can't open " + tmp.path().asString() ) );
918 ZYPP_THROW (Exception( "Can't open " + toedit.filepath().asString() ) );
920 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
921 fit != filerepos.end();
924 // if the alias is different, dump the original
925 // if it is the same, dump the provided one
926 if ( (*fit).alias() != toedit.alias() )
927 (*fit).dumpRepoOn(file);
929 newinfo.dumpRepoOn(file);
934 ////////////////////////////////////////////////////////////////////////////
936 RepoInfo RepoManager::getRepositoryInfo( const std::string &alias,
937 const ProgressData::ReceiverFnc & progressrcv )
939 std::list<RepoInfo> repos = knownRepositories();
940 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
944 if ( (*it).alias() == alias )
948 info.setAlias(info.alias());
949 ZYPP_THROW(RepoNotFoundException(info));
952 ////////////////////////////////////////////////////////////////////////////
954 RepoInfo RepoManager::getRepositoryInfo( const Url & url,
955 const url::ViewOption & urlview,
956 const ProgressData::ReceiverFnc & progressrcv )
958 std::list<RepoInfo> repos = knownRepositories();
959 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
963 for(RepoInfo::urls_const_iterator urlit = (*it).baseUrlsBegin();
964 urlit != (*it).baseUrlsEnd();
967 if ((*urlit).asString(urlview) == url.asString(urlview))
972 info.setAlias(info.alias());
973 info.setBaseUrl(url);
974 ZYPP_THROW(RepoNotFoundException(info));
977 ////////////////////////////////////////////////////////////////////////////
979 std::ostream & operator<<( std::ostream & str, const RepoManager & obj )
981 return str << *obj._pimpl;
984 /////////////////////////////////////////////////////////////////
986 ///////////////////////////////////////////////////////////////////