libzypp  16.13.0
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/base/LogTools.h"
18 
19 #include "zypp/RepoInfo.h"
20 #include "zypp/Glob.h"
21 #include "zypp/TriBool.h"
22 #include "zypp/Pathname.h"
23 #include "zypp/ZConfig.h"
25 #include "zypp/ExternalProgram.h"
26 #include "zypp/media/MediaAccess.h"
27 
28 #include "zypp/base/IOStream.h"
29 #include "zypp/base/InputStream.h"
30 #include "zypp/parser/xml/Reader.h"
31 
32 using std::endl;
33 using zypp::xml::escape;
34 
36 namespace zypp
37 {
38 
40  //
41  // CLASS NAME : RepoInfo::Impl
42  //
45  {
46  Impl()
47  : _gpgCheck( indeterminate )
48  , _repoGpgCheck( indeterminate )
49  , _pkgGpgCheck( indeterminate )
50  , _validRepoSignature( indeterminate )
51  , keeppackages(indeterminate)
53  , type(repo::RepoType::NONE_e)
54  , emptybaseurls(false)
55  {}
56 
58  {}
59 
60  public:
61  static const unsigned defaultPriority = 99;
62  static const unsigned noPriority = unsigned(-1);
63 
64  void setProbedType( const repo::RepoType & t ) const
65  {
67  && t != repo::RepoType::NONE )
68  {
69  // lazy init!
70  const_cast<Impl*>(this)->type = t;
71  }
72  }
73 
74  public:
76  Pathname licenseTgz() const
77  {
78  Pathname ret;
79  if ( !metadataPath().empty() )
80  {
82  g.add( metadataPath() / path / "repodata/*license.tar.gz" );
83  if ( g.empty() )
84  g.add( metadataPath() / path / "license.tar.gz" );
85 
86  if ( !g.empty() )
87  ret = *g.begin();
88  }
89  return ret;
90  }
91 
93  {
94  const Url & mlurl( _mirrorListUrl.transformed() ); // Variables replaced!
95  if ( _baseUrls.empty() && ! mlurl.asString().empty() )
96  {
97  emptybaseurls = true;
98  DBG << "MetadataPath: " << metadataPath() << endl;
100  _baseUrls.raw().insert( _baseUrls.raw().end(), rmurls.getUrls().begin(), rmurls.getUrls().end() );
101  }
102  return _baseUrls;
103  }
104 
106  { return _baseUrls; }
107 
108  bool baseurl2dump() const
109  { return !emptybaseurls && !_baseUrls.empty(); }
110 
111 
113  { return _gpgKeyUrls; }
114 
116  { return _gpgKeyUrls; }
117 
118 
119  const std::set<std::string> & contentKeywords() const
120  { hasContent()/*init if not yet done*/; return _keywords.second; }
121 
122  void addContent( const std::string & keyword_r )
123  { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
124 
125  bool hasContent() const
126  {
127  if ( !_keywords.first && ! metadataPath().empty() )
128  {
129  // HACK directly check master index file until RepoManager offers
130  // some content probing and zypper uses it.
132  MIL << "Empty keywords...." << metadataPath() << endl;
133  Pathname master;
134  if ( PathInfo( (master=metadataPath()/"/repodata/repomd.xml") ).isFile() )
135  {
136  //MIL << "GO repomd.." << endl;
137  xml::Reader reader( master );
138  while ( reader.seekToNode( 2, "content" ) )
139  {
140  _keywords.second.insert( reader.nodeText().asString() );
141  reader.seekToEndNode( 2, "content" );
142  }
143  _keywords.first = true; // valid content in _keywords even if empty
144  }
145  else if ( PathInfo( (master=metadataPath()/"/content") ).isFile() )
146  {
147  //MIL << "GO content.." << endl;
148  iostr::forEachLine( InputStream( master ),
149  [this]( int num_r, std::string line_r )->bool
150  {
151  if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
152  {
153  std::vector<std::string> words;
154  if ( str::split( line_r, std::back_inserter(words) ) > 1
155  && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
156  {
157  this->_keywords.second.insert( ++words.begin(), words.end() );
158  }
159  return true; // mult. occurrances are ok.
160  }
161  return( ! str::startsWith( line_r, "META " ) ); // no need to parse into META section.
162  } );
163  _keywords.first = true; // valid content in _keywords even if empty
164  }
166  }
167  return _keywords.first;
168  }
169 
170  bool hasContent( const std::string & keyword_r ) const
171  { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
172 
178  {
179  if ( ! indeterminate(_validRepoSignature) ) return _validRepoSignature;
180  // check metadata:
181  if ( ! metadataPath().empty() )
182  {
183  //TODO: a missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
184  TriBool linkval = triBoolFromPath( metadataPath() / ".repo_gpgcheck" );
185  return linkval;
186  }
187  return indeterminate;
188  }
189 
191  {
192  if ( PathInfo(metadataPath()).isDir() )
193  {
194  Pathname gpgcheckFile( metadataPath() / ".repo_gpgcheck" );
195  if ( PathInfo(gpgcheckFile).isExist() )
196  {
197  TriBool linkval( indeterminate );
198  if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
199  return; // existing symlink fits value_r
200  else
201  filesystem::unlink( gpgcheckFile ); // will write a new one
202  }
203  filesystem::symlink( asString(value_r), gpgcheckFile );
204  }
205  _validRepoSignature = value_r;
206  }
207 
208  bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
209  {
210  static const Pathname truePath( "true" );
211  static const Pathname falsePath( "false" );
212  static const Pathname indeterminatePath( "indeterminate" );
213  Pathname linkval( filesystem::readlink( path_r ) );
214  bool known = true;
215  if ( linkval == truePath )
216  ret_r = true;
217  else if ( linkval == falsePath )
218  ret_r = false;
219  else if ( linkval == indeterminatePath )
220  ret_r = indeterminate;
221  else
222  known = false;
223  return known;
224  }
225 
226  TriBool triBoolFromPath( const Pathname & path_r ) const
227  { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
228 
230 
231  public:
235  private:
237  public:
242  Pathname path;
243  std::string service;
244  std::string targetDistro;
245 
246  void metadataPath( Pathname new_r )
247  { _metadataPath = std::move( new_r ); }
248 
249  void packagesPath( Pathname new_r )
250  { _packagesPath = std::move( new_r ); }
251 
253  { return str::hasSuffix( _metadataPath.asString(), "/%AUTO%" ); }
254 
255  Pathname metadataPath() const
256  {
257  if ( usesAutoMethadataPaths() )
258  return _metadataPath.dirname() / "%RAW%";
259  return _metadataPath;
260  }
261 
262  Pathname packagesPath() const
263  {
264  if ( _packagesPath.empty() && usesAutoMethadataPaths() )
265  return _metadataPath.dirname() / "%PKG%";
266  return _packagesPath;
267  }
268 
270  mutable bool emptybaseurls;
272 
273  private:
274  Pathname _metadataPath;
275  Pathname _packagesPath;
276 
278  mutable std::pair<FalseBool, std::set<std::string> > _keywords;
279 
281 
282  friend Impl * rwcowClone<Impl>( const Impl * rhs );
284  Impl * clone() const
285  { return new Impl( *this ); }
286  };
288 
290  inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
291  {
292  return str << "RepoInfo::Impl";
293  }
294 
296  //
297  // CLASS NAME : RepoInfo
298  //
300 
302 
304  : _pimpl( new Impl() )
305  {}
306 
308  {}
309 
310  unsigned RepoInfo::priority() const
311  { return _pimpl->priority; }
312 
314  { return Impl::defaultPriority; }
315 
317  { return Impl::noPriority; }
318 
319  void RepoInfo::setPriority( unsigned newval_r )
320  { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
321 
322 
323  bool RepoInfo::gpgCheck() const
324  { return indeterminate(_pimpl->_gpgCheck) ? ZConfig::instance().gpgCheck() : (bool)_pimpl->_gpgCheck; }
325 
327  { _pimpl->_gpgCheck = value_r; }
328 
329  void RepoInfo::setGpgCheck( bool value_r ) // deprecated legacy and for squid
330  { setGpgCheck( TriBool(value_r) ); }
331 
332 
334  {
335  if ( ! indeterminate(_pimpl->_repoGpgCheck) ) return _pimpl->_repoGpgCheck;
336  if ( ! indeterminate(ZConfig::instance().repoGpgCheck()) ) return ZConfig::instance().repoGpgCheck();
337  return gpgCheck(); // no preference: follow gpgCheck
338  }
339 
341  { _pimpl->_repoGpgCheck = value_r; }
342 
343 
345  {
346  if ( ! indeterminate(_pimpl->_pkgGpgCheck) ) return _pimpl->_pkgGpgCheck;
347  if ( ! indeterminate(ZConfig::instance().pkgGpgCheck()) ) return ZConfig::instance().pkgGpgCheck();
348  // no preference: follow gpgCheck and check package if repo signature not available or not checked
349  return gpgCheck() && ( !repoGpgCheck() || !(bool)validRepoSignature() ); // !(bool)TriBool ==> false or indeterminate
350  }
351 
353  { _pimpl->_pkgGpgCheck = value_r; }
354 
355  void RepoInfo::getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const
356  {
357  g_r = _pimpl->_gpgCheck;
358  r_r = _pimpl->_repoGpgCheck;
359  p_r = _pimpl->_pkgGpgCheck;
360  }
361 
363  {
365  // keep indeterminate(=unsigned) but invalidate any signature if !repoGpgCheck
366  if ( !indeterminate(ret) && !repoGpgCheck() )
367  ret = false;
368  return ret;
369  }
370 
372  { _pimpl->internalSetValidRepoSignature( value_r ); }
373 
374 
375  void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
376  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = false; }
377 
378  void RepoInfo::setMetalinkUrl( const Url & url_r ) // Raw
379  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = true; }
380 
382  { _pimpl->gpgKeyUrls().raw().swap( urls ); }
383 
384  void RepoInfo::setGpgKeyUrl( const Url & url_r )
385  {
386  _pimpl->gpgKeyUrls().raw().clear();
387  _pimpl->gpgKeyUrls().raw().push_back( url_r );
388  }
389 
390  void RepoInfo::addBaseUrl( const Url & url_r )
391  {
392  for ( const auto & url : _pimpl->baseUrls().raw() ) // Raw unique!
393  if ( url == url_r )
394  return;
395  _pimpl->baseUrls().raw().push_back( url_r );
396  }
397 
398  void RepoInfo::setBaseUrl( const Url & url_r )
399  {
400  _pimpl->baseUrls().raw().clear();
401  _pimpl->baseUrls().raw().push_back( url_r );
402  }
403 
405  { _pimpl->baseUrls().raw().swap( urls ); }
406 
407  void RepoInfo::setPath( const Pathname &path )
408  { _pimpl->path = path; }
409 
411  { _pimpl->type = t; }
412 
414  { _pimpl->setProbedType( t ); }
415 
416 
417  void RepoInfo::setMetadataPath( const Pathname &path )
418  { _pimpl->metadataPath( path ); }
419 
420  void RepoInfo::setPackagesPath( const Pathname &path )
421  { _pimpl->packagesPath( path ); }
422 
423  void RepoInfo::setKeepPackages( bool keep )
424  { _pimpl->keeppackages = keep; }
425 
426  void RepoInfo::setService( const std::string& name )
427  { _pimpl->service = name; }
428 
431 
433  { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
434 
435  Pathname RepoInfo::metadataPath() const
436  { return _pimpl->metadataPath(); }
437 
438  Pathname RepoInfo::packagesPath() const
439  { return _pimpl->packagesPath(); }
440 
442  { return _pimpl->usesAutoMethadataPaths(); }
443 
445  { return _pimpl->type; }
446 
447  Url RepoInfo::mirrorListUrl() const // Variables replaced!
448  { return _pimpl->_mirrorListUrl.transformed(); }
449 
451  { return _pimpl->_mirrorListUrl.raw(); }
452 
454  { return _pimpl->gpgKeyUrls().empty(); }
455 
457  { return _pimpl->gpgKeyUrls().size(); }
458 
459  RepoInfo::url_set RepoInfo::gpgKeyUrls() const // Variables replaced!
460  { return _pimpl->gpgKeyUrls().transformed(); }
461 
463  { return _pimpl->gpgKeyUrls().raw(); }
464 
465  Url RepoInfo::gpgKeyUrl() const // Variables replaced!
466  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
467 
469  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
470 
471  RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
472  { return _pimpl->baseUrls().transformed(); }
473 
475  { return _pimpl->baseUrls().raw(); }
476 
477  Pathname RepoInfo::path() const
478  { return _pimpl->path; }
479 
480  std::string RepoInfo::service() const
481  { return _pimpl->service; }
482 
483  std::string RepoInfo::targetDistribution() const
484  { return _pimpl->targetDistro; }
485 
487  { return( _pimpl->baseUrls().empty() ? Url() : *_pimpl->baseUrls().rawBegin() ); }
488 
490  { return _pimpl->baseUrls().transformedBegin(); }
491 
493  { return _pimpl->baseUrls().transformedEnd(); }
494 
496  { return _pimpl->baseUrls().size(); }
497 
499  { return _pimpl->baseUrls().empty(); }
500 
501  bool RepoInfo::baseUrlSet() const
502  { return _pimpl->baseurl2dump(); }
503 
504  const std::set<std::string> & RepoInfo::contentKeywords() const
505  { return _pimpl->contentKeywords(); }
506 
507  void RepoInfo::addContent( const std::string & keyword_r )
508  { _pimpl->addContent( keyword_r ); }
509 
510  bool RepoInfo::hasContent() const
511  { return _pimpl->hasContent(); }
512 
513  bool RepoInfo::hasContent( const std::string & keyword_r ) const
514  { return _pimpl->hasContent( keyword_r ); }
515 
517 
518  bool RepoInfo::hasLicense() const
519  {
520  return !_pimpl->licenseTgz().empty();
521  }
522 
524  {
525  static const std::string noAcceptanceFile = "no-acceptance-needed\n";
526  bool accept = true;
527 
528  const Pathname & licenseTgz( _pimpl->licenseTgz() );
529  if ( licenseTgz.empty() )
530  return false; // no licenses at all
531 
533  cmd.push_back( "tar" );
534  cmd.push_back( "-t" );
535  cmd.push_back( "-z" );
536  cmd.push_back( "-f" );
537  cmd.push_back( licenseTgz.asString() );
538 
540  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
541  {
542  if ( output == noAcceptanceFile )
543  {
544  accept = false;
545  }
546  }
547  MIL << "License for " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
548  return accept;
549  }
550 
551  std::string RepoInfo::getLicense( const Locale & lang_r )
552  { return const_cast<const RepoInfo *>(this)->getLicense( lang_r ); }
553 
554  std::string RepoInfo::getLicense( const Locale & lang_r ) const
555  {
556  LocaleSet avlocales( getLicenseLocales() );
557  if ( avlocales.empty() )
558  return std::string();
559 
560  Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
561  if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
562  {
563  WAR << "License.tar.gz contains no fallback text! " << *this << endl;
564  // Using the fist locale instead of returning no text at all.
565  // So the user might recognize that there is a license, even if he
566  // can't read it.
567  getLang = *avlocales.begin();
568  }
569 
570  // now extract the license file.
571  static const std::string licenseFileFallback( "license.txt" );
572  std::string licenseFile( !getLang ? licenseFileFallback
573  : str::form( "license.%s.txt", getLang.c_str() ) );
574 
576  cmd.push_back( "tar" );
577  cmd.push_back( "-x" );
578  cmd.push_back( "-z" );
579  cmd.push_back( "-O" );
580  cmd.push_back( "-f" );
581  cmd.push_back( _pimpl->licenseTgz().asString() ); // if it not exists, avlocales was empty.
582  cmd.push_back( licenseFile );
583 
584  std::string ret;
586  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
587  {
588  ret += output;
589  }
590  prog.close();
591  return ret;
592  }
593 
595  {
596  const Pathname & licenseTgz( _pimpl->licenseTgz() );
597  if ( licenseTgz.empty() )
598  return LocaleSet();
599 
601  cmd.push_back( "tar" );
602  cmd.push_back( "-t" );
603  cmd.push_back( "-z" );
604  cmd.push_back( "-f" );
605  cmd.push_back( licenseTgz.asString() );
606 
607  LocaleSet ret;
609  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
610  {
611  static const C_Str license( "license." );
612  static const C_Str dotTxt( ".txt\n" );
613  if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
614  {
615  if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
616  ret.insert( Locale() );
617  else
618  ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
619  }
620  }
621  prog.close();
622  return ret;
623  }
624 
626 
627  std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
628  {
630  if ( _pimpl->baseurl2dump() )
631  {
632  for ( const auto & url : _pimpl->baseUrls().raw() )
633  {
634  str << "- url : " << url << std::endl;
635  }
636  }
637 
638  // print if non empty value
639  auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
640  if ( ! value_r.empty() )
641  str << tag_r << value_r << std::endl;
642  });
643 
644  strif( (_pimpl->_mirrorListForceMetalink ? "- metalink : " : "- mirrorlist : "), rawMirrorListUrl().asString() );
645  strif( "- path : ", path().asString() );
646  str << "- type : " << type() << std::endl;
647  str << "- priority : " << priority() << std::endl;
648 
649  // Yes No Default(Y) Default(N)
650 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
651  str << "- gpgcheck : " << OUTS(_pimpl->_gpgCheck,gpgCheck())
652  << " repo" << OUTS(_pimpl->_repoGpgCheck,repoGpgCheck())
653  << " sig" << asString( validRepoSignature(), "?", "Y", "N" )
654  << " pkg" << OUTS(_pimpl->_pkgGpgCheck,pkgGpgCheck())
655  << std::endl;
656 #undef OUTS
657 
658  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
659  {
660  str << "- gpgkey : " << url << std::endl;
661  }
662 
663  if ( ! indeterminate(_pimpl->keeppackages) )
664  str << "- keeppackages: " << keepPackages() << std::endl;
665 
666  strif( "- service : ", service() );
667  strif( "- targetdistro: ", targetDistribution() );
668  strif( "- filePath: ", filepath().asString() );
669  strif( "- metadataPath: ", metadataPath().asString() );
670  strif( "- packagesPath: ", packagesPath().asString() );
671 
672  return str;
673  }
674 
675  std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
676  {
677  RepoInfoBase::dumpAsIniOn(str);
678 
679  if ( _pimpl->baseurl2dump() )
680  {
681  str << "baseurl=";
682  std::string indent;
683  for ( const auto & url : _pimpl->baseUrls().raw() )
684  {
685  str << indent << url << endl;
686  if ( indent.empty() ) indent = " "; // "baseurl="
687  }
688  }
689 
690  if ( ! _pimpl->path.empty() )
691  str << "path="<< path() << endl;
692 
693  if ( ! (rawMirrorListUrl().asString().empty()) )
694  str << (_pimpl->_mirrorListForceMetalink ? "metalink=" : "mirrorlist=") << rawMirrorListUrl() << endl;
695 
696  str << "type=" << type().asString() << endl;
697 
698  if ( priority() != defaultPriority() )
699  str << "priority=" << priority() << endl;
700 
701  if ( ! indeterminate(_pimpl->_gpgCheck) )
702  str << "gpgcheck=" << (_pimpl->_gpgCheck ? "1" : "0") << endl;
703 
704  if ( ! indeterminate(_pimpl->_repoGpgCheck) )
705  str << "repo_gpgcheck=" << (_pimpl->_repoGpgCheck ? "1" : "0") << endl;
706 
707  if ( ! indeterminate(_pimpl->_pkgGpgCheck) )
708  str << "pkg_gpgcheck=" << (_pimpl->_pkgGpgCheck ? "1" : "0") << endl;
709 
710  {
711  std::string indent( "gpgkey=");
712  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
713  {
714  str << indent << url << endl;
715  if ( indent[0] != ' ' )
716  indent = " ";
717  }
718  }
719 
720  if (!indeterminate(_pimpl->keeppackages))
721  str << "keeppackages=" << keepPackages() << endl;
722 
723  if( ! service().empty() )
724  str << "service=" << service() << endl;
725 
726  return str;
727  }
728 
729  std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
730  {
731  std::string tmpstr;
732  str
733  << "<repo"
734  << " alias=\"" << escape(alias()) << "\""
735  << " name=\"" << escape(name()) << "\"";
736  if (type() != repo::RepoType::NONE)
737  str << " type=\"" << type().asString() << "\"";
738  str
739  << " priority=\"" << priority() << "\""
740  << " enabled=\"" << enabled() << "\""
741  << " autorefresh=\"" << autorefresh() << "\""
742  << " gpgcheck=\"" << gpgCheck() << "\""
743  << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
744  << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
745  if (!(tmpstr = gpgKeyUrl().asString()).empty())
746  str << " gpgkey=\"" << escape(tmpstr) << "\"";
747  if (!(tmpstr = mirrorListUrl().asString()).empty())
748  str << (_pimpl->_mirrorListForceMetalink ? " metalink=\"" : " mirrorlist=\"") << escape(tmpstr) << "\"";
749  str << ">" << endl;
750 
751  if ( _pimpl->baseurl2dump() )
752  {
753  for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
754  str << "<url>" << escape((*it).asString()) << "</url>" << endl;
755  }
756 
757  str << "</repo>" << endl;
758  return str;
759  }
760 
761 
762  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
763  {
764  return obj.dumpOn(str);
765  }
766 
767 
769 } // namespace zypp
static const Locale noCode
Empty code.
Definition: Locale.h:74
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:594
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Definition: RepoInfo.cc:177
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:483
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:453
#define MIL
Definition: Logger.h:64
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:384
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:313
std::string alias() const
unique identifier for this source.
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1006
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:486
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:675
void packagesPath(Pathname new_r)
Definition: RepoInfo.cc:249
TriBool _pkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck && no valid repo sign.))
Definition: RepoInfo.cc:234
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
bool _mirrorListForceMetalink
Definition: RepoInfo.cc:240
static ZConfig & instance()
Singleton ctor.
Definition: Resolver.cc:125
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:319
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like &#39;readlink&#39;.
Definition: PathInfo.cc:847
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:462
Pathname filepath() const
File where this repo was read from.
Pathname metadataPath() const
Definition: RepoInfo.cc:255
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:459
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:375
repo::RepoVariablesUrlReplacer replacer
Definition: RepoInfo.cc:271
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:489
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
Definition: String.cc:369
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
Definition: PtrTypes.h:151
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:435
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Definition: RepoInfo.cc:290
String related utilities and Regular expression matching.
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:344
std::list< Url > url_set
Definition: RepoInfo.h:103
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:413
What is known about a repository.
Definition: RepoInfo.h:71
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition: RepoInfo.cc:355
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:326
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
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:398
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:492
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
void internalSetValidRepoSignature(TriBool value_r)
Definition: RepoInfo.cc:190
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:438
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:310
#define OUTS(T, B)
Pathname packagesPath() const
Definition: RepoInfo.cc:262
TriBool triBoolFromPath(const Pathname &path_r) const
Definition: RepoInfo.cc:226
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:371
std::vector< std::string > Arguments
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:333
bool seekToNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:212
TriBool _gpgCheck
default gpgcheck behavior: Y/N/ZConf
Definition: RepoInfo.cc:232
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:462
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:105
Pathname _metadataPath
Definition: RepoInfo.cc:274
RepoVariablesReplacedUrlList _baseUrls
Definition: RepoInfo.cc:277
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:210
RepoInfo implementation.
Definition: RepoInfo.cc:44
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:432
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:523
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:450
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
Definition: String.h:519
virtual ~RepoInfo()
Definition: RepoInfo.cc:307
bool gpgCheck() const
Turn signature checking on/off (on)
Definition: ZConfig.cc:1003
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
int unlink(const Pathname &path)
Like &#39;unlink&#39;.
Definition: PathInfo.cc:653
RepoVariablesReplacedUrlList & baseUrls()
Definition: RepoInfo.cc:105
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:340
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:447
bool hasContent() const
Definition: RepoInfo.cc:125
void addContent(const std::string &keyword_r)
Definition: RepoInfo.cc:122
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:90
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
Definition: IOStream.cc:100
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1009
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:407
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:510
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:426
#define WAR
Definition: Logger.h:65
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition: RepoInfo.cc:417
bool gpgCheck() const
Whether default signature checking should be performed for this repo.
Definition: RepoInfo.cc:323
RepoVariablesReplacedUrlList & gpgKeyUrls()
Definition: RepoInfo.cc:115
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:456
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
Definition: String.h:1086
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:410
TriBool _validRepoSignature
have signed and valid repo metadata
Definition: RepoInfo.cc:236
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:501
Impl * clone() const
clone for RWCOW_pointer
Definition: RepoInfo.cc:284
std::pair< FalseBool, std::set< std::string > > _keywords
Definition: RepoInfo.cc:278
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:423
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:480
bool baseurl2dump() const
Definition: RepoInfo.cc:108
const std::string & asString() const
Definition: RepoType.cc:56
bool seekToEndNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:232
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like &#39;symlink&#39;.
Definition: PathInfo.cc:780
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:390
std::string receiveLine()
Read one line from the input stream.
Find pathnames matching a pattern.
Definition: Glob.h:57
bool empty() const
Whether matches were found.
Definition: Glob.h:189
static const RepoType NONE
Definition: RepoType.h:32
static const unsigned noPriority
Definition: RepoInfo.cc:62
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
const_iterator begin() const
Iterator pointing to the first result.
Definition: Glob.h:197
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:420
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:471
const std::vector< Url > & getUrls() const
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:474
std::string asString() const
Explicit conversion to std::string.
Definition: XmlString.h:77
int close()
Wait for the progamm to complete.
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:49
TriBool _repoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:233
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:378
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:498
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:381
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:444
void setProbedType(const repo::RepoType &t) const
Definition: RepoInfo.cc:64
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition: RepoInfo.cc:208
const char * c_str() const
Definition: IdStringType.h:105
Pathname licenseTgz() const
Path to a license tarball in case it exists in the repo.
Definition: RepoInfo.cc:76
url_set::size_type urls_size_type
Definition: RepoInfo.h:104
bool hasSuffix(const C_Str &str_r, const C_Str &suffix_r)
Return whether str_r has suffix suffix_r.
Definition: String.h:1042
const std::set< std::string > & contentKeywords() const
Definition: RepoInfo.cc:119
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:429
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:554
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value...
Definition: Reader.cc:140
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:518
RepoVariablesReplacedUrlList _gpgKeyUrls
Definition: RepoInfo.cc:280
bool hasContent(const std::string &keyword_r) const
Definition: RepoInfo.cc:170
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:465
RepoVariablesReplacedUrl _mirrorListUrl
Definition: RepoInfo.cc:239
DefaultIntegral< unsigned, defaultPriority > priority
Definition: RepoInfo.cc:269
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:131
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:504
bool usesAutoMethadataPaths() const
Definition: RepoInfo.cc:252
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:404
std::string targetDistro
Definition: RepoInfo.cc:244
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition: RepoInfo.cc:441
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:80
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:507
size_type size() const
Definition: String.h:105
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:729
repo::RepoType type
Definition: RepoInfo.cc:241
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:362
Functor replacing repository variables.
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:495
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
static const unsigned defaultPriority
Definition: RepoInfo.cc:61
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Definition: RepoInfo.cc:112
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:316
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:1028
const RepoVariablesReplacedUrlList & baseUrls() const
Definition: RepoInfo.cc:92
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:352
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
Definition: RepoInfo.cc:468
Pathname _packagesPath
Definition: RepoInfo.cc:275
Url manipulation class.
Definition: Url.h:87
void metadataPath(Pathname new_r)
Definition: RepoInfo.cc:246
Pathname path() const
Repository path.
Definition: RepoInfo.cc:477
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:627
#define DBG
Definition: Logger.h:63
std::string service
Definition: RepoInfo.cc:243
detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
Definition: XmlEscape.h:51
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:762