libzypp 17.35.1
repomanagerwf.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#include "repomanagerwf.h"
10
12
14#include <zypp-core/zyppng/io/Process>
15#include <zypp-core/zyppng/pipelines/MTry>
16#include <zypp-core/zyppng/pipelines/Algorithm>
17#include <zypp-media/MediaException>
18#include <zypp-media/ng/Provide>
19#include <zypp-media/ng/ProvideSpec>
20
22#include <zypp/HistoryLog.h>
23#include <zypp/base/Algorithm.h>
24#include <zypp/ng/Context>
28#include <zypp/ng/repomanager.h>
29
30#include <utility>
31#include <fstream>
32
33#undef ZYPP_BASE_LOGGER_LOGGROUP
34#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager"
35
37
38 using namespace zyppng::operators;
39
40 namespace {
41
42 template <class Executor, class OpType>
43 struct ProbeRepoLogic : public LogicBase<Executor, OpType>
44 {
45 protected:
47
48 public:
50 using ProvideType = typename remove_smart_ptr_t<ZyppContextRefType>::ProvideType;
51 using MediaHandle = typename ProvideType::MediaHandle;
52 using LazyMediaHandle = typename ProvideType::LazyMediaHandle;
53 using ProvideRes = typename ProvideType::Res;
54
55 ProbeRepoLogic(ZyppContextRefType zyppCtx, LazyMediaHandle &&medium, zypp::Pathname &&path, std::optional<zypp::Pathname> &&targetPath )
56 : _zyppContext(std::move(zyppCtx))
57 , _medium(std::move(medium))
58 , _path(std::move(path))
59 , _targetPath(std::move(targetPath))
60 {}
61
63 const auto &url = _medium.baseUrl();
64 MIL << "going to probe the repo type at " << url << " (" << _path << ")" << std::endl;
65
66 if ( url.getScheme() == "dir" && ! zypp::PathInfo( url.getPathName()/_path ).isDir() ) {
67 // Handle non existing local directory in advance
68 MIL << "Probed type NONE (not exists) at " << url << " (" << _path << ")" << std::endl;
70 }
71
72 // prepare exception to be thrown if the type could not be determined
73 // due to a media exception. We can't throw right away, because of some
74 // problems with proxy servers returning an incorrect error
75 // on ftp file-not-found(bnc #335906). Instead we'll check another types
76 // before throwing.
77
78 std::shared_ptr<ProvideType> providerRef = _zyppContext->provider();
79
80 // TranslatorExplanation '%s' is an URL
81 _error = zypp::repo::RepoException (zypp::str::form( _("Error trying to read from '%s'"), url.asString().c_str() ));
82
83 return providerRef->attachMediaIfNeeded( _medium )
84 | and_then([this, providerRef]( MediaHandle medium )
85 {
86 // first try rpmmd
87 return providerRef->provide( medium, _path/"repodata/repomd.xml", ProvideFileSpec().setCheckExistsOnly( !_targetPath.has_value() ) )
88 | and_then( maybeCopyResultToDest("repodata/repomd.xml") )
90 // try susetags if rpmmd fails and remember the error
91 | or_else( [this, providerRef, medium]( std::exception_ptr err ) {
92 try {
93 std::rethrow_exception (err);
95 // do nothing
96 ;
97 } catch( const zypp::media::MediaException &e ) {
98 DBG << "problem checking for repodata/repomd.xml file" << std::endl;
99 _error.remember ( err );
100 _gotMediaError = true;
101 } catch( ... ) {
102 // any other error, we give up
104 }
105 return providerRef->provide( medium, _path/"content", ProvideFileSpec().setCheckExistsOnly( !_targetPath.has_value() ) )
106 | and_then( maybeCopyResultToDest("content") )
108 })
109 // no rpmmd and no susetags!
110 | or_else( [this, medium]( std::exception_ptr err ) {
111
112 try {
113 std::rethrow_exception (err);
114 } catch ( const zypp::media::MediaFileNotFoundException &e ) {
115 // do nothing
116 ;
117 } catch( const zypp::media::MediaException &e ) {
118 DBG << "problem checking for content file" << std::endl;
119 _error.remember ( err );
120 _gotMediaError = true;
121 } catch( zypp::Exception &e ) {
123 // any other error, we give up
125 } catch(...) {
126 // any other error, we give up
128 }
129
130 const auto &url = medium.baseUrl();
131
132 // if it is a non-downloading URL denoting a directory (bsc#1191286: and no plugin)
133 if ( ! ( url.schemeIsDownloading() || url.schemeIsPlugin() ) ) {
134
135 if ( medium.localPath() && zypp::PathInfo(medium.localPath().value()/_path).isDir() ) {
136 // allow empty dirs for now
137 MIL << "Probed type RPMPLAINDIR at " << url << " (" << _path << ")" << std::endl;
139 }
140 }
141
142 if( _gotMediaError )
144
145 MIL << "Probed type NONE at " << url << " (" << _path << ")" << std::endl;
147 })
148 ;
149 });
150 }
151
152 private:
157 auto maybeCopyResultToDest ( std::string &&subPath ) {
158 return [this, subPath = std::move(subPath)]( ProvideRes file ) -> MaybeAsyncRef<expected<void>> {
159 if ( _targetPath ) {
160 MIL << "Target path is set, copying " << file.file() << " to " << *_targetPath/subPath << std::endl;
161 return std::move(file)
162 | ProvideType::copyResultToDest( _zyppContext->provider(), *_targetPath/subPath)
163 | and_then([]( zypp::ManagedFile file ){ file.resetDispose(); return expected<void>::success(); } );
164 }
166 };
167 }
168
169 private:
170 ZyppContextRefType _zyppContext;
173 std::optional<zypp::Pathname> _targetPath;
174
176 bool _gotMediaError = false;
177 };
178
179 template <class RefreshContextRef>
180 auto probeRepoLogic( RefreshContextRef ctx, RepoInfo repo, std::optional<zypp::Pathname> targetPath)
181 {
182 using namespace zyppng::operators;
183 return ctx->provider()->prepareMedia( repo.url(), zyppng::ProvideMediaSpec() )
184 | and_then( [ctx, path = repo.path() ]( auto &&mediaHandle ) {
185 return probeRepoType( ctx, std::forward<decltype(mediaHandle)>(mediaHandle), path );
186 });
187 }
188 }
189
191 {
192 return SimpleExecutor< ProbeRepoLogic, AsyncOp<expected<zypp::repo::RepoType>> >::run( std::move(ctx), std::move(medium), std::move(path), std::move(targetPath) );
193 }
194
196 {
197 return SimpleExecutor< ProbeRepoLogic, SyncOp<expected<zypp::repo::RepoType>> >::run( std::move(ctx), std::move(medium), std::move(path), std::move(targetPath) );
198 }
199
200 AsyncOpRef<expected<zypp::repo::RepoType> > probeRepoType( ContextRef ctx, RepoInfo repo, std::optional<zypp::Pathname> targetPath )
201 {
202 return probeRepoLogic( std::move(ctx), std::move(repo), std::move(targetPath) );
203 }
204
205 expected<zypp::repo::RepoType> probeRepoType ( SyncContextRef ctx, RepoInfo repo, std::optional<zypp::Pathname> targetPath )
206 {
207 return probeRepoLogic( std::move(ctx), std::move(repo), std::move(targetPath) );
208 }
209
210
211 namespace {
212 template <class ZyppContextRef>
213 auto readRepoFileLogic( ZyppContextRef ctx, zypp::Url repoFileUrl )
214 {
215 using namespace zyppng::operators;
216 return ctx->provider()->provide( repoFileUrl, ProvideFileSpec() )
217 | and_then([repoFileUrl]( auto local ){
218 DBG << "reading repo file " << repoFileUrl << ", local path: " << local.file() << std::endl;
219 return repositories_in_file( local.file() );
220 });
221 }
222 }
223
228
233
234 namespace {
235
236 template<typename Executor, class OpType>
237 struct CheckIfToRefreshMetadataLogic : public LogicBase<Executor, OpType> {
238
240 public:
241
242 using RefreshContextRefType = std::conditional_t<zyppng::detail::is_async_op_v<OpType>, repo::AsyncRefreshContextRef, repo::SyncRefreshContextRef>;
243 using ZyppContextRefType = typename RefreshContextRefType::element_type::ContextRefType;
244 using ZyppContextType = typename RefreshContextRefType::element_type::ContextType;
245 using ProvideType = typename ZyppContextType::ProvideType;
246 using LazyMediaHandle = typename ProvideType::LazyMediaHandle;
247 using MediaHandle = typename ProvideType::MediaHandle;
248 using ProvideRes = typename ProvideType::Res;
249
250 CheckIfToRefreshMetadataLogic( RefreshContextRefType refCtx, LazyMediaHandle &&medium, ProgressObserverRef progressObserver )
251 : _refreshContext(std::move(refCtx))
252 , _progress(std::move( progressObserver ))
253 , _medium(std::move( medium ))
254 {}
255
257
258 MIL << "Going to CheckIfToRefreshMetadata" << std::endl;
259
260 return assert_alias( _refreshContext->repoInfo() )
261 | and_then( [this] {
262
263 const auto &info = _refreshContext->repoInfo();
264 MIL << "Check if to refresh repo " << _refreshContext->repoInfo().alias() << " at " << _medium.baseUrl() << " (" << info.type() << ")" << std::endl;
265
266 // first check old (cached) metadata
268 })
270
271 const auto &info = _refreshContext->repoInfo();
272
273 if ( oldstatus.empty() ) {
274 MIL << "No cached metadata, going to refresh" << std::endl;
276 }
277
278 if ( _medium.baseUrl().schemeIsVolatile() ) {
279 MIL << "Never refresh CD/DVD" << std::endl;
281 }
282
284 MIL << "Forced refresh!" << std::endl;
286 }
287
288 if ( _medium.baseUrl().schemeIsLocal() ) {
290 }
291
292 // Check whether repo.refresh.delay applies...
294 {
295 // bsc#1174016: Prerequisite to skipping the refresh is that metadata
296 // and solv cache status match. They will not, if the repos URL was
297 // changed e.g. due to changed repovars.
300
301 if ( oldstatus == *cachestatus ) {
302 // difference in seconds
303 double diff = ::difftime( (zypp::Date::ValueType)zypp::Date::now(), (zypp::Date::ValueType)oldstatus.timestamp() ) / 60;
304 const auto refDelay = _refreshContext->zyppContext()->config().repo_refresh_delay();
305 if ( diff < refDelay ) {
306 if ( diff < 0 ) {
307 WAR << "Repository '" << info.alias() << "' was refreshed in the future!" << std::endl;
308 }
309 else {
310 MIL << "Repository '" << info.alias()
311 << "' has been refreshed less than repo.refresh.delay ("
312 << refDelay
313 << ") minutes ago. Advising to skip refresh" << std::endl;
315 }
316 }
317 }
318 else {
319 MIL << "Metadata and solv cache don't match. Check data on server..." << std::endl;
320 }
321 }
322
323 return info.type() | [this]( zypp::repo::RepoType repokind ) {
324 // if unknown: probe it
326 return probeRepoType( _refreshContext->zyppContext(), _medium, _refreshContext->repoInfo().path()/*, _refreshContext->targetDir()*/ );
329
330 // make sure to remember the repo type
331 _refreshContext->repoInfo().setProbedType( repokind );
332
333 auto dlContext = std::make_shared<repo::DownloadContext<ZyppContextRefType>>( _refreshContext->zyppContext(), _refreshContext->repoInfo(), _refreshContext->targetDir() );
336 // check status
337 if ( oldstatus == newstatus ) {
338 MIL << "repo has not changed" << std::endl;
341 }
342 else { // includes newstatus.empty() if e.g. repo format changed
343 MIL << "repo has changed, going to refresh" << std::endl;
344 MIL << "Old status: " << oldstatus << " New Status: " << newstatus << std::endl;
346 }
347 });
348 });
349 });
350 }
351
352 protected:
353 RefreshContextRefType _refreshContext;
354 ProgressObserverRef _progress;
356 };
357 }
358
363
368
369
370 namespace {
371
372 template<typename Executor, class OpType>
373 struct RefreshMetadataLogic : public LogicBase<Executor, OpType>{
374
376
377 public:
378
379 using RefreshContextRefType = std::conditional_t<zyppng::detail::is_async_op_v<OpType>, repo::AsyncRefreshContextRef, repo::SyncRefreshContextRef>;
380 using ZyppContextRefType = typename RefreshContextRefType::element_type::ContextRefType;
381 using ZyppContextType = typename RefreshContextRefType::element_type::ContextType;
382 using ProvideType = typename ZyppContextType::ProvideType;
383 using MediaHandle = typename ProvideType::MediaHandle;
384 using LazyMediaHandle = typename ProvideType::LazyMediaHandle;
385 using ProvideRes = typename ProvideType::Res;
386
387 using DlContextType = repo::DownloadContext<ZyppContextRefType>;
388 using DlContextRefType = std::shared_ptr<DlContextType>;
389
390 RefreshMetadataLogic( RefreshContextRefType refCtx, LazyMediaHandle &&medium, ProgressObserverRef progressObserver )
391 : _refreshContext(std::move(refCtx))
392 , _progress ( std::move( progressObserver ) )
393 , _medium ( std::move( medium ) )
394 { }
395
397
398 return assert_alias( _refreshContext->repoInfo() )
399 | and_then( [this](){ return assert_urls( _refreshContext->repoInfo() ); })
400 | and_then( [this](){ return checkIfToRefreshMetadata ( _refreshContext, _medium, _progress ); })
401 | and_then( [this]( repo::RefreshCheckStatus status ){
402
403 MIL << "RefreshCheckStatus returned: " << status << std::endl;
404
405 // check whether to refresh metadata
406 // if the check fails for this url, it throws, so another url will be checked
408 return makeReadyResult ( expected<RefreshContextRefType>::success( std::move(_refreshContext) ) );
409
410 MIL << "Going to refresh metadata from " << _medium.baseUrl() << std::endl;
411
412 // bsc#1048315: Always re-probe in case of repo format change.
413 // TODO: Would be sufficient to verify the type and re-probe
414 // if verification failed (or type is RepoType::NONE)
415 return probeRepoType ( _refreshContext->zyppContext(), _medium, _refreshContext->repoInfo().path() /*, _refreshContext->targetDir()*/ )
417
418 auto &info = _refreshContext->repoInfo();
419
420 if ( info.type() != repokind ) {
421 _refreshContext->setProbedType( repokind );
422 // Adjust the probed type in RepoInfo
423 info.setProbedType( repokind ); // lazy init!
424 }
425
426 // no need to continue with an unknown type
429
430 const zypp::Pathname &mediarootpath = _refreshContext->rawCachePath();
432 auto exception = ZYPP_EXCPT_PTR (zypp::Exception(zypp::str::form( _("Can't create %s"), mediarootpath.c_str() )));
433 return makeReadyResult( expected<DlContextRefType>::error( std::move(exception) ));
434 }
435
436 auto dlContext = std::make_shared<DlContextType>( _refreshContext->zyppContext(), _refreshContext->repoInfo(), _refreshContext->targetDir() );
437 dlContext->setPluginRepoverification( _refreshContext->pluginRepoverification() );
438
439 return RepoDownloaderWorkflow::download ( dlContext, _medium, _progress );
440
441 })
442 | and_then([this]( DlContextRefType && ) {
443
444 // ok we have the metadata, now exchange
445 // the contents
446 _refreshContext->saveToRawCache();
447 // if ( ! isTmpRepo( info ) )
448 // reposManip(); // remember to trigger appdata refresh
449
450 // we are done.
451 return expected<RefreshContextRefType>::success( std::move(_refreshContext) );
452 });
453 });
454 }
455
456 RefreshContextRefType _refreshContext;
457 ProgressObserverRef _progress;
460
461 };
462 }
463
468
473
474 namespace {
475 template <class RefreshContextRef>
477 {
478 // small shared helper struct to pass around the exception and to remember that we tried the first URL
479 struct ExHelper {
480 bool isFirst;
481 // we will throw this later if no URL checks out fine
483 };
484
485 auto helper = std::make_shared<ExHelper>( ExHelper{
486 false,
487 zypp::repo::RepoException { refCtx->repoInfo(), PL_("Valid metadata not found at specified URL",
488 "Valid metadata not found at specified URLs",
489 refCtx->repoInfo().baseUrlsSize() ) }
490 });
491
492 // the actual logic pipeline, attaches the medium and tries to refresh from it
494 return refCtx->zyppContext()->provider()->prepareMedia( url, zyppng::ProvideMediaSpec() )
495 | and_then( [ refCtx , progressObserver]( auto mediaHandle ) mutable { return refreshMetadata ( std::move(refCtx), std::move(mediaHandle), progressObserver ); } );
496 };
497
498 // predicate that accepts only valid results, and in addition collects all errors in rexception
499 auto predicate = [ info = refCtx->repoInfo(), helper ]( const expected<RefreshContextRef> &res ) -> bool{
500 if ( !res ) {
501 try {
502 ZYPP_RETHROW( res.error() );
503 } catch ( const zypp::Exception &e ) {
504 ERR << "Trying another url..." << std::endl;
505
506 // remember the exception caught for the *first URL*
507 // if all other URLs fail, the rexception will be thrown with the
508 // cause of the problem of the first URL remembered
509 if ( helper->isFirst ) {
510 helper->rexception.remember( e );
511 helper->isFirst = false;
512 } else {
513 helper->rexception.addHistory( e.asUserString() );
514 }
515 }
516 return false;
517 }
518 return true;
519 };
520
521 // now go over the urls until we find one that works
522 return refCtx->repoInfo().baseUrls()
523 | firstOf( std::move(refreshPipeline), expected<RefreshContextRef>::error( std::make_exception_ptr(NotFoundException()) ), std::move(predicate) )
524 | [helper]( expected<RefreshContextRef> result ) {
525 if ( !result ) {
526 // none of the URLs worked
527 ERR << "No more urls..." << std::endl;
529 }
530 // we are done.
531 return result;
532 };
533 }
534 }
535
536 AsyncOpRef<expected<repo::AsyncRefreshContextRef> > refreshMetadata( repo::AsyncRefreshContextRef refCtx, ProgressObserverRef progressObserver) {
537 return refreshMetadataLogic ( std::move(refCtx), std::move(progressObserver) );
538 }
539
540 expected<repo::SyncRefreshContextRef> refreshMetadata( repo::SyncRefreshContextRef refCtx, ProgressObserverRef progressObserver) {
541 return refreshMetadataLogic ( std::move(refCtx), std::move(progressObserver) );
542 }
543
544
545 namespace {
546
547 template <typename ZyppCtxRef> struct Repo2SolvOp;
548
549 template <>
550 struct Repo2SolvOp<ContextRef> : public AsyncOp<expected<void>>
551 {
552 Repo2SolvOp() { }
553
555 MIL << "Starting repo2solv for repo " << repo.alias () << std::endl;
556 auto me = std::make_shared<Repo2SolvOp<ContextRef>>();
557 me->_repo = std::move(repo);
558 me->_proc = Process::create();
559 me->_proc->connect( &Process::sigFinished, *me, &Repo2SolvOp<ContextRef>::procFinished );
560 me->_proc->connect( &Process::sigReadyRead, *me, &Repo2SolvOp<ContextRef>::readyRead );
561
562 std::vector<const char *> argsIn;
563 argsIn.reserve ( args.size() );
564 std::for_each( args.begin (), args.end(), [&]( const std::string &s ) { argsIn.push_back(s.data()); });
565 argsIn.push_back (nullptr);
566 me->_proc->setOutputChannelMode ( Process::Merged );
567 if (!me->_proc->start( argsIn.data() )) {
568 return makeReadyResult( expected<void>::error(ZYPP_EXCPT_PTR(zypp::repo::RepoException ( me->_repo, _("Failed to cache repo ( unable to start repo2solv ).") ))) );
569 }
570 return me;
571 }
572
573 void readyRead (){
574 const ByteArray &data = _proc->readLine();
575 const std::string &line = data.asString();
576 WAR << " " << line;
577 _errdetail += line;
578 }
579
580 void procFinished( int ret ) {
581
582 while ( _proc->canReadLine() )
583 readyRead();
584
585 if ( ret != 0 ) {
586 zypp::repo::RepoException ex( _repo, zypp::str::form( _("Failed to cache repo (%d)."), ret ));
587 ex.addHistory( zypp::str::Str() << _proc->executedCommand() << std::endl << _errdetail << _proc->execError() ); // errdetail lines are NL-terminaled!
589 return;
590 }
591 setReady( expected<void>::success() );
592 }
593
594 private:
595 ProcessRef _proc;
597 std::string _errdetail;
598 };
599
600 template <>
601 struct Repo2SolvOp<SyncContextRef>
602 {
605 std::string errdetail;
606
607 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
608 WAR << " " << output;
609 errdetail += output;
610 }
611
612 int ret = prog.close();
613 if ( ret != 0 )
614 {
615 zypp::repo::RepoException ex(repo, zypp::str::form( _("Failed to cache repo (%d)."), ret ));
616 ex.addHistory( zypp::str::Str() << prog.command() << std::endl << errdetail << prog.execError() ); // errdetail lines are NL-terminaled!
618 }
620 }
621 };
622
623 template<typename Executor, class OpType>
624 struct BuildCacheLogic : public LogicBase<Executor, OpType>{
625
626 using RefreshContextRefType = std::conditional_t<zyppng::detail::is_async_op_v<OpType>, repo::AsyncRefreshContextRef, repo::SyncRefreshContextRef>;
627 using ZyppContextRefType = typename RefreshContextRefType::element_type::ContextRefType;
628 using ZyppContextType = typename RefreshContextRefType::element_type::ContextType;
629 using ProvideType = typename ZyppContextType::ProvideType;
630 using MediaHandle = typename ProvideType::MediaHandle;
631 using ProvideRes = typename ProvideType::Res;
632
634
635 BuildCacheLogic( RefreshContextRefType &&refCtx, zypp::RepoManagerFlags::CacheBuildPolicy policy, ProgressObserverRef &&progressObserver )
636 : _refCtx( std::move(refCtx) )
637 , _policy( policy )
639 {}
640
642
643 ProgressObserver::setup ( _progressObserver, zypp::str::form(_("Building repository '%s' cache"), _refCtx->repoInfo().label().c_str()), 100 );
644
645 return assert_alias(_refCtx->repoInfo() )
646 | and_then( mtry( [this] {
647 _mediarootpath = rawcache_path_for_repoinfo( _refCtx->repoManagerOptions(), _refCtx->repoInfo() ).unwrap();
648 _productdatapath = rawproductdata_path_for_repoinfo( _refCtx->repoManagerOptions(), _refCtx->repoInfo() ).unwrap();
649 }))
650 | and_then( [this] {
651
652 const auto &options = _refCtx->repoManagerOptions();
653
654 if( zypp::filesystem::assert_dir( options.repoCachePath ) ) {
655 auto ex = ZYPP_EXCPT_PTR( zypp::Exception (zypp::str::form( _("Can't create %s"), options.repoCachePath.c_str()) ) );
656 return expected<RepoStatus>::error( std::move(ex) );
657 }
658
659 return RepoManager<ZyppContextRefType>::metadataStatus( _refCtx->repoInfo(), options );
660
662
663 if ( raw_metadata_status.empty() )
664 {
665 /* if there is no cache at this point, we refresh the raw
666 in case this is the first time - if it's !autorefresh,
667 we may still refresh */
668 return refreshMetadata( _refCtx, ProgressObserver::makeSubTask( _progressObserver ) )
669 | and_then([this]( auto /*refCtx*/) { return RepoManager<ZyppContextRefType>::metadataStatus( _refCtx->repoInfo(), _refCtx->repoManagerOptions() ); } );
670 }
672
673 }) | and_then( [this]( RepoStatus raw_metadata_status ) {
674
675 bool needs_cleaning = false;
676 const auto &info = _refCtx->repoInfo();
677 if ( _refCtx->repoManager()->isCached( info ) )
678 {
679 MIL << info.alias() << " is already cached." << std::endl;
681 if ( !cache_status )
683
685 {
686 MIL << info.alias() << " cache is up to date with metadata." << std::endl;
688 {
689 // On the fly add missing solv.idx files for bash completion.
690 return makeReadyResult(
691 solv_path_for_repoinfo( _refCtx->repoManagerOptions(), info)
692 | and_then([this]( zypp::Pathname base ){
693 if ( ! zypp::PathInfo(base/"solv.idx").isExist() )
694 return mtry( zypp::sat::updateSolvFileIndex, base/"solv" );
695 return expected<void>::success ();
696 })
697 );
698 }
699 else {
700 MIL << info.alias() << " cache rebuild is forced" << std::endl;
701 }
702 }
703
704 needs_cleaning = true;
705 }
706
707 ProgressObserver::start( _progressObserver );
708
709 if (needs_cleaning)
710 {
711 auto r = _refCtx->repoManager()->cleanCache(info);
712 if ( !r )
713 return makeReadyResult( expected<void>::error(r.error()) );
714 }
715
716 MIL << info.alias() << " building cache..." << info.type() << std::endl;
717
718 expected<zypp::Pathname> base = solv_path_for_repoinfo( _refCtx->repoManagerOptions(), info);
719 if ( !base )
721
723 {
724 zypp::Exception ex(zypp::str::form( _("Can't create %s"), base->c_str()) );
726 }
727
728 if( ! zypp::PathInfo(*base).userMayW() )
729 {
730 zypp::Exception ex(zypp::str::form( _("Can't create cache at %s - no writing permissions."), base->c_str()) );
732 }
733
734 zypp::Pathname solvfile = *base / "solv";
735
736 // do we have type?
737 zypp::repo::RepoType repokind = info.type();
738
739 // if the type is unknown, try probing.
740 switch ( repokind.toEnum() )
741 {
743 // unknown, probe the local metadata
745 break;
746 default:
747 break;
748 }
749
750 MIL << "repo type is " << repokind << std::endl;
751
752 return mountIfRequired( repokind, info )
753 | and_then([this, repokind, solvfile = std::move(solvfile) ]( std::optional<MediaHandle> forPlainDirs ) mutable {
754
755 const auto &info = _refCtx->repoInfo();
756
757 switch ( repokind.toEnum() )
758 {
759 case zypp::repo::RepoType::RPMMD_e :
760 case zypp::repo::RepoType::YAST2_e :
761 case zypp::repo::RepoType::RPMPLAINDIR_e :
762 {
763 // Take care we unlink the solvfile on error
764 zypp::ManagedFile guard( solvfile, zypp::filesystem::unlink );
765
766 zypp::ExternalProgram::Arguments cmd;
767 cmd.push_back( zypp::PathInfo( "/usr/bin/repo2solv" ).isFile() ? "repo2solv" : "repo2solv.sh" );
768 // repo2solv expects -o as 1st arg!
769 cmd.push_back( "-o" );
770 cmd.push_back( solvfile.asString() );
771 cmd.push_back( "-X" ); // autogenerate pattern from pattern-package
772 // bsc#1104415: no more application support // cmd.push_back( "-A" ); // autogenerate application pseudo packages
773
774 if ( repokind == zypp::repo::RepoType::RPMPLAINDIR )
775 {
776 // recusive for plaindir as 2nd arg!
777 cmd.push_back( "-R" );
778
779 std::optional<zypp::Pathname> localPath = forPlainDirs.has_value() ? forPlainDirs->localPath() : zypp::Pathname();
780 if ( !localPath )
781 return makeReadyResult( expected<void>::error( ZYPP_EXCPT_PTR( zypp::repo::RepoException( zypp::str::Format(_("Failed to cache repo %1%")) % _refCtx->repoInfo() ))) );
782
783 // FIXME this does only work for dir: URLs
784 cmd.push_back( (*localPath / info.path().absolutename()).c_str() );
785 }
786 else
787 cmd.push_back( _productdatapath.asString() );
788
789 return Repo2SolvOp<ZyppContextRefType>::run( info, std::move(cmd) )
790 | and_then( [this, guard = std::move(guard), solvfile = std::move(solvfile) ]() mutable {
791 // We keep it.
792 guard.resetDispose();
793 return mtry( zypp::sat::updateSolvFileIndex, solvfile ); // content digest for zypper bash completion
794 });
795 }
796 break;
797 default:
798 return makeReadyResult( expected<void>::error( ZYPP_EXCPT_PTR(zypp::repo::RepoUnknownTypeException( info, _("Unhandled repository type") )) ) );
799 break;
800 }
801 })
802 | and_then([this, raw_metadata_status](){
803 // update timestamp and checksum
804 return _refCtx->repoManager()->setCacheStatus( _refCtx->repoInfo(), raw_metadata_status );
805 });
806 })
807 | and_then( [this](){
808 MIL << "Commit cache.." << std::endl;
810 return make_expected_success ( _refCtx );
811
812 })
813 | or_else ( [this]( std::exception_ptr e ) {
816 });
817 }
818
819 private:
822 return makeReadyResult( make_expected_success( std::optional<MediaHandle>() ));
823
824 return _refCtx->zyppContext()->provider()->attachMedia( info.url(), ProvideMediaSpec() )
825 | and_then( [this]( MediaHandle handle ) {
826 return makeReadyResult( make_expected_success( std::optional<MediaHandle>( std::move(handle)) ));
827 });
828 }
829
830 private:
831 RefreshContextRefType _refCtx;
833 ProgressObserverRef _progressObserver;
834
837 };
838 }
839
844
849
850
851 // Add repository logic
852 namespace {
853
854 template<typename Executor, class OpType>
855 struct AddRepoLogic : public LogicBase<Executor, OpType>{
856
858
860
861 AddRepoLogic( RepoManagerPtrType &&repoMgrRef, RepoInfo &&info, ProgressObserverRef &&myProgress )
862 : _repoMgrRef( std::move(repoMgrRef) )
863 , _info( std::move(info) )
864 , _myProgress ( std::move(myProgress) )
865 {}
866
868 using namespace zyppng::operators;
869
870 return assert_alias(_info)
871 | and_then([this]( ) {
872
873 MIL << "Try adding repo " << _info << std::endl;
874 ProgressObserver::setup( _myProgress, zypp::str::form(_("Adding repository '%s'"), _info.label().c_str()) );
876
877 if ( _repoMgrRef->repos().find(_info) != _repoMgrRef->repos().end() )
879
880 // check the first url for now
881 if ( _repoMgrRef->options().probe )
882 {
883 DBG << "unknown repository type, probing" << std::endl;
884 return assert_urls(_info)
885 | and_then([this]{ return probeRepoType( _repoMgrRef->zyppContext(), _info ); })
887
890
892 tosave.setType(probedtype);
894 });
895 }
897 })
898 | inspect( operators::setProgress( _myProgress, 50 ) )
899 | and_then( [this]( RepoInfo tosave ){ return _repoMgrRef->addProbedRepository( tosave, tosave.type() ); })
900 | and_then( [this]( RepoInfo updated ) {
902 MIL << "done" << std::endl;
904 })
905 | or_else( [this]( std::exception_ptr e) {
906 ProgressObserver::finish ( _myProgress, ProgressObserver::Error );
907 MIL << "done" << std::endl;
909 })
910 ;
911 }
912
913 RepoManagerPtrType _repoMgrRef;
915 ProgressObserverRef _myProgress;
916 };
917 };
918
920 {
921 return SimpleExecutor<AddRepoLogic, AsyncOp<expected<RepoInfo>>>::run( std::move(mgr), std::move(info), std::move(myProgress) );
922 }
923
925 {
926 return SimpleExecutor<AddRepoLogic, SyncOp<expected<RepoInfo>>>::run( std::move(mgr), RepoInfo(info), std::move(myProgress) );
927 }
928
929 namespace {
930
931 template<typename Executor, class OpType>
932 struct AddReposLogic : public LogicBase<Executor, OpType>{
933
936
937 AddReposLogic( RepoManagerPtrType &&repoMgrRef, zypp::Url &&url, ProgressObserverRef &&myProgress )
938 : _repoMgrRef( std::move(repoMgrRef) )
939 , _url( std::move(url) )
940 , _myProgress ( std::move(myProgress) )
941 {}
942
944 using namespace zyppng::operators;
945
947 | and_then([this]( zypp::Url repoFileUrl ) { return readRepoFile( _repoMgrRef->zyppContext(), std::move(repoFileUrl) ); } )
948 | and_then([this]( std::list<RepoInfo> repos ) {
949
950 for ( std::list<RepoInfo>::const_iterator it = repos.begin();
951 it != repos.end();
952 ++it )
953 {
954 // look if the alias is in the known repos.
955 for_ ( kit, _repoMgrRef->repoBegin(), _repoMgrRef->repoEnd() )
956 {
957 if ( (*it).alias() == (*kit).alias() )
958 {
959 ERR << "To be added repo " << (*it).alias() << " conflicts with existing repo " << (*kit).alias() << std::endl;
961 }
962 }
963 }
964
965 std::string filename = zypp::Pathname(_url.getPathName()).basename();
966 if ( filename == zypp::Pathname() )
967 {
968 // TranslatorExplanation '%s' is an URL
969 return expected<void>::error(ZYPP_EXCPT_PTR(zypp::repo::RepoException(zypp::str::form( _("Invalid repo file name at '%s'"), _url.asString().c_str() ))));
970 }
971
972 const auto &options = _repoMgrRef->options();
973
974 // assert the directory exists
975 zypp::filesystem::assert_dir( options.knownReposPath );
976
977 zypp::Pathname repofile = _repoMgrRef->generateNonExistingName( options.knownReposPath, filename );
978 // now we have a filename that does not exists
979 MIL << "Saving " << repos.size() << " repo" << ( repos.size() ? "s" : "" ) << " in " << repofile << std::endl;
980
981 std::ofstream file(repofile.c_str());
982 if (!file)
983 {
984 // TranslatorExplanation '%s' is a filename
985 return expected<void>::error(ZYPP_EXCPT_PTR( zypp::Exception(zypp::str::form( _("Can't open file '%s' for writing."), repofile.c_str() ))));
986 }
987
988 for ( std::list<RepoInfo>::iterator it = repos.begin();
989 it != repos.end();
990 ++it )
991 {
992 MIL << "Saving " << (*it).alias() << std::endl;
993
994 const auto &rawCachePath = rawcache_path_for_repoinfo( options, *it );
995 if ( !rawCachePath ) return expected<void>::error(rawCachePath.error());
996
997 const auto &pckCachePath = packagescache_path_for_repoinfo( options, *it ) ;
998 if ( !pckCachePath ) return expected<void>::error(pckCachePath.error());
999
1000 it->dumpAsIniOn(file);
1001 it->setFilepath(repofile);
1002 it->setMetadataPath( *rawCachePath );
1003 it->setPackagesPath( *pckCachePath );
1004 _repoMgrRef->reposManip().insert(*it);
1005
1006 zypp::HistoryLog( _repoMgrRef->options().rootDir).addRepository(*it);
1007 }
1008
1009 MIL << "done" << std::endl;
1010 return expected<void>::success();
1011 });
1012 }
1013
1014 private:
1015 RepoManagerPtrType _repoMgrRef;
1017 ProgressObserverRef _myProgress;
1018 };
1019
1020 }
1021
1023 {
1024 return SimpleExecutor<AddReposLogic, AsyncOp<expected<void>>>::run( std::move(mgr), std::move(url), std::move(myProgress) );
1025 }
1026
1028 {
1029 return SimpleExecutor<AddReposLogic, SyncOp<expected<void>>>::run( std::move(mgr), std::move(url), std::move(myProgress) );
1030 }
1031
1032
1033 namespace {
1034
1035 template<typename Executor, class OpType>
1036 struct RefreshGeoIpLogic : public LogicBase<Executor, OpType>{
1037 protected:
1039
1040 public:
1042 using ZyppContextType = typename ZyppContextRefType::element_type;
1043 using ProvideType = typename ZyppContextType::ProvideType;
1044 using MediaHandle = typename ProvideType::MediaHandle;
1045 using ProvideRes = typename ProvideType::Res;
1046
1047
1048 RefreshGeoIpLogic( ZyppContextRefType &&zyppCtx, RepoInfo::url_set &&urls )
1049 : _zyppCtx( std::move(zyppCtx) )
1050 , _urls( std::move(urls) )
1051 { }
1052
1053 MaybeAsyncRef<expected<void>> execute() {
1054
1055 using namespace zyppng::operators;
1056
1057 if ( !_zyppCtx->config().geoipEnabled() ) {
1058 MIL << "GeoIp disabled via ZConfig, not refreshing the GeoIP information." << std::endl;
1060 }
1061
1062 std::vector<std::string> hosts;
1063 for ( const auto &baseUrl : _urls ) {
1064 const auto &host = baseUrl.getHost();
1065 if ( zypp::any_of( _zyppCtx->config().geoipHostnames(), [&host]( const auto &elem ){ return ( zypp::str::compareCI( host, elem ) == 0 ); } ) ) {
1066 hosts.push_back( host );
1067 break;
1068 }
1069 }
1070
1071 if ( hosts.empty() ) {
1072 MIL << "No configured geoip URL found, not updating geoip data" << std::endl;
1074 }
1075
1076 _geoIPCache = _zyppCtx->config().geoipCachePath();
1077
1079 MIL << "Unable to create cache directory for GeoIP." << std::endl;
1081 }
1082
1083 if ( !zypp::PathInfo(_geoIPCache).userMayRWX() ) {
1084 MIL << "No access rights for the GeoIP cache directory." << std::endl;
1086 }
1087
1088 // remove all older cache entries
1090 if ( entry.type != zypp::filesystem::FT_FILE )
1091 return true;
1092
1093 zypp::PathInfo pi( dir/entry.name );
1094 auto age = std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t( pi.mtime() );
1095 if ( age < std::chrono::hours(24) )
1096 return true;
1097
1098 MIL << "Removing GeoIP file for " << entry.name << " since it's older than 24hrs." << std::endl;
1099 zypp::filesystem::unlink( dir/entry.name );
1100 return true;
1101 });
1102
1103 auto firstOfCb = [this]( std::string hostname ) {
1104
1105 // do not query files that are still there
1106 if ( zypp::PathInfo( _geoIPCache / hostname ).isExist() ) {
1107 MIL << "Skipping GeoIP request for " << hostname << " since a valid cache entry exists." << std::endl;
1108 return makeReadyResult(false);
1109 }
1110
1111 MIL << "Query GeoIP for " << hostname << std::endl;
1112
1113 zypp::Url url;
1114 try {
1115 url.setHost(hostname);
1116 url.setScheme("https");
1117
1118 } catch(const zypp::Exception &e ) {
1119 ZYPP_CAUGHT(e);
1120 MIL << "Ignoring invalid GeoIP hostname: " << hostname << std::endl;
1121 return makeReadyResult(false);
1122 }
1123
1124 // always https ,but attaching makes things easier
1125 return _zyppCtx->provider()->attachMedia( url, ProvideMediaSpec() )
1126 | and_then( [this]( MediaHandle provideHdl ) { return _zyppCtx->provider()->provide( provideHdl, "/geopip", ProvideFileSpec() ); })
1127 | inspect_err( [hostname]( const std::exception_ptr& ){ MIL << "Failed to query GeoIP from hostname: " << hostname << std::endl; } )
1128 | and_then( [hostname, this]( ProvideRes provideRes ) {
1129
1130 // here we got something from the server, we will stop after this hostname and mark the process as success()
1131
1132 constexpr auto writeHostToFile = []( const zypp::Pathname &fName, const std::string &host ){
1133 std::ofstream out;
1134 out.open( fName.asString(), std::ios_base::trunc );
1135 if ( out.is_open() ) {
1136 out << host << std::endl;
1137 } else {
1138 MIL << "Failed to create/open GeoIP cache file " << fName << std::endl;
1139 }
1140 };
1141
1142 std::string geoipMirror;
1143 try {
1145 if ( reader.seekToNode( 1, "host" ) ) {
1146 const auto &str = reader.nodeText().asString();
1147
1148 // make a dummy URL to ensure the hostname is valid
1150 testUrl.setHost(str);
1151 testUrl.setScheme("https");
1152
1153 if ( testUrl.isValid() ) {
1154 MIL << "Storing geoIP redirection: " << hostname << " -> " << str << std::endl;
1155 geoipMirror = str;
1156 }
1157
1158 } else {
1159 MIL << "No host entry or empty file returned for GeoIP, remembering for 24hrs" << std::endl;
1160 }
1161 } catch ( const zypp::Exception &e ) {
1162 ZYPP_CAUGHT(e);
1163 MIL << "Empty or invalid GeoIP file, not requesting again for 24hrs" << std::endl;
1164 }
1165
1167 return expected<void>::success(); // need to return a expected<> due to and_then requirements
1168 })
1169 | []( expected<void> res ) { return res.is_valid(); };
1170 };
1171
1172 return std::move(hosts)
1174 | []( bool foundGeoIP ){
1175
1176 if ( foundGeoIP ) {
1177 MIL << "Successfully queried GeoIP data." << std::endl;
1178 return expected<void>::success ();
1179 }
1180
1181 MIL << "Failed to query GeoIP data." << std::endl;
1182 return expected<void>::error( std::make_exception_ptr( zypp::Exception("No valid geoIP url found" )) );
1183
1184 };
1185 }
1186
1187 private:
1188 ZyppContextRefType _zyppCtx;
1191
1192 };
1193 }
1194
1199
1204
1205
1206
1207}
Predicate predicate
Definition PoolQuery.cc:314
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
reference value() const
Reference to the Tp object.
void resetDispose()
Set no dispose function.
std::string asString() const
Definition ByteArray.h:24
time_t ValueType
Definition Date.h:38
static Date now()
Return the current time.
Definition Date.h:78
Base class for Exception.
Definition Exception.h:147
void remember(const Exception &old_r)
Store an other Exception as history.
Definition Exception.cc:141
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
Writing the zypp history file.
Definition HistoryLog.h:57
void addRepository(const RepoInfo &repo)
Log a newly added repository.
What is known about a repository.
Definition RepoInfo.h:72
Url url() const
Pars pro toto: The first repository url.
Definition RepoInfo.h:136
Pathname path() const
Repository path.
Definition RepoInfo.cc:635
std::list< Url > url_set
Definition RepoInfo.h:108
Track changing files or directories.
Definition RepoStatus.h:41
Url manipulation class.
Definition Url.h:92
std::string asString() const
Returns a default string representation of the Url object.
Definition Url.cc:501
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition Url.cc:608
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition Url.cc:752
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition Url.cc:672
Wrapper class for stat/lstat.
Definition PathInfo.h:222
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:282
std::string basename() const
Return the last component of this path.
Definition Pathname.h:130
Just inherits Exception to separate media exceptions.
Repository already exists and some unique attribute can't be duplicated.
Exception for repository handling.
std::string alias() const
unique identifier for this source.
thrown when it was impossible to determine this repo type.
xmlTextReader based interface to iterate xml streams.
Definition Reader.h:96
SignalProxy< void()> sigReadyRead()
Definition iodevice.cc:368
static Ptr create()
Definition process.cpp:49
SignalProxy< void(int)> sigFinished()
Definition process.cpp:294
static ProgressObserverRef makeSubTask(ProgressObserverRef parentProgress, float weight=1.0, const std::string &label=std::string(), int steps=100)
static void setup(ProgressObserverRef progress, const std::string &label=std::string(), int steps=100)
static void finish(ProgressObserverRef progress, ProgressObserver::FinishResult result=ProgressObserver::Success)
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
Definition provideres.h:36
The RepoManager class Provides knowledge and methods to maintain repo settings and metadata for a giv...
expected< RepoStatus > cacheStatus(const RepoInfo &info) const
static expected< void > touchIndexFile(const RepoInfo &info, const RepoManagerOptions &options)
static zypp::repo::RepoType probeCache(const zypp::Pathname &path_r)
Probe Metadata in a local cache directory.
static expected< RepoStatus > metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
static expected success(ConsParams &&...params)
Definition expected.h:115
static expected error(ConsParams &&...params)
Definition expected.h:126
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
Definition Arch.h:364
typename conditional< B, T, F >::type conditional_t
Definition TypeTraits.h:39
String related utilities and Regular expression matching.
RefreshCheckStatus
Possibly return state of RepoManager::checkIfToRefreshMetadata function.
@ REFRESH_NEEDED
refresh is needed
@ REPO_UP_TO_DATE
repository not changed
@ REPO_CHECK_DELAYED
refresh is delayed due to settings
bool provide(const Pathname &delta_r, const Pathname &new_r, const Progress &report_r)
Apply a binary delta to on-disk data to re-create a new rpm.
int unlink(const Pathname &path)
Like 'unlink'.
Definition PathInfo.cc:705
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition PathInfo.cc:324
int dirForEachExt(const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r)
Simiar to.
Definition PathInfo.cc:598
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
Definition Pool.cc:286
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
std::list< RepoInfo > readRepoFile(const Url &repo_file)
Parses repo_file and returns a list of RepoInfo objects corresponding to repositories found within th...
bool any_of(const Container &c, Fnc &&cb)
Definition Algorithm.h:76
AsyncOpRef< expected< repo::AsyncDownloadContextRef > > download(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver=nullptr)
AsyncOpRef< expected< zypp::RepoStatus > > repoStatus(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle)
AsyncOpRef< expected< zypp::repo::RepoType > > probeRepoType(ContextRef ctx, AsyncLazyMediaHandle medium, zypp::Pathname path, std::optional< zypp::Pathname > targetPath)
AsyncOpRef< expected< RepoInfo > > addRepository(AsyncRepoManagerRef mgr, RepoInfo info, ProgressObserverRef myProgress)
AsyncOpRef< expected< repo::RefreshCheckStatus > > checkIfToRefreshMetadata(repo::AsyncRefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
AsyncOpRef< expected< std::list< RepoInfo > > > readRepoFile(ContextRef ctx, zypp::Url repoFileUrl)
AsyncOpRef< expected< void > > refreshGeoIPData(ContextRef ctx, RepoInfo::url_set urls)
AsyncOpRef< expected< void > > addRepositories(AsyncRepoManagerRef mgr, zypp::Url url, ProgressObserverRef myProgress)
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > refreshMetadata(repo::AsyncRefreshContextRef refCtx, LazyMediaHandle< Provide > medium, ProgressObserverRef progressObserver)
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > buildCache(repo::AsyncRefreshContextRef refCtx, zypp::RepoManagerFlags::CacheBuildPolicy policy, ProgressObserverRef progressObserver)
auto or_else(Fun &&function)
Definition expected.h:630
auto and_then(Fun &&function)
Definition expected.h:623
auto mtry(Fun &&function)
Definition mtry.h:58
Exp mtry(F &&f, Args &&...args)
Definition mtry.h:28
expected< void > assert_urls(const RepoInfo &info)
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
Definition asyncop.h:297
typename remove_smart_ptr< T >::type remove_smart_ptr_t
static expected< std::decay_t< Type >, Err > make_expected_success(Type &&t)
Definition expected.h:397
expected< zypp::Pathname > rawcache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the raw cache path for a repository, this is usually /var/cache/zypp/alias.
expected< void > assert_alias(const RepoInfo &info)
Definition repomanager.h:57
ResultType or_else(const expected< T, E > &exp, Function &&f)
Definition expected.h:463
ResultType and_then(const expected< T, E > &exp, Function &&f)
Definition expected.h:423
auto firstOf(Transformation &&transformFunc, DefaultType &&def, Predicate &&predicate=detail::ContinueUntilValidPredicate())
Definition algorithm.h:149
RepoManagerRef< SyncContextRef > SyncRepoManagerRef
Definition repomanager.h:48
expected< zypp::Pathname > solv_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the solv cache path for a repository.
expected< std::list< RepoInfo > > repositories_in_file(const zypp::Pathname &file)
Reads RepoInfo's from a repo file.
RepoManagerRef< ContextRef > AsyncRepoManagerRef
Definition repomanager.h:51
expected< zypp::Pathname > packagescache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the packages cache path for a repository.
expected< zypp::Pathname > rawproductdata_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the raw product metadata path for a repository, this is inside the raw cache dir,...
expected< T, E > inspect(expected< T, E > exp, Function &&f)
Definition expected.h:531
expected< T, E > inspect_err(expected< T, E > exp, Function &&f)
Definition expected.h:544
RepoManagerPtrType _repoMgrRef
std::string _errdetail
zypp::Pathname _path
ZyppContextRefType _zyppContext
zypp::Url _url
RepoInfo _info
RepoInfo::url_set _urls
std::optional< zypp::Pathname > _targetPath
zypp::RepoInfo _repo
zypp::Pathname _productdatapath
RefreshContextRefType _refreshContext
zypp::Pathname _geoIPCache
zypp::repo::RepoException _error
zypp::RepoManagerFlags::CacheBuildPolicy _policy
ProgressObserverRef _progress
ProcessRef _proc
RefreshContextRefType _refCtx
ZyppContextRefType _zyppCtx
bool _gotMediaError
ProgressObserverRef _myProgress
LazyMediaHandle _medium
zypp::Pathname _mediarootpath
ProgressObserverRef _progressObserver
Listentry returned by readdir.
Definition PathInfo.h:502
Repository type enumeration.
Definition RepoType.h:29
static const RepoType YAST2
Definition RepoType.h:31
static const RepoType RPMMD
Definition RepoType.h:30
static const RepoType NONE
Definition RepoType.h:33
static const RepoType RPMPLAINDIR
Definition RepoType.h:32
Functor replacing repository variables.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:212
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:28
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
Definition Exception.h:444
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition Exception.h:440
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition Exception.h:428
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.
Definition Exception.h:436
#define PL_(MSG1, MSG2, N)
Definition Gettext.h:42
#define _(MSG)
Definition Gettext.h:39
#define DBG
Definition Logger.h:97
#define MIL
Definition Logger.h:98
#define ERR
Definition Logger.h:100
#define WAR
Definition Logger.h:99