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