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