libzypp  17.8.1
RepoInfo.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13 #include <vector>
14 #include <fstream>
15 
16 #include "zypp/base/Gettext.h"
17 #include "zypp/base/LogTools.h"
20 
21 #include "zypp/ManagedFile.h"
22 #include "zypp/PublicKey.h"
23 #include "zypp/MediaSetAccess.h"
24 #include "zypp/RepoInfo.h"
25 #include "zypp/Glob.h"
26 #include "zypp/TriBool.h"
27 #include "zypp/Pathname.h"
28 #include "zypp/ZConfig.h"
30 #include "zypp/ExternalProgram.h"
31 #include "zypp/media/MediaAccess.h"
32 
33 #include "zypp/base/IOStream.h"
34 #include "zypp/base/InputStream.h"
35 #include "zypp/parser/xml/Reader.h"
36 
37 
38 #include "zypp/base/StrMatcher.h"
39 #include "zypp/KeyRing.h"
40 #include "zypp/TmpPath.h"
41 #include "zypp/ZYppFactory.h"
42 #include "zypp/ZYppCallbacks.h"
43 
44 using std::endl;
45 using zypp::xml::escape;
46 
48 namespace zypp
49 {
50 
52  //
53  // CLASS NAME : RepoInfo::Impl
54  //
57  {
58  Impl()
59  : _rawGpgCheck( indeterminate )
60  , _rawRepoGpgCheck( indeterminate )
61  , _rawPkgGpgCheck( indeterminate )
62  , _validRepoSignature( indeterminate )
63  , keeppackages(indeterminate)
65  , type(repo::RepoType::NONE_e)
66  , emptybaseurls(false)
67  {}
68 
70  {}
71 
72  public:
73  static const unsigned defaultPriority = 99;
74  static const unsigned noPriority = unsigned(-1);
75 
76  void setProbedType( const repo::RepoType & t ) const
77  {
79  && t != repo::RepoType::NONE )
80  {
81  // lazy init!
82  const_cast<Impl*>(this)->type = t;
83  }
84  }
85 
86  public:
88  Pathname licenseTgz( const std::string & name_r ) const
89  {
90  Pathname ret;
91  if ( !metadataPath().empty() )
92  {
93  std::string licenseStem( "license" );
94  if ( !name_r.empty() )
95  {
96  licenseStem += "-";
97  licenseStem += name_r;
98  }
99 
101  // TODO: REPOMD: this assumes we know the name of the tarball. In fact
102  // we'd need to get the file from repomd.xml (<data type="license[-name_r]">)
103  g.add( metadataPath() / path / ("repodata/*"+licenseStem+".tar.gz") );
104  if ( g.empty() )
105  g.add( metadataPath() / path / (licenseStem+".tar.gz") );
106 
107  if ( !g.empty() )
108  ret = *g.begin();
109  }
110  return ret;
111  }
112 
114  {
115  const Url & mlurl( _mirrorListUrl.transformed() ); // Variables replaced!
116  if ( _baseUrls.empty() && ! mlurl.asString().empty() )
117  {
118  emptybaseurls = true;
119  DBG << "MetadataPath: " << metadataPath() << endl;
121  _baseUrls.raw().insert( _baseUrls.raw().end(), rmurls.getUrls().begin(), rmurls.getUrls().end() );
122  }
123  return _baseUrls;
124  }
125 
127  { return _baseUrls; }
128 
129  bool baseurl2dump() const
130  { return !emptybaseurls && !_baseUrls.empty(); }
131 
132 
134  { return _gpgKeyUrls; }
135 
137  { return _gpgKeyUrls; }
138 
139 
140  const std::set<std::string> & contentKeywords() const
141  { hasContent()/*init if not yet done*/; return _keywords.second; }
142 
143  void addContent( const std::string & keyword_r )
144  { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
145 
146  bool hasContent() const
147  {
148  if ( !_keywords.first && ! metadataPath().empty() )
149  {
150  // HACK directly check master index file until RepoManager offers
151  // some content probing and zypper uses it.
153  MIL << "Empty keywords...." << metadataPath() << endl;
154  Pathname master;
155  if ( PathInfo( (master=metadataPath()/"/repodata/repomd.xml") ).isFile() )
156  {
157  //MIL << "GO repomd.." << endl;
158  xml::Reader reader( master );
159  while ( reader.seekToNode( 2, "content" ) )
160  {
161  _keywords.second.insert( reader.nodeText().asString() );
162  reader.seekToEndNode( 2, "content" );
163  }
164  _keywords.first = true; // valid content in _keywords even if empty
165  }
166  else if ( PathInfo( (master=metadataPath()/"/content") ).isFile() )
167  {
168  //MIL << "GO content.." << endl;
169  iostr::forEachLine( InputStream( master ),
170  [this]( int num_r, std::string line_r )->bool
171  {
172  if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
173  {
174  std::vector<std::string> words;
175  if ( str::split( line_r, std::back_inserter(words) ) > 1
176  && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
177  {
178  this->_keywords.second.insert( ++words.begin(), words.end() );
179  }
180  return true; // mult. occurrances are ok.
181  }
182  return( ! str::startsWith( line_r, "META " ) ); // no need to parse into META section.
183  } );
184  _keywords.first = true; // valid content in _keywords even if empty
185  }
187  }
188  return _keywords.first;
189  }
190 
191  bool hasContent( const std::string & keyword_r ) const
192  { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
193 
199  {
200  if ( ! indeterminate(_validRepoSignature) )
201  return _validRepoSignature;
202  // check metadata:
203  if ( ! metadataPath().empty() )
204  {
205  // A missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
206  TriBool linkval = triBoolFromPath( metadataPath() / ".repo_gpgcheck" );
207  return linkval;
208  }
209  return indeterminate;
210  }
211 
213  {
214  if ( PathInfo(metadataPath()).isDir() )
215  {
216  Pathname gpgcheckFile( metadataPath() / ".repo_gpgcheck" );
217  if ( PathInfo(gpgcheckFile).isExist() )
218  {
219  TriBool linkval( indeterminate );
220  if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
221  return; // existing symlink fits value_r
222  else
223  filesystem::unlink( gpgcheckFile ); // will write a new one
224  }
225  filesystem::symlink( asString(value_r), gpgcheckFile );
226  }
227  _validRepoSignature = value_r;
228  }
229 
235  {
236  TriBool linkval( true ); // want to see it being switched to indeterminate
237  return triBoolFromPath( metadataPath() / ".repo_gpgcheck", linkval ) && indeterminate(linkval);
238  }
239 
240  bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
241  {
242  static const Pathname truePath( "true" );
243  static const Pathname falsePath( "false" );
244  static const Pathname indeterminatePath( "indeterminate" );
245 
246  // Quiet readlink;
247  static const ssize_t bufsiz = 63;
248  static char buf[bufsiz+1];
249  ssize_t ret = ::readlink( path_r.c_str(), buf, bufsiz );
250  buf[ret == -1 ? 0 : ret] = '\0';
251 
252  Pathname linkval( buf );
253 
254  bool known = true;
255  if ( linkval == truePath )
256  ret_r = true;
257  else if ( linkval == falsePath )
258  ret_r = false;
259  else if ( linkval == indeterminatePath )
260  ret_r = indeterminate;
261  else
262  known = false;
263  return known;
264  }
265 
266  TriBool triBoolFromPath( const Pathname & path_r ) const
267  { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
268 
270 
271  private:
275 
276  public:
277  TriBool rawGpgCheck() const { return _rawGpgCheck; }
280 
281  void rawGpgCheck( TriBool val_r ) { _rawGpgCheck = val_r; }
282  void rawRepoGpgCheck( TriBool val_r ) { _rawRepoGpgCheck = val_r; }
283  void rawPkgGpgCheck( TriBool val_r ) { _rawPkgGpgCheck = val_r; }
284 
285  bool cfgGpgCheck() const
286  { return indeterminate(_rawGpgCheck) ? ZConfig::instance().gpgCheck() : (bool)_rawGpgCheck; }
288  { return indeterminate(_rawGpgCheck) && indeterminate(_rawRepoGpgCheck) ? ZConfig::instance().repoGpgCheck() : _rawRepoGpgCheck; }
290  { return indeterminate(_rawGpgCheck) && indeterminate(_rawPkgGpgCheck) ? ZConfig::instance().pkgGpgCheck() : _rawPkgGpgCheck; }
291 
292  private:
294  public:
300  std::string service;
301  std::string targetDistro;
302 
303  void metadataPath( Pathname new_r )
304  { _metadataPath = std::move( new_r ); }
305 
306  void packagesPath( Pathname new_r )
307  { _packagesPath = std::move( new_r ); }
308 
310  { return str::hasSuffix( _metadataPath.asString(), "/%AUTO%" ); }
311 
313  {
314  if ( usesAutoMethadataPaths() )
315  return _metadataPath.dirname() / "%RAW%";
316  return _metadataPath;
317  }
318 
320  {
322  return _metadataPath.dirname() / "%PKG%";
323  return _packagesPath;
324  }
325 
327  mutable bool emptybaseurls;
328 
329  private:
332 
334  mutable std::pair<FalseBool, std::set<std::string> > _keywords;
335 
337 
338  friend Impl * rwcowClone<Impl>( const Impl * rhs );
340  Impl * clone() const
341  { return new Impl( *this ); }
342  };
344 
346  inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
347  {
348  return str << "RepoInfo::Impl";
349  }
350 
352  //
353  // CLASS NAME : RepoInfo
354  //
356 
358 
360  : _pimpl( new Impl() )
361  {}
362 
364  {}
365 
366  unsigned RepoInfo::priority() const
367  { return _pimpl->priority; }
368 
370  { return Impl::defaultPriority; }
371 
373  { return Impl::noPriority; }
374 
375  void RepoInfo::setPriority( unsigned newval_r )
376  { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
377 
378 
379  bool RepoInfo::gpgCheck() const
380  { return _pimpl->cfgGpgCheck(); }
381 
383  { _pimpl->rawGpgCheck( value_r ); }
384 
385  void RepoInfo::setGpgCheck( bool value_r ) // deprecated legacy and for squid
386  { setGpgCheck( TriBool(value_r) ); }
387 
388 
390  { return gpgCheck() || _pimpl->cfgRepoGpgCheck(); }
391 
393  {
394  bool ret = ( gpgCheck() && indeterminate(_pimpl->cfgRepoGpgCheck()) ) || _pimpl->cfgRepoGpgCheck();
395  if ( ret && _pimpl->internalUnsignedConfirmed() ) // relax if unsigned repo was confirmed in the past
396  ret = false;
397  return ret;
398  }
399 
401  { _pimpl->rawRepoGpgCheck( value_r ); }
402 
403 
405  { return _pimpl->cfgPkgGpgCheck() || ( gpgCheck() && !bool(validRepoSignature())/*enforced*/ ) ; }
406 
408  { return _pimpl->cfgPkgGpgCheck() || ( gpgCheck() && indeterminate(_pimpl->cfgPkgGpgCheck()) && !bool(validRepoSignature())/*enforced*/ ); }
409 
411  { _pimpl->rawPkgGpgCheck( value_r ); }
412 
413 
414  void RepoInfo::getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const
415  {
416  g_r = _pimpl->rawGpgCheck();
417  r_r = _pimpl->rawRepoGpgCheck();
418  p_r = _pimpl->rawPkgGpgCheck();
419  }
420 
421 
423  {
425  if ( ret && !repoGpgCheck() ) ret = false; // invalidate any old signature if repoGpgCheck is off
426  return ret;
427  }
428 
430  { _pimpl->internalSetValidRepoSignature( value_r ); }
431 
433  namespace
434  {
435  inline bool changeGpgCheckTo( TriBool & lhs, TriBool rhs )
436  { if ( ! sameTriboolState( lhs, rhs ) ) { lhs = rhs; return true; } return false; }
437 
438  inline bool changeGpgCheckTo( TriBool ogpg[3], TriBool g, TriBool r, TriBool p )
439  {
440  bool changed = false;
441  if ( changeGpgCheckTo( ogpg[0], g ) ) changed = true;
442  if ( changeGpgCheckTo( ogpg[1], r ) ) changed = true;
443  if ( changeGpgCheckTo( ogpg[2], p ) ) changed = true;
444  return changed;
445  }
446  } // namespace
449  {
450  TriBool ogpg[3]; // Gpg RepoGpg PkgGpg
451  getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
452 
453  bool changed = false;
454  switch ( mode_r )
455  {
456  case GpgCheck::On:
457  changed = changeGpgCheckTo( ogpg, true, indeterminate, indeterminate );
458  break;
459  case GpgCheck::Strict:
460  changed = changeGpgCheckTo( ogpg, true, true, true );
461  break;
463  changed = changeGpgCheckTo( ogpg, true, false, false );
464  break;
466  changed = changeGpgCheckTo( ogpg, true, false, indeterminate );
467  break;
469  changed = changeGpgCheckTo( ogpg, true, indeterminate, false );
470  break;
471  case GpgCheck::Default:
472  changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
473  break;
474  case GpgCheck::Off:
475  changed = changeGpgCheckTo( ogpg, false, indeterminate, indeterminate );
476  break;
477  case GpgCheck::indeterminate: // no change
478  break;
479  }
480 
481  if ( changed )
482  {
483  setGpgCheck ( ogpg[0] );
484  setRepoGpgCheck( ogpg[1] );
485  setPkgGpgCheck ( ogpg[2] );
486  }
487  return changed;
488  }
489 
490  void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
491  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = false; }
492 
493  void RepoInfo::setMetalinkUrl( const Url & url_r ) // Raw
494  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = true; }
495 
497  { _pimpl->gpgKeyUrls().raw().swap( urls ); }
498 
499  void RepoInfo::setGpgKeyUrl( const Url & url_r )
500  {
501  _pimpl->gpgKeyUrls().raw().clear();
502  _pimpl->gpgKeyUrls().raw().push_back( url_r );
503  }
504 
505  Pathname RepoInfo::provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
506  {
507  if ( keyID_r.empty() )
508  return Pathname();
509 
510  MIL << "Check for " << keyID_r << " at " << targetDirectory_r << endl;
511  std::string keyIDStr( keyID_r.size() > 8 ? keyID_r.substr( keyID_r.size()-8 ) : keyID_r ); // print short ID in Jobreports
512  filesystem::TmpDir tmpKeyRingDir;
513  KeyRing tempKeyRing(tmpKeyRingDir.path());
514 
515  // translator: %1% is a gpg key ID like 3DBDC284
516  // %2% is a cache directories path
517  JobReport::info( str::Format(_("Looking for gpg key ID %1% in cache %2%.") ) % keyIDStr % targetDirectory_r );
518  filesystem::dirForEach(targetDirectory_r,
519  StrMatcher(".key", Match::STRINGEND),
520  [&tempKeyRing]( const Pathname & dir_r, const std::string & str_r ){
521  try {
522 
523  // deprecate a month old keys
524  PathInfo fileInfo ( dir_r/str_r );
525  if ( Date::now() - fileInfo.mtime() > Date::month ) {
526  //if unlink fails, the file will be overriden in the next step, no need
527  //to show a error
528  filesystem::unlink( dir_r/str_r );
529  } else {
530  tempKeyRing.multiKeyImport(dir_r/str_r, true);
531  }
532  } catch (const KeyRingException& e) {
533  ZYPP_CAUGHT(e);
534  ERR << "Error importing cached key from file '"<<dir_r/str_r<<"'."<<endl;
535  }
536  return true;
537  });
538 
539  // no key in the cache is what we are looking for, lets download
540  // all keys specified in gpgkey= entries
541  if ( !tempKeyRing.isKeyTrusted(keyID_r) ) {
542  if ( ! gpgKeyUrlsEmpty() ) {
543  // translator: %1% is a gpg key ID like 3DBDC284
544  // %2% is a repositories name
545  JobReport::info( str::Format(_("Looking for gpg key ID %1% in repository %2%.") ) % keyIDStr % asUserString() );
546  for ( const Url &url : gpgKeyUrls() ) {
547  try {
548  JobReport::info( " gpgkey=" + url.asString() );
550  if ( f->empty() )
551  continue;
552 
553  PublicKey key(f);
554  if ( !key.isValid() )
555  continue;
556 
557  // import all keys into our temporary keyring
558  tempKeyRing.multiKeyImport(f, true);
559 
560  } catch ( const std::exception & e ) {
561  //ignore and continue to next url
562  ZYPP_CAUGHT(e);
563  MIL << "Key import from url:'"<<url<<"' failed." << endl;
564  }
565  }
566  }
567  else {
568  // translator: %1% is a repositories name
569  JobReport::info( str::Format(_("Repository %1% does not define additional 'gpgkey=' URLs.") ) % asUserString() );
570  }
571  }
572 
573  filesystem::assert_dir( targetDirectory_r );
574 
575  //now write all keys into their own files in cache, override existing ones to always have
576  //up to date key data
577  for ( const auto & key: tempKeyRing.trustedPublicKeyData()) {
578  MIL << "KEY ID in KEYRING: " << key.id() << endl;
579 
580  Pathname keyFile = targetDirectory_r/(str::Format("%1%.key") % key.rpmName()).asString();
581 
582  std::ofstream fout( keyFile.c_str(), std::ios_base::out | std::ios_base::trunc );
583 
584  if (!fout)
585  ZYPP_THROW(Exception(str::form("Cannot open file %s",keyFile.c_str())));
586 
587  tempKeyRing.dumpTrustedPublicKey( key.id(), fout );
588  }
589 
590  // key is STILL not known, we give up
591  if ( !tempKeyRing.isKeyTrusted(keyID_r) ) {
592  return Pathname();
593  }
594 
595  PublicKeyData keyData( tempKeyRing.trustedPublicKeyData( keyID_r ) );
596  if ( !keyData ) {
597  ERR << "Error when exporting key from temporary keychain." << endl;
598  return Pathname();
599  }
600 
601  return targetDirectory_r/(str::Format("%1%.key") % keyData.rpmName()).asString();
602  }
603 
604  void RepoInfo::addBaseUrl( const Url & url_r )
605  {
606  for ( const auto & url : _pimpl->baseUrls().raw() ) // Raw unique!
607  if ( url == url_r )
608  return;
609  _pimpl->baseUrls().raw().push_back( url_r );
610  }
611 
612  void RepoInfo::setBaseUrl( const Url & url_r )
613  {
614  _pimpl->baseUrls().raw().clear();
615  _pimpl->baseUrls().raw().push_back( url_r );
616  }
617 
619  { _pimpl->baseUrls().raw().swap( urls ); }
620 
621  void RepoInfo::setPath( const Pathname &path )
622  { _pimpl->path = path; }
623 
625  { _pimpl->type = t; }
626 
628  { _pimpl->setProbedType( t ); }
629 
630 
632  { _pimpl->metadataPath( path ); }
633 
635  { _pimpl->packagesPath( path ); }
636 
637  void RepoInfo::setKeepPackages( bool keep )
638  { _pimpl->keeppackages = keep; }
639 
640  void RepoInfo::setService( const std::string& name )
641  { _pimpl->service = name; }
642 
643  void RepoInfo::setTargetDistribution( const std::string & targetDistribution )
645 
647  { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
648 
650  { return _pimpl->metadataPath(); }
651 
653  { return _pimpl->packagesPath(); }
654 
656  { return _pimpl->usesAutoMethadataPaths(); }
657 
659  { return _pimpl->type; }
660 
661  Url RepoInfo::mirrorListUrl() const // Variables replaced!
662  { return _pimpl->_mirrorListUrl.transformed(); }
663 
665  { return _pimpl->_mirrorListUrl.raw(); }
666 
668  { return _pimpl->gpgKeyUrls().empty(); }
669 
671  { return _pimpl->gpgKeyUrls().size(); }
672 
673  RepoInfo::url_set RepoInfo::gpgKeyUrls() const // Variables replaced!
674  { return _pimpl->gpgKeyUrls().transformed(); }
675 
677  { return _pimpl->gpgKeyUrls().raw(); }
678 
679  Url RepoInfo::gpgKeyUrl() const // Variables replaced!
680  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
681 
683  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
684 
685  RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
686  { return _pimpl->baseUrls().transformed(); }
687 
689  { return _pimpl->baseUrls().raw(); }
690 
692  { return _pimpl->path; }
693 
694  std::string RepoInfo::service() const
695  { return _pimpl->service; }
696 
697  std::string RepoInfo::targetDistribution() const
698  { return _pimpl->targetDistro; }
699 
701  { return( _pimpl->baseUrls().empty() ? Url() : *_pimpl->baseUrls().rawBegin() ); }
702 
704  { return _pimpl->baseUrls().transformedBegin(); }
705 
707  { return _pimpl->baseUrls().transformedEnd(); }
708 
710  { return _pimpl->baseUrls().size(); }
711 
713  { return _pimpl->baseUrls().empty(); }
714 
715  bool RepoInfo::baseUrlSet() const
716  { return _pimpl->baseurl2dump(); }
717 
718  const std::set<std::string> & RepoInfo::contentKeywords() const
719  { return _pimpl->contentKeywords(); }
720 
721  void RepoInfo::addContent( const std::string & keyword_r )
722  { _pimpl->addContent( keyword_r ); }
723 
724  bool RepoInfo::hasContent() const
725  { return _pimpl->hasContent(); }
726 
727  bool RepoInfo::hasContent( const std::string & keyword_r ) const
728  { return _pimpl->hasContent( keyword_r ); }
729 
731 
732  bool RepoInfo::hasLicense() const
733  { return hasLicense( std::string() ); }
734 
735  bool RepoInfo::hasLicense( const std::string & name_r ) const
736  { return !_pimpl->licenseTgz( name_r ).empty(); }
737 
738 
740  { return needToAcceptLicense( std::string() ); }
741 
742  bool RepoInfo::needToAcceptLicense( const std::string & name_r ) const
743  {
744  const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
745  if ( licenseTgz.empty() )
746  return false; // no licenses at all
747 
749  cmd.push_back( "tar" );
750  cmd.push_back( "-t" );
751  cmd.push_back( "-z" );
752  cmd.push_back( "-f" );
753  cmd.push_back( licenseTgz.asString() );
755 
756  bool accept = true;
757  static const std::string noAcceptanceFile = "no-acceptance-needed\n";
758  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
759  {
760  if ( output == noAcceptanceFile )
761  {
762  accept = false;
763  }
764  }
765  prog.close();
766  MIL << "License(" << name_r << ") in " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
767  return accept;
768  }
769 
770 
771  std::string RepoInfo::getLicense( const Locale & lang_r )
772  { return const_cast<const RepoInfo *>(this)->getLicense( std::string(), lang_r ); }
773 
774  std::string RepoInfo::getLicense( const Locale & lang_r ) const
775  { return getLicense( std::string(), lang_r ); }
776 
777  std::string RepoInfo::getLicense( const std::string & name_r, const Locale & lang_r ) const
778  {
779  LocaleSet avlocales( getLicenseLocales( name_r ) );
780  if ( avlocales.empty() )
781  return std::string();
782 
783  Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
784  if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
785  {
786  WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
787  // Using the fist locale instead of returning no text at all.
788  // So the user might recognize that there is a license, even if he
789  // can't read it.
790  getLang = *avlocales.begin();
791  }
792 
793  // now extract the license file.
794  static const std::string licenseFileFallback( "license.txt" );
795  std::string licenseFile( !getLang ? licenseFileFallback
796  : str::form( "license.%s.txt", getLang.c_str() ) );
797 
799  cmd.push_back( "tar" );
800  cmd.push_back( "-x" );
801  cmd.push_back( "-z" );
802  cmd.push_back( "-O" );
803  cmd.push_back( "-f" );
804  cmd.push_back( _pimpl->licenseTgz( name_r ).asString() ); // if it not exists, avlocales was empty.
805  cmd.push_back( licenseFile );
806 
807  std::string ret;
809  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
810  {
811  ret += output;
812  }
813  prog.close();
814  return ret;
815  }
816 
817 
819  { return getLicenseLocales( std::string() ); }
820 
821  LocaleSet RepoInfo::getLicenseLocales( const std::string & name_r ) const
822  {
823  const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
824  if ( licenseTgz.empty() )
825  return LocaleSet();
826 
828  cmd.push_back( "tar" );
829  cmd.push_back( "-t" );
830  cmd.push_back( "-z" );
831  cmd.push_back( "-f" );
832  cmd.push_back( licenseTgz.asString() );
833 
834  LocaleSet ret;
836  for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
837  {
838  static const C_Str license( "license." );
839  static const C_Str dotTxt( ".txt\n" );
840  if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
841  {
842  if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
843  ret.insert( Locale() );
844  else
845  ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
846  }
847  }
848  prog.close();
849  return ret;
850  }
851 
853 
854  std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
855  {
857  if ( _pimpl->baseurl2dump() )
858  {
859  for ( const auto & url : _pimpl->baseUrls().raw() )
860  {
861  str << "- url : " << url << std::endl;
862  }
863  }
864 
865  // print if non empty value
866  auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
867  if ( ! value_r.empty() )
868  str << tag_r << value_r << std::endl;
869  });
870 
871  strif( (_pimpl->_mirrorListForceMetalink ? "- metalink : " : "- mirrorlist : "), rawMirrorListUrl().asString() );
872  strif( "- path : ", path().asString() );
873  str << "- type : " << type() << std::endl;
874  str << "- priority : " << priority() << std::endl;
875 
876  // Yes No Default(Y) Default(N)
877 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
878  str << "- gpgcheck : " << OUTS(_pimpl->rawGpgCheck(),gpgCheck())
879  << " repo" << OUTS(_pimpl->rawRepoGpgCheck(),repoGpgCheck()) << (repoGpgCheckIsMandatory() ? "* ": " " )
880  << "sig" << asString( validRepoSignature(), "?", "Y", "N" )
881  << " pkg" << OUTS(_pimpl->rawPkgGpgCheck(),pkgGpgCheck()) << (pkgGpgCheckIsMandatory() ? "* ": " " )
882  << std::endl;
883 #undef OUTS
884 
885  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
886  {
887  str << "- gpgkey : " << url << std::endl;
888  }
889 
890  if ( ! indeterminate(_pimpl->keeppackages) )
891  str << "- keeppackages: " << keepPackages() << std::endl;
892 
893  strif( "- service : ", service() );
894  strif( "- targetdistro: ", targetDistribution() );
895  strif( "- filePath: ", filepath().asString() );
896  strif( "- metadataPath: ", metadataPath().asString() );
897  strif( "- packagesPath: ", packagesPath().asString() );
898 
899  return str;
900  }
901 
902  std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
903  {
904  RepoInfoBase::dumpAsIniOn(str);
905 
906  if ( _pimpl->baseurl2dump() )
907  {
908  str << "baseurl=";
909  std::string indent;
910  for ( const auto & url : _pimpl->baseUrls().raw() )
911  {
912  str << indent << url << endl;
913  if ( indent.empty() ) indent = " "; // "baseurl="
914  }
915  }
916 
917  if ( ! _pimpl->path.empty() )
918  str << "path="<< path() << endl;
919 
920  if ( ! (rawMirrorListUrl().asString().empty()) )
921  str << (_pimpl->_mirrorListForceMetalink ? "metalink=" : "mirrorlist=") << rawMirrorListUrl() << endl;
922 
923  str << "type=" << type().asString() << endl;
924 
925  if ( priority() != defaultPriority() )
926  str << "priority=" << priority() << endl;
927 
928  if ( ! indeterminate(_pimpl->rawGpgCheck()) )
929  str << "gpgcheck=" << (_pimpl->rawGpgCheck() ? "1" : "0") << endl;
930 
931  if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
932  str << "repo_gpgcheck=" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << endl;
933 
934  if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
935  str << "pkg_gpgcheck=" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << endl;
936 
937  {
938  std::string indent( "gpgkey=");
939  for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
940  {
941  str << indent << url << endl;
942  if ( indent[0] != ' ' )
943  indent = " ";
944  }
945  }
946 
947  if (!indeterminate(_pimpl->keeppackages))
948  str << "keeppackages=" << keepPackages() << endl;
949 
950  if( ! service().empty() )
951  str << "service=" << service() << endl;
952 
953  return str;
954  }
955 
956  std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
957  {
958  std::string tmpstr;
959  str
960  << "<repo"
961  << " alias=\"" << escape(alias()) << "\""
962  << " name=\"" << escape(name()) << "\"";
963  if (type() != repo::RepoType::NONE)
964  str << " type=\"" << type().asString() << "\"";
965  str
966  << " priority=\"" << priority() << "\""
967  << " enabled=\"" << enabled() << "\""
968  << " autorefresh=\"" << autorefresh() << "\""
969  << " gpgcheck=\"" << gpgCheck() << "\""
970  << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
971  << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
972  if (!(tmpstr = gpgKeyUrl().asString()).empty())
973  str << " gpgkey=\"" << escape(tmpstr) << "\"";
974  if (!(tmpstr = mirrorListUrl().asString()).empty())
975  str << (_pimpl->_mirrorListForceMetalink ? " metalink=\"" : " mirrorlist=\"") << escape(tmpstr) << "\"";
976  str << ">" << endl;
977 
978  if ( _pimpl->baseurl2dump() )
979  {
980  for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
981  str << "<url>" << escape((*it).asString()) << "</url>" << endl;
982  }
983 
984  str << "</repo>" << endl;
985  return str;
986  }
987 
988 
989  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
990  {
991  return obj.dumpOn(str);
992  }
993 
994  std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj )
995  {
996  switch ( obj )
997  {
998 #define OUTS( V ) case RepoInfo::V: return str << #V; break
999  OUTS( GpgCheck::On );
1000  OUTS( GpgCheck::Strict );
1001  OUTS( GpgCheck::AllowUnsigned );
1002  OUTS( GpgCheck::AllowUnsignedRepo );
1003  OUTS( GpgCheck::AllowUnsignedPackage );
1004  OUTS( GpgCheck::Default );
1005  OUTS( GpgCheck::Off );
1006  OUTS( GpgCheck::indeterminate );
1007 #undef OUTS
1008  }
1009  return str << "GpgCheck::UNKNOWN";
1010  }
1011 
1013 } // namespace zypp
static ManagedFile provideOptionalFileFromUrl(const Url &file_url)
Provides an optional file from url.
static const Locale noCode
Empty code.
Definition: Locale.h:74
Pathname filepath() const
File where this repo was read from.
int assert_dir(const Pathname &path, unsigned mode)
Like &#39;mkdir -p&#39;.
Definition: PathInfo.cc:320
Pathname path() const
Repository path.
Definition: RepoInfo.cc:691
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:366
Interface to gettext.
#define MIL
Definition: Logger.h:79
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:732
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:673
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:499
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:369
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
Definition: RepoInfo.cc:682
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:700
TriBool rawPkgGpgCheck() const
Definition: RepoInfo.cc:279
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:718
void packagesPath(Pathname new_r)
Definition: RepoInfo.cc:306
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:854
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:392
bool _mirrorListForceMetalink
Definition: RepoInfo.cc:297
static ZConfig & instance()
Singleton ctor.
Definition: Resolver.cc:130
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:694
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:627
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:375
Gpg key handling.
Definition: KeyRing.h:168
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like &#39;readlink&#39;.
Definition: PathInfo.cc:877
void rawGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:281
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:551
Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
downloads all configured gpg keys into the defined directory
Definition: RepoInfo.cc:505
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition: StrMatcher.h:297
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:490
Class representing one GPG Public Keys data.
Definition: PublicKey.h:139
time_t mtime() const
Definition: PathInfo.h:376
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
Definition: PtrTypes.h:151
const char * c_str() const
String representation.
Definition: Pathname.h:109
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Definition: RepoInfo.cc:346
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:407
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:676
String related utilities and Regular expression matching.
std::list< Url > url_set
Definition: RepoInfo.h:103
bool hasContent() const
Definition: RepoInfo.cc:146
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:382
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:274
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \)
Split line_r into words.
Definition: String.h:502
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
Pathname path() const
Definition: TmpPath.cc:146
std::string asUserString() const
User string: label (alias or name)
Definition: RepoInfoBase.h:82
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:612
Convenient building of std::string with boost::format.
Definition: String.h:251
bool usesAutoMethadataPaths() const
Definition: RepoInfo.cc:309
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
void internalSetValidRepoSignature(TriBool value_r)
Definition: RepoInfo.cc:212
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:679
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Definition: RepoInfo.cc:198
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
#define OUTS(T, B)
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:389
#define ERR
Definition: Logger.h:81
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition: RepoInfo.cc:240
const_iterator begin() const
Iterator pointing to the first result.
Definition: Glob.h:197
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition: RepoInfo.cc:655
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:429
std::vector< std::string > Arguments
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:703
bool seekToNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:212
static const ValueType month
Definition: Date.h:49
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:712
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:105
size_type size() const
Definition: String.h:105
Pathname _metadataPath
Definition: RepoInfo.cc:330
const std::string & asString() const
Definition: RepoType.cc:56
RepoVariablesReplacedUrlList _baseUrls
Definition: RepoInfo.cc:333
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:213
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:131
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:661
RepoInfo implementation.
Definition: RepoInfo.cc:56
bool empty() const
Test for an empty path.
Definition: Pathname.h:113
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:646
std::string asString() const
Returns a default string representation of the Url object.
Definition: Url.cc:491
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:667
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
Definition: String.cc:369
virtual ~RepoInfo()
Definition: RepoInfo.cc:363
GpgCheck
Some predefined settings.
Definition: RepoInfo.h:365
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1054
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition: TmpPath.h:177
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:404
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
Pathname packagesPath() const
Definition: RepoInfo.cc:319
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
int unlink(const Pathname &path)
Like &#39;unlink&#39;.
Definition: PathInfo.cc:653
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition: RepoInfo.cc:392
RepoVariablesReplacedUrlList & baseUrls()
Definition: RepoInfo.cc:126
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:400
const std::string & asString() const
String representation.
Definition: Pathname.h:90
TriBool triBoolFromPath(const Pathname &path_r) const
Definition: RepoInfo.cc:266
std::string alias() const
unique identifier for this source.
void addContent(const std::string &keyword_r)
Definition: RepoInfo.cc:143
bool gpgCheck() const
Turn signature checking on/off (on)
Definition: ZConfig.cc:1052
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:90
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
Definition: IOStream.cc:100
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:664
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:621
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:422
Pathname dirname() const
Return all but the last component od this path.
Definition: Pathname.h:123
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:818
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:640
#define WAR
Definition: Logger.h:80
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition: RepoInfo.cc:631
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:715
RepoVariablesReplacedUrlList & gpgKeyUrls()
Definition: RepoInfo.cc:136
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
Definition: String.h:1078
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition: RepoInfo.cc:414
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:624
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1053
bool gpgCheck() const
Whether default signature checking should be performed.
Definition: RepoInfo.cc:379
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
Definition: RepoInfo.cc:272
TriBool _validRepoSignature
have signed and valid repo metadata
Definition: RepoInfo.cc:293
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:724
std::pair< FalseBool, std::set< std::string > > _keywords
Definition: RepoInfo.cc:334
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:637
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:774
bool baseurl2dump() const
Definition: RepoInfo.cc:129
bool empty() const
Whether matches were found.
Definition: Glob.h:189
Match at string end.
Definition: StrMatcher.h:45
bool seekToEndNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:232
const RepoVariablesReplacedUrlList & baseUrls() const
Definition: RepoInfo.cc:113
#define _(MSG)
Definition: Gettext.h:37
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like &#39;symlink&#39;.
Definition: PathInfo.cc:808
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:604
TriBool cfgPkgGpgCheck() const
Definition: RepoInfo.cc:289
std::string receiveLine()
Read one line from the input stream.
bool cfgGpgCheck() const
Definition: RepoInfo.cc:285
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:273
Find pathnames matching a pattern.
Definition: Glob.h:57
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:649
static const RepoType NONE
Definition: RepoType.h:32
static const unsigned noPriority
Definition: RepoInfo.cc:74
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
int add(const Pathname &pattern_r, Flags flags_r=Flags())
Add pathnames matching pattern_r to the current result.
Definition: Glob.h:155
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:634
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:956
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:49
int close()
Wait for the progamm to complete.
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:493
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:496
const std::set< std::string > & contentKeywords() const
Definition: RepoInfo.cc:140
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition: Exception.h:396
void setProbedType(const repo::RepoType &t) const
Definition: RepoInfo.cc:76
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:272
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:1034
void rawRepoGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:282
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:688
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:643
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:739
Base class for Exception.
Definition: Exception.h:145
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:902
static Date now()
Return the current time.
Definition: Date.h:78
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value...
Definition: Reader.cc:140
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Definition: RepoInfo.cc:133
std::string name() const
Repository name.
std::string asString() const
Explicit conversion to std::string.
Definition: XmlString.h:77
Pathname licenseTgz(const std::string &name_r) const
Path to a license tarball in case it exists in the repo.
Definition: RepoInfo.cc:88
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)? I.e.
Definition: RepoInfo.cc:234
RepoVariablesReplacedUrlList _gpgKeyUrls
Definition: RepoInfo.cc:336
TriBool rawRepoGpgCheck() const
Definition: RepoInfo.cc:278
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:92
RepoVariablesReplacedUrl _mirrorListUrl
Definition: RepoInfo.cc:296
DefaultIntegral< unsigned, defaultPriority > priority
Definition: RepoInfo.cc:326
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:697
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:652
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:618
std::string targetDistro
Definition: RepoInfo.cc:301
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:220
int dirForEach(const Pathname &dir_r, function< bool(const Pathname &, const char *const)> fnc_r)
Invoke callback function fnc_r for each entry in directory dir_r.
Definition: PathInfo.cc:542
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:80
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:706
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:721
void rawPkgGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:283
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:709
const std::vector< Url > & getUrls() const
repo::RepoType type
Definition: RepoInfo.cc:298
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:670
Pathname metadataPath() const
Definition: RepoInfo.cc:312
bool isValid() const
Definition: PublicKey.h:308
TriBool rawGpgCheck() const
Definition: RepoInfo.cc:277
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
static const unsigned defaultPriority
Definition: RepoInfo.cc:73
Impl * clone() const
clone for RWCOW_pointer
Definition: RepoInfo.cc:340
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:372
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:1020
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:685
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:410
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:658
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
TriBool cfgRepoGpgCheck() const
Definition: RepoInfo.cc:287
const char * c_str() const
Definition: IdStringType.h:105
Pathname _packagesPath
Definition: RepoInfo.cc:331
Url manipulation class.
Definition: Url.h:87
void metadataPath(Pathname new_r)
Definition: RepoInfo.cc:303
#define DBG
Definition: Logger.h:78
std::string service
Definition: RepoInfo.cc:300
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
bool hasContent(const std::string &keyword_r) const
Definition: RepoInfo.cc:191