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