libzypp  17.37.10
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 ( !mirrorUrls().empty() ){
148  return RepoVariablesReplacedUrl( _mirrorUrls.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 resetMirrorUrls() const {
165  _mirrorUrls.clear ();
166  _lastMirrorUrlsUpdate = std::chrono::steady_clock::time_point::min();
167  }
168 
175  {
176  if ( !_mirrorUrls.empty()
177  && ( std::chrono::steady_clock::now() - _lastMirrorUrlsUpdate < std::chrono::hours(1) ) )
178  return _mirrorUrls;
179 
180  _mirrorUrls.clear();
181  _lastMirrorUrlsUpdate = std::chrono::steady_clock::now();
182 
183  bool isAutoMirrorList = false; // bsc#1243901 Allows mirrorlist parsing to fail if automatically switched on
184 
185  Url mlurl( mirrorListUrl().transformed() ); // Variables replaced!
186  if ( mlurl.asString().empty()
187  && _baseUrls.raw().size() == 1
188  && repo::RepoMirrorList::urlSupportsMirrorLink( *_baseUrls.transformedBegin() ) ) {
189 
190  mlurl = *_baseUrls.transformedBegin ();
191  mlurl.pathNameSetTrailingSlash();
192  mlurl.setQueryParam("mirrorlist", std::string() );
193 
194  MIL << "Detected opensuse.org baseUrl with no mirrors, requesting them from : " << mlurl.asString() << std::endl;
195  isAutoMirrorList = true;
196  }
197 
198  if ( !mlurl.asString().empty() ) {
199  try {
200  DBG << "MetadataPath: " << metadataPath() << endl;
201  repo::RepoMirrorList rmurls( mlurl, metadataPath() );
202 
203  // propagate internally used URL params like 'proxy' to the mirrors
204  const auto &tf = [urlTemplate =mirrorListUrl().transformed()]( const zypp::Url &in ){
205  return internal::propagateQueryParams ( in , urlTemplate );
206  };
207  _mirrorUrls.insert( _mirrorUrls.end(), make_transform_iterator( rmurls.getUrls().begin(), tf ), make_transform_iterator( rmurls.getUrls().end(), tf ) );
208  } catch ( const zypp::Exception & e ) {
209  // failed to fetch the mirrorlist/metalink, if we still have a baseUrl we can go on, otherwise this is a error
210  MIL << "Mirrorlist failed, repo either returns invalid data or has no mirrors at all!" << std::endl;
211  if ( !isAutoMirrorList ) {
213  data.set("error", e );
214  JobReport::warning( _("Failed to fetch mirrorlist/metalink data."), data );
215  }
216  }
217  }
218  return _mirrorUrls;
219  }
220 
222  {
223  MirroredOriginSet origins;
224  origins.addEndpoints( _baseUrls.transformedBegin(), _baseUrls.transformedEnd() );
225 
226  const auto &mirrs = mirrorUrls ();
227  origins.addEndpoints( mirrs.begin(), mirrs.end() );
228 
229  return origins;
230  }
231 
233  { return _baseUrls; }
234 
235  bool baseurl2dump() const
236  { return !_baseUrls.empty(); }
237 
238 
240  { return _gpgKeyUrls; }
241 
243  { return _gpgKeyUrls; }
244 
245  std::string repoStatusString() const
246  {
247  if ( mirrorListUrl().transformed().isValid() )
248  return mirrorListUrl().transformed().asString();
249  if ( !baseUrls().empty() )
250  return (*baseUrls().transformedBegin()).asString();
251  return std::string();
252  }
253 
254  const std::set<std::string> & contentKeywords() const
255  { hasContent()/*init if not yet done*/; return _keywords.second; }
256 
257  void addContent( const std::string & keyword_r )
258  { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
259 
260  bool hasContent() const
261  {
262  if ( !_keywords.first && ! metadataPath().empty() )
263  {
264  // HACK directly check master index file until RepoManager offers
265  // some content probing and zypper uses it.
267  MIL << "Empty keywords...." << metadataPath() << endl;
268  Pathname master;
269  if ( PathInfo( (master=metadataPath()/"/repodata/repomd.xml") ).isFile() )
270  {
271  //MIL << "GO repomd.." << endl;
272  xml::Reader reader( master );
273  while ( reader.seekToNode( 2, "content" ) )
274  {
275  _keywords.second.insert( reader.nodeText().asString() );
276  reader.seekToEndNode( 2, "content" );
277  }
278  _keywords.first = true; // valid content in _keywords even if empty
279  }
280  else if ( PathInfo( (master=metadataPath()/"/content") ).isFile() )
281  {
282  //MIL << "GO content.." << endl;
283  iostr::forEachLine( InputStream( master ),
284  [this]( int num_r, const std::string& line_r )->bool
285  {
286  if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
287  {
288  std::vector<std::string> words;
289  if ( str::split( line_r, std::back_inserter(words) ) > 1
290  && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
291  {
292  this->_keywords.second.insert( ++words.begin(), words.end() );
293  }
294  return true; // mult. occurrances are ok.
295  }
296  return( ! str::startsWith( line_r, "META " ) ); // no need to parse into META section.
297  } );
298  _keywords.first = true; // valid content in _keywords even if empty
299  }
301  }
302  return _keywords.first;
303  }
304 
305  bool hasContent( const std::string & keyword_r ) const
306  { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
307 
313  {
314  if ( ! indeterminate(_validRepoSignature) )
315  return _validRepoSignature;
316  // check metadata:
317  if ( ! metadataPath().empty() )
318  {
319  // A missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
320  TriBool linkval = triBoolFromPath( metadataPath() / ".repo_gpgcheck" );
321  return linkval;
322  }
323  return indeterminate;
324  }
325 
327  {
328  if ( PathInfo(metadataPath()).isDir() )
329  {
330  Pathname gpgcheckFile( metadataPath() / ".repo_gpgcheck" );
331  if ( PathInfo(gpgcheckFile).isExist() )
332  {
333  TriBool linkval( indeterminate );
334  if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
335  return; // existing symlink fits value_r
336  else
337  filesystem::unlink( gpgcheckFile ); // will write a new one
338  }
339  filesystem::symlink( asString(value_r), gpgcheckFile );
340  }
341  _validRepoSignature = value_r;
342  }
343 
349  {
350  TriBool linkval( true ); // want to see it being switched to indeterminate
351  return triBoolFromPath( metadataPath() / ".repo_gpgcheck", linkval ) && indeterminate(linkval);
352  }
353 
354  bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
355  {
356  static const Pathname truePath( "true" );
357  static const Pathname falsePath( "false" );
358  static const Pathname indeterminatePath( "indeterminate" );
359 
360  // Quiet readlink;
361  static const ssize_t bufsiz = 63;
362  static char buf[bufsiz+1];
363  ssize_t ret = ::readlink( path_r.c_str(), buf, bufsiz );
364  buf[ret == -1 ? 0 : ret] = '\0';
365 
366  Pathname linkval( buf );
367 
368  bool known = true;
369  if ( linkval == truePath )
370  ret_r = true;
371  else if ( linkval == falsePath )
372  ret_r = false;
373  else if ( linkval == indeterminatePath )
374  ret_r = indeterminate;
375  else
376  known = false;
377  return known;
378  }
379 
380  TriBool triBoolFromPath( const Pathname & path_r ) const
381  { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
382 
384 
385  private:
389 
390  public:
391  TriBool rawGpgCheck() const { return _rawGpgCheck; }
394 
395  void rawGpgCheck( TriBool val_r ) { _rawGpgCheck = val_r; }
396  void rawRepoGpgCheck( TriBool val_r ) { _rawRepoGpgCheck = val_r; }
397  void rawPkgGpgCheck( TriBool val_r ) { _rawPkgGpgCheck = val_r; }
398 
399  bool cfgGpgCheck() const
400  { return indeterminate(_rawGpgCheck) ? ZConfig::instance().gpgCheck() : (bool)_rawGpgCheck; }
402  { return indeterminate(_rawGpgCheck) && indeterminate(_rawRepoGpgCheck) ? ZConfig::instance().repoGpgCheck() : _rawRepoGpgCheck; }
404  { return indeterminate(_rawGpgCheck) && indeterminate(_rawPkgGpgCheck) ? ZConfig::instance().pkgGpgCheck() : _rawPkgGpgCheck; }
405 
406  private:
409 
410  private:
413  public:
416  { return _cfgMirrorlistUrl.transformed().isValid() ? _cfgMirrorlistUrl : _cfgMetalinkUrl; }
417 
418  void setMirrorlistUrl( const Url & url_r ) // Raw
419  { _cfgMirrorlistUrl.raw() = url_r; }
420 
421  void setMetalinkUrl( const Url & url_r ) // Raw
422  { _cfgMetalinkUrl.raw() = url_r; }
423 
426  { return _cfgMirrorlistUrl; }
429  { return _cfgMetalinkUrl; }
430 
431  public:
434  std::string service;
435  std::string targetDistro;
436 
437  void metadataPath( Pathname new_r )
438  { _metadataPath = std::move( new_r ); }
439 
440  void packagesPath( Pathname new_r )
441  { _packagesPath = std::move( new_r ); }
442 
444  { return str::hasSuffix( _metadataPath.asString(), "/%AUTO%" ); }
445 
447  {
448  if ( usesAutoMetadataPaths() )
449  return _metadataPath.dirname() / "%RAW%";
450  return _metadataPath;
451  }
452 
454  {
456  return _metadataPath.dirname() / "%PKG%";
457  return _packagesPath;
458  }
459 
461  {
462  return packagesPath() / ".preload";
463  }
464 
466 
467  private:
470 
471  mutable RepoVariablesReplacedUrlList _baseUrls; //< baseUrls as configured
472 
473  mutable url_set _mirrorUrls; //< possible mirrors as fetched via mirrorlist or metalink
474  mutable std::chrono::steady_clock::time_point _lastMirrorUrlsUpdate = std::chrono::steady_clock::time_point::min();
475  mutable std::vector<MirroredOrigin> _repoOrigins;
476 
477  mutable std::pair<FalseBool, std::set<std::string> > _keywords;
478 
480 
481  friend Impl * rwcowClone<Impl>( const Impl * rhs );
483  Impl * clone() const
484  { return new Impl( *this ); }
485  };
487 
489  inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
490  {
491  return str << "RepoInfo::Impl";
492  }
493 
495  //
496  // CLASS NAME : RepoInfo
497  //
499 
501 
503  : _pimpl( new Impl() )
504  {}
505 
507  {}
508 
509  unsigned RepoInfo::priority() const
510  { return _pimpl->priority; }
511 
513  { return Impl::defaultPriority; }
514 
516  { return Impl::noPriority; }
517 
518  void RepoInfo::setPriority( unsigned newval_r )
519  { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
520 
521 
522  bool RepoInfo::gpgCheck() const
523  { return _pimpl->cfgGpgCheck(); }
524 
526  { _pimpl->rawGpgCheck( value_r ); }
527 
528  void RepoInfo::setGpgCheck( bool value_r ) // deprecated legacy and for squid
529  { setGpgCheck( TriBool(value_r) ); }
530 
531 
533  { return gpgCheck() || bool(_pimpl->cfgRepoGpgCheck()); }
534 
536  {
537  bool ret = ( gpgCheck() && indeterminate(_pimpl->cfgRepoGpgCheck()) ) || bool(_pimpl->cfgRepoGpgCheck());
538  if ( ret && _pimpl->internalUnsignedConfirmed() ) // relax if unsigned repo was confirmed in the past
539  ret = false;
540  return ret;
541  }
542 
544  { _pimpl->rawRepoGpgCheck( value_r ); }
545 
546 
548  { return bool(_pimpl->cfgPkgGpgCheck()) || ( gpgCheck() && !bool(validRepoSignature())/*enforced*/ ) ; }
549 
551  { return bool(_pimpl->cfgPkgGpgCheck()) || ( gpgCheck() && indeterminate(_pimpl->cfgPkgGpgCheck()) && !bool(validRepoSignature())/*enforced*/ ); }
552 
554  { _pimpl->rawPkgGpgCheck( value_r ); }
555 
556 
557  void RepoInfo::getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const
558  {
559  g_r = _pimpl->rawGpgCheck();
560  r_r = _pimpl->rawRepoGpgCheck();
561  p_r = _pimpl->rawPkgGpgCheck();
562  }
563 
564 
566  {
568  if ( ret && !repoGpgCheck() ) ret = false; // invalidate any old signature if repoGpgCheck is off
569  return ret;
570  }
571 
573  { _pimpl->internalSetValidRepoSignature( value_r ); }
574 
576  namespace
577  {
578  inline bool changeGpgCheckTo( TriBool & lhs, TriBool rhs )
579  { if ( ! sameTriboolState( lhs, rhs ) ) { lhs = rhs; return true; } return false; }
580 
581  inline bool changeGpgCheckTo( TriBool ogpg[3], TriBool g, TriBool r, TriBool p )
582  {
583  bool changed = false;
584  if ( changeGpgCheckTo( ogpg[0], g ) ) changed = true;
585  if ( changeGpgCheckTo( ogpg[1], r ) ) changed = true;
586  if ( changeGpgCheckTo( ogpg[2], p ) ) changed = true;
587  return changed;
588  }
589  } // namespace
592  {
593  TriBool ogpg[3]; // Gpg RepoGpg PkgGpg
594  getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
595 
596  bool changed = false;
597  switch ( mode_r )
598  {
599  case GpgCheck::On:
600  changed = changeGpgCheckTo( ogpg, true, indeterminate, indeterminate );
601  break;
602  case GpgCheck::Strict:
603  changed = changeGpgCheckTo( ogpg, true, true, true );
604  break;
606  changed = changeGpgCheckTo( ogpg, true, false, false );
607  break;
609  changed = changeGpgCheckTo( ogpg, true, false, indeterminate );
610  break;
612  changed = changeGpgCheckTo( ogpg, true, indeterminate, false );
613  break;
614  case GpgCheck::Default:
615  changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
616  break;
617  case GpgCheck::Off:
618  changed = changeGpgCheckTo( ogpg, false, indeterminate, indeterminate );
619  break;
620  case GpgCheck::indeterminate: // no change
621  break;
622  }
623 
624  if ( changed )
625  {
626  setGpgCheck ( ogpg[0] );
627  setRepoGpgCheck( ogpg[1] );
628  setPkgGpgCheck ( ogpg[2] );
629  }
630  return changed;
631  }
632 
633  void RepoInfo::setMirrorlistUrl( const Url & url_r ) // Raw
634  { _pimpl->setMirrorlistUrl( url_r ); }
635 
636  void RepoInfo::setMetalinkUrl( const Url & url_r ) // Raw
637  { _pimpl->setMetalinkUrl( url_r ); }
638 
640  { return _pimpl->cfgMirrorlistUrl().raw(); }
641 
643  { return _pimpl->cfgMetalinkUrl().raw(); }
644 
645 #if LEGACY(1735)
646  void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
647  { setMirrorlistUrl( url_r ); }
648  void RepoInfo::setMirrorListUrls( url_set urls ) // Raw
649  { _pimpl->setMirrorlistUrl( urls.empty() ? Url() : urls.front() ); }
650  void RepoInfo::setMetalinkUrls( url_set urls ) // Raw
651  { _pimpl->setMetalinkUrl( urls.empty() ? Url() : urls.front() ); }
652 #endif
653 
655  { _pimpl->gpgKeyUrls().raw().swap( urls ); }
656 
657  void RepoInfo::setGpgKeyUrl( const Url & url_r )
658  {
659  _pimpl->gpgKeyUrls().raw().clear();
660  _pimpl->gpgKeyUrls().raw().push_back( url_r );
661  }
662 
663  std::string RepoInfo::repoStatusString() const
664  { return _pimpl->repoStatusString(); }
665 
666  void RepoInfo::addBaseUrl( Url url_r )
667  {
668  for ( const auto & url : _pimpl->baseUrls().raw() ) // Raw unique!
669  if ( url == url_r )
670  return;
671 
672  _pimpl->baseUrls().raw().push_back( url_r );
674  }
675 
676  void RepoInfo::setBaseUrl( Url url_r )
677  {
678  _pimpl->baseUrls().raw().clear();
680  _pimpl->baseUrls().raw().push_back( std::move(url_r) );
681  }
682 
684  {
686  _pimpl->baseUrls().raw().swap( urls );
687  }
688 
690  {
691  return _pimpl->repoOrigins();
692  }
693 
695  {
696  return ( _pimpl->baseUrls().empty () && _pimpl->mirrorUrls().empty() );
697  }
698 
699  void RepoInfo::setPath( const Pathname &path )
700  { _pimpl->path = path; }
701 
703  { _pimpl->setType( t ); }
704 
706  { _pimpl->setProbedType( t ); }
707 
708 
710  { _pimpl->metadataPath( path ); }
711 
713  { _pimpl->packagesPath( path ); }
714 
716  { return _pimpl->predownloadPath(); }
717 
718  void RepoInfo::setKeepPackages( bool keep )
719  { _pimpl->keeppackages = keep; }
720 
721  void RepoInfo::setService( const std::string& name )
722  { _pimpl->service = name; }
723 
724  void RepoInfo::setTargetDistribution( const std::string & targetDistribution )
726 
728  { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
729 
731  { return keepPackages() || PathInfo(packagesPath().dirname()/".keep_packages").isExist(); }
732 
734  { return _pimpl->metadataPath(); }
735 
737  { return _pimpl->packagesPath(); }
738 
740  { return _pimpl->usesAutoMetadataPaths(); }
741 
743  { return _pimpl->type(); }
744 
745  Url RepoInfo::mirrorListUrl() const // Variables replaced!
746  { return _pimpl->mirrorListUrl().transformed(); }
747 
749  { return _pimpl->mirrorListUrl().raw(); }
750 
752  { return _pimpl->gpgKeyUrls().empty(); }
753 
755  { return _pimpl->gpgKeyUrls().size(); }
756 
757  RepoInfo::url_set RepoInfo::gpgKeyUrls() const // Variables replaced!
758  { return _pimpl->gpgKeyUrls().transformed(); }
759 
761  { return _pimpl->gpgKeyUrls().raw(); }
762 
763  Url RepoInfo::gpgKeyUrl() const // Variables replaced!
764  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
765 
767  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
768 
769  RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
770  { return _pimpl->baseUrls().transformed(); }
771 
773  { return _pimpl->baseUrls().raw(); }
774 
776  { return _pimpl->path; }
777 
778  std::string RepoInfo::service() const
779  { return _pimpl->service; }
780 
781  std::string RepoInfo::targetDistribution() const
782  { return _pimpl->targetDistro; }
783 
785  { return _pimpl->baseUrl().raw(); }
786 
788  { return _pimpl->location (); }
789 
791  { return _pimpl->baseUrls().transformedBegin(); }
792 
794  { return _pimpl->baseUrls().transformedEnd(); }
795 
797  { return _pimpl->baseUrls().size(); }
798 
800  { return _pimpl->baseUrls().empty(); }
801 
802  bool RepoInfo::baseUrlSet() const
803  { return _pimpl->baseurl2dump(); }
804 
806  {
807  return _pimpl->baseUrl().transformed();
808  }
809 
810  const std::set<std::string> & RepoInfo::contentKeywords() const
811  { return _pimpl->contentKeywords(); }
812 
813  void RepoInfo::addContent( const std::string & keyword_r )
814  { _pimpl->addContent( keyword_r ); }
815 
816  bool RepoInfo::hasContent() const
817  { return _pimpl->hasContent(); }
818 
819  bool RepoInfo::hasContent( const std::string & keyword_r ) const
820  { return _pimpl->hasContent( keyword_r ); }
821 
823 
824  bool RepoInfo::hasLicense() const
825  { return hasLicense( std::string() ); }
826 
827  bool RepoInfo::hasLicense( const std::string & name_r ) const
828  { return !_pimpl->licenseTgz( name_r ).empty(); }
829 
830 
832  { return needToAcceptLicense( std::string() ); }
833 
834  bool RepoInfo::needToAcceptLicense( const std::string & name_r ) const
835  {
836  const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
837  if ( licenseTgz.empty() )
838  return false; // no licenses at all
839 
841  cmd.push_back( "tar" );
842  cmd.push_back( "-t" );
843  cmd.push_back( "-z" );
844  cmd.push_back( "-f" );
845  cmd.push_back( licenseTgz.asString() );
847 
848  bool accept = true;
849  static const std::string noAcceptanceFile = "no-acceptance-needed\n";
850  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
851  {
852  if ( output == noAcceptanceFile )
853  {
854  accept = false;
855  }
856  }
857  prog.close();
858  MIL << "License(" << name_r << ") in " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
859  return accept;
860  }
861 
862 
863  std::string RepoInfo::getLicense( const Locale & lang_r )
864  { return const_cast<const RepoInfo *>(this)->getLicense( std::string(), lang_r ); }
865 
866  std::string RepoInfo::getLicense( const Locale & lang_r ) const
867  { return getLicense( std::string(), lang_r ); }
868 
869  std::string RepoInfo::getLicense( const std::string & name_r, const Locale & lang_r ) const
870  {
871  LocaleSet avlocales( getLicenseLocales( name_r ) );
872  if ( avlocales.empty() )
873  return std::string();
874 
875  Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
876  if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
877  {
878  WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
879  // Using the fist locale instead of returning no text at all.
880  // So the user might recognize that there is a license, even if they
881  // can't read it.
882  getLang = *avlocales.begin();
883  }
884 
885  // now extract the license file.
886  static const std::string licenseFileFallback( "license.txt" );
887  std::string licenseFile( !getLang ? licenseFileFallback
888  : str::form( "license.%s.txt", getLang.c_str() ) );
889 
891  cmd.push_back( "tar" );
892  cmd.push_back( "-x" );
893  cmd.push_back( "-z" );
894  cmd.push_back( "-O" );
895  cmd.push_back( "-f" );
896  cmd.push_back( _pimpl->licenseTgz( name_r ).asString() ); // if it not exists, avlocales was empty.
897  cmd.push_back( licenseFile );
898 
899  std::string ret;
901  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
902  {
903  ret += output;
904  }
905  prog.close();
906  return ret;
907  }
908 
909 
911  { return getLicenseLocales( std::string() ); }
912 
913  LocaleSet RepoInfo::getLicenseLocales( const std::string & name_r ) const
914  {
915  const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
916  if ( licenseTgz.empty() )
917  return LocaleSet();
918 
920  cmd.push_back( "tar" );
921  cmd.push_back( "-t" );
922  cmd.push_back( "-z" );
923  cmd.push_back( "-f" );
924  cmd.push_back( licenseTgz.asString() );
925 
926  LocaleSet ret;
928  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
929  {
930  static const C_Str license( "license." );
931  static const C_Str dotTxt( ".txt\n" );
932  if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
933  {
934  if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
935  ret.insert( Locale() );
936  else
937  ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
938  }
939  }
940  prog.close();
941  return ret;
942  }
943 
945 
946  std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
947  {
949  if ( _pimpl->baseurl2dump() )
950  {
951  for ( const auto & url : _pimpl->baseUrls().raw() )
952  {
953  str << "- url : " << url << std::endl;
954  }
955  }
956 
957  // print if non empty value
958  auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
959  if ( ! value_r.empty() )
960  str << tag_r << value_r << std::endl;
961  });
962 
963  strif( "- mirrorlist : ", _pimpl->cfgMirrorlistUrl().raw().asString() );
964  strif( "- metalink : ", _pimpl->cfgMetalinkUrl().raw().asString() );
965  strif( "- path : ", path().asString() );
966  str << "- type : " << type() << std::endl;
967  str << "- priority : " << priority() << std::endl;
968 
969  // Yes No Default(Y) Default(N)
970 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
971  str << "- gpgcheck : " << OUTS(_pimpl->rawGpgCheck(),gpgCheck())
972  << " repo" << OUTS(_pimpl->rawRepoGpgCheck(),repoGpgCheck()) << (repoGpgCheckIsMandatory() ? "* ": " " )
973  << "sig" << asString( validRepoSignature(), "?", "Y", "N" )
974  << " pkg" << OUTS(_pimpl->rawPkgGpgCheck(),pkgGpgCheck()) << (pkgGpgCheckIsMandatory() ? "* ": " " )
975  << std::endl;
976 #undef OUTS
977 
978  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
979  {
980  str << "- gpgkey : " << url << std::endl;
981  }
982 
983  if ( ! indeterminate(_pimpl->keeppackages) )
984  str << "- keeppackages: " << keepPackages() << std::endl;
985 
986  strif( "- service : ", service() );
987  strif( "- targetdistro: ", targetDistribution() );
988  strif( "- filePath: ", filepath().asString() );
989  strif( "- metadataPath: ", metadataPath().asString() );
990  strif( "- packagesPath: ", packagesPath().asString() );
991 
992  return str;
993  }
994 
995  std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
996  {
997  // libzypp/#638: Add a note to service maintained repo entries
998  if( ! service().empty() ) {
999  str << "# Repository '"<<alias()<<"' is maintained by the '"<<service()<<"' service." << endl;
1000  str << "# Manual changes may be overwritten by a service refresh." << endl;
1001  str << "# See also 'man zypper', section 'Services'." << endl;
1002  }
1003  RepoInfoBase::dumpAsIniOn(str);
1004 
1005  if ( _pimpl->baseurl2dump() )
1006  {
1007  str << "baseurl=";
1008  std::string indent;
1009  for ( const auto & url : _pimpl->baseUrls().raw() )
1010  {
1011  str << indent << hotfix1050625::asString( url ) << endl;
1012  if ( indent.empty() ) indent = " "; // "baseurl="
1013  }
1014  }
1015 
1016  if ( ! _pimpl->path.empty() )
1017  str << "path="<< path() << endl;
1018 
1019  if ( ! _pimpl->cfgMirrorlistUrl().raw().asString().empty() )
1020  str << "mirrorlist=" << hotfix1050625::asString( _pimpl->cfgMirrorlistUrl().raw() ) << endl;
1021 
1022  if ( ! _pimpl->cfgMetalinkUrl().raw().asString().empty() )
1023  str << "metalink=" << hotfix1050625::asString( _pimpl->cfgMetalinkUrl().raw() ) << endl;
1024 
1025  if ( type() != repo::RepoType::NONE )
1026  str << "type=" << type().asString() << endl;
1027 
1028  if ( priority() != defaultPriority() )
1029  str << "priority=" << priority() << endl;
1030 
1031  if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1032  str << "gpgcheck=" << (_pimpl->rawGpgCheck() ? "1" : "0") << endl;
1033 
1034  if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1035  str << "repo_gpgcheck=" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << endl;
1036 
1037  if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1038  str << "pkg_gpgcheck=" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << endl;
1039 
1040  {
1041  std::string indent( "gpgkey=");
1042  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
1043  {
1044  str << indent << url << endl;
1045  if ( indent[0] != ' ' )
1046  indent = " ";
1047  }
1048  }
1049 
1050  if (!indeterminate(_pimpl->keeppackages))
1051  str << "keeppackages=" << keepPackages() << endl;
1052 
1053  if( ! service().empty() )
1054  str << "service=" << service() << endl;
1055 
1056  return str;
1057  }
1058 
1059  std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
1060  {
1061  std::string tmpstr;
1062  str
1063  << "<repo"
1064  << " alias=\"" << escape(alias()) << "\""
1065  << " name=\"" << escape(name()) << "\"";
1066  if (type() != repo::RepoType::NONE)
1067  str << " type=\"" << type().asString() << "\"";
1068  str
1069  << " priority=\"" << priority() << "\""
1070  << " enabled=\"" << enabled() << "\""
1071  << " autorefresh=\"" << autorefresh() << "\""
1072  << " gpgcheck=\"" << gpgCheck() << "\""
1073  << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
1074  << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
1075  if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1076  str << " raw_gpgcheck=\"" << (_pimpl->rawGpgCheck() ? "1" : "0") << "\"";
1077  if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1078  str << " raw_repo_gpgcheck=\"" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << "\"";
1079  if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1080  str << " raw_pkg_gpgcheck=\"" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << "\"";
1081  if (!(tmpstr = gpgKeyUrl().asString()).empty())
1082  str << " gpgkey=\"" << escape(tmpstr) << "\"";
1083  if ( ! (tmpstr = _pimpl->cfgMirrorlistUrl().transformed().asString()).empty() )
1084  str << " mirrorlist=\"" << escape(tmpstr) << "\"";
1085  if ( ! (tmpstr = _pimpl->cfgMetalinkUrl().transformed().asString()).empty() )
1086  str << " metalink=\"" << escape(tmpstr) << "\"";
1087  str << ">" << endl;
1088 
1089  if ( _pimpl->baseurl2dump() )
1090  {
1091  for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
1092  str << "<url>" << escape((*it).asString()) << "</url>" << endl;
1093  }
1094 
1095  str << "</repo>" << endl;
1096  return str;
1097  }
1098 
1099 
1100  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
1101  {
1102  return obj.dumpOn(str);
1103  }
1104 
1105  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj )
1106  {
1107  switch ( obj )
1108  {
1109 #define OUTS( V ) case RepoInfo::V: return str << #V; break
1110  OUTS( GpgCheck::On );
1111  OUTS( GpgCheck::Strict );
1112  OUTS( GpgCheck::AllowUnsigned );
1113  OUTS( GpgCheck::AllowUnsignedRepo );
1114  OUTS( GpgCheck::AllowUnsignedPackage );
1116  OUTS( GpgCheck::Off );
1117  OUTS( GpgCheck::indeterminate );
1118 #undef OUTS
1119  }
1120  return str << "GpgCheck::UNKNOWN";
1121  }
1122 
1124  {
1125  // We skip the check for downloading media unless a local copy of the
1126  // media file exists and states that there is more than one medium.
1127  const auto &origins = _pimpl->repoOrigins ();
1128  bool canSkipMediaCheck = std::all_of( origins.begin(), origins.end(), []( const MirroredOrigin &origin ) { return origin.authority().url().schemeIsDownloading(); });
1129  if ( canSkipMediaCheck ) {
1130  const auto &mDataPath = metadataPath();
1131  if ( not mDataPath.empty() ) {
1132  PathInfo mediafile { mDataPath/"media.1/media" };
1133  if ( mediafile.isExist() ) {
1134  repo::SUSEMediaVerifier lverifier { mediafile.path() };
1135  if ( lverifier && lverifier.totalMedia() > 1 ) {
1136  canSkipMediaCheck = false;
1137  }
1138  }
1139  }
1140  }
1141  if ( canSkipMediaCheck )
1142  DBG << "Can SKIP media.1/media check for status calc of repo " << alias() << endl;
1143  return not canSkipMediaCheck;
1144  }
1145 
1147 } // 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:415
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:425
void setBaseUrl(Url url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:676
Pathname path() const
Repository path.
Definition: RepoInfo.cc:775
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:509
Interface to gettext.
#define MIL
Definition: Logger.h:100
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:824
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:757
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:657
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:512
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
Definition: RepoInfo.cc:766
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced) this is either rawBaseUrls()...
Definition: RepoInfo.cc:784
TriBool rawPkgGpgCheck() const
Definition: RepoInfo.cc:393
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:810
std::chrono::steady_clock::time_point _lastMirrorUrlsUpdate
Definition: RepoInfo.cc:474
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:440
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:778
bool usesAutoMetadataPaths() const
Definition: RepoInfo.cc:443
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:705
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:518
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
Definition: curlhelper.cc:424
MirroredOriginSet repoOrigins() const
The repodata origins.
Definition: RepoInfo.cc:689
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:395
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:617
Url rawCfgMetalinkUrl() const
The configured raw metalink url.
Definition: RepoInfo.cc:642
RepoVariablesReplacedUrl _cfgMirrorlistUrl
Definition: RepoInfo.cc:411
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:489
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:550
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:760
String related utilities and Regular expression matching.
bool hasContent() const
Definition: RepoInfo.cc:260
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:525
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:388
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:428
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:326
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:763
RepoVariablesReplacedUrl baseUrl() const
Definition: RepoInfo.cc:143
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Definition: RepoInfo.cc:312
#define OUTS(T, B)
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:532
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition: RepoInfo.cc:354
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:572
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:790
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:799
size_type size() const
Definition: String.h:109
void setMirrorlistUrl(const Url &url)
Set the raw mirrorlist url.
Definition: RepoInfo.cc:633
Pathname _metadataPath
Definition: RepoInfo.cc:468
const std::string & asString() const
Definition: RepoType.cc:56
MirroredOriginSet repoOrigins() const
Definition: RepoInfo.cc:221
RepoVariablesReplacedUrlList _baseUrls
Definition: RepoInfo.cc:471
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:805
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:745
RepoInfo implementation.
Definition: RepoInfo.cc:78
bool empty() const
Test for an empty path.
Definition: Pathname.h:116
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:727
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
void resetMirrorUrls() const
Definition: RepoInfo.cc:164
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:751
Url rawCfgMirrorlistUrl() const
The configured raw mirrorlist url.
Definition: RepoInfo.cc:639
GpgCheck
Some predefined settings.
Definition: RepoInfo.h:412
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1243
std::string repoStatusString() const
Definition: RepoInfo.cc:245
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:547
Pathname packagesPath() const
Definition: RepoInfo.cc:453
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
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:535
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
RepoVariablesReplacedUrlList & baseUrls()
Definition: RepoInfo.cc:232
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:543
const std::string & asString() const
String representation.
Definition: Pathname.h:93
TriBool triBoolFromPath(const Pathname &path_r) const
Definition: RepoInfo.cc:380
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:257
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:748
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:699
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:565
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:910
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:721
#define WAR
Definition: Logger.h:101
RepoVariablesReplacedUrl _cfgMetalinkUrl
Definition: RepoInfo.cc:412
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition: RepoInfo.cc:709
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:802
RepoVariablesReplacedUrlList & gpgKeyUrls()
Definition: RepoInfo.cc:242
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:557
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:702
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:522
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
Definition: RepoInfo.cc:386
bool repoOriginsEmpty() const
whether repo origins are available
Definition: RepoInfo.cc:694
TriBool _validRepoSignature
have signed and valid repo metadata
Definition: RepoInfo.cc:407
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:816
std::vector< MirroredOrigin > _repoOrigins
Definition: RepoInfo.cc:475
std::pair< FalseBool, std::set< std::string > > _keywords
Definition: RepoInfo.cc:477
Pathname predownloadPath() const
Definition: RepoInfo.cc:460
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:718
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:866
bool baseurl2dump() const
Definition: RepoInfo.cc:235
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:403
std::ostream & dumpOn(std::ostream &str) const override
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:946
std::list< Url > url_set
Definition: RepoInfo.h:108
bool cfgGpgCheck() const
Definition: RepoInfo.cc:399
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:387
bool requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
Definition: RepoInfo.cc:1123
Find pathnames matching a pattern.
Definition: Glob.h:57
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:733
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:1059
static const unsigned noPriority
Definition: RepoInfo.cc:98
repo::RepoType type() const
Definition: RepoInfo.cc:109
repo::RepoType _type
Definition: RepoInfo.cc:408
Pathname predownloadPath() const
Path where this repo packages are predownloaded.
Definition: RepoInfo.cc:715
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition: RepoInfo.cc:739
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:712
void addEndpoints(InputIterator first, InputIterator last)
A convenience method to add multiple endpoints from a range.
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:636
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:654
const std::set< std::string > & contentKeywords() const
Definition: RepoInfo.cc:254
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:396
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:772
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:724
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:831
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:995
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:787
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:666
void setMirrorlistUrl(const Url &url_r)
Definition: RepoInfo.cc:418
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Definition: RepoInfo.cc:239
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:348
RepoVariablesReplacedUrlList _gpgKeyUrls
Definition: RepoInfo.cc:479
Typesafe passing of user data via callbacks.
Definition: UserData.h:39
TriBool rawRepoGpgCheck() const
Definition: RepoInfo.cc:392
DefaultIntegral< unsigned, defaultPriority > priority
Definition: RepoInfo.cc:465
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:781
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:736
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:683
std::string targetDistro
Definition: RepoInfo.cc:435
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:225
~RepoInfo() override
Definition: RepoInfo.cc:506
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:663
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:793
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:813
void rawPkgGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:397
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:796
void setMetalinkUrl(const Url &url_r)
Definition: RepoInfo.cc:421
const std::vector< Url > & getUrls() const
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:754
Pathname metadataPath() const
Definition: RepoInfo.cc:446
TriBool rawGpgCheck() const
Definition: RepoInfo.cc:391
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
static const unsigned defaultPriority
Definition: RepoInfo.cc:97
Impl * clone() const
clone for RWCOW_pointer
Definition: RepoInfo.cc:483
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:515
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:769
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:553
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:742
TriBool cfgRepoGpgCheck() const
Definition: RepoInfo.cc:401
const char * c_str() const
Definition: IdStringType.h:107
Pathname _packagesPath
Definition: RepoInfo.cc:469
bool effectiveKeepPackages() const
keepPackages unless the package cache itself enforces keeping the packages.
Definition: RepoInfo.cc:730
Url location() const
Definition: RepoInfo.cc:158
Url manipulation class.
Definition: Url.h:92
void metadataPath(Pathname new_r)
Definition: RepoInfo.cc:437
A smart container that manages a collection of MirroredOrigin objects, automatically grouping endpoin...
#define DBG
Definition: Logger.h:99
std::string service
Definition: RepoInfo.cc:434
Repository type enumeration.
Definition: RepoType.h:28
bool hasContent(const std::string &keyword_r) const
Definition: RepoInfo.cc:305
url_set & mirrorUrls() const
Fetch the repo mirrors from the server.
Definition: RepoInfo.cc:174