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