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().repoCachePath();
61 repoRawCachePath = ZConfig::instance().repoMetadataPath();
62 knownReposPath = ZConfig::instance().knownReposPath();
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 CombinedProgressData subprogrcv(progress);
652 repo::cached::RepoOptions opts( info, _pimpl->options.repoCachePath, id );
653 opts.readingResolvablesProgress = subprogrcv;
654 repo::cached::RepoImpl::Ptr repoimpl =
655 new repo::cached::RepoImpl( opts );
657 repoimpl->resolvables();
658 // read the resolvables from cache
659 return Repository(repoimpl);
662 ////////////////////////////////////////////////////////////////////////////
665 * Generate a non existing filename in a directory, using a base
666 * name. For example if a directory contains 3 files
672 * If you try to generate a unique filename for this directory,
673 * based on "ruu" you will get "ruu", but if you use the base
674 * "foo" you will get "foo_1"
676 * \param dir Directory where the file needs to be unique
677 * \param basefilename string to base the filename on.
679 static Pathname generate_non_existing_name( const Pathname &dir,
680 const std::string &basefilename )
682 string final_filename = basefilename;
684 while ( PathInfo(dir + final_filename).isExist() )
686 final_filename = basefilename + "_" + str::numstring(counter);
689 return dir + Pathname(final_filename);
692 ////////////////////////////////////////////////////////////////////////////
695 * \short Generate a related filename from a repo info
697 * From a repo info, it will try to use the alias as a filename
698 * escaping it if necessary. Other fallbacks can be added to
699 * this function in case there is no way to use the alias
701 static std::string generate_filename( const RepoInfo &info )
705 std::string filename = info.alias();
706 // replace slashes with underscores
707 size_t pos = filename.find(fnd);
708 while(pos!=string::npos)
710 filename.replace(pos,fnd.length(),rep);
711 pos = filename.find(fnd,pos+rep.length());
713 filename = Pathname(filename).extend(".repo").asString();
714 MIL << "generating filename for repo [" << info.alias() << "] : '" << filename << "'" << endl;
719 ////////////////////////////////////////////////////////////////////////////
721 void RepoManager::addRepository( const RepoInfo &info,
722 const ProgressData::ReceiverFnc & progressrcv )
726 ProgressData progress(100);
727 callback::SendReport<ProgressReport> report;
728 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
729 progress.name(str::form(_("Adding repository '%s'"), info.alias().c_str()));
732 std::list<RepoInfo> repos = knownRepositories();
733 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
737 if ( info.alias() == (*it).alias() )
738 ZYPP_THROW(RepoAlreadyExistsException(info.alias()));
743 // assert the directory exists
744 filesystem::assert_dir(_pimpl->options.knownReposPath);
746 Pathname repofile = generate_non_existing_name(_pimpl->options.knownReposPath,
747 generate_filename(info));
748 // now we have a filename that does not exists
749 MIL << "Saving repo in " << repofile << endl;
751 std::ofstream file(repofile.c_str());
753 ZYPP_THROW (Exception( "Can't open " + repofile.asString() ) );
756 info.dumpRepoOn(file);
758 MIL << "done" << endl;
761 void RepoManager::addRepositories( const Url &url,
762 const ProgressData::ReceiverFnc & progressrcv )
764 std::list<RepoInfo> knownrepos = knownRepositories();
765 std::list<RepoInfo> repos = readRepoFile(url);
766 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
770 // look if the alias is in the known repos.
771 for ( std::list<RepoInfo>::const_iterator kit = knownrepos.begin();
772 kit != knownrepos.end();
775 if ( (*it).alias() == (*kit).alias() )
777 ERR << "To be added repo " << (*it).alias() << " conflicts with existing repo " << (*kit).alias() << endl;
778 ZYPP_THROW(RepoAlreadyExistsException((*it).alias()));
783 string filename = Pathname(url.getPathName()).basename();
785 if ( filename == Pathname() )
786 ZYPP_THROW(RepoException("Invalid repo file name at " + url.asString() ));
788 // assert the directory exists
789 filesystem::assert_dir(_pimpl->options.knownReposPath);
791 Pathname repofile = generate_non_existing_name(_pimpl->options.knownReposPath, filename);
792 // now we have a filename that does not exists
793 MIL << "Saving " << repos.size() << " repo" << ( repos.size() ? "s" : "" ) << " in " << repofile << endl;
795 std::ofstream file(repofile.c_str());
797 ZYPP_THROW (Exception( "Can't open " + repofile.asString() ) );
800 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
804 MIL << "Saving " << (*it).alias() << endl;
805 (*it).dumpRepoOn(file);
807 MIL << "done" << endl;
810 ////////////////////////////////////////////////////////////////////////////
812 void RepoManager::removeRepository( const RepoInfo & info,
813 const ProgressData::ReceiverFnc & progressrcv)
815 MIL << "Going to delete repo " << info.alias() << endl;
817 std::list<RepoInfo> repos = knownRepositories();
818 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
822 // they can be the same only if the provided is empty, that means
823 // the provided repo has no alias
825 if ( (!info.alias().empty()) && ( info.alias() != (*it).alias() ) )
830 // we have a matcing repository, now we need to know
831 // where it does come from.
832 RepoInfo todelete = *it;
833 if (todelete.filepath().empty())
835 ZYPP_THROW(RepoException("Can't figure where the repo is stored"));
839 // figure how many repos are there in the file:
840 std::list<RepoInfo> filerepos = repositories_in_file(todelete.filepath());
841 if ( (filerepos.size() == 1) && ( filerepos.front().alias() == todelete.alias() ) )
843 // easy, only this one, just delete the file
844 if ( filesystem::unlink(todelete.filepath()) != 0 )
846 ZYPP_THROW(RepoException("Can't delete " + todelete.filepath().asString()));
848 MIL << todelete.alias() << " sucessfully deleted." << endl;
852 // there are more repos in the same file
853 // write them back except the deleted one.
855 //std::ofstream file(tmp.path().c_str());
857 // assert the directory exists
858 filesystem::assert_dir(todelete.filepath().dirname());
860 std::ofstream file(todelete.filepath().c_str());
862 //ZYPP_THROW (Exception( "Can't open " + tmp.path().asString() ) );
863 ZYPP_THROW (Exception( "Can't open " + todelete.filepath().asString() ) );
865 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
866 fit != filerepos.end();
869 if ( (*fit).alias() != todelete.alias() )
870 (*fit).dumpRepoOn(file);
874 // now delete it from cache
875 cache::CacheStore store(_pimpl->options.repoCachePath);
877 if ( store.isCached( todelete.alias() ) ) {
878 MIL << "repository was cached. cleaning cache" << endl;
879 store.cleanRepository(todelete.alias());
883 MIL << todelete.alias() << " sucessfully deleted." << endl;
885 } // else filepath is empty
888 // should not be reached on a sucess workflow
889 ZYPP_THROW(RepoNotFoundException(info));
892 ////////////////////////////////////////////////////////////////////////////
894 void RepoManager::modifyRepository( const std::string &alias,
895 const RepoInfo & newinfo,
896 const ProgressData::ReceiverFnc & progressrcv )
898 RepoInfo toedit = getRepositoryInfo(alias);
900 if (toedit.filepath().empty())
902 ZYPP_THROW(RepoException("Can't figure where the repo is stored"));
906 // figure how many repos are there in the file:
907 std::list<RepoInfo> filerepos = repositories_in_file(toedit.filepath());
909 // there are more repos in the same file
910 // write them back except the deleted one.
912 //std::ofstream file(tmp.path().c_str());
914 // assert the directory exists
915 filesystem::assert_dir(toedit.filepath().dirname());
917 std::ofstream file(toedit.filepath().c_str());
919 //ZYPP_THROW (Exception( "Can't open " + tmp.path().asString() ) );
920 ZYPP_THROW (Exception( "Can't open " + toedit.filepath().asString() ) );
922 for ( std::list<RepoInfo>::const_iterator fit = filerepos.begin();
923 fit != filerepos.end();
926 // if the alias is different, dump the original
927 // if it is the same, dump the provided one
928 if ( (*fit).alias() != toedit.alias() )
929 (*fit).dumpRepoOn(file);
931 newinfo.dumpRepoOn(file);
936 ////////////////////////////////////////////////////////////////////////////
938 RepoInfo RepoManager::getRepositoryInfo( const std::string &alias,
939 const ProgressData::ReceiverFnc & progressrcv )
941 std::list<RepoInfo> repos = knownRepositories();
942 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
946 if ( (*it).alias() == alias )
950 info.setAlias(info.alias());
951 ZYPP_THROW(RepoNotFoundException(info));
954 ////////////////////////////////////////////////////////////////////////////
956 RepoInfo RepoManager::getRepositoryInfo( const Url & url,
957 const url::ViewOption & urlview,
958 const ProgressData::ReceiverFnc & progressrcv )
960 std::list<RepoInfo> repos = knownRepositories();
961 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
965 for(RepoInfo::urls_const_iterator urlit = (*it).baseUrlsBegin();
966 urlit != (*it).baseUrlsEnd();
969 if ((*urlit).asString(urlview) == url.asString(urlview))
974 info.setAlias(info.alias());
975 info.setBaseUrl(url);
976 ZYPP_THROW(RepoNotFoundException(info));
979 ////////////////////////////////////////////////////////////////////////////
981 std::ostream & operator<<( std::ostream & str, const RepoManager & obj )
983 return str << *obj._pimpl;
986 /////////////////////////////////////////////////////////////////
988 ///////////////////////////////////////////////////////////////////