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