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