libzypp  17.37.5
RepoInfo.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <iostream>
14 #include <vector>
15 
16 #include <zypp/base/Gettext.h>
17 #include <zypp/base/LogTools.h>
18 #include <zypp-core/base/DefaultIntegral>
20 
21 #include <zypp/ManagedFile.h>
22 #include <zypp-common/PublicKey.h>
23 #include <zypp/MediaSetAccess.h>
24 #include <zypp/RepoInfo.h>
25 #include <zypp/Glob.h>
26 #include <zypp/TriBool.h>
27 #include <zypp/Pathname.h>
28 #include <zypp/ZConfig.h>
31 #include <zypp/ExternalProgram.h>
32 
33 #include <zypp/base/IOStream.h>
34 #include <zypp-core/base/InputStream>
35 #include <zypp/parser/xml/Reader.h>
36 
37 
38 #include <zypp/base/StrMatcher.h>
39 #include <zypp/KeyRing.h>
40 #include <zypp/TmpPath.h>
41 #include <zypp/ZYppFactory.h>
42 #include <zypp/ZYppCallbacks.h>
43 
46 
47 using std::endl;
48 using zypp::xml::escape;
49 
51 namespace zypp
52 {
53 
54  namespace
55  {
56  repo::RepoType probeCache( const Pathname & path_r )
57  {
58  repo::RepoType ret = repo::RepoType::NONE;
59  if ( PathInfo(path_r).isDir() )
60  {
61  if ( PathInfo(path_r/"/repodata/repomd.xml").isFile() )
62  { ret = repo::RepoType::RPMMD; }
63  else if ( PathInfo(path_r/"/content").isFile() )
64  { ret = repo::RepoType::YAST2; }
65  else if ( PathInfo(path_r/"/cookie").isFile() )
67  }
68  DBG << "Probed cached type " << ret << " at " << path_r << endl;
69  return ret;
70  }
71  } // namespace
72 
74  //
75  // CLASS NAME : RepoInfo::Impl
76  //
79  {
80  Impl()
81  : _rawGpgCheck( indeterminate )
82  , _rawRepoGpgCheck( indeterminate )
83  , _rawPkgGpgCheck( indeterminate )
84  , _validRepoSignature( indeterminate )
85  , _type(repo::RepoType::NONE_e)
86  , keeppackages(indeterminate)
87  {}
88 
89  Impl(const Impl &) = default;
90  Impl(Impl &&) = delete;
91  Impl &operator=(const Impl &) = delete;
92  Impl &operator=(Impl &&) = delete;
93 
94  ~Impl() {}
95 
96  public:
97  static const unsigned defaultPriority = 99;
98  static const unsigned noPriority = unsigned(-1);
99 
100  void setType( const repo::RepoType & t )
101  { _type = t; }
102 
103  void setProbedType( const repo::RepoType & t ) const
104  {
106  { const_cast<Impl*>(this)->_type = t; }
107  }
108 
110  {
111  if ( _type == repo::RepoType::NONE && not metadataPath().empty() )
112  setProbedType( probeCache( metadataPath() / path ) );
113  return _type;
114  }
115 
116  public:
118  Pathname licenseTgz( const std::string & name_r ) const
119  {
120  Pathname ret;
121  if ( !metadataPath().empty() )
122  {
123  std::string licenseStem( "license" );
124  if ( !name_r.empty() )
125  {
126  licenseStem += "-";
127  licenseStem += name_r;
128  }
129 
131  // TODO: REPOMD: this assumes we know the name of the tarball. In fact
132  // we'd need to get the file from repomd.xml (<data type="license[-name_r]">)
133  g.add( metadataPath() / path / ("repodata/*"+licenseStem+".tar.gz") );
134  if ( g.empty() )
135  g.add( metadataPath() / path / (licenseStem+".tar.gz") );
136 
137  if ( !g.empty() )
138  ret = *g.begin();
139  }
140  return ret;
141  }
142 
144  if ( !_baseUrls.empty() ) {
145  return RepoVariablesReplacedUrl( _baseUrls.raw ().front(), _baseUrls.transformator() );
146  }
147  if ( !effectiveBaseUrls().empty() ) {
148  return RepoVariablesReplacedUrl( effectiveBaseUrls ().front (), _baseUrls.transformator() );
149  }
150  return RepoVariablesReplacedUrl();
151  }
152 
154  {
155  return _baseUrls;
156  }
157 
158  Url location() const {
159  if ( !_baseUrls.empty() )
160  return *_baseUrls.transformedBegin ();
161  return mirrorListUrl().transformed();
162  }
163 
164  void resetEffectiveUrls() const {
165  _effectiveBaseUrls.clear ();
166  _lastEffectiveUrlsUpdate = std::chrono::steady_clock::time_point::min();
167  }
168 
170  {
171  if ( !_effectiveBaseUrls.empty()
172  && ( std::chrono::steady_clock::now() - _lastEffectiveUrlsUpdate < std::chrono::hours(1) ) )
173  return _effectiveBaseUrls;
174 
175  _effectiveBaseUrls.clear();
176  _lastEffectiveUrlsUpdate = std::chrono::steady_clock::now();
177 
178  // prefer baseUrl over mirrors, this should prevent us from downloading old metadata from mirrors
179  _effectiveBaseUrls.insert( _effectiveBaseUrls.end(), _baseUrls.transformedBegin (), _baseUrls.transformedEnd () );
180 
181  bool isAutoMirrorList = false; // bsc#1243901 Allows mirrorlist parsing to fail if automatically switched on
182 
183  Url mlurl( mirrorListUrl().transformed() ); // Variables replaced!
184  if ( mlurl.asString().empty()
185  && _baseUrls.raw().size() == 1
186  && repo::RepoMirrorList::urlSupportsMirrorLink( *_baseUrls.transformedBegin() ) ) {
187 
188  mlurl = *_baseUrls.transformedBegin ();
189  mlurl.pathNameSetTrailingSlash();
190  mlurl.setQueryParam("mirrorlist", std::string() );
191 
192  MIL << "Detected opensuse.org baseUrl with no mirrors, requesting them from : " << mlurl.asString() << std::endl;
193  isAutoMirrorList = true;
194  }
195 
196  if ( !mlurl.asString().empty() )
197  {
198  try {
199  DBG << "MetadataPath: " << metadataPath() << endl;
200  repo::RepoMirrorList rmurls( mlurl, metadataPath() );
201 
202  // propagate internally used URL params like 'proxy' to the mirrors
203  const auto &tf = [urlTemplate =mirrorListUrl().transformed()]( const zypp::Url &in ){
204  return internal::propagateQueryParams ( in , urlTemplate );
205  };
206  _effectiveBaseUrls.insert( _effectiveBaseUrls.end(), make_transform_iterator( rmurls.getUrls().begin(), tf ), make_transform_iterator( rmurls.getUrls().end(), tf ) );
207  } catch ( const zypp::Exception & e ) {
208  // failed to fetch the mirrorlist/metalink, if we still have a baseUrl we can go on, otherwise this is a error
209  if ( _baseUrls.empty () ) {
210  _lastEffectiveUrlsUpdate = std::chrono::steady_clock::time_point::min();
211  _effectiveBaseUrls.clear();
212  throw;
213  } else {
214  MIL << "Mirrorlist failed, repo either returns invalid data or has no mirrors at all, falling back to only baseUrl!" << std::endl;
215  if ( !isAutoMirrorList ) {
217  data.set("error", e );
218  JobReport::warning( _("Failed to fetch mirrorlist/metalink data."), data );
219  }
220  }
221  }
222  }
223  return _effectiveBaseUrls;
224  }
225 
226  std::vector<std::vector<Url>> groupedBaseUrls() const
227  {
228  // here we group the URLs to figure out mirrors
229  std::vector<std::vector<Url>> urlGroups;
230  int dlUrlIndex = -1; //we remember the index of the first downloading URL
231 
232  const auto &baseUrls = effectiveBaseUrls();
233  std::for_each ( baseUrls.begin(), baseUrls.end(), [&]( const zypp::Url &url ){
234  if ( !url.schemeIsDownloading () ) {
235  urlGroups.push_back ( { url } );
236  return;
237  }
238 
239  if ( dlUrlIndex >= 0) {
240  urlGroups[dlUrlIndex].push_back ( url );
241  return;
242  }
243 
244  // start a new group
245  urlGroups.push_back ( {url} );
246  dlUrlIndex = urlGroups.size() - 1;
247  });
248 
249  return urlGroups;
250  }
251 
253  { return _baseUrls; }
254 
255  bool baseurl2dump() const
256  { return !_baseUrls.empty(); }
257 
258 
260  { return _gpgKeyUrls; }
261 
263  { return _gpgKeyUrls; }
264 
265  std::string repoStatusString() const
266  {
267  if ( mirrorListUrl().transformed().isValid() )
268  return mirrorListUrl().transformed().asString();
269  if ( !baseUrls().empty() )
270  return (*baseUrls().transformedBegin()).asString();
271  return std::string();
272  }
273 
274  const std::set<std::string> & contentKeywords() const
275  { hasContent()/*init if not yet done*/; return _keywords.second; }
276 
277  void addContent( const std::string & keyword_r )
278  { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
279 
280  bool hasContent() const
281  {
282  if ( !_keywords.first && ! metadataPath().empty() )
283  {
284  // HACK directly check master index file until RepoManager offers
285  // some content probing and zypper uses it.
287  MIL << "Empty keywords...." << metadataPath() << endl;
288  Pathname master;
289  if ( PathInfo( (master=metadataPath()/"/repodata/repomd.xml") ).isFile() )
290  {
291  //MIL << "GO repomd.." << endl;
292  xml::Reader reader( master );
293  while ( reader.seekToNode( 2, "content" ) )
294  {
295  _keywords.second.insert( reader.nodeText().asString() );
296  reader.seekToEndNode( 2, "content" );
297  }
298  _keywords.first = true; // valid content in _keywords even if empty
299  }
300  else if ( PathInfo( (master=metadataPath()/"/content") ).isFile() )
301  {
302  //MIL << "GO content.." << endl;
303  iostr::forEachLine( InputStream( master ),
304  [this]( int num_r, const std::string& line_r )->bool
305  {
306  if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
307  {
308  std::vector<std::string> words;
309  if ( str::split( line_r, std::back_inserter(words) ) > 1
310  && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
311  {
312  this->_keywords.second.insert( ++words.begin(), words.end() );
313  }
314  return true; // mult. occurrances are ok.
315  }
316  return( ! str::startsWith( line_r, "META " ) ); // no need to parse into META section.
317  } );
318  _keywords.first = true; // valid content in _keywords even if empty
319  }
321  }
322  return _keywords.first;
323  }
324 
325  bool hasContent( const std::string & keyword_r ) const
326  { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
327 
333  {
334  if ( ! indeterminate(_validRepoSignature) )
335  return _validRepoSignature;
336  // check metadata:
337  if ( ! metadataPath().empty() )
338  {
339  // A missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
340  TriBool linkval = triBoolFromPath( metadataPath() / ".repo_gpgcheck" );
341  return linkval;
342  }
343  return indeterminate;
344  }
345 
347  {
348  if ( PathInfo(metadataPath()).isDir() )
349  {
350  Pathname gpgcheckFile( metadataPath() / ".repo_gpgcheck" );
351  if ( PathInfo(gpgcheckFile).isExist() )
352  {
353  TriBool linkval( indeterminate );
354  if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
355  return; // existing symlink fits value_r
356  else
357  filesystem::unlink( gpgcheckFile ); // will write a new one
358  }
359  filesystem::symlink( asString(value_r), gpgcheckFile );
360  }
361  _validRepoSignature = value_r;
362  }
363 
369  {
370  TriBool linkval( true ); // want to see it being switched to indeterminate
371  return triBoolFromPath( metadataPath() / ".repo_gpgcheck", linkval ) && indeterminate(linkval);
372  }
373 
374  bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
375  {
376  static const Pathname truePath( "true" );
377  static const Pathname falsePath( "false" );
378  static const Pathname indeterminatePath( "indeterminate" );
379 
380  // Quiet readlink;
381  static const ssize_t bufsiz = 63;
382  static char buf[bufsiz+1];
383  ssize_t ret = ::readlink( path_r.c_str(), buf, bufsiz );
384  buf[ret == -1 ? 0 : ret] = '\0';
385 
386  Pathname linkval( buf );
387 
388  bool known = true;
389  if ( linkval == truePath )
390  ret_r = true;
391  else if ( linkval == falsePath )
392  ret_r = false;
393  else if ( linkval == indeterminatePath )
394  ret_r = indeterminate;
395  else
396  known = false;
397  return known;
398  }
399 
400  TriBool triBoolFromPath( const Pathname & path_r ) const
401  { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
402 
404 
405  private:
409 
410  public:
411  TriBool rawGpgCheck() const { return _rawGpgCheck; }
414 
415  void rawGpgCheck( TriBool val_r ) { _rawGpgCheck = val_r; }
416  void rawRepoGpgCheck( TriBool val_r ) { _rawRepoGpgCheck = val_r; }
417  void rawPkgGpgCheck( TriBool val_r ) { _rawPkgGpgCheck = val_r; }
418 
419  bool cfgGpgCheck() const
420  { return indeterminate(_rawGpgCheck) ? ZConfig::instance().gpgCheck() : (bool)_rawGpgCheck; }
422  { return indeterminate(_rawGpgCheck) && indeterminate(_rawRepoGpgCheck) ? ZConfig::instance().repoGpgCheck() : _rawRepoGpgCheck; }
424  { return indeterminate(_rawGpgCheck) && indeterminate(_rawPkgGpgCheck) ? ZConfig::instance().pkgGpgCheck() : _rawPkgGpgCheck; }
425 
426  private:
429 
430  private:
433  public:
436  { return _cfgMirrorlistUrl.transformed().isValid() ? _cfgMirrorlistUrl : _cfgMetalinkUrl; }
437 
438  void setMirrorlistUrl( const Url & url_r ) // Raw
439  { _cfgMirrorlistUrl.raw() = url_r; }
440 
441  void setMetalinkUrl( const Url & url_r ) // Raw
442  { _cfgMetalinkUrl.raw() = url_r; }
443 
446  { return _cfgMirrorlistUrl; }
449  { return _cfgMetalinkUrl; }
450 
451  public:
454  std::string service;
455  std::string targetDistro;
456 
457  void metadataPath( Pathname new_r )
458  { _metadataPath = std::move( new_r ); }
459 
460  void packagesPath( Pathname new_r )
461  { _packagesPath = std::move( new_r ); }
462 
464  { return str::hasSuffix( _metadataPath.asString(), "/%AUTO%" ); }
465 
467  {
468  if ( usesAutoMetadataPaths() )
469  return _metadataPath.dirname() / "%RAW%";
470  return _metadataPath;
471  }
472 
474  {
476  return _metadataPath.dirname() / "%PKG%";
477  return _packagesPath;
478  }
479 
481  {
482  return packagesPath() / ".preload";
483  }
484 
486 
487  private:
490 
493  mutable std::chrono::steady_clock::time_point _lastEffectiveUrlsUpdate = std::chrono::steady_clock::time_point::min();
494  mutable std::pair<FalseBool, std::set<std::string> > _keywords;
495 
497 
498  friend Impl * rwcowClone<Impl>( const Impl * rhs );
500  Impl * clone() const
501  { return new Impl( *this ); }
502  };
504 
506  inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
507  {
508  return str << "RepoInfo::Impl";
509  }
510 
512  //
513  // CLASS NAME : RepoInfo
514  //
516 
518 
520  : _pimpl( new Impl() )
521  {}
522 
524  {}
525 
526  unsigned RepoInfo::priority() const
527  { return _pimpl->priority; }
528 
530  { return Impl::defaultPriority; }
531 
533  { return Impl::noPriority; }
534 
535  void RepoInfo::setPriority( unsigned newval_r )
536  { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
537 
538 
539  bool RepoInfo::gpgCheck() const
540  { return _pimpl->cfgGpgCheck(); }
541 
543  { _pimpl->rawGpgCheck( value_r ); }
544 
545  void RepoInfo::setGpgCheck( bool value_r ) // deprecated legacy and for squid
546  { setGpgCheck( TriBool(value_r) ); }
547 
548 
550  { return gpgCheck() || bool(_pimpl->cfgRepoGpgCheck()); }
551 
553  {
554  bool ret = ( gpgCheck() && indeterminate(_pimpl->cfgRepoGpgCheck()) ) || bool(_pimpl->cfgRepoGpgCheck());
555  if ( ret && _pimpl->internalUnsignedConfirmed() ) // relax if unsigned repo was confirmed in the past
556  ret = false;
557  return ret;
558  }
559 
561  { _pimpl->rawRepoGpgCheck( value_r ); }
562 
563 
565  { return bool(_pimpl->cfgPkgGpgCheck()) || ( gpgCheck() && !bool(validRepoSignature())/*enforced*/ ) ; }
566 
568  { return bool(_pimpl->cfgPkgGpgCheck()) || ( gpgCheck() && indeterminate(_pimpl->cfgPkgGpgCheck()) && !bool(validRepoSignature())/*enforced*/ ); }
569 
571  { _pimpl->rawPkgGpgCheck( value_r ); }
572 
573 
574  void RepoInfo::getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const
575  {
576  g_r = _pimpl->rawGpgCheck();
577  r_r = _pimpl->rawRepoGpgCheck();
578  p_r = _pimpl->rawPkgGpgCheck();
579  }
580 
581 
583  {
585  if ( ret && !repoGpgCheck() ) ret = false; // invalidate any old signature if repoGpgCheck is off
586  return ret;
587  }
588 
590  { _pimpl->internalSetValidRepoSignature( value_r ); }
591 
593  namespace
594  {
595  inline bool changeGpgCheckTo( TriBool & lhs, TriBool rhs )
596  { if ( ! sameTriboolState( lhs, rhs ) ) { lhs = rhs; return true; } return false; }
597 
598  inline bool changeGpgCheckTo( TriBool ogpg[3], TriBool g, TriBool r, TriBool p )
599  {
600  bool changed = false;
601  if ( changeGpgCheckTo( ogpg[0], g ) ) changed = true;
602  if ( changeGpgCheckTo( ogpg[1], r ) ) changed = true;
603  if ( changeGpgCheckTo( ogpg[2], p ) ) changed = true;
604  return changed;
605  }
606  } // namespace
609  {
610  TriBool ogpg[3]; // Gpg RepoGpg PkgGpg
611  getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
612 
613  bool changed = false;
614  switch ( mode_r )
615  {
616  case GpgCheck::On:
617  changed = changeGpgCheckTo( ogpg, true, indeterminate, indeterminate );
618  break;
619  case GpgCheck::Strict:
620  changed = changeGpgCheckTo( ogpg, true, true, true );
621  break;
623  changed = changeGpgCheckTo( ogpg, true, false, false );
624  break;
626  changed = changeGpgCheckTo( ogpg, true, false, indeterminate );
627  break;
629  changed = changeGpgCheckTo( ogpg, true, indeterminate, false );
630  break;
631  case GpgCheck::Default:
632  changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
633  break;
634  case GpgCheck::Off:
635  changed = changeGpgCheckTo( ogpg, false, indeterminate, indeterminate );
636  break;
637  case GpgCheck::indeterminate: // no change
638  break;
639  }
640 
641  if ( changed )
642  {
643  setGpgCheck ( ogpg[0] );
644  setRepoGpgCheck( ogpg[1] );
645  setPkgGpgCheck ( ogpg[2] );
646  }
647  return changed;
648  }
649 
650  void RepoInfo::setMirrorlistUrl( const Url & url_r ) // Raw
651  { _pimpl->setMirrorlistUrl( url_r ); }
652 
653  void RepoInfo::setMetalinkUrl( const Url & url_r ) // Raw
654  { _pimpl->setMetalinkUrl( url_r ); }
655 
657  { return _pimpl->cfgMirrorlistUrl().raw(); }
658 
660  { return _pimpl->cfgMetalinkUrl().raw(); }
661 
662 #if LEGACY(1735)
663  void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
664  { setMirrorlistUrl( url_r ); }
665  void RepoInfo::setMirrorListUrls( url_set urls ) // Raw
666  { _pimpl->setMirrorlistUrl( urls.empty() ? Url() : urls.front() ); }
667  void RepoInfo::setMetalinkUrls( url_set urls ) // Raw
668  { _pimpl->setMetalinkUrl( urls.empty() ? Url() : urls.front() ); }
669 #endif
670 
672  { _pimpl->gpgKeyUrls().raw().swap( urls ); }
673 
674  void RepoInfo::setGpgKeyUrl( const Url & url_r )
675  {
676  _pimpl->gpgKeyUrls().raw().clear();
677  _pimpl->gpgKeyUrls().raw().push_back( url_r );
678  }
679 
680  std::string RepoInfo::repoStatusString() const
681  { return _pimpl->repoStatusString(); }
682 
683  void RepoInfo::addBaseUrl( Url url_r )
684  {
685  for ( const auto & url : _pimpl->baseUrls().raw() ) // Raw unique!
686  if ( url == url_r )
687  return;
688 
689  _pimpl->baseUrls().raw().push_back( url_r );
691  }
692 
693  void RepoInfo::setBaseUrl( Url url_r )
694  {
695  _pimpl->baseUrls().raw().clear();
697  _pimpl->baseUrls().raw().push_back( std::move(url_r) );
698  }
699 
701  {
703  _pimpl->baseUrls().raw().swap( urls );
704  }
705 
707  {
708  return _pimpl->effectiveBaseUrls().empty();
709  }
710 
712  {
713  return _pimpl->effectiveBaseUrls();
714  }
715 
716  void RepoInfo::setPath( const Pathname &path )
717  { _pimpl->path = path; }
718 
720  { _pimpl->setType( t ); }
721 
723  { _pimpl->setProbedType( t ); }
724 
725 
727  { _pimpl->metadataPath( path ); }
728 
730  { _pimpl->packagesPath( path ); }
731 
733  { return _pimpl->predownloadPath(); }
734 
735  void RepoInfo::setKeepPackages( bool keep )
736  { _pimpl->keeppackages = keep; }
737 
738  void RepoInfo::setService( const std::string& name )
739  { _pimpl->service = name; }
740 
741  void RepoInfo::setTargetDistribution( const std::string & targetDistribution )
743 
745  { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
746 
748  { return keepPackages() || PathInfo(packagesPath().dirname()/".keep_packages").isExist(); }
749 
751  { return _pimpl->metadataPath(); }
752 
754  { return _pimpl->packagesPath(); }
755 
757  { return _pimpl->usesAutoMetadataPaths(); }
758 
760  { return _pimpl->type(); }
761 
762  Url RepoInfo::mirrorListUrl() const // Variables replaced!
763  { return _pimpl->mirrorListUrl().transformed(); }
764 
766  { return _pimpl->mirrorListUrl().raw(); }
767 
769  { return _pimpl->gpgKeyUrls().empty(); }
770 
772  { return _pimpl->gpgKeyUrls().size(); }
773 
774  RepoInfo::url_set RepoInfo::gpgKeyUrls() const // Variables replaced!
775  { return _pimpl->gpgKeyUrls().transformed(); }
776 
778  { return _pimpl->gpgKeyUrls().raw(); }
779 
780  Url RepoInfo::gpgKeyUrl() const // Variables replaced!
781  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
782 
784  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
785 
786  RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
787  { return _pimpl->baseUrls().transformed(); }
788 
790  { return _pimpl->baseUrls().raw(); }
791 
793  { return _pimpl->path; }
794 
795  std::string RepoInfo::service() const
796  { return _pimpl->service; }
797 
798  std::string RepoInfo::targetDistribution() const
799  { return _pimpl->targetDistro; }
800 
802  { return _pimpl->baseUrl().raw(); }
803 
805  { return _pimpl->location (); }
806 
807  std::vector<std::vector<Url>> RepoInfo::groupedBaseUrls() const
808  { return _pimpl->groupedBaseUrls(); }
809 
811  { return _pimpl->baseUrls().transformedBegin(); }
812 
814  { return _pimpl->baseUrls().transformedEnd(); }
815 
817  { return _pimpl->baseUrls().size(); }
818 
820  { return _pimpl->baseUrls().empty(); }
821 
822  bool RepoInfo::baseUrlSet() const
823  { return _pimpl->baseurl2dump(); }
824 
826  {
827  return _pimpl->baseUrl().transformed();
828  }
829 
830  const std::set<std::string> & RepoInfo::contentKeywords() const
831  { return _pimpl->contentKeywords(); }
832 
833  void RepoInfo::addContent( const std::string & keyword_r )
834  { _pimpl->addContent( keyword_r ); }
835 
836  bool RepoInfo::hasContent() const
837  { return _pimpl->hasContent(); }
838 
839  bool RepoInfo::hasContent( const std::string & keyword_r ) const
840  { return _pimpl->hasContent( keyword_r ); }
841 
843 
844  bool RepoInfo::hasLicense() const
845  { return hasLicense( std::string() ); }
846 
847  bool RepoInfo::hasLicense( const std::string & name_r ) const
848  { return !_pimpl->licenseTgz( name_r ).empty(); }
849 
850 
852  { return needToAcceptLicense( std::string() ); }
853 
854  bool RepoInfo::needToAcceptLicense( const std::string & name_r ) const
855  {
856  const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
857  if ( licenseTgz.empty() )
858  return false; // no licenses at all
859 
861  cmd.push_back( "tar" );
862  cmd.push_back( "-t" );
863  cmd.push_back( "-z" );
864  cmd.push_back( "-f" );
865  cmd.push_back( licenseTgz.asString() );
867 
868  bool accept = true;
869  static const std::string noAcceptanceFile = "no-acceptance-needed\n";
870  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
871  {
872  if ( output == noAcceptanceFile )
873  {
874  accept = false;
875  }
876  }
877  prog.close();
878  MIL << "License(" << name_r << ") in " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
879  return accept;
880  }
881 
882 
883  std::string RepoInfo::getLicense( const Locale & lang_r )
884  { return const_cast<const RepoInfo *>(this)->getLicense( std::string(), lang_r ); }
885 
886  std::string RepoInfo::getLicense( const Locale & lang_r ) const
887  { return getLicense( std::string(), lang_r ); }
888 
889  std::string RepoInfo::getLicense( const std::string & name_r, const Locale & lang_r ) const
890  {
891  LocaleSet avlocales( getLicenseLocales( name_r ) );
892  if ( avlocales.empty() )
893  return std::string();
894 
895  Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
896  if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
897  {
898  WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
899  // Using the fist locale instead of returning no text at all.
900  // So the user might recognize that there is a license, even if they
901  // can't read it.
902  getLang = *avlocales.begin();
903  }
904 
905  // now extract the license file.
906  static const std::string licenseFileFallback( "license.txt" );
907  std::string licenseFile( !getLang ? licenseFileFallback
908  : str::form( "license.%s.txt", getLang.c_str() ) );
909 
911  cmd.push_back( "tar" );
912  cmd.push_back( "-x" );
913  cmd.push_back( "-z" );
914  cmd.push_back( "-O" );
915  cmd.push_back( "-f" );
916  cmd.push_back( _pimpl->licenseTgz( name_r ).asString() ); // if it not exists, avlocales was empty.
917  cmd.push_back( licenseFile );
918 
919  std::string ret;
921  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
922  {
923  ret += output;
924  }
925  prog.close();
926  return ret;
927  }
928 
929 
931  { return getLicenseLocales( std::string() ); }
932 
933  LocaleSet RepoInfo::getLicenseLocales( const std::string & name_r ) const
934  {
935  const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
936  if ( licenseTgz.empty() )
937  return LocaleSet();
938 
940  cmd.push_back( "tar" );
941  cmd.push_back( "-t" );
942  cmd.push_back( "-z" );
943  cmd.push_back( "-f" );
944  cmd.push_back( licenseTgz.asString() );
945 
946  LocaleSet ret;
948  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
949  {
950  static const C_Str license( "license." );
951  static const C_Str dotTxt( ".txt\n" );
952  if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
953  {
954  if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
955  ret.insert( Locale() );
956  else
957  ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
958  }
959  }
960  prog.close();
961  return ret;
962  }
963 
965 
966  std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
967  {
969  if ( _pimpl->baseurl2dump() )
970  {
971  for ( const auto & url : _pimpl->baseUrls().raw() )
972  {
973  str << "- url : " << url << std::endl;
974  }
975  }
976 
977  // print if non empty value
978  auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
979  if ( ! value_r.empty() )
980  str << tag_r << value_r << std::endl;
981  });
982 
983  strif( "- mirrorlist : ", _pimpl->cfgMirrorlistUrl().raw().asString() );
984  strif( "- metalink : ", _pimpl->cfgMetalinkUrl().raw().asString() );
985  strif( "- path : ", path().asString() );
986  str << "- type : " << type() << std::endl;
987  str << "- priority : " << priority() << std::endl;
988 
989  // Yes No Default(Y) Default(N)
990 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
991  str << "- gpgcheck : " << OUTS(_pimpl->rawGpgCheck(),gpgCheck())
992  << " repo" << OUTS(_pimpl->rawRepoGpgCheck(),repoGpgCheck()) << (repoGpgCheckIsMandatory() ? "* ": " " )
993  << "sig" << asString( validRepoSignature(), "?", "Y", "N" )
994  << " pkg" << OUTS(_pimpl->rawPkgGpgCheck(),pkgGpgCheck()) << (pkgGpgCheckIsMandatory() ? "* ": " " )
995  << std::endl;
996 #undef OUTS
997 
998  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
999  {
1000  str << "- gpgkey : " << url << std::endl;
1001  }
1002 
1003  if ( ! indeterminate(_pimpl->keeppackages) )
1004  str << "- keeppackages: " << keepPackages() << std::endl;
1005 
1006  strif( "- service : ", service() );
1007  strif( "- targetdistro: ", targetDistribution() );
1008  strif( "- filePath: ", filepath().asString() );
1009  strif( "- metadataPath: ", metadataPath().asString() );
1010  strif( "- packagesPath: ", packagesPath().asString() );
1011 
1012  return str;
1013  }
1014 
1015  std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
1016  {
1017  // libzypp/#638: Add a note to service maintained repo entries
1018  if( ! service().empty() ) {
1019  str << "# Repository '"<<alias()<<"' is maintained by the '"<<service()<<"' service." << endl;
1020  str << "# Manual changes may be overwritten by a service refresh." << endl;
1021  str << "# See also 'man zypper', section 'Services'." << endl;
1022  }
1023  RepoInfoBase::dumpAsIniOn(str);
1024 
1025  if ( _pimpl->baseurl2dump() )
1026  {
1027  str << "baseurl=";
1028  std::string indent;
1029  for ( const auto & url : _pimpl->baseUrls().raw() )
1030  {
1031  str << indent << hotfix1050625::asString( url ) << endl;
1032  if ( indent.empty() ) indent = " "; // "baseurl="
1033  }
1034  }
1035 
1036  if ( ! _pimpl->path.empty() )
1037  str << "path="<< path() << endl;
1038 
1039  if ( ! _pimpl->cfgMirrorlistUrl().raw().asString().empty() )
1040  str << "mirrorlist=" << hotfix1050625::asString( _pimpl->cfgMirrorlistUrl().raw() ) << endl;
1041 
1042  if ( ! _pimpl->cfgMetalinkUrl().raw().asString().empty() )
1043  str << "metalink=" << hotfix1050625::asString( _pimpl->cfgMetalinkUrl().raw() ) << endl;
1044 
1045  if ( type() != repo::RepoType::NONE )
1046  str << "type=" << type().asString() << endl;
1047 
1048  if ( priority() != defaultPriority() )
1049  str << "priority=" << priority() << endl;
1050 
1051  if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1052  str << "gpgcheck=" << (_pimpl->rawGpgCheck() ? "1" : "0") << endl;
1053 
1054  if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1055  str << "repo_gpgcheck=" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << endl;
1056 
1057  if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1058  str << "pkg_gpgcheck=" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << endl;
1059 
1060  {
1061  std::string indent( "gpgkey=");
1062  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
1063  {
1064  str << indent << url << endl;
1065  if ( indent[0] != ' ' )
1066  indent = " ";
1067  }
1068  }
1069 
1070  if (!indeterminate(_pimpl->keeppackages))
1071  str << "keeppackages=" << keepPackages() << endl;
1072 
1073  if( ! service().empty() )
1074  str << "service=" << service() << endl;
1075 
1076  return str;
1077  }
1078 
1079  std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
1080  {
1081  std::string tmpstr;
1082  str
1083  << "<repo"
1084  << " alias=\"" << escape(alias()) << "\""
1085  << " name=\"" << escape(name()) << "\"";
1086  if (type() != repo::RepoType::NONE)
1087  str << " type=\"" << type().asString() << "\"";
1088  str
1089  << " priority=\"" << priority() << "\""
1090  << " enabled=\"" << enabled() << "\""
1091  << " autorefresh=\"" << autorefresh() << "\""
1092  << " gpgcheck=\"" << gpgCheck() << "\""
1093  << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
1094  << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
1095  if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1096  str << " raw_gpgcheck=\"" << (_pimpl->rawGpgCheck() ? "1" : "0") << "\"";
1097  if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1098  str << " raw_repo_gpgcheck=\"" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << "\"";
1099  if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1100  str << " raw_pkg_gpgcheck=\"" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << "\"";
1101  if (!(tmpstr = gpgKeyUrl().asString()).empty())
1102  str << " gpgkey=\"" << escape(tmpstr) << "\"";
1103  if ( ! (tmpstr = _pimpl->cfgMirrorlistUrl().transformed().asString()).empty() )
1104  str << " mirrorlist=\"" << escape(tmpstr) << "\"";
1105  if ( ! (tmpstr = _pimpl->cfgMetalinkUrl().transformed().asString()).empty() )
1106  str << " metalink=\"" << escape(tmpstr) << "\"";
1107  str << ">" << endl;
1108 
1109  if ( _pimpl->baseurl2dump() )
1110  {
1111  for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
1112  str << "<url>" << escape((*it).asString()) << "</url>" << endl;
1113  }
1114 
1115  str << "</repo>" << endl;
1116  return str;
1117  }
1118 
1119 
1120  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
1121  {
1122  return obj.dumpOn(str);
1123  }
1124 
1125  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj )
1126  {
1127  switch ( obj )
1128  {
1129 #define OUTS( V ) case RepoInfo::V: return str << #V; break
1130  OUTS( GpgCheck::On );
1131  OUTS( GpgCheck::Strict );
1132  OUTS( GpgCheck::AllowUnsigned );
1133  OUTS( GpgCheck::AllowUnsignedRepo );
1134  OUTS( GpgCheck::AllowUnsignedPackage );
1136  OUTS( GpgCheck::Off );
1137  OUTS( GpgCheck::indeterminate );
1138 #undef OUTS
1139  }
1140  return str << "GpgCheck::UNKNOWN";
1141  }
1142 
1144  {
1145  // We skip the check for downloading media unless a local copy of the
1146  // media file exists and states that there is more than one medium.
1147  const auto &effUrls = _pimpl->effectiveBaseUrls ();
1148  bool canSkipMediaCheck = std::all_of( effUrls.begin(), effUrls.end(), []( const zypp::Url &url ) { return url.schemeIsDownloading(); });
1149  if ( canSkipMediaCheck ) {
1150  const auto &mDataPath = metadataPath();
1151  if ( not mDataPath.empty() ) {
1152  PathInfo mediafile { mDataPath/"media.1/media" };
1153  if ( mediafile.isExist() ) {
1154  repo::SUSEMediaVerifier lverifier { mediafile.path() };
1155  if ( lverifier && lverifier.totalMedia() > 1 ) {
1156  canSkipMediaCheck = false;
1157  }
1158  }
1159  }
1160  }
1161  if ( canSkipMediaCheck )
1162  DBG << "Can SKIP media.1/media check for status calc of repo " << alias() << endl;
1163  return not canSkipMediaCheck;
1164  }
1165 
1167 } // namespace zypp
std::string asString(const Patch::Category &obj)
Definition: Patch.cc:122
static const Locale noCode
Empty code.
Definition: Locale.h:75
const RepoVariablesReplacedUrl & mirrorListUrl() const
THE mirrorListUrl to work with (either_cfgMirrorlistUrl or _cfgMetalinkUrl)
Definition: RepoInfo.cc:435
Pathname filepath() const
File where this repo was read from.
static const ContentType repoRefreshMirrorlist
const RepoVariablesReplacedUrl & cfgMirrorlistUrl() const
Config file writing needs to tell them appart.
Definition: RepoInfo.cc:445
void setBaseUrl(Url url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:693
bool effectiveBaseUrlsEmpty() const
whether effective repository urls are available
Definition: RepoInfo.cc:706
Pathname path() const
Repository path.
Definition: RepoInfo.cc:792
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:526
Interface to gettext.
#define MIL
Definition: Logger.h:100
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:844
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:774
ZYPP_API detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
Definition: XmlEscape.h:51
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:674
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:529
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
Definition: RepoInfo.cc:783
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced) this is either rawBaseUrls()...
Definition: RepoInfo.cc:801
TriBool rawPkgGpgCheck() const
Definition: RepoInfo.cc:413
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:830
Implementation of the traditional SUSE media verifier.
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:31
#define _(MSG)
Definition: Gettext.h:39
void packagesPath(Pathname new_r)
Definition: RepoInfo.cc:460
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition: Url.cc:894
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:940
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
Definition: RepoInfo.cc:795
bool usesAutoMetadataPaths() const
Definition: RepoInfo.cc:463
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects...
Definition: RepoInfo.cc:722
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:535
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
Definition: curlhelper.cc:424
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like &#39;readlink&#39;.
Definition: PathInfo.cc:929
void rawGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:415
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:624
Url rawCfgMetalinkUrl() const
The configured raw metalink url.
Definition: RepoInfo.cc:659
RepoVariablesReplacedUrl _cfgMirrorlistUrl
Definition: RepoInfo.cc:431
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:29
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
const char * c_str() const
String representation.
Definition: Pathname.h:112
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Definition: RepoInfo.cc:506
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:567
int forEachLine(std::istream &str_r, const function< bool(int, std::string)> &consume_r)
Simple lineparser: Call functor consume_r for each line.
Definition: IOStream.cc:100
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:777
String related utilities and Regular expression matching.
std::vector< std::vector< Url > > groupedBaseUrls() const
Definition: RepoInfo.cc:226
bool hasContent() const
Definition: RepoInfo.cc:280
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
What is known about a repository.
Definition: RepoInfo.h:71
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:542
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:408
Helper to create and pass std::istream.
Definition: inputstream.h:56
std::string receiveLine()
Read one line from the input stream.
Request the standard behavior (as defined in zypp.conf or &#39;Job&#39;)
const RepoVariablesReplacedUrl & cfgMetalinkUrl() const
Config file writing needs to tell them appart.
Definition: RepoInfo.cc:448
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:39
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
Definition: RepoInfoBase.cc:98
void internalSetValidRepoSignature(TriBool value_r)
Definition: RepoInfo.cc:346
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:780
RepoVariablesReplacedUrl baseUrl() const
Definition: RepoInfo.cc:143
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Definition: RepoInfo.cc:332
#define OUTS(T, B)
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:549
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition: RepoInfo.cc:374
const_iterator begin() const
Iterator pointing to the first result.
Definition: Glob.h:197
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:589
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:810
bool seekToNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:194
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:819
size_type size() const
Definition: String.h:109
void setMirrorlistUrl(const Url &url)
Set the raw mirrorlist url.
Definition: RepoInfo.cc:650
Pathname _metadataPath
Definition: RepoInfo.cc:488
const std::string & asString() const
Definition: RepoType.cc:56
RepoVariablesReplacedUrlList _baseUrls
Definition: RepoInfo.cc:491
static Locale bestMatch(const LocaleSet &avLocales_r, Locale requested_r=Locale())
Return the best match for Locale requested_r within the available avLocales_r.
Definition: Locale.cc:213
Url url() const
Pars pro toto: The first repository url, this is either baseUrls().front() or if no baseUrl is define...
Definition: RepoInfo.cc:825
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:762
RepoInfo implementation.
Definition: RepoInfo.cc:78
bool empty() const
Test for an empty path.
Definition: Pathname.h:116
url_set effectiveBaseUrls() const
The complete set of effective repository urls.
Definition: RepoInfo.cc:711
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:744
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \, const Trim trim_r=NO_TRIM)
Split line_r into words.
Definition: String.h:602
std::string asString() const
Returns a default string representation of the Url object.
Definition: Url.cc:515
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:768
Url rawCfgMirrorlistUrl() const
The configured raw mirrorlist url.
Definition: RepoInfo.cc:656
GpgCheck
Some predefined settings.
Definition: RepoInfo.h:419
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1243
std::string repoStatusString() const
Definition: RepoInfo.cc:265
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:564
Pathname packagesPath() const
Definition: RepoInfo.cc:473
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
url_set _effectiveBaseUrls
Definition: RepoInfo.cc:492
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
Definition: UserData.h:119
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition: RepoInfo.cc:552
RepoVariablesReplacedUrlList & baseUrls()
Definition: RepoInfo.cc:252
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:560
const std::string & asString() const
String representation.
Definition: Pathname.h:93
TriBool triBoolFromPath(const Pathname &path_r) const
Definition: RepoInfo.cc:400
std::string alias() const
unique identifier for this source.
bool isExist() const
Return whether valid stat info exists.
Definition: PathInfo.h:286
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
Definition: String.cc:374
void addContent(const std::string &keyword_r)
Definition: RepoInfo.cc:277
bool gpgCheck() const
Turn signature checking on/off (on)
Definition: ZConfig.cc:1241
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:91
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:765
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:716
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:582
Pathname dirname() const
Return all but the last component od this path.
Definition: Pathname.h:126
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:930
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:738
#define WAR
Definition: Logger.h:101
RepoVariablesReplacedUrl _cfgMetalinkUrl
Definition: RepoInfo.cc:432
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition: RepoInfo.cc:726
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:822
RepoVariablesReplacedUrlList & gpgKeyUrls()
Definition: RepoInfo.cc:262
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
Definition: String.h:1156
int close() override
Wait for the progamm to complete.
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition: RepoInfo.cc:574
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:719
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1242
bool gpgCheck() const
Whether default signature checking should be performed.
Definition: RepoInfo.cc:539
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
Definition: RepoInfo.cc:406
TriBool _validRepoSignature
have signed and valid repo metadata
Definition: RepoInfo.cc:427
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:836
std::pair< FalseBool, std::set< std::string > > _keywords
Definition: RepoInfo.cc:494
Pathname predownloadPath() const
Definition: RepoInfo.cc:480
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:735
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:886
bool baseurl2dump() const
Definition: RepoInfo.cc:255
std::vector< std::vector< Url > > groupedBaseUrls() const
Returns the currently known effective baseUrls in groups, where each group contains a primary base ur...
Definition: RepoInfo.cc:807
bool empty() const
Whether matches were found.
Definition: Glob.h:189
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
std::string asString(const Url &url_r)
Definition: Url.cc:948
url_set::size_type urls_size_type
Definition: RepoInfo.h:109
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:580
bool seekToEndNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:214
const RepoVariablesReplacedUrlList & baseUrls() const
Definition: RepoInfo.cc:153
TriBool cfgPkgGpgCheck() const
Definition: RepoInfo.cc:423
std::ostream & dumpOn(std::ostream &str) const override
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:966
std::list< Url > url_set
Definition: RepoInfo.h:108
bool cfgGpgCheck() const
Definition: RepoInfo.cc:419
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:407
bool requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
Definition: RepoInfo.cc:1143
Find pathnames matching a pattern.
Definition: Glob.h:57
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:750
std::vector< std::string > Arguments
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:110
int unlink(const Pathname &path)
Like &#39;unlink&#39;.
Definition: PathInfo.cc:705
static const RepoType NONE
Definition: RepoType.h:33
std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const override
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:1079
static const unsigned noPriority
Definition: RepoInfo.cc:98
repo::RepoType type() const
Definition: RepoInfo.cc:109
repo::RepoType _type
Definition: RepoInfo.cc:428
Pathname predownloadPath() const
Path where this repo packages are predownloaded.
Definition: RepoInfo.cc:732
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition: RepoInfo.cc:756
int add(const Pathname &pattern_r, Flags flags_r=Flags())
Add pathnames matching pattern_r to the current result.
Definition: Glob.h:155
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:729
void resetEffectiveUrls() const
Definition: RepoInfo.cc:164
zypp::Url Url
Definition: url.h:15
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:50
static bool urlSupportsMirrorLink(const zypp::Url &url)
void setMetalinkUrl(const Url &url)
Set the raw metalink url.
Definition: RepoInfo.cc:653
static const RepoType RPMMD
Definition: RepoType.h:30
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:671
const std::set< std::string > & contentKeywords() const
Definition: RepoInfo.cc:274
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like &#39;symlink&#39;.
Definition: PathInfo.cc:860
void setProbedType(const repo::RepoType &t) const
Definition: RepoInfo.cc:103
static const RepoType YAST2
Definition: RepoType.h:31
bool hasSuffix(const C_Str &str_r, const C_Str &suffix_r)
Return whether str_r has suffix suffix_r.
Definition: String.h:1112
void rawRepoGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:416
std::chrono::steady_clock::time_point _lastEffectiveUrlsUpdate
Definition: RepoInfo.cc:493
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:789
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:741
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:851
Base class for Exception.
Definition: Exception.h:152
std::ostream & dumpAsIniOn(std::ostream &str) const override
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:1015
Impl & operator=(const Impl &)=delete
Url location() const
Returns the location URL for the repository, this is either the first configured baseUrl or a configu...
Definition: RepoInfo.cc:804
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value...
Definition: Reader.cc:122
void addBaseUrl(Url url)
Add a base url.
Definition: RepoInfo.cc:683
void setMirrorlistUrl(const Url &url_r)
Definition: RepoInfo.cc:438
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Definition: RepoInfo.cc:259
std::string name() const
Repository name.
void pathNameSetTrailingSlash(bool apply_r=true)
Apply or remove a trailing &#39;/&#39; from pathName.
Definition: Url.cc:829
std::string asString() const
Explicit conversion to std::string.
Definition: XmlString.h:77
Pathname licenseTgz(const std::string &name_r) const
Path to a license tarball in case it exists in the repo.
Definition: RepoInfo.cc:118
void setType(const repo::RepoType &t)
Definition: RepoInfo.cc:100
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)? I.e.
Definition: RepoInfo.cc:368
RepoVariablesReplacedUrlList _gpgKeyUrls
Definition: RepoInfo.cc:496
Typesafe passing of user data via callbacks.
Definition: UserData.h:39
TriBool rawRepoGpgCheck() const
Definition: RepoInfo.cc:412
DefaultIntegral< unsigned, defaultPriority > priority
Definition: RepoInfo.cc:485
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:798
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:753
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:700
std::string targetDistro
Definition: RepoInfo.cc:455
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:225
~RepoInfo() override
Definition: RepoInfo.cc:523
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:85
std::string repoStatusString() const
A string value to track changes requiring a refresh.
Definition: RepoInfo.cc:680
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:813
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:833
void rawPkgGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:417
static const RepoType RPMPLAINDIR
Definition: RepoType.h:32
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:816
void setMetalinkUrl(const Url &url_r)
Definition: RepoInfo.cc:441
const std::vector< Url > & getUrls() const
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
Definition: Url.cc:493
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:771
Pathname metadataPath() const
Definition: RepoInfo.cc:466
TriBool rawGpgCheck() const
Definition: RepoInfo.cc:411
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
static const unsigned defaultPriority
Definition: RepoInfo.cc:97
url_set & effectiveBaseUrls() const
Definition: RepoInfo.cc:169
Impl * clone() const
clone for RWCOW_pointer
Definition: RepoInfo.cc:500
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:532
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:1098
url_set baseUrls() const
The complete set of repository urls as configured.
Definition: RepoInfo.cc:786
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:570
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:759
TriBool cfgRepoGpgCheck() const
Definition: RepoInfo.cc:421
const char * c_str() const
Definition: IdStringType.h:107
Pathname _packagesPath
Definition: RepoInfo.cc:489
bool effectiveKeepPackages() const
keepPackages unless the package cache itself enforces keeping the packages.
Definition: RepoInfo.cc:747
Url location() const
Definition: RepoInfo.cc:158
Url manipulation class.
Definition: Url.h:92
void metadataPath(Pathname new_r)
Definition: RepoInfo.cc:457
#define DBG
Definition: Logger.h:99
std::string service
Definition: RepoInfo.cc:454
Repository type enumeration.
Definition: RepoType.h:28
bool hasContent(const std::string &keyword_r) const
Definition: RepoInfo.cc:325