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);
259 for ( RepoInfoList::iterator it = repos.begin();
263 // set the metadata path for the repo
264 Pathname metadata_path = rawcache_path_for_repoinfo(_pimpl->options, (*it));
265 (*it).setMetadataPath(metadata_path);
270 return std::list<RepoInfo>();
275 ////////////////////////////////////////////////////////////////////////////
277 RepoStatus RepoManager::metadataStatus( const RepoInfo &info ) const
279 Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info );
280 RepoType repokind = info.type();
283 switch ( repokind.toEnum() )
285 case RepoType::NONE_e:
286 // unknown, probe the local metadata
287 repokind = probe(rawpath.asUrl());
293 switch ( repokind.toEnum() )
295 case RepoType::RPMMD_e :
297 status = RepoStatus( rawpath + "/repodata/repomd.xml");
301 case RepoType::YAST2_e :
303 status = RepoStatus( rawpath + "/content");
307 case RepoType::RPMPLAINDIR_e :
309 if ( PathInfo(Pathname(rawpath + "/cookie")).isExist() )
310 status = RepoStatus( rawpath + "/cookie");
314 case RepoType::NONE_e :
315 // Return default RepoStatus in case of RepoType::NONE
316 // indicating it should be created?
317 // ZYPP_THROW(RepoUnknownTypeException());
323 void RepoManager::refreshMetadata( const RepoInfo &info,
324 RawMetadataRefreshPolicy policy,
325 const ProgressData::ReceiverFnc & progress )
330 RepoStatus oldstatus;
331 RepoStatus newstatus;
332 // try urls one by one
333 for ( RepoInfo::urls_const_iterator it = info.baseUrlsBegin(); it != info.baseUrlsEnd(); ++it )
339 repo::RepoType repokind = info.type();
341 // if the type is unknown, try probing.
342 switch ( repokind.toEnum() )
344 case RepoType::NONE_e:
346 repokind = probe(*it);
352 Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info );
353 filesystem::assert_dir(rawpath);
354 oldstatus = metadataStatus(info);
356 // create temp dir as sibling of rawpath
357 filesystem::TmpDir tmpdir( filesystem::TmpDir::makeSibling( rawpath ) );
359 if ( ( repokind.toEnum() == RepoType::RPMMD_e ) ||
360 ( repokind.toEnum() == RepoType::YAST2_e ) )
362 MediaSetAccess media(url);
363 shared_ptr<repo::Downloader> downloader_ptr;
365 if ( repokind.toEnum() == RepoType::RPMMD_e )
366 downloader_ptr.reset(new yum::Downloader(info.path()));
368 downloader_ptr.reset( new susetags::Downloader(info.path()));
371 * Given a downloader, sets the other repos raw metadata
372 * path as cache paths for the fetcher, so if another
373 * repo has the same file, it will not download it
374 * but copy it from the other repository
376 std::list<RepoInfo> repos = knownRepositories();
377 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
381 downloader_ptr->addCachePath(rawcache_path_for_repoinfo( _pimpl->options, *it ));
384 RepoStatus newstatus = downloader_ptr->status(media);
385 bool refresh = false;
386 if ( oldstatus.checksum() == newstatus.checksum() )
388 MIL << "repo has not changed" << endl;
389 if ( policy == RefreshForced )
391 MIL << "refresh set to forced" << endl;
400 downloader_ptr->download( media, tmpdir.path());
405 else if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e )
407 RepoStatus newstatus = parser::plaindir::dirStatus(url.getPathName());
408 bool refresh = false;
409 if ( oldstatus.checksum() == newstatus.checksum() )
411 MIL << "repo has not changed" << endl;
412 if ( policy == RefreshForced )
414 MIL << "refresh set to forced" << endl;
425 std::ofstream file(( tmpdir.path() + "/cookie").c_str());
427 ZYPP_THROW (Exception( "Can't open " + tmpdir.path().asString() + "/cookie" ) );
430 file << newstatus.checksum() << endl;
440 ZYPP_THROW(RepoUnknownTypeException());
443 // ok we have the metadata, now exchange
445 TmpDir oldmetadata( TmpDir::makeSibling( rawpath ) );
446 filesystem::rename( rawpath, oldmetadata.path() );
447 // move the just downloaded there
448 filesystem::rename( tmpdir.path(), rawpath );
452 catch ( const Exception &e )
455 ERR << "Trying another url..." << endl;
458 ERR << "No more urls..." << endl;
459 ZYPP_THROW(RepoException("Cant refresh metadata"));
462 ////////////////////////////////////////////////////////////////////////////
464 void RepoManager::cleanMetadata( const RepoInfo &info,
465 const ProgressData::ReceiverFnc & progress )
467 filesystem::recursive_rmdir(rawcache_path_for_repoinfo(_pimpl->options, info));
470 void RepoManager::buildCache( const RepoInfo &info,
471 CacheBuildPolicy policy,
472 const ProgressData::ReceiverFnc & progressrcv )
474 ProgressData progress(100);
475 callback::SendReport<ProgressReport> report;
476 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
477 progress.name(str::form(_("Building repository '%s' cache"), info.alias().c_str()));
481 Pathname rawpath = rawcache_path_for_repoinfo(_pimpl->options, info);
483 cache::CacheStore store(_pimpl->options.repoCachePath);
485 RepoStatus raw_metadata_status = metadataStatus(info);
486 if ( raw_metadata_status.empty() )
488 ZYPP_THROW(RepoMetadataException(info));
491 if ( store.isCached( info.alias() ) )
493 MIL << info.alias() << " is already cached." << endl;
494 data::RecordId id = store.lookupRepository(info.alias());
495 RepoStatus cache_status = store.repositoryStatus(id);
497 if ( cache_status.checksum() == raw_metadata_status.checksum() )
499 MIL << info.alias() << " cache is up to date with metadata." << endl;
500 if ( policy == BuildIfNeeded ) {
505 MIL << info.alias() << " cache rebuild is forced" << endl;
508 MIL << info.alias() << " cleaning cache..." << endl;
509 store.cleanRepository(id);
512 MIL << info.alias() << " building cache..." << endl;
513 data::RecordId id = store.lookupOrAppendRepository(info.alias());
515 repo::RepoType repokind = info.type();
517 // if the type is unknown, try probing.
518 switch ( repokind.toEnum() )
520 case RepoType::NONE_e:
521 // unknown, probe the local metadata
522 repokind = probe(rawpath.asUrl());
528 CombinedProgressData subprogrcv( progress, 100);
530 switch ( repokind.toEnum() )
532 case RepoType::RPMMD_e :
534 parser::yum::RepoParser parser(id, store, parser::yum::RepoParserOpts(), subprogrcv);
535 parser.parse(rawpath);
539 case RepoType::YAST2_e :
541 parser::susetags::RepoParser parser(id, store, subprogrcv);
542 parser.parse(rawpath);
546 case RepoType::RPMPLAINDIR_e :
548 InputStream is(rawpath + "cookie");
550 getline( is.stream(), buffer);
552 parser::plaindir::RepoParser parser(id, store, subprogrcv);
553 parser.parse(url.getPathName());
557 ZYPP_THROW(RepoUnknownTypeException());
560 // update timestamp and checksum
561 store.updateRepositoryStatus(id, raw_metadata_status);
563 MIL << "Commit cache.." << endl;
568 ////////////////////////////////////////////////////////////////////////////
570 repo::RepoType RepoManager::probe( const Url &url ) const
572 if ( url.getScheme() == "dir" && ! PathInfo( url.getPathName() ).isDir() )
574 // Handle non existing local directory in advance, as
575 // MediaSetAccess does not support it.
576 return repo::RepoType::NONE;
579 MediaSetAccess access(url);
580 if ( access.doesFileExist("/repodata/repomd.xml") )
581 return repo::RepoType::RPMMD;
582 if ( access.doesFileExist("/content") )
583 return repo::RepoType::YAST2;
585 // if it is a local url of type dir
586 if ( (! media::MediaManager::downloads(url)) && ( url.getScheme() == "dir" ) )
588 Pathname path = Pathname(url.getPathName());
589 if ( PathInfo(path).isDir() )
591 // allow empty dirs for now
592 return repo::RepoType::RPMPLAINDIR;
596 return repo::RepoType::NONE;
599 ////////////////////////////////////////////////////////////////////////////
601 void RepoManager::cleanCache( const RepoInfo &info,
602 const ProgressData::ReceiverFnc & progressrcv )
604 ProgressData progress(100);
605 callback::SendReport<ProgressReport> report;
606 progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
607 progress.name(str::form(_("Cleaning repository '%s' cache"), info.alias().c_str()));
610 cache::CacheStore store(_pimpl->options.repoCachePath);
612 data::RecordId id = store.lookupRepository(info.alias());
613 store.cleanRepository(id);
617 ////////////////////////////////////////////////////////////////////////////
619 bool RepoManager::isCached( const RepoInfo &info ) const
621 cache::CacheStore store(_pimpl->options.repoCachePath);
622 return store.isCached(info.alias());
625 RepoStatus RepoManager::cacheStatus( const RepoInfo &info ) const
627 cache::CacheStore store(_pimpl->options.repoCachePath);
628 data::RecordId id = store.lookupRepository(info.alias());
629 RepoStatus cache_status = store.repositoryStatus(id);
633 Repository RepoManager::createFromCache( const RepoInfo &info,
634 const ProgressData::ReceiverFnc & progressrcv )
636 callback::SendReport<ProgressReport> report;
637 ProgressData progress;
638 progress.sendTo(ProgressReportAdaptor( progressrcv, report ));
639 progress.sendTo( progressrcv );
640 progress.name(str::form(_("Reading repository '%s' cache"), info.alias().c_str()));
643 cache::CacheStore store(_pimpl->options.repoCachePath);
645 if ( ! store.isCached( info.alias() ) )
646 ZYPP_THROW(RepoNotCachedException());
648 MIL << "Repository " << info.alias() << " is cached" << endl;
650 data::RecordId id = store.lookupRepository(info.alias());
652 repo::cached::RepoOptions opts( info, _pimpl->options.repoCachePath, id );
653 opts.readingResolvablesProgress = progressrcv;
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 ///////////////////////////////////////////////////////////////////