libzypp  16.1.1
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/TriBool.h"
21 #include "zypp/Pathname.h"
22 #include "zypp/ZConfig.h"
24 #include "zypp/ExternalProgram.h"
25 #include "zypp/media/MediaAccess.h"
26 
27 #include "zypp/base/IOStream.h"
28 #include "zypp/base/InputStream.h"
29 #include "zypp/parser/xml/Reader.h"
30 
31 using std::endl;
32 using zypp::xml::escape;
33 
35 namespace zypp
36 {
37 
39  //
40  // CLASS NAME : RepoInfo::Impl
41  //
44  {
45  Impl()
46  : _gpgCheck( indeterminate )
47  , _repoGpgCheck( indeterminate )
48  , _pkgGpgCheck( indeterminate )
49  , _validRepoSignature( indeterminate )
50  , keeppackages(indeterminate)
52  , type(repo::RepoType::NONE_e)
53  , emptybaseurls(false)
54  {}
55 
57  {}
58 
59  public:
60  static const unsigned defaultPriority = 99;
61  static const unsigned noPriority = unsigned(-1);
62 
63  void setProbedType( const repo::RepoType & t ) const
64  {
66  && t != repo::RepoType::NONE )
67  {
68  // lazy init!
69  const_cast<Impl*>(this)->type = t;
70  }
71  }
72 
73  public:
74  Pathname licenseTgz() const
75  { return metadatapath.empty() ? Pathname() : metadatapath / path / "license.tar.gz"; }
76 
78  {
79  const Url & mlurl( _mirrorListUrl.transformed() ); // Variables replaced!
80  if ( _baseUrls.empty() && ! mlurl.asString().empty() )
81  {
82  emptybaseurls = true;
83  DBG << "MetadataPath: " << metadatapath << endl;
85  _baseUrls.raw().insert( _baseUrls.raw().end(), rmurls.getUrls().begin(), rmurls.getUrls().end() );
86  }
87  return _baseUrls;
88  }
89 
91  { return _baseUrls; }
92 
93  bool baseurl2dump() const
94  { return !emptybaseurls && !_baseUrls.empty(); }
95 
96 
97  const std::set<std::string> & contentKeywords() const
98  { hasContent()/*init if not yet done*/; return _keywords.second; }
99 
100  void addContent( const std::string & keyword_r )
101  { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
102 
103  bool hasContent() const
104  {
105  if ( !_keywords.first && ! metadatapath.empty() )
106  {
107  // HACK directly check master index file until RepoManager offers
108  // some content probing and zypper uses it.
110  MIL << "Empty keywords...." << metadatapath << endl;
111  Pathname master;
112  if ( PathInfo( (master=metadatapath/"/repodata/repomd.xml") ).isFile() )
113  {
114  //MIL << "GO repomd.." << endl;
115  xml::Reader reader( master );
116  while ( reader.seekToNode( 2, "content" ) )
117  {
118  _keywords.second.insert( reader.nodeText().asString() );
119  reader.seekToEndNode( 2, "content" );
120  }
121  _keywords.first = true; // valid content in _keywords even if empty
122  }
123  else if ( PathInfo( (master=metadatapath/"/content") ).isFile() )
124  {
125  //MIL << "GO content.." << endl;
126  iostr::forEachLine( InputStream( master ),
127  [this]( int num_r, std::string line_r )->bool
128  {
129  if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
130  {
131  std::vector<std::string> words;
132  if ( str::split( line_r, std::back_inserter(words) ) > 1
133  && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
134  {
135  this->_keywords.second.insert( ++words.begin(), words.end() );
136  }
137  return true; // mult. occurrances are ok.
138  }
139  return( ! str::startsWith( line_r, "META " ) ); // no need to parse into META section.
140  } );
141  _keywords.first = true; // valid content in _keywords even if empty
142  }
144  }
145  return _keywords.first;
146  }
147 
148  bool hasContent( const std::string & keyword_r ) const
149  { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
150 
156  {
157  if ( ! indeterminate(_validRepoSignature) ) return _validRepoSignature;
158  // check metadata:
159  if ( ! metadatapath.empty() )
160  {
161  //TODO: a missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
162  TriBool linkval = triBoolFromPath( metadatapath / ".repo_gpgcheck" );
163  return linkval;
164  }
165  return indeterminate;
166  }
167 
169  {
170  if ( PathInfo(metadatapath).isDir() )
171  {
172  Pathname gpgcheckFile( metadatapath / ".repo_gpgcheck" );
173  if ( PathInfo(gpgcheckFile).isExist() )
174  {
175  TriBool linkval( indeterminate );
176  if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
177  return; // existing symlink fits value_r
178  else
179  filesystem::unlink( gpgcheckFile ); // will write a new one
180  }
181  filesystem::symlink( asString(value_r), gpgcheckFile );
182  }
183  _validRepoSignature = value_r;
184  }
185 
186  bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
187  {
188  static const Pathname truePath( "true" );
189  static const Pathname falsePath( "false" );
190  static const Pathname indeterminatePath( "indeterminate" );
191  Pathname linkval( filesystem::readlink( path_r ) );
192  bool known = true;
193  if ( linkval == truePath )
194  ret_r = true;
195  else if ( linkval == falsePath )
196  ret_r = false;
197  else if ( linkval == indeterminatePath )
198  ret_r = indeterminate;
199  else
200  known = false;
201  return known;
202  }
203 
204  TriBool triBoolFromPath( const Pathname & path_r ) const
205  { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
206 
208 
209  public:
213  private:
215  public:
221  Pathname path;
222  std::string service;
223  std::string targetDistro;
224  Pathname metadatapath;
225  Pathname packagespath;
227  mutable bool emptybaseurls;
229 
230  private:
232  mutable std::pair<FalseBool, std::set<std::string> > _keywords;
233 
234  friend Impl * rwcowClone<Impl>( const Impl * rhs );
236  Impl * clone() const
237  { return new Impl( *this ); }
238  };
240 
242  inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
243  {
244  return str << "RepoInfo::Impl";
245  }
246 
248  //
249  // CLASS NAME : RepoInfo
250  //
252 
254 
256  : _pimpl( new Impl() )
257  {}
258 
260  {}
261 
262  unsigned RepoInfo::priority() const
263  { return _pimpl->priority; }
264 
266  { return Impl::defaultPriority; }
267 
269  { return Impl::noPriority; }
270 
271  void RepoInfo::setPriority( unsigned newval_r )
272  { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
273 
274 
275  bool RepoInfo::gpgCheck() const
276  { return indeterminate(_pimpl->_gpgCheck) ? ZConfig::instance().gpgCheck() : (bool)_pimpl->_gpgCheck; }
277 
279  { _pimpl->_gpgCheck = value_r; }
280 
281  void RepoInfo::setGpgCheck( bool value_r ) // deprecated legacy and for squid
282  { setGpgCheck( TriBool(value_r) ); }
283 
284 
286  {
287  if ( ! indeterminate(_pimpl->_repoGpgCheck) ) return _pimpl->_repoGpgCheck;
288  if ( ! indeterminate(ZConfig::instance().repoGpgCheck()) ) return ZConfig::instance().repoGpgCheck();
289  return gpgCheck(); // no preference: follow gpgCheck
290  }
291 
293  { _pimpl->_repoGpgCheck = value_r; }
294 
295 
297  {
298  if ( ! indeterminate(_pimpl->_pkgGpgCheck) ) return _pimpl->_pkgGpgCheck;
299  if ( ! indeterminate(ZConfig::instance().pkgGpgCheck()) ) return ZConfig::instance().pkgGpgCheck();
300  // no preference: follow gpgCheck and check package if repo signature not available or not checked
301  return gpgCheck() && ( !repoGpgCheck() || !(bool)validRepoSignature() ); // !(bool)TriBool ==> false or indeterminate
302  }
303 
305  { _pimpl->_pkgGpgCheck = value_r; }
306 
307  void RepoInfo::getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const
308  {
309  g_r = _pimpl->_gpgCheck;
310  r_r = _pimpl->_repoGpgCheck;
311  p_r = _pimpl->_pkgGpgCheck;
312  }
313 
315  {
317  // keep indeterminate(=unsigned) but invalidate any signature if !repoGpgCheck
318  if ( !indeterminate(ret) && !repoGpgCheck() )
319  ret = false;
320  return ret;
321  }
322 
324  { _pimpl->internalSetValidRepoSignature( value_r ); }
325 
326 
327  void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
328  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = false; }
329 
330  void RepoInfo::setMetalinkUrl( const Url & url_r ) // Raw
331  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = true; }
332 
333  void RepoInfo::setGpgKeyUrl( const Url & url_r )
334  { _pimpl->_gpgKeyUrl.raw() = url_r; }
335 
336  void RepoInfo::addBaseUrl( const Url & url_r )
337  {
338  for ( const auto & url : _pimpl->baseUrls().raw() ) // Raw unique!
339  if ( url == url_r )
340  return;
341  _pimpl->baseUrls().raw().push_back( url_r );
342  }
343 
344  void RepoInfo::setBaseUrl( const Url & url_r )
345  {
346  _pimpl->baseUrls().raw().clear();
347  _pimpl->baseUrls().raw().push_back( url_r );
348  }
349 
351  { _pimpl->baseUrls().raw().swap( urls ); }
352 
353  void RepoInfo::setPath( const Pathname &path )
354  { _pimpl->path = path; }
355 
357  { _pimpl->type = t; }
358 
360  { _pimpl->setProbedType( t ); }
361 
362 
363  void RepoInfo::setMetadataPath( const Pathname &path )
364  { _pimpl->metadatapath = path; }
365 
366  void RepoInfo::setPackagesPath( const Pathname &path )
367  { _pimpl->packagespath = path; }
368 
369  void RepoInfo::setKeepPackages( bool keep )
370  { _pimpl->keeppackages = keep; }
371 
372  void RepoInfo::setService( const std::string& name )
373  { _pimpl->service = name; }
374 
377 
379  { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
380 
381  Pathname RepoInfo::metadataPath() const
382  { return _pimpl->metadatapath; }
383 
384  Pathname RepoInfo::packagesPath() const
385  { return _pimpl->packagespath; }
386 
388  { return _pimpl->type; }
389 
390  Url RepoInfo::mirrorListUrl() const // Variables replaced!
391  { return _pimpl->_mirrorListUrl.transformed(); }
392 
394  { return _pimpl->_mirrorListUrl.raw(); }
395 
396  Url RepoInfo::gpgKeyUrl() const // Variables replaced!
397  { return _pimpl->_gpgKeyUrl.transformed(); }
398 
400  { return _pimpl->_gpgKeyUrl.raw(); }
401 
402  RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
403  { return _pimpl->baseUrls().transformed(); }
404 
406  { return _pimpl->baseUrls().raw(); }
407 
408  Pathname RepoInfo::path() const
409  { return _pimpl->path; }
410 
411  std::string RepoInfo::service() const
412  { return _pimpl->service; }
413 
414  std::string RepoInfo::targetDistribution() const
415  { return _pimpl->targetDistro; }
416 
418  { return( _pimpl->baseUrls().empty() ? Url() : *_pimpl->baseUrls().rawBegin() ); }
419 
421  { return _pimpl->baseUrls().transformedBegin(); }
422 
424  { return _pimpl->baseUrls().transformedEnd(); }
425 
427  { return _pimpl->baseUrls().size(); }
428 
430  { return _pimpl->baseUrls().empty(); }
431 
432  bool RepoInfo::baseUrlSet() const
433  { return _pimpl->baseurl2dump(); }
434 
435  const std::set<std::string> & RepoInfo::contentKeywords() const
436  { return _pimpl->contentKeywords(); }
437 
438  void RepoInfo::addContent( const std::string & keyword_r )
439  { _pimpl->addContent( keyword_r ); }
440 
441  bool RepoInfo::hasContent() const
442  { return _pimpl->hasContent(); }
443 
444  bool RepoInfo::hasContent( const std::string & keyword_r ) const
445  { return _pimpl->hasContent( keyword_r ); }
446 
448 
449  bool RepoInfo::hasLicense() const
450  {
451  Pathname licenseTgz( _pimpl->licenseTgz() );
452  return ! licenseTgz.empty() && PathInfo(licenseTgz).isFile();
453  }
454 
456  {
457  static const std::string noAcceptanceFile = "no-acceptance-needed\n";
458  bool accept = true;
459 
460  Pathname licenseTgz( _pimpl->licenseTgz() );
461  if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
462  return false; // no licenses at all
463 
465  cmd.push_back( "tar" );
466  cmd.push_back( "-t" );
467  cmd.push_back( "-z" );
468  cmd.push_back( "-f" );
469  cmd.push_back( licenseTgz.asString() );
470 
472  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
473  {
474  if ( output == noAcceptanceFile )
475  {
476  accept = false;
477  }
478  }
479  MIL << "License for " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
480  return accept;
481  }
482 
483  std::string RepoInfo::getLicense( const Locale & lang_r )
484  { return const_cast<const RepoInfo *>(this)->getLicense( lang_r ); }
485 
486  std::string RepoInfo::getLicense( const Locale & lang_r ) const
487  {
488  LocaleSet avlocales( getLicenseLocales() );
489  if ( avlocales.empty() )
490  return std::string();
491 
492  Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
493  if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
494  {
495  WAR << "License.tar.gz contains no fallback text! " << *this << endl;
496  // Using the fist locale instead of returning no text at all.
497  // So the user might recognize that there is a license, even if he
498  // can't read it.
499  getLang = *avlocales.begin();
500  }
501 
502  // now extract the license file.
503  static const std::string licenseFileFallback( "license.txt" );
504  std::string licenseFile( !getLang ? licenseFileFallback
505  : str::form( "license.%s.txt", getLang.c_str() ) );
506 
508  cmd.push_back( "tar" );
509  cmd.push_back( "-x" );
510  cmd.push_back( "-z" );
511  cmd.push_back( "-O" );
512  cmd.push_back( "-f" );
513  cmd.push_back( _pimpl->licenseTgz().asString() ); // if it not exists, avlocales was empty.
514  cmd.push_back( licenseFile );
515 
516  std::string ret;
518  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
519  {
520  ret += output;
521  }
522  prog.close();
523  return ret;
524  }
525 
527  {
528  Pathname licenseTgz( _pimpl->licenseTgz() );
529  if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
530  return LocaleSet();
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 
539  LocaleSet ret;
541  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
542  {
543  static const C_Str license( "license." );
544  static const C_Str dotTxt( ".txt\n" );
545  if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
546  {
547  if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
548  ret.insert( Locale() );
549  else
550  ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
551  }
552  }
553  prog.close();
554  return ret;
555  }
556 
558 
559  std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
560  {
562  if ( _pimpl->baseurl2dump() )
563  {
564  for ( const auto & url : _pimpl->baseUrls().raw() )
565  {
566  str << "- url : " << url << std::endl;
567  }
568  }
569 
570  // print if non empty value
571  auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
572  if ( ! value_r.empty() )
573  str << tag_r << value_r << std::endl;
574  });
575 
576  strif( (_pimpl->_mirrorListForceMetalink ? "- metalink : " : "- mirrorlist : "), rawMirrorListUrl().asString() );
577  strif( "- path : ", path().asString() );
578  str << "- type : " << type() << std::endl;
579  str << "- priority : " << priority() << std::endl;
580 
581  // Yes No Default(Y) Default(N)
582 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
583  str << "- gpgcheck : " << OUTS(_pimpl->_gpgCheck,gpgCheck())
584  << " repo" << OUTS(_pimpl->_repoGpgCheck,repoGpgCheck())
585  << " sig" << asString( validRepoSignature(), "?", "Y", "N" )
586  << " pkg" << OUTS(_pimpl->_pkgGpgCheck,pkgGpgCheck())
587  << std::endl;
588 #undef OUTS
589 
590  strif( "- gpgkey : ", rawGpgKeyUrl().asString() );
591 
592  if ( ! indeterminate(_pimpl->keeppackages) )
593  str << "- keeppackages: " << keepPackages() << std::endl;
594 
595  strif( "- service : ", service() );
596  strif( "- targetdistro: ", targetDistribution() );
597  strif( "- metadataPath: ", metadataPath().asString() );
598  strif( "- packagesPath: ", packagesPath().asString() );
599 
600  return str;
601  }
602 
603  std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
604  {
605  RepoInfoBase::dumpAsIniOn(str);
606 
607  if ( _pimpl->baseurl2dump() )
608  {
609  str << "baseurl=";
610  std::string indent;
611  for ( const auto & url : _pimpl->baseUrls().raw() )
612  {
613  str << indent << url << endl;
614  if ( indent.empty() ) indent = " "; // "baseurl="
615  }
616  }
617 
618  if ( ! _pimpl->path.empty() )
619  str << "path="<< path() << endl;
620 
621  if ( ! (rawMirrorListUrl().asString().empty()) )
622  str << (_pimpl->_mirrorListForceMetalink ? "metalink=" : "mirrorlist=") << rawMirrorListUrl() << endl;
623 
624  str << "type=" << type().asString() << endl;
625 
626  if ( priority() != defaultPriority() )
627  str << "priority=" << priority() << endl;
628 
629  if ( ! indeterminate(_pimpl->_gpgCheck) )
630  str << "gpgcheck=" << (_pimpl->_gpgCheck ? "1" : "0") << endl;
631 
632  if ( ! indeterminate(_pimpl->_repoGpgCheck) )
633  str << "repo_gpgcheck=" << (_pimpl->_repoGpgCheck ? "1" : "0") << endl;
634 
635  if ( ! indeterminate(_pimpl->_pkgGpgCheck) )
636  str << "pkg_gpgcheck=" << (_pimpl->_pkgGpgCheck ? "1" : "0") << endl;
637 
638  if ( ! (rawGpgKeyUrl().asString().empty()) )
639  str << "gpgkey=" << rawGpgKeyUrl() << endl;
640 
641  if (!indeterminate(_pimpl->keeppackages))
642  str << "keeppackages=" << keepPackages() << endl;
643 
644  if( ! service().empty() )
645  str << "service=" << service() << endl;
646 
647  return str;
648  }
649 
650  std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
651  {
652  std::string tmpstr;
653  str
654  << "<repo"
655  << " alias=\"" << escape(alias()) << "\""
656  << " name=\"" << escape(name()) << "\"";
657  if (type() != repo::RepoType::NONE)
658  str << " type=\"" << type().asString() << "\"";
659  str
660  << " priority=\"" << priority() << "\""
661  << " enabled=\"" << enabled() << "\""
662  << " autorefresh=\"" << autorefresh() << "\""
663  << " gpgcheck=\"" << gpgCheck() << "\""
664  << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
665  << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
666  if (!(tmpstr = gpgKeyUrl().asString()).empty())
667  str << " gpgkey=\"" << escape(tmpstr) << "\"";
668  if (!(tmpstr = mirrorListUrl().asString()).empty())
669  str << (_pimpl->_mirrorListForceMetalink ? " metalink=\"" : " mirrorlist=\"") << escape(tmpstr) << "\"";
670  str << ">" << endl;
671 
672  if ( _pimpl->baseurl2dump() )
673  {
674  for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
675  str << "<url>" << escape((*it).asString()) << "</url>" << endl;
676  }
677 
678  str << "</repo>" << endl;
679  return str;
680  }
681 
682 
683  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
684  {
685  return obj.dumpOn(str);
686  }
687 
688 
690 } // 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:526
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadatapath.
Definition: RepoInfo.cc:155
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:414
#define MIL
Definition: Logger.h:64
void setGpgKeyUrl(const Url &gpgkey)
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:333
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:265
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:417
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:603
TriBool _pkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck && no valid repo sign.))
Definition: RepoInfo.cc:212
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
bool _mirrorListForceMetalink
Definition: RepoInfo.cc:219
static ZConfig & instance()
Singleton ctor.
Definition: Resolver.cc:121
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:271
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:445
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:327
repo::RepoVariablesUrlReplacer replacer
Definition: RepoInfo.cc:228
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:420
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:381
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Definition: RepoInfo.cc:242
Pathname metadatapath
Definition: RepoInfo.cc:224
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:296
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:359
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:307
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:278
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:344
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
RepoVariablesReplacedUrl _gpgKeyUrl
Definition: RepoInfo.cc:217
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:423
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:168
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:384
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:262
#define OUTS(T, B)
TriBool triBoolFromPath(const Pathname &path_r) const
Definition: RepoInfo.cc:204
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:323
std::vector< std::string > Arguments
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:285
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:210
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
RepoVariablesReplacedUrlList _baseUrls
Definition: RepoInfo.cc:231
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:43
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:378
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:455
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:393
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:259
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:90
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:292
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:390
bool hasContent() const
Definition: RepoInfo.cc:103
void addContent(const std::string &keyword_r)
Definition: RepoInfo.cc:100
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:353
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:441
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:372
#define WAR
Definition: Logger.h:65
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:363
bool gpgCheck() const
Whether default signature checking should be performed for this repo.
Definition: RepoInfo.cc:275
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
Definition: String.h:1058
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:356
TriBool _validRepoSignature
have signed and valid repo metadata
Definition: RepoInfo.cc:214
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:432
Impl * clone() const
clone for RWCOW_pointer
Definition: RepoInfo.cc:236
std::pair< FalseBool, std::set< std::string > > _keywords
Definition: RepoInfo.cc:232
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:369
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:411
bool baseurl2dump() const
Definition: RepoInfo.cc:93
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:336
std::string receiveLine()
Read one line from the input stream.
static const RepoType NONE
Definition: RepoType.h:32
static const unsigned noPriority
Definition: RepoInfo.cc:61
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:366
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:402
const std::vector< Url > & getUrls() const
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:405
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:211
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:330
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:429
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:387
void setProbedType(const repo::RepoType &t) const
Definition: RepoInfo.cc:63
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition: RepoInfo.cc:186
const char * c_str() const
Definition: IdStringType.h:105
Pathname licenseTgz() const
Definition: RepoInfo.cc:74
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:1036
const std::set< std::string > & contentKeywords() const
Definition: RepoInfo.cc:97
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:375
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:486
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
XmlString nodeText()
If the curent node is not empty, advances the reader to the next node, and returns the value...
Definition: Reader.cc:140
Pathname packagespath
Definition: RepoInfo.cc:225
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:449
bool hasContent(const std::string &keyword_r) const
Definition: RepoInfo.cc:148
Url gpgKeyUrl() const
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:396
RepoVariablesReplacedUrl _mirrorListUrl
Definition: RepoInfo.cc:218
DefaultIntegral< unsigned, defaultPriority > priority
Definition: RepoInfo.cc:226
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:435
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:350
std::string targetDistro
Definition: RepoInfo.cc:223
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:438
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:650
repo::RepoType type
Definition: RepoInfo.cc:220
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:314
Functor replacing repository variables.
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:426
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
static const unsigned defaultPriority
Definition: RepoInfo.cc:60
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:268
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:77
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:304
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
Url rawGpgKeyUrl() const
The raw gpgKeyUrl (no variables replaced).
Definition: RepoInfo.cc:399
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:408
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:559
#define DBG
Definition: Logger.h:63
std::string service
Definition: RepoInfo.cc:222
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:683