libzypp 17.31.7
RepoInfo.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <vector>
14#include <fstream>
15
16#include <zypp/base/Gettext.h>
17#include <zypp/base/LogTools.h>
18#include <zypp-core/base/DefaultIntegral>
19#include <zypp/parser/xml/XmlEscape.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>
31#include <zypp/ExternalProgram.h>
32
33#include <zypp/base/IOStream.h>
34#include <zypp-core/base/InputStream>
36
37
39#include <zypp/KeyRing.h>
40#include <zypp/TmpPath.h>
41#include <zypp/ZYppFactory.h>
42#include <zypp/ZYppCallbacks.h>
43
44using std::endl;
46
48namespace 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 DBG << "Probed cached type " << ret << " at " << path_r << endl;
66 return ret;
67 }
68 } // namespace
69
71 //
72 // CLASS NAME : RepoInfo::Impl
73 //
76 {
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 {
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;
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 {
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
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 {
449 TriBool ret( _pimpl->internalValidRepoSignature() );
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;
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
519 { setMirrorListUrl( urls.empty() ? Url() : urls.front() ); }
520
521 void RepoInfo::setMetalinkUrl( const Url & url_r ) // Raw
522 { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = true; }
523
525 { setMetalinkUrl( urls.empty() ? Url() : urls.front() ); }
526
528 { _pimpl->gpgKeyUrls().raw().swap( urls ); }
529
530 void RepoInfo::setGpgKeyUrl( const Url & url_r )
531 {
532 _pimpl->gpgKeyUrls().raw().clear();
533 _pimpl->gpgKeyUrls().raw().push_back( url_r );
534 }
535
536 Pathname RepoInfo::provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
537 {
538 if ( keyID_r.empty() )
539 return Pathname();
540
541 MIL << "Check for " << keyID_r << " at " << targetDirectory_r << endl;
542 std::string keyIDStr( keyID_r.size() > 8 ? keyID_r.substr( keyID_r.size()-8 ) : keyID_r ); // print short ID in Jobreports
543 filesystem::TmpDir tmpKeyRingDir;
544 KeyRing tempKeyRing(tmpKeyRingDir.path());
545
546 // translator: %1% is a gpg key ID like 3DBDC284
547 // %2% is a cache directories path
548 JobReport::info( str::Format(_("Looking for gpg key ID %1% in cache %2%.") ) % keyIDStr % targetDirectory_r );
549 filesystem::dirForEach(targetDirectory_r,
551 [&tempKeyRing]( const Pathname & dir_r, const std::string & str_r ){
552 try {
553
554 // deprecate a month old keys
555 PathInfo fileInfo ( dir_r/str_r );
556 if ( Date::now() - fileInfo.mtime() > Date::month ) {
557 //if unlink fails, the file will be overriden in the next step, no need
558 //to show a error
559 filesystem::unlink( dir_r/str_r );
560 } else {
561 tempKeyRing.multiKeyImport(dir_r/str_r, true);
562 }
563 } catch (const KeyRingException& e) {
564 ZYPP_CAUGHT(e);
565 ERR << "Error importing cached key from file '"<<dir_r/str_r<<"'."<<endl;
566 }
567 return true;
568 });
569
570 // no key in the cache is what we are looking for, lets download
571 // all keys specified in gpgkey= entries
572 if ( !tempKeyRing.isKeyTrusted(keyID_r) ) {
573 if ( ! gpgKeyUrlsEmpty() ) {
574 // translator: %1% is a gpg key ID like 3DBDC284
575 // %2% is a repositories name
576 JobReport::info( str::Format(_("Looking for gpg key ID %1% in repository %2%.") ) % keyIDStr % asUserString() );
577 for ( const Url &url : gpgKeyUrls() ) {
578 try {
579 JobReport::info( " gpgkey=" + url.asString() );
581 if ( f->empty() )
582 continue;
583
584 PublicKey key(f);
585 if ( !key.isValid() )
586 continue;
587
588 // import all keys into our temporary keyring
589 tempKeyRing.multiKeyImport(f, true);
590
591 } catch ( const std::exception & e ) {
592 //ignore and continue to next url
593 ZYPP_CAUGHT(e);
594 MIL << "Key import from url:'"<<url<<"' failed." << endl;
595 }
596 }
597 }
598 else {
599 // translator: %1% is a repositories name
600 JobReport::info( str::Format(_("Repository %1% does not define additional 'gpgkey=' URLs.") ) % asUserString() );
601 }
602 }
603
604 filesystem::assert_dir( targetDirectory_r );
605
606 //now write all keys into their own files in cache, override existing ones to always have
607 //up to date key data
608 for ( const auto & key: tempKeyRing.trustedPublicKeyData()) {
609 MIL << "KEY ID in KEYRING: " << key.id() << endl;
610
611 Pathname keyFile = targetDirectory_r/(str::Format("%1%.key") % key.rpmName()).asString();
612
613 std::ofstream fout( keyFile.c_str(), std::ios_base::out | std::ios_base::trunc );
614
615 if (!fout)
616 ZYPP_THROW(Exception(str::form("Cannot open file %s",keyFile.c_str())));
617
618 tempKeyRing.dumpTrustedPublicKey( key.id(), fout );
619 }
620
621 // key is STILL not known, we give up
622 if ( !tempKeyRing.isKeyTrusted(keyID_r) ) {
623 return Pathname();
624 }
625
626 PublicKeyData keyData( tempKeyRing.trustedPublicKeyData( keyID_r ) );
627 if ( !keyData ) {
628 ERR << "Error when exporting key from temporary keychain." << endl;
629 return Pathname();
630 }
631
632 return targetDirectory_r/(str::Format("%1%.key") % keyData.rpmName()).asString();
633 }
634
635 void RepoInfo::addBaseUrl( const Url & url_r )
636 {
637 for ( const auto & url : _pimpl->baseUrls().raw() ) // Raw unique!
638 if ( url == url_r )
639 return;
640 _pimpl->baseUrls().raw().push_back( url_r );
641 }
642
643 void RepoInfo::setBaseUrl( const Url & url_r )
644 {
645 _pimpl->baseUrls().raw().clear();
646 _pimpl->baseUrls().raw().push_back( url_r );
647 }
648
650 { _pimpl->baseUrls().raw().swap( urls ); }
651
652 void RepoInfo::setPath( const Pathname &path )
653 { _pimpl->path = path; }
654
656 { _pimpl->setType( t ); }
657
659 { _pimpl->setProbedType( t ); }
660
661
663 { _pimpl->metadataPath( path ); }
664
666 { _pimpl->packagesPath( path ); }
667
669 { _pimpl->keeppackages = keep; }
670
671 void RepoInfo::setService( const std::string& name )
672 { _pimpl->service = name; }
673
674 void RepoInfo::setTargetDistribution( const std::string & targetDistribution )
675 { _pimpl->targetDistro = targetDistribution; }
676
678 { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
679
681 { return _pimpl->metadataPath(); }
682
684 { return _pimpl->packagesPath(); }
685
687 { return _pimpl->usesAutoMethadataPaths(); }
688
690 { return _pimpl->type(); }
691
692 Url RepoInfo::mirrorListUrl() const // Variables replaced!
693 { return _pimpl->_mirrorListUrl.transformed(); }
694
696 { return _pimpl->_mirrorListUrl.raw(); }
697
699 { return _pimpl->gpgKeyUrls().empty(); }
700
702 { return _pimpl->gpgKeyUrls().size(); }
703
704 RepoInfo::url_set RepoInfo::gpgKeyUrls() const // Variables replaced!
705 { return _pimpl->gpgKeyUrls().transformed(); }
706
708 { return _pimpl->gpgKeyUrls().raw(); }
709
710 Url RepoInfo::gpgKeyUrl() const // Variables replaced!
711 { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
712
714 { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
715
716 RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
717 { return _pimpl->baseUrls().transformed(); }
718
720 { return _pimpl->baseUrls().raw(); }
721
723 { return _pimpl->path; }
724
725 std::string RepoInfo::service() const
726 { return _pimpl->service; }
727
729 { return _pimpl->targetDistro; }
730
732 { return( _pimpl->baseUrls().empty() ? Url() : *_pimpl->baseUrls().rawBegin() ); }
733
735 { return _pimpl->baseUrls().transformedBegin(); }
736
738 { return _pimpl->baseUrls().transformedEnd(); }
739
741 { return _pimpl->baseUrls().size(); }
742
744 { return _pimpl->baseUrls().empty(); }
745
747 { return _pimpl->baseurl2dump(); }
748
749 const std::set<std::string> & RepoInfo::contentKeywords() const
750 { return _pimpl->contentKeywords(); }
751
752 void RepoInfo::addContent( const std::string & keyword_r )
753 { _pimpl->addContent( keyword_r ); }
754
756 { return _pimpl->hasContent(); }
757
758 bool RepoInfo::hasContent( const std::string & keyword_r ) const
759 { return _pimpl->hasContent( keyword_r ); }
760
762
764 { return hasLicense( std::string() ); }
765
766 bool RepoInfo::hasLicense( const std::string & name_r ) const
767 { return !_pimpl->licenseTgz( name_r ).empty(); }
768
769
771 { return needToAcceptLicense( std::string() ); }
772
773 bool RepoInfo::needToAcceptLicense( const std::string & name_r ) const
774 {
775 const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
776 if ( licenseTgz.empty() )
777 return false; // no licenses at all
778
780 cmd.push_back( "tar" );
781 cmd.push_back( "-t" );
782 cmd.push_back( "-z" );
783 cmd.push_back( "-f" );
784 cmd.push_back( licenseTgz.asString() );
786
787 bool accept = true;
788 static const std::string noAcceptanceFile = "no-acceptance-needed\n";
789 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
790 {
791 if ( output == noAcceptanceFile )
792 {
793 accept = false;
794 }
795 }
796 prog.close();
797 MIL << "License(" << name_r << ") in " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
798 return accept;
799 }
800
801
802 std::string RepoInfo::getLicense( const Locale & lang_r )
803 { return const_cast<const RepoInfo *>(this)->getLicense( std::string(), lang_r ); }
804
805 std::string RepoInfo::getLicense( const Locale & lang_r ) const
806 { return getLicense( std::string(), lang_r ); }
807
808 std::string RepoInfo::getLicense( const std::string & name_r, const Locale & lang_r ) const
809 {
810 LocaleSet avlocales( getLicenseLocales( name_r ) );
811 if ( avlocales.empty() )
812 return std::string();
813
814 Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
815 if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
816 {
817 WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
818 // Using the fist locale instead of returning no text at all.
819 // So the user might recognize that there is a license, even if they
820 // can't read it.
821 getLang = *avlocales.begin();
822 }
823
824 // now extract the license file.
825 static const std::string licenseFileFallback( "license.txt" );
826 std::string licenseFile( !getLang ? licenseFileFallback
827 : str::form( "license.%s.txt", getLang.c_str() ) );
828
830 cmd.push_back( "tar" );
831 cmd.push_back( "-x" );
832 cmd.push_back( "-z" );
833 cmd.push_back( "-O" );
834 cmd.push_back( "-f" );
835 cmd.push_back( _pimpl->licenseTgz( name_r ).asString() ); // if it not exists, avlocales was empty.
836 cmd.push_back( licenseFile );
837
838 std::string ret;
840 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
841 {
842 ret += output;
843 }
844 prog.close();
845 return ret;
846 }
847
848
850 { return getLicenseLocales( std::string() ); }
851
852 LocaleSet RepoInfo::getLicenseLocales( const std::string & name_r ) const
853 {
854 const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
855 if ( licenseTgz.empty() )
856 return LocaleSet();
857
859 cmd.push_back( "tar" );
860 cmd.push_back( "-t" );
861 cmd.push_back( "-z" );
862 cmd.push_back( "-f" );
863 cmd.push_back( licenseTgz.asString() );
864
865 LocaleSet ret;
867 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
868 {
869 static const C_Str license( "license." );
870 static const C_Str dotTxt( ".txt\n" );
871 if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
872 {
873 if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
874 ret.insert( Locale() );
875 else
876 ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
877 }
878 }
879 prog.close();
880 return ret;
881 }
882
884
885 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
886 {
888 if ( _pimpl->baseurl2dump() )
889 {
890 for ( const auto & url : _pimpl->baseUrls().raw() )
891 {
892 str << "- url : " << url << std::endl;
893 }
894 }
895
896 // print if non empty value
897 auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
898 if ( ! value_r.empty() )
899 str << tag_r << value_r << std::endl;
900 });
901
902 strif( (_pimpl->_mirrorListForceMetalink ? "- metalink : " : "- mirrorlist : "), rawMirrorListUrl().asString() );
903 strif( "- path : ", path().asString() );
904 str << "- type : " << type() << std::endl;
905 str << "- priority : " << priority() << std::endl;
906
907 // Yes No Default(Y) Default(N)
908#define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
909 str << "- gpgcheck : " << OUTS(_pimpl->rawGpgCheck(),gpgCheck())
910 << " repo" << OUTS(_pimpl->rawRepoGpgCheck(),repoGpgCheck()) << (repoGpgCheckIsMandatory() ? "* ": " " )
911 << "sig" << asString( validRepoSignature(), "?", "Y", "N" )
912 << " pkg" << OUTS(_pimpl->rawPkgGpgCheck(),pkgGpgCheck()) << (pkgGpgCheckIsMandatory() ? "* ": " " )
913 << std::endl;
914#undef OUTS
915
916 for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
917 {
918 str << "- gpgkey : " << url << std::endl;
919 }
920
921 if ( ! indeterminate(_pimpl->keeppackages) )
922 str << "- keeppackages: " << keepPackages() << std::endl;
923
924 strif( "- service : ", service() );
925 strif( "- targetdistro: ", targetDistribution() );
926 strif( "- filePath: ", filepath().asString() );
927 strif( "- metadataPath: ", metadataPath().asString() );
928 strif( "- packagesPath: ", packagesPath().asString() );
929
930 return str;
931 }
932
933 std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
934 {
935 RepoInfoBase::dumpAsIniOn(str);
936
937 if ( _pimpl->baseurl2dump() )
938 {
939 str << "baseurl=";
940 std::string indent;
941 for ( const auto & url : _pimpl->baseUrls().raw() )
942 {
943 str << indent << hotfix1050625::asString( url ) << endl;
944 if ( indent.empty() ) indent = " "; // "baseurl="
945 }
946 }
947
948 if ( ! _pimpl->path.empty() )
949 str << "path="<< path() << endl;
950
951 if ( ! (rawMirrorListUrl().asString().empty()) )
952 str << (_pimpl->_mirrorListForceMetalink ? "metalink=" : "mirrorlist=") << hotfix1050625::asString( rawMirrorListUrl() ) << endl;
953
954 if ( type() != repo::RepoType::NONE )
955 str << "type=" << type().asString() << endl;
956
957 if ( priority() != defaultPriority() )
958 str << "priority=" << priority() << endl;
959
960 if ( ! indeterminate(_pimpl->rawGpgCheck()) )
961 str << "gpgcheck=" << (_pimpl->rawGpgCheck() ? "1" : "0") << endl;
962
963 if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
964 str << "repo_gpgcheck=" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << endl;
965
966 if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
967 str << "pkg_gpgcheck=" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << endl;
968
969 {
970 std::string indent( "gpgkey=");
971 for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
972 {
973 str << indent << url << endl;
974 if ( indent[0] != ' ' )
975 indent = " ";
976 }
977 }
978
979 if (!indeterminate(_pimpl->keeppackages))
980 str << "keeppackages=" << keepPackages() << endl;
981
982 if( ! service().empty() )
983 str << "service=" << service() << endl;
984
985 return str;
986 }
987
988 std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
989 {
990 std::string tmpstr;
991 str
992 << "<repo"
993 << " alias=\"" << escape(alias()) << "\""
994 << " name=\"" << escape(name()) << "\"";
995 if (type() != repo::RepoType::NONE)
996 str << " type=\"" << type().asString() << "\"";
997 str
998 << " priority=\"" << priority() << "\""
999 << " enabled=\"" << enabled() << "\""
1000 << " autorefresh=\"" << autorefresh() << "\""
1001 << " gpgcheck=\"" << gpgCheck() << "\""
1002 << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
1003 << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
1004 if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1005 str << " raw_gpgcheck=\"" << (_pimpl->rawGpgCheck() ? "1" : "0") << "\"";
1006 if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1007 str << " raw_repo_gpgcheck=\"" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << "\"";
1008 if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1009 str << " raw_pkg_gpgcheck=\"" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << "\"";
1010 if (!(tmpstr = gpgKeyUrl().asString()).empty())
1011 if (!(tmpstr = gpgKeyUrl().asString()).empty())
1012 str << " gpgkey=\"" << escape(tmpstr) << "\"";
1013 if (!(tmpstr = mirrorListUrl().asString()).empty())
1014 str << (_pimpl->_mirrorListForceMetalink ? " metalink=\"" : " mirrorlist=\"") << escape(tmpstr) << "\"";
1015 str << ">" << endl;
1016
1017 if ( _pimpl->baseurl2dump() )
1018 {
1019 for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
1020 str << "<url>" << escape((*it).asString()) << "</url>" << endl;
1021 }
1022
1023 str << "</repo>" << endl;
1024 return str;
1025 }
1026
1027
1028 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
1029 {
1030 return obj.dumpOn(str);
1031 }
1032
1033 std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj )
1034 {
1035 switch ( obj )
1036 {
1037#define OUTS( V ) case RepoInfo::V: return str << #V; break
1038 OUTS( GpgCheck::On );
1039 OUTS( GpgCheck::Strict );
1040 OUTS( GpgCheck::AllowUnsigned );
1041 OUTS( GpgCheck::AllowUnsignedRepo );
1042 OUTS( GpgCheck::AllowUnsignedPackage );
1043 OUTS( GpgCheck::Default );
1044 OUTS( GpgCheck::Off );
1045 OUTS( GpgCheck::indeterminate );
1046#undef OUTS
1047 }
1048 return str << "GpgCheck::UNKNOWN";
1049 }
1050
1052 {
1053 bool canSkipMediaCheck = std::all_of( baseUrlsBegin(), baseUrlsEnd(), []( const zypp::Url &url ) { return url.schemeIsDownloading(); });
1054
1055 const auto &mDataPath = metadataPath();
1056 if ( canSkipMediaCheck && !mDataPath.empty() ) {
1057 zypp::Pathname mediafile = mDataPath/"media.1/media";
1058
1059 zypp::repo::SUSEMediaVerifier lverifier { mediafile };
1060 if ( lverifier ) {
1061 canSkipMediaCheck = lverifier.totalMedia() == 1;
1062 }
1063 }
1064
1065 DBG << "Can SKIP media.1/media check for status calc: " << canSkipMediaCheck << " for repo " << *this << std::endl;
1066 return !canSkipMediaCheck;
1067 }
1068
1070} // namespace zypp
#define OUTS(T, B)
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
Helper managing repo variables replaced url lists.
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
Helper managing repo variables replaced urls.
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Definition: String.h:91
size_type size() const
Definition: String.h:108
static const ValueType month
Definition: Date.h:49
static Date now()
Return the current time.
Definition: Date.h:78
Base class for Exception.
Definition: Exception.h:146
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
int close()
Wait for the progamm to complete.
const char * c_str() const
Definition: IdStringType.h:105
Helper to create and pass std::istream.
Definition: inputstream.h:57
Gpg key handling.
Definition: KeyRing.h:187
void dumpTrustedPublicKey(const std::string &id, std::ostream &stream)
Definition: KeyRing.h:237
void multiKeyImport(const Pathname &keyfile_r, bool trusted_r=false)
Initial import from RpmDb.
Definition: KeyRing.cc:812
std::list< PublicKeyData > trustedPublicKeyData()
Get a list of trusted public key data in the keyring (key data only)
Definition: KeyRing.cc:830
bool isKeyTrusted(const std::string &id)
true if the key id is trusted
Definition: KeyRing.cc:882
'Language[_Country]' codes.
Definition: Locale.h:50
static const Locale noCode
Empty code.
Definition: Locale.h:74
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
@ STRINGEND
Match at string end.
Definition: StrMatcher.h:45
static ManagedFile provideOptionalFileFromUrl(const Url &file_url)
Provides an optional file from url.
Class representing one GPG Public Keys data.
Definition: PublicKey.h:207
std::string rpmName() const
Gpg-pubkey name as computed by rpm.
Definition: PublicKey.cc:450
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:359
bool isValid() const
Definition: PublicKey.h:397
What is known about a repository.
Definition: RepoInfo.h:72
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:435
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:527
std::list< Url > url_set
Definition: RepoInfo.h:103
void setMirrorListUrls(url_set urls)
Like setMirrorListUrl but take an url_set.
Definition: RepoInfo.cc:518
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:521
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:680
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:635
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition: RepoInfo.cc:530
GpgCheck
Some predefined settings.
Definition: RepoInfo.h:368
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:743
bool hasContent() const
Check for content keywords.
Definition: RepoInfo.cc:755
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:668
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:643
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition: RepoInfo.cc:704
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced)
Definition: RepoInfo.cc:713
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:515
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:731
Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
downloads all configured gpg keys into the defined directory
Definition: RepoInfo.cc:536
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:689
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition: RepoInfo.cc:707
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition: RepoInfo.cc:397
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:740
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:677
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:131
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:80
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition: RepoInfo.cc:749
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:737
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:885
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:665
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:805
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:746
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:933
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:671
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:407
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:988
Pathname path() const
Repository path.
Definition: RepoInfo.cc:722
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition: RepoInfo.cc:701
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:849
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:716
virtual ~RepoInfo()
Definition: RepoInfo.cc:388
bool requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
Definition: RepoInfo.cc:1051
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:432
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:719
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:692
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition: RepoInfo.cc:686
url_set::size_type urls_size_type
Definition: RepoInfo.h:104
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:658
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition: RepoInfo.cc:649
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:725
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:674
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:391
bool gpgCheck() const
Whether default signature checking should be performed.
Definition: RepoInfo.cc:404
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:652
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition: RepoInfo.cc:710
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:454
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:394
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:770
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:400
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:560
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:734
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:763
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition: RepoInfo.cc:417
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition: RepoInfo.cc:662
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned.
Definition: RepoInfo.cc:447
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:425
void setMetalinkUrls(url_set urls)
Like setMirrorListUrls but expect metalink format.
Definition: RepoInfo.cc:524
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:683
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:752
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:414
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:105
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:728
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition: RepoInfo.cc:439
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:655
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:429
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:695
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition: RepoInfo.cc:698
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition: StrMatcher.h:298
Url manipulation class.
Definition: Url.h:92
std::string asString() const
Returns a default string representation of the Url object.
Definition: Url.cc:497
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
Definition: Url.cc:475
bool gpgCheck() const
Turn signature checking on/off (on)
Definition: ZConfig.cc:1121
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1123
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:832
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1122
std::string receiveLine()
Read one line from the input stream.
Find pathnames matching a pattern.
Definition: Glob.h:58
bool empty() const
Whether matches were found.
Definition: Glob.h:189
const_iterator begin() const
Iterator pointing to the first result.
Definition: Glob.h:197
int add(const Pathname &pattern_r, Flags flags_r=Flags())
Add pathnames matching pattern_r to the current result.
Definition: Glob.h:155
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:221
time_t mtime() const
Definition: PathInfo.h:376
Pathname dirname() const
Return all but the last component od this path.
Definition: Pathname.h:124
const char * c_str() const
String representation.
Definition: Pathname.h:110
const std::string & asString() const
String representation.
Definition: Pathname.h:91
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition: TmpPath.h:178
Pathname path() const
Definition: TmpPath.cc:146
std::string asUserString() const
User string: label (alias or name)
Definition: RepoInfoBase.h:82
Pathname filepath() const
File where this repo was read from.
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
std::string name() const
Repository name.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
std::string alias() const
unique identifier for this source.
const std::vector< Url > & getUrls() const
Implementation of the traditional SUSE media verifier.
xmlTextReader based interface to iterate xml streams.
Definition: Reader.h:96
bool seekToEndNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:232
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value.
Definition: Reader.cc:140
bool seekToNode(int depth_r, const std::string &name_r)
Definition: Reader.cc:212
std::string asString() const
Explicit conversion to std::string.
Definition: XmlString.h:77
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
String related utilities and Regular expression matching.
int unlink(const Pathname &path)
Like 'unlink'.
Definition: PathInfo.cc:700
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
Definition: PathInfo.cc:32
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
Definition: PathInfo.cc:924
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition: PathInfo.cc:319
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
Definition: PathInfo.cc:855
std::string asString(const Url &url_r)
Definition: Url.cc:886
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
bool hasSuffix(const C_Str &str_r, const C_Str &suffix_r)
Return whether str_r has suffix suffix_r.
Definition: String.h:1041
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:1027
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
Definition: String.h:1085
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
Definition: String.cc:371
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
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:531
detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
Definition: XmlEscape.h:51
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:567
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
std::string asString(const Patch::Category &obj)
Definition: Patch.cc:122
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
RepoInfo implementation.
Definition: RepoInfo.cc:76
repo::RepoType _type
Definition: RepoInfo.cc:319
Pathname _packagesPath
Definition: RepoInfo.cc:356
TriBool rawPkgGpgCheck() const
Definition: RepoInfo.cc:304
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:298
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Definition: RepoInfo.cc:223
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition: RepoInfo.cc:265
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)?...
Definition: RepoInfo.cc:259
TriBool triBoolFromPath(const Pathname &path_r) const
Definition: RepoInfo.cc:291
void packagesPath(Pathname new_r)
Definition: RepoInfo.cc:331
void rawRepoGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:307
void rawPkgGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:308
bool usesAutoMethadataPaths() const
Definition: RepoInfo.cc:334
Pathname _metadataPath
Definition: RepoInfo.cc:355
Pathname licenseTgz(const std::string &name_r) const
Path to a license tarball in case it exists in the repo.
Definition: RepoInfo.cc:113
RepoVariablesReplacedUrl _mirrorListUrl
Definition: RepoInfo.cc:322
bool _mirrorListForceMetalink
Definition: RepoInfo.cc:323
Impl * clone() const
clone for RWCOW_pointer
Definition: RepoInfo.cc:365
Pathname metadataPath() const
Definition: RepoInfo.cc:337
DefaultIntegral< unsigned, defaultPriority > priority
Definition: RepoInfo.cc:351
bool cfgGpgCheck() const
Definition: RepoInfo.cc:310
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Stream output.
Definition: RepoInfo.cc:371
void setType(const repo::RepoType &t)
Definition: RepoInfo.cc:95
bool hasContent(const std::string &keyword_r) const
Definition: RepoInfo.cc:216
const std::set< std::string > & contentKeywords() const
Definition: RepoInfo.cc:165
TriBool cfgPkgGpgCheck() const
Definition: RepoInfo.cc:314
bool baseurl2dump() const
Definition: RepoInfo.cc:154
const RepoVariablesReplacedUrlList & baseUrls() const
Definition: RepoInfo.cc:138
bool hasContent() const
Definition: RepoInfo.cc:171
RepoVariablesReplacedUrlList _gpgKeyUrls
Definition: RepoInfo.cc:361
RepoVariablesReplacedUrlList _baseUrls
Definition: RepoInfo.cc:358
std::string service
Definition: RepoInfo.cc:325
void rawGpgCheck(TriBool val_r)
Definition: RepoInfo.cc:306
void addContent(const std::string &keyword_r)
Definition: RepoInfo.cc:168
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
Definition: RepoInfo.cc:297
Pathname packagesPath() const
Definition: RepoInfo.cc:344
void metadataPath(Pathname new_r)
Definition: RepoInfo.cc:328
TriBool rawGpgCheck() const
Definition: RepoInfo.cc:302
TriBool rawRepoGpgCheck() const
Definition: RepoInfo.cc:303
void internalSetValidRepoSignature(TriBool value_r)
Definition: RepoInfo.cc:237
std::string targetDistro
Definition: RepoInfo.cc:326
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Definition: RepoInfo.cc:158
TriBool cfgRepoGpgCheck() const
Definition: RepoInfo.cc:312
static const unsigned defaultPriority
Definition: RepoInfo.cc:92
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition: RepoInfo.cc:299
void setProbedType(const repo::RepoType &t) const
Definition: RepoInfo.cc:98
RepoVariablesReplacedUrlList & baseUrls()
Definition: RepoInfo.cc:151
TriBool _validRepoSignature
have signed and valid repo metadata
Definition: RepoInfo.cc:318
repo::RepoType type() const
Definition: RepoInfo.cc:104
std::pair< FalseBool, std::set< std::string > > _keywords
Definition: RepoInfo.cc:359
RepoVariablesReplacedUrlList & gpgKeyUrls()
Definition: RepoInfo.cc:161
static const unsigned noPriority
Definition: RepoInfo.cc:93
Repository type enumeration.
Definition: RepoType.h:28
static const RepoType YAST2
Definition: RepoType.h:30
const std::string & asString() const
Definition: RepoType.cc:56
static const RepoType RPMMD
Definition: RepoType.h:29
static const RepoType NONE
Definition: RepoType.h:32
static const RepoType RPMPLAINDIR
Definition: RepoType.h:31
Convenient building of std::string with boost::format.
Definition: String.h:253
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition: Exception.h:436
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:428
#define _(MSG)
Definition: Gettext.h:37
#define DBG
Definition: Logger.h:95
#define MIL
Definition: Logger.h:96
#define ERR
Definition: Logger.h:98
#define WAR
Definition: Logger.h:97