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