libzypp 17.37.0
RepoInfo.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
13#include <iostream>
14#include <vector>
15
16#include <zypp/base/Gettext.h>
17#include <zypp/base/LogTools.h>
18#include <zypp-core/base/DefaultIntegral>
20
21#include <zypp/ManagedFile.h>
22#include <zypp-common/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>
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
46
47using std::endl;
49
51namespace zypp
52{
53
54 namespace
55 {
56 repo::RepoType probeCache( const Pathname & path_r )
57 {
59 if ( PathInfo(path_r).isDir() )
60 {
61 if ( PathInfo(path_r/"/repodata/repomd.xml").isFile() )
62 { ret = repo::RepoType::RPMMD; }
63 else if ( PathInfo(path_r/"/content").isFile() )
64 { ret = repo::RepoType::YAST2; }
65 else if ( PathInfo(path_r/"/cookie").isFile() )
67 }
68 DBG << "Probed cached type " << ret << " at " << path_r << endl;
69 return ret;
70 }
71 } // namespace
72
74 //
75 // CLASS NAME : RepoInfo::Impl
76 //
79 {
89
90 Impl(const Impl &) = default;
91 Impl(Impl &&) = delete;
92 Impl &operator=(const Impl &) = delete;
93 Impl &operator=(Impl &&) = delete;
94
95 ~Impl() {}
96
97 public:
98 static const unsigned defaultPriority = 99;
99 static const unsigned noPriority = unsigned(-1);
100
101 void setType( const repo::RepoType & t )
102 { _type = t; }
103
104 void setProbedType( const repo::RepoType & t ) const
105 {
107 { const_cast<Impl*>(this)->_type = t; }
108 }
109
111 {
112 if ( _type == repo::RepoType::NONE && not metadataPath().empty() )
113 setProbedType( probeCache( metadataPath() / path ) );
114 return _type;
115 }
116
117 public:
119 Pathname licenseTgz( const std::string & name_r ) const
120 {
121 Pathname ret;
122 if ( !metadataPath().empty() )
123 {
124 std::string licenseStem( "license" );
125 if ( !name_r.empty() )
126 {
127 licenseStem += "-";
128 licenseStem += name_r;
129 }
130
132 // TODO: REPOMD: this assumes we know the name of the tarball. In fact
133 // we'd need to get the file from repomd.xml (<data type="license[-name_r]">)
134 g.add( metadataPath() / path / ("repodata/*"+licenseStem+".tar.gz") );
135 if ( g.empty() )
136 g.add( metadataPath() / path / (licenseStem+".tar.gz") );
137
138 if ( !g.empty() )
139 ret = *g.begin();
140 }
141 return ret;
142 }
143
145 if ( !_baseUrls.empty() ) {
146 return RepoVariablesReplacedUrl( _baseUrls.raw ().front(), _baseUrls.transformator() );
147 }
148 if ( !effectiveBaseUrls().empty() ) {
149 return RepoVariablesReplacedUrl( effectiveBaseUrls ().front (), _baseUrls.transformator() );
150 }
152 }
153
155 {
156 return _baseUrls;
157 }
158
159 Url location() const {
160 if ( !_baseUrls.empty() )
161 return *_baseUrls.transformedBegin ();
162 return _mirrorListUrl.transformed();
163 }
164
165 void resetEffectiveUrls() const {
166 _effectiveBaseUrls.clear ();
167 _lastEffectiveUrlsUpdate = std::chrono::steady_clock::time_point::min();
168 }
169
171 {
172 if ( !_effectiveBaseUrls.empty()
173 && ( std::chrono::steady_clock::now() - _lastEffectiveUrlsUpdate < std::chrono::hours(1) ) )
174 return _effectiveBaseUrls;
175
176 _effectiveBaseUrls.clear();
177 _lastEffectiveUrlsUpdate = std::chrono::steady_clock::now();
178
179 Url mlurl( _mirrorListUrl.transformed() ); // Variables replaced!
180 if ( mlurl.asString().empty()
181 && _baseUrls.raw().size() == 1
182 && repo::RepoMirrorList::urlSupportsMirrorLink( *_baseUrls.transformedBegin() ) ) {
183
184 mlurl = *_baseUrls.transformedBegin ();
185 mlurl.appendPathName("/");
186 mlurl.setQueryParam("mirrorlist", std::string() );
187
188 MIL << "Detected opensuse.org baseUrl with no mirrors, requesting them from : " << mlurl.asString() << std::endl;
189 }
190
191 if ( !mlurl.asString().empty() )
192 {
193 try {
194 DBG << "MetadataPath: " << metadataPath() << endl;
195 repo::RepoMirrorList rmurls( mlurl, metadataPath() );
196
197 // propagate internally used URL params like 'proxy' to the mirrors
198 const auto &tf = [urlTemplate =_mirrorListUrl.transformed()]( const zypp::Url &in ){
199 return internal::propagateQueryParams ( in , urlTemplate );
200 };
201 _effectiveBaseUrls.insert( _effectiveBaseUrls.end(), make_transform_iterator( rmurls.getUrls().begin(), tf ), make_transform_iterator( rmurls.getUrls().end(), tf ) );
202 } catch ( const zypp::Exception & e ) {
203 // failed to fetch the mirrorlist/metalink, if we still have a baseUrl we can go on, otherwise this is a error
204 if ( _baseUrls.empty () )
205 throw;
206 else {
208 data.set("error", e );
209 JobReport::warning( _("Failed to fetch mirrorlist/metalink data."), data );
210 }
211 }
212 }
213
214 _effectiveBaseUrls.insert( _effectiveBaseUrls.end(), _baseUrls.transformedBegin (), _baseUrls.transformedEnd () );
215 return _effectiveBaseUrls;
216 }
217
218 std::vector<std::vector<Url>> groupedBaseUrls() const
219 {
220 // here we group the URLs to figure out mirrors
221 std::vector<std::vector<Url>> urlGroups;
222 int dlUrlIndex = -1; //we remember the index of the first downloading URL
223
224 const auto &baseUrls = effectiveBaseUrls();
225 std::for_each ( baseUrls.begin(), baseUrls.end(), [&]( const zypp::Url &url ){
226 if ( !url.schemeIsDownloading () ) {
227 urlGroups.push_back ( { url } );
228 return;
229 }
230
231 if ( dlUrlIndex >= 0) {
232 urlGroups[dlUrlIndex].push_back ( url );
233 return;
234 }
235
236 // start a new group
237 urlGroups.push_back ( {url} );
238 dlUrlIndex = urlGroups.size() - 1;
239 });
240
241 return urlGroups;
242 }
243
246
247 bool baseurl2dump() const
248 { return !_baseUrls.empty(); }
249
250
252 { return _gpgKeyUrls; }
253
256
257 std::string repoStatusString() const
258 {
259 if ( _mirrorListUrl.transformed().isValid() )
260 return _mirrorListUrl.transformed().asString();
261 if ( !baseUrls().empty() )
262 return (*baseUrls().transformedBegin()).asString();
263 return std::string();
264 }
265
266 const std::set<std::string> & contentKeywords() const
267 { hasContent()/*init if not yet done*/; return _keywords.second; }
268
269 void addContent( const std::string & keyword_r )
270 { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
271
272 bool hasContent() const
273 {
274 if ( !_keywords.first && ! metadataPath().empty() )
275 {
276 // HACK directly check master index file until RepoManager offers
277 // some content probing and zypper uses it.
279 MIL << "Empty keywords...." << metadataPath() << endl;
280 Pathname master;
281 if ( PathInfo( (master=metadataPath()/"/repodata/repomd.xml") ).isFile() )
282 {
283 //MIL << "GO repomd.." << endl;
284 xml::Reader reader( master );
285 while ( reader.seekToNode( 2, "content" ) )
286 {
287 _keywords.second.insert( reader.nodeText().asString() );
288 reader.seekToEndNode( 2, "content" );
289 }
290 _keywords.first = true; // valid content in _keywords even if empty
291 }
292 else if ( PathInfo( (master=metadataPath()/"/content") ).isFile() )
293 {
294 //MIL << "GO content.." << endl;
296 [this]( int num_r, const std::string& line_r )->bool
297 {
298 if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
299 {
300 std::vector<std::string> words;
301 if ( str::split( line_r, std::back_inserter(words) ) > 1
302 && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
303 {
304 this->_keywords.second.insert( ++words.begin(), words.end() );
305 }
306 return true; // mult. occurrances are ok.
307 }
308 return( ! str::startsWith( line_r, "META " ) ); // no need to parse into META section.
309 } );
310 _keywords.first = true; // valid content in _keywords even if empty
311 }
313 }
314 return _keywords.first;
315 }
316
317 bool hasContent( const std::string & keyword_r ) const
318 { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
319
325 {
327 return _validRepoSignature;
328 // check metadata:
329 if ( ! metadataPath().empty() )
330 {
331 // A missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
332 TriBool linkval = triBoolFromPath( metadataPath() / ".repo_gpgcheck" );
333 return linkval;
334 }
335 return indeterminate;
336 }
337
339 {
340 if ( PathInfo(metadataPath()).isDir() )
341 {
342 Pathname gpgcheckFile( metadataPath() / ".repo_gpgcheck" );
343 if ( PathInfo(gpgcheckFile).isExist() )
344 {
345 TriBool linkval( indeterminate );
346 if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
347 return; // existing symlink fits value_r
348 else
349 filesystem::unlink( gpgcheckFile ); // will write a new one
350 }
351 filesystem::symlink( asString(value_r), gpgcheckFile );
352 }
353 _validRepoSignature = value_r;
354 }
355
361 {
362 TriBool linkval( true ); // want to see it being switched to indeterminate
363 return triBoolFromPath( metadataPath() / ".repo_gpgcheck", linkval ) && indeterminate(linkval);
364 }
365
366 bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
367 {
368 static const Pathname truePath( "true" );
369 static const Pathname falsePath( "false" );
370 static const Pathname indeterminatePath( "indeterminate" );
371
372 // Quiet readlink;
373 static const ssize_t bufsiz = 63;
374 static char buf[bufsiz+1];
375 ssize_t ret = ::readlink( path_r.c_str(), buf, bufsiz );
376 buf[ret == -1 ? 0 : ret] = '\0';
377
378 Pathname linkval( buf );
379
380 bool known = true;
381 if ( linkval == truePath )
382 ret_r = true;
383 else if ( linkval == falsePath )
384 ret_r = false;
385 else if ( linkval == indeterminatePath )
386 ret_r = indeterminate;
387 else
388 known = false;
389 return known;
390 }
391
392 TriBool triBoolFromPath( const Pathname & path_r ) const
393 { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
394
396
397 private:
401
402 public:
403 TriBool rawGpgCheck() const { return _rawGpgCheck; }
406
407 void rawGpgCheck( TriBool val_r ) { _rawGpgCheck = val_r; }
408 void rawRepoGpgCheck( TriBool val_r ) { _rawRepoGpgCheck = val_r; }
409 void rawPkgGpgCheck( TriBool val_r ) { _rawPkgGpgCheck = val_r; }
410
417
418 private:
421 public:
426 std::string service;
427 std::string targetDistro;
428
429 void metadataPath( Pathname new_r )
430 { _metadataPath = std::move( new_r ); }
431
432 void packagesPath( Pathname new_r )
433 { _packagesPath = std::move( new_r ); }
434
436 { return str::hasSuffix( _metadataPath.asString(), "/%AUTO%" ); }
437
439 {
440 if ( usesAutoMetadataPaths() )
441 return _metadataPath.dirname() / "%RAW%";
442 return _metadataPath;
443 }
444
446 {
447 if ( _packagesPath.empty() && usesAutoMetadataPaths() )
448 return _metadataPath.dirname() / "%PKG%";
449 return _packagesPath;
450 }
451
453 {
454 return packagesPath() / ".preload";
455 }
456
458
459 private:
462
465 mutable std::chrono::steady_clock::time_point _lastEffectiveUrlsUpdate = std::chrono::steady_clock::time_point::min();
466 mutable std::pair<FalseBool, std::set<std::string> > _keywords;
467
469
470 friend Impl * rwcowClone<Impl>( const Impl * rhs );
472 Impl * clone() const
473 { return new Impl( *this ); }
474 };
475
476
478 inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
479 {
480 return str << "RepoInfo::Impl";
481 }
482
484 //
485 // CLASS NAME : RepoInfo
486 //
488
490
492 : _pimpl( new Impl() )
493 {}
494
497
498 unsigned RepoInfo::priority() const
499 { return _pimpl->priority; }
500
503
505 { return Impl::noPriority; }
506
507 void RepoInfo::setPriority( unsigned newval_r )
508 { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
509
510
512 { return _pimpl->cfgGpgCheck(); }
513
515 { _pimpl->rawGpgCheck( value_r ); }
516
517 void RepoInfo::setGpgCheck( bool value_r ) // deprecated legacy and for squid
518 { setGpgCheck( TriBool(value_r) ); }
519
520
522 { return gpgCheck() || bool(_pimpl->cfgRepoGpgCheck()); }
523
525 {
526 bool ret = ( gpgCheck() && indeterminate(_pimpl->cfgRepoGpgCheck()) ) || bool(_pimpl->cfgRepoGpgCheck());
527 if ( ret && _pimpl->internalUnsignedConfirmed() ) // relax if unsigned repo was confirmed in the past
528 ret = false;
529 return ret;
530 }
531
533 { _pimpl->rawRepoGpgCheck( value_r ); }
534
535
537 { return bool(_pimpl->cfgPkgGpgCheck()) || ( gpgCheck() && !bool(validRepoSignature())/*enforced*/ ) ; }
538
540 { return bool(_pimpl->cfgPkgGpgCheck()) || ( gpgCheck() && indeterminate(_pimpl->cfgPkgGpgCheck()) && !bool(validRepoSignature())/*enforced*/ ); }
541
543 { _pimpl->rawPkgGpgCheck( value_r ); }
544
545
546 void RepoInfo::getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const
547 {
548 g_r = _pimpl->rawGpgCheck();
549 r_r = _pimpl->rawRepoGpgCheck();
550 p_r = _pimpl->rawPkgGpgCheck();
551 }
552
553
555 {
556 TriBool ret( _pimpl->internalValidRepoSignature() );
557 if ( ret && !repoGpgCheck() ) ret = false; // invalidate any old signature if repoGpgCheck is off
558 return ret;
559 }
560
562 { _pimpl->internalSetValidRepoSignature( value_r ); }
563
565 namespace
566 {
567 inline bool changeGpgCheckTo( TriBool & lhs, TriBool rhs )
568 { if ( ! sameTriboolState( lhs, rhs ) ) { lhs = rhs; return true; } return false; }
569
570 inline bool changeGpgCheckTo( TriBool ogpg[3], TriBool g, TriBool r, TriBool p )
571 {
572 bool changed = false;
573 if ( changeGpgCheckTo( ogpg[0], g ) ) changed = true;
574 if ( changeGpgCheckTo( ogpg[1], r ) ) changed = true;
575 if ( changeGpgCheckTo( ogpg[2], p ) ) changed = true;
576 return changed;
577 }
578 } // namespace
581 {
582 TriBool ogpg[3]; // Gpg RepoGpg PkgGpg
583 getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
584
585 bool changed = false;
586 switch ( mode_r )
587 {
588 case GpgCheck::On:
589 changed = changeGpgCheckTo( ogpg, true, indeterminate, indeterminate );
590 break;
591 case GpgCheck::Strict:
592 changed = changeGpgCheckTo( ogpg, true, true, true );
593 break;
595 changed = changeGpgCheckTo( ogpg, true, false, false );
596 break;
598 changed = changeGpgCheckTo( ogpg, true, false, indeterminate );
599 break;
601 changed = changeGpgCheckTo( ogpg, true, indeterminate, false );
602 break;
604 changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
605 break;
606 case GpgCheck::Off:
607 changed = changeGpgCheckTo( ogpg, false, indeterminate, indeterminate );
608 break;
609 case GpgCheck::indeterminate: // no change
610 break;
611 }
612
613 if ( changed )
614 {
615 setGpgCheck ( ogpg[0] );
616 setRepoGpgCheck( ogpg[1] );
617 setPkgGpgCheck ( ogpg[2] );
618 }
619 return changed;
620 }
621
622 void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
623 { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = false; }
624
626 { setMirrorListUrl( urls.empty() ? Url() : urls.front() ); }
627
628 void RepoInfo::setMetalinkUrl( const Url & url_r ) // Raw
629 { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = true; }
630
632 { setMetalinkUrl( urls.empty() ? Url() : urls.front() ); }
633
635 { _pimpl->gpgKeyUrls().raw().swap( urls ); }
636
637 void RepoInfo::setGpgKeyUrl( const Url & url_r )
638 {
639 _pimpl->gpgKeyUrls().raw().clear();
640 _pimpl->gpgKeyUrls().raw().push_back( url_r );
641 }
642
643 std::string RepoInfo::repoStatusString() const
644 { return _pimpl->repoStatusString(); }
645
647 {
648 for ( const auto & url : _pimpl->baseUrls().raw() ) // Raw unique!
649 if ( url == url_r )
650 return;
651
652 _pimpl->baseUrls().raw().push_back( url_r );
653 _pimpl->resetEffectiveUrls ();
654 }
655
657 {
658 _pimpl->baseUrls().raw().clear();
659 _pimpl->resetEffectiveUrls ();
660 _pimpl->baseUrls().raw().push_back( std::move(url_r) );
661 }
662
664 {
665 _pimpl->resetEffectiveUrls ();
666 _pimpl->baseUrls().raw().swap( urls );
667 }
668
670 {
671 return _pimpl->effectiveBaseUrls().empty();
672 }
673
675 {
676 return _pimpl->effectiveBaseUrls();
677 }
678
680 { _pimpl->path = path; }
681
683 { _pimpl->setType( t ); }
684
686 { _pimpl->setProbedType( t ); }
687
688
690 { _pimpl->metadataPath( path ); }
691
693 { _pimpl->packagesPath( path ); }
694
696 { return _pimpl->predownloadPath(); }
697
699 { _pimpl->keeppackages = keep; }
700
701 void RepoInfo::setService( const std::string& name )
702 { _pimpl->service = name; }
703
705 { _pimpl->targetDistro = targetDistribution; }
706
708 { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
709
711 { return keepPackages() || PathInfo(packagesPath().dirname()/".keep_packages").isExist(); }
712
714 { return _pimpl->metadataPath(); }
715
717 { return _pimpl->packagesPath(); }
718
720 { return _pimpl->usesAutoMetadataPaths(); }
721
723 { return _pimpl->type(); }
724
725 Url RepoInfo::mirrorListUrl() const // Variables replaced!
726 { return _pimpl->_mirrorListUrl.transformed(); }
727
729 { return _pimpl->_mirrorListUrl.raw(); }
730
732 { return _pimpl->gpgKeyUrls().empty(); }
733
735 { return _pimpl->gpgKeyUrls().size(); }
736
737 RepoInfo::url_set RepoInfo::gpgKeyUrls() const // Variables replaced!
738 { return _pimpl->gpgKeyUrls().transformed(); }
739
741 { return _pimpl->gpgKeyUrls().raw(); }
742
743 Url RepoInfo::gpgKeyUrl() const // Variables replaced!
744 { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
745
747 { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
748
749 RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
750 { return _pimpl->baseUrls().transformed(); }
751
753 { return _pimpl->baseUrls().raw(); }
754
756 { return _pimpl->path; }
757
758 std::string RepoInfo::service() const
759 { return _pimpl->service; }
760
762 { return _pimpl->targetDistro; }
763
765 { return _pimpl->baseUrl().raw(); }
766
768 { return _pimpl->location (); }
769
770 std::vector<std::vector<Url>> RepoInfo::groupedBaseUrls() const
771 { return _pimpl->groupedBaseUrls(); }
772
774 { return _pimpl->baseUrls().transformedBegin(); }
775
777 { return _pimpl->baseUrls().transformedEnd(); }
778
780 { return _pimpl->baseUrls().size(); }
781
783 { return _pimpl->baseUrls().empty(); }
784
786 { return _pimpl->baseurl2dump(); }
787
789 {
790 return _pimpl->baseUrl().transformed();
791 }
792
793 const std::set<std::string> & RepoInfo::contentKeywords() const
794 { return _pimpl->contentKeywords(); }
795
796 void RepoInfo::addContent( const std::string & keyword_r )
797 { _pimpl->addContent( keyword_r ); }
798
800 { return _pimpl->hasContent(); }
801
802 bool RepoInfo::hasContent( const std::string & keyword_r ) const
803 { return _pimpl->hasContent( keyword_r ); }
804
806
808 { return hasLicense( std::string() ); }
809
810 bool RepoInfo::hasLicense( const std::string & name_r ) const
811 { return !_pimpl->licenseTgz( name_r ).empty(); }
812
813
815 { return needToAcceptLicense( std::string() ); }
816
817 bool RepoInfo::needToAcceptLicense( const std::string & name_r ) const
818 {
819 const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
820 if ( licenseTgz.empty() )
821 return false; // no licenses at all
822
824 cmd.push_back( "tar" );
825 cmd.push_back( "-t" );
826 cmd.push_back( "-z" );
827 cmd.push_back( "-f" );
828 cmd.push_back( licenseTgz.asString() );
830
831 bool accept = true;
832 static const std::string noAcceptanceFile = "no-acceptance-needed\n";
833 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
834 {
835 if ( output == noAcceptanceFile )
836 {
837 accept = false;
838 }
839 }
840 prog.close();
841 MIL << "License(" << name_r << ") in " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
842 return accept;
843 }
844
845
846 std::string RepoInfo::getLicense( const Locale & lang_r )
847 { return const_cast<const RepoInfo *>(this)->getLicense( std::string(), lang_r ); }
848
849 std::string RepoInfo::getLicense( const Locale & lang_r ) const
850 { return getLicense( std::string(), lang_r ); }
851
852 std::string RepoInfo::getLicense( const std::string & name_r, const Locale & lang_r ) const
853 {
854 LocaleSet avlocales( getLicenseLocales( name_r ) );
855 if ( avlocales.empty() )
856 return std::string();
857
858 Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
859 if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
860 {
861 WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
862 // Using the fist locale instead of returning no text at all.
863 // So the user might recognize that there is a license, even if they
864 // can't read it.
865 getLang = *avlocales.begin();
866 }
867
868 // now extract the license file.
869 static const std::string licenseFileFallback( "license.txt" );
870 std::string licenseFile( !getLang ? licenseFileFallback
871 : str::form( "license.%s.txt", getLang.c_str() ) );
872
874 cmd.push_back( "tar" );
875 cmd.push_back( "-x" );
876 cmd.push_back( "-z" );
877 cmd.push_back( "-O" );
878 cmd.push_back( "-f" );
879 cmd.push_back( _pimpl->licenseTgz( name_r ).asString() ); // if it not exists, avlocales was empty.
880 cmd.push_back( licenseFile );
881
882 std::string ret;
884 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
885 {
886 ret += output;
887 }
888 prog.close();
889 return ret;
890 }
891
892
894 { return getLicenseLocales( std::string() ); }
895
896 LocaleSet RepoInfo::getLicenseLocales( const std::string & name_r ) const
897 {
898 const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
899 if ( licenseTgz.empty() )
900 return LocaleSet();
901
903 cmd.push_back( "tar" );
904 cmd.push_back( "-t" );
905 cmd.push_back( "-z" );
906 cmd.push_back( "-f" );
907 cmd.push_back( licenseTgz.asString() );
908
909 LocaleSet ret;
911 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
912 {
913 static const C_Str license( "license." );
914 static const C_Str dotTxt( ".txt\n" );
915 if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
916 {
917 if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
918 ret.insert( Locale() );
919 else
920 ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
921 }
922 }
923 prog.close();
924 return ret;
925 }
926
928
929 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
930 {
931 RepoInfoBase::dumpOn(str);
932 if ( _pimpl->baseurl2dump() )
933 {
934 for ( const auto & url : _pimpl->baseUrls().raw() )
935 {
936 str << "- url : " << url << std::endl;
937 }
938 }
939
940 // print if non empty value
941 auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
942 if ( ! value_r.empty() )
943 str << tag_r << value_r << std::endl;
944 });
945
946 strif( (_pimpl->_mirrorListForceMetalink ? "- metalink : " : "- mirrorlist : "), rawMirrorListUrl().asString() );
947 strif( "- path : ", path().asString() );
948 str << "- type : " << type() << std::endl;
949 str << "- priority : " << priority() << std::endl;
950
951 // Yes No Default(Y) Default(N)
952#define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
953 str << "- gpgcheck : " << OUTS(_pimpl->rawGpgCheck(),gpgCheck())
954 << " repo" << OUTS(_pimpl->rawRepoGpgCheck(),repoGpgCheck()) << (repoGpgCheckIsMandatory() ? "* ": " " )
955 << "sig" << asString( validRepoSignature(), "?", "Y", "N" )
956 << " pkg" << OUTS(_pimpl->rawPkgGpgCheck(),pkgGpgCheck()) << (pkgGpgCheckIsMandatory() ? "* ": " " )
957 << std::endl;
958#undef OUTS
959
960 for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
961 {
962 str << "- gpgkey : " << url << std::endl;
963 }
964
965 if ( ! indeterminate(_pimpl->keeppackages) )
966 str << "- keeppackages: " << keepPackages() << std::endl;
967
968 strif( "- service : ", service() );
969 strif( "- targetdistro: ", targetDistribution() );
970 strif( "- filePath: ", filepath().asString() );
971 strif( "- metadataPath: ", metadataPath().asString() );
972 strif( "- packagesPath: ", packagesPath().asString() );
973
974 return str;
975 }
976
977 std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
978 {
979 RepoInfoBase::dumpAsIniOn(str);
980
981 if ( _pimpl->baseurl2dump() )
982 {
983 str << "baseurl=";
984 std::string indent;
985 for ( const auto & url : _pimpl->baseUrls().raw() )
986 {
987 str << indent << hotfix1050625::asString( url ) << endl;
988 if ( indent.empty() ) indent = " "; // "baseurl="
989 }
990 }
991
992 if ( ! _pimpl->path.empty() )
993 str << "path="<< path() << endl;
994
995 if ( ! (rawMirrorListUrl().asString().empty()) )
996 str << (_pimpl->_mirrorListForceMetalink ? "metalink=" : "mirrorlist=") << hotfix1050625::asString( rawMirrorListUrl() ) << endl;
997
998 if ( type() != repo::RepoType::NONE )
999 str << "type=" << type().asString() << endl;
1000
1001 if ( priority() != defaultPriority() )
1002 str << "priority=" << priority() << endl;
1003
1004 if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1005 str << "gpgcheck=" << (_pimpl->rawGpgCheck() ? "1" : "0") << endl;
1006
1007 if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1008 str << "repo_gpgcheck=" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << endl;
1009
1010 if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1011 str << "pkg_gpgcheck=" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << endl;
1012
1013 {
1014 std::string indent( "gpgkey=");
1015 for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
1016 {
1017 str << indent << url << endl;
1018 if ( indent[0] != ' ' )
1019 indent = " ";
1020 }
1021 }
1022
1023 if (!indeterminate(_pimpl->keeppackages))
1024 str << "keeppackages=" << keepPackages() << endl;
1025
1026 if( ! service().empty() )
1027 str << "service=" << service() << endl;
1028
1029 return str;
1030 }
1031
1032 std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
1033 {
1034 std::string tmpstr;
1035 str
1036 << "<repo"
1037 << " alias=\"" << escape(alias()) << "\""
1038 << " name=\"" << escape(name()) << "\"";
1039 if (type() != repo::RepoType::NONE)
1040 str << " type=\"" << type().asString() << "\"";
1041 str
1042 << " priority=\"" << priority() << "\""
1043 << " enabled=\"" << enabled() << "\""
1044 << " autorefresh=\"" << autorefresh() << "\""
1045 << " gpgcheck=\"" << gpgCheck() << "\""
1046 << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
1047 << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
1048 if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1049 str << " raw_gpgcheck=\"" << (_pimpl->rawGpgCheck() ? "1" : "0") << "\"";
1050 if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1051 str << " raw_repo_gpgcheck=\"" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << "\"";
1052 if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1053 str << " raw_pkg_gpgcheck=\"" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << "\"";
1054 if (!(tmpstr = gpgKeyUrl().asString()).empty())
1055 if (!(tmpstr = gpgKeyUrl().asString()).empty())
1056 str << " gpgkey=\"" << escape(tmpstr) << "\"";
1057 if (!(tmpstr = mirrorListUrl().asString()).empty())
1058 str << (_pimpl->_mirrorListForceMetalink ? " metalink=\"" : " mirrorlist=\"") << escape(tmpstr) << "\"";
1059 str << ">" << endl;
1060
1061 if ( _pimpl->baseurl2dump() )
1062 {
1063 for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
1064 str << "<url>" << escape((*it).asString()) << "</url>" << endl;
1065 }
1066
1067 str << "</repo>" << endl;
1068 return str;
1069 }
1070
1071
1072 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
1073 {
1074 return obj.dumpOn(str);
1075 }
1076
1077 std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj )
1078 {
1079 switch ( obj )
1080 {
1081#define OUTS( V ) case RepoInfo::V: return str << #V; break
1082 OUTS( GpgCheck::On );
1083 OUTS( GpgCheck::Strict );
1084 OUTS( GpgCheck::AllowUnsigned );
1085 OUTS( GpgCheck::AllowUnsignedRepo );
1086 OUTS( GpgCheck::AllowUnsignedPackage );
1087 OUTS( GpgCheck::Default );
1088 OUTS( GpgCheck::Off );
1089 OUTS( GpgCheck::indeterminate );
1090#undef OUTS
1091 }
1092 return str << "GpgCheck::UNKNOWN";
1093 }
1094
1096 {
1097 // We skip the check for downloading media unless a local copy of the
1098 // media file exists and states that there is more than one medium.
1099 const auto &effUrls = _pimpl->effectiveBaseUrls ();
1100 bool canSkipMediaCheck = std::all_of( effUrls.begin(), effUrls.end(), []( const zypp::Url &url ) { return url.schemeIsDownloading(); });
1101 if ( canSkipMediaCheck ) {
1102 const auto &mDataPath = metadataPath();
1103 if ( not mDataPath.empty() ) {
1104 PathInfo mediafile { mDataPath/"media.1/media" };
1105 if ( mediafile.isExist() ) {
1106 repo::SUSEMediaVerifier lverifier { mediafile.path() };
1107 if ( lverifier && lverifier.totalMedia() > 1 ) {
1108 canSkipMediaCheck = false;
1109 }
1110 }
1111 }
1112 }
1113 if ( canSkipMediaCheck )
1114 DBG << "Can SKIP media.1/media check for status calc of repo " << alias() << endl;
1115 return not canSkipMediaCheck;
1116 }
1117
1119} // namespace zypp
ZYPP_API detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
Definition XmlEscape.h:51
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
Helper managing repo variables replaced urls.
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
Helper managing repo variables replaced url lists.
#define OUTS(V)
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Definition String.h:92
size_type size() const
Definition String.h:109
Integral type with defined initial value when default constructed.
Base class for Exception.
Definition Exception.h:153
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
int close() override
Wait for the progamm to complete.
std::vector< std::string > Arguments
const char * c_str() const
Helper to create and pass std::istream.
Definition inputstream.h:57
'Language[_Country]' codes.
Definition Locale.h:51
static const Locale noCode
Empty code.
Definition Locale.h:75
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
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:542
std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const override
Write an XML representation of this RepoInfo object.
Definition RepoInfo.cc:1032
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
Definition RepoInfo.cc:634
void setMirrorListUrls(url_set urls)
Like setMirrorListUrl but take an url_set.
Definition RepoInfo.cc:625
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition RepoInfo.cc:628
std::ostream & dumpOn(std::ostream &str) const override
Write a human-readable representation of this RepoInfo object into the str stream.
Definition RepoInfo.cc:929
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition RepoInfo.cc:713
url_set::size_type urls_size_type
Definition RepoInfo.h:109
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
Definition RepoInfo.cc:637
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
Definition RepoInfo.cc:719
GpgCheck
Some predefined settings.
Definition RepoInfo.h:407
bool baseUrlsEmpty() const
whether repository urls are available
Definition RepoInfo.cc:782
Pathname predownloadPath() const
Path where this repo packages are predownloaded.
Definition RepoInfo.cc:695
bool hasContent() const
Check for content keywords.
Definition RepoInfo.cc:799
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition RepoInfo.cc:698
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Definition RepoInfo.cc:737
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced)
Definition RepoInfo.cc:746
~RepoInfo() override
Definition RepoInfo.cc:495
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition RepoInfo.h:110
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition RepoInfo.cc:622
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced) this is either rawBaseUrls()....
Definition RepoInfo.cc:764
repo::RepoType type() const
Type of repository,.
Definition RepoInfo.cc:722
url_set effectiveBaseUrls() const
The complete set of effective repository urls.
Definition RepoInfo.cc:674
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
Definition RepoInfo.cc:740
static unsigned noPriority()
The least priority (unsigned(-1)).
Definition RepoInfo.cc:504
urls_size_type baseUrlsSize() const
number of repository urls
Definition RepoInfo.cc:779
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition RepoInfo.cc:707
Url url() const
Pars pro toto: The first repository url, this is either baseUrls().front() or if no baseUrl is define...
Definition RepoInfo.cc:788
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition RepoInfo.h:85
void setBaseUrl(Url url)
Clears current base URL list and adds url.
Definition RepoInfo.cc:656
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Definition RepoInfo.cc:793
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition RepoInfo.cc:776
Url location() const
Returns the location URL for the repository, this is either the first configured baseUrl or a configu...
Definition RepoInfo.cc:767
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition RepoInfo.cc:692
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition RepoInfo.cc:849
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition RepoInfo.cc:785
void setService(const std::string &name)
sets service which added this repository
Definition RepoInfo.cc:701
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:514
bool effectiveKeepPackages() const
keepPackages unless the package cache itself enforces keeping the packages.
Definition RepoInfo.cc:710
Pathname path() const
Repository path.
Definition RepoInfo.cc:755
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
Definition RepoInfo.cc:734
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition RepoInfo.cc:893
url_set baseUrls() const
The complete set of repository urls as configured.
Definition RepoInfo.cc:749
bool requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
Definition RepoInfo.cc:1095
void addBaseUrl(Url url)
Add a base url.
Definition RepoInfo.cc:646
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition RepoInfo.cc:539
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition RepoInfo.cc:752
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition RepoInfo.cc:725
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:685
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
Definition RepoInfo.cc:663
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:758
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition RepoInfo.cc:704
std::ostream & dumpAsIniOn(std::ostream &str) const override
Write this RepoInfo object into str in a .repo file format.
Definition RepoInfo.cc:977
unsigned priority() const
Repository priority for solver.
Definition RepoInfo.cc:498
bool gpgCheck() const
Whether default signature checking should be performed.
Definition RepoInfo.cc:511
void setPath(const Pathname &path)
set the product path.
Definition RepoInfo.cc:679
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
Definition RepoInfo.cc:743
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition RepoInfo.cc:561
static unsigned defaultPriority()
The default priority (99).
Definition RepoInfo.cc:501
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition RepoInfo.cc:814
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition RepoInfo.cc:507
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition RepoInfo.h:612
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition RepoInfo.cc:773
bool hasLicense() const
Whether there is a license associated with the repo.
Definition RepoInfo.cc:807
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition RepoInfo.cc:524
std::vector< std::vector< Url > > groupedBaseUrls() const
Returns the currently known effective baseUrls in groups, where each group contains a primary base ur...
Definition RepoInfo.cc:770
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Definition RepoInfo.cc:689
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned.
Definition RepoInfo.cc:554
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition RepoInfo.cc:532
void setMetalinkUrls(url_set urls)
Like setMirrorListUrls but expect metalink format.
Definition RepoInfo.cc:631
Pathname packagesPath() const
Path where this repo packages are cached.
Definition RepoInfo.cc:716
void addContent(const std::string &keyword_r)
Add content keywords.
Definition RepoInfo.cc:796
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition RepoInfo.cc:521
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition RepoInfo.cc:761
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Definition RepoInfo.cc:546
void setType(const repo::RepoType &t)
set the repository type
Definition RepoInfo.cc:682
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition RepoInfo.cc:536
std::string repoStatusString() const
A string value to track changes requiring a refresh.
Definition RepoInfo.cc:643
std::list< Url > url_set
Definition RepoInfo.h:108
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition RepoInfo.cc:728
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
Definition RepoInfo.cc:731
bool effectiveBaseUrlsEmpty() const
whether effective repository urls are available
Definition RepoInfo.cc:669
Url manipulation class.
Definition Url.h:93
std::string asString() const
Returns a default string representation of the Url object.
Definition Url.cc:515
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition Url.cc:878
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
Definition Url.cc:804
bool gpgCheck() const
Turn signature checking on/off (on)
Definition ZConfig.cc:1241
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition ZConfig.cc:1243
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:940
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Definition ZConfig.cc:1242
Typesafe passing of user data via callbacks.
Definition UserData.h:40
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
Definition UserData.h:119
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:226
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:286
const char * c_str() const
String representation.
Definition Pathname.h:112
const std::string & asString() const
String representation.
Definition Pathname.h:93
bool empty() const
Test for an empty path.
Definition Pathname.h:116
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.
static bool urlSupportsMirrorLink(const zypp::Url &url)
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:214
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value.
Definition Reader.cc:122
bool seekToNode(int depth_r, const std::string &name_r)
Definition Reader.cc:194
std::string asString() const
Explicit conversion to std::string.
Definition XmlString.h:77
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
String related utilities and Regular expression matching.
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
Definition PathInfo.cc:860
int unlink(const Pathname &path)
Like 'unlink'.
Definition PathInfo.cc:705
std::string asString(const Url &url_r)
Definition Url.cc:932
int forEachLine(std::istream &str_r, const 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:1111
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition String.h:1097
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
Definition String.h:1155
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
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:602
ZYPP_API 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.
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
static const ContentType repoRefreshMirrorlist
D * rwcowClone(const D *rhs)
Clone the underlying object.
Definition PtrTypes.h:453
RepoInfo implementation.
Definition RepoInfo.cc:79
repo::RepoType _type
Definition RepoInfo.cc:420
TriBool rawPkgGpgCheck() const
Definition RepoInfo.cc:405
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition RepoInfo.cc:399
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Definition RepoInfo.cc:324
std::string repoStatusString() const
Definition RepoInfo.cc:257
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition RepoInfo.cc:366
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)?
Definition RepoInfo.cc:360
TriBool triBoolFromPath(const Pathname &path_r) const
Definition RepoInfo.cc:392
Impl(const Impl &)=default
void packagesPath(Pathname new_r)
Definition RepoInfo.cc:432
url_set _effectiveBaseUrls
Definition RepoInfo.cc:464
void rawRepoGpgCheck(TriBool val_r)
Definition RepoInfo.cc:408
std::vector< std::vector< Url > > groupedBaseUrls() const
Definition RepoInfo.cc:218
void rawPkgGpgCheck(TriBool val_r)
Definition RepoInfo.cc:409
Pathname predownloadPath() const
Definition RepoInfo.cc:452
Pathname licenseTgz(const std::string &name_r) const
Path to a license tarball in case it exists in the repo.
Definition RepoInfo.cc:119
RepoVariablesReplacedUrl _mirrorListUrl
Definition RepoInfo.cc:423
Impl * clone() const
clone for RWCOW_pointer
Definition RepoInfo.cc:472
Pathname metadataPath() const
Definition RepoInfo.cc:438
DefaultIntegral< unsigned, defaultPriority > priority
Definition RepoInfo.cc:457
bool cfgGpgCheck() const
Definition RepoInfo.cc:411
void resetEffectiveUrls() const
Definition RepoInfo.cc:165
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Stream output.
Definition RepoInfo.cc:478
void setType(const repo::RepoType &t)
Definition RepoInfo.cc:101
RepoVariablesReplacedUrl baseUrl() const
Definition RepoInfo.cc:144
bool hasContent(const std::string &keyword_r) const
Definition RepoInfo.cc:317
const std::set< std::string > & contentKeywords() const
Definition RepoInfo.cc:266
TriBool cfgPkgGpgCheck() const
Definition RepoInfo.cc:415
Url location() const
Definition RepoInfo.cc:159
bool baseurl2dump() const
Definition RepoInfo.cc:247
const RepoVariablesReplacedUrlList & baseUrls() const
Definition RepoInfo.cc:154
bool hasContent() const
Definition RepoInfo.cc:272
RepoVariablesReplacedUrlList _gpgKeyUrls
Definition RepoInfo.cc:468
RepoVariablesReplacedUrlList _baseUrls
Definition RepoInfo.cc:463
Impl & operator=(Impl &&)=delete
std::string service
Definition RepoInfo.cc:426
void rawGpgCheck(TriBool val_r)
Definition RepoInfo.cc:407
void addContent(const std::string &keyword_r)
Definition RepoInfo.cc:269
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
Definition RepoInfo.cc:398
Pathname packagesPath() const
Definition RepoInfo.cc:445
void metadataPath(Pathname new_r)
Definition RepoInfo.cc:429
url_set & effectiveBaseUrls() const
Definition RepoInfo.cc:170
TriBool rawGpgCheck() const
Definition RepoInfo.cc:403
TriBool rawRepoGpgCheck() const
Definition RepoInfo.cc:404
void internalSetValidRepoSignature(TriBool value_r)
Definition RepoInfo.cc:338
std::string targetDistro
Definition RepoInfo.cc:427
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Definition RepoInfo.cc:251
TriBool cfgRepoGpgCheck() const
Definition RepoInfo.cc:413
static const unsigned defaultPriority
Definition RepoInfo.cc:98
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition RepoInfo.cc:400
void setProbedType(const repo::RepoType &t) const
Definition RepoInfo.cc:104
RepoVariablesReplacedUrlList & baseUrls()
Definition RepoInfo.cc:244
TriBool _validRepoSignature
have signed and valid repo metadata
Definition RepoInfo.cc:419
repo::RepoType type() const
Definition RepoInfo.cc:110
Impl & operator=(const Impl &)=delete
std::chrono::steady_clock::time_point _lastEffectiveUrlsUpdate
Definition RepoInfo.cc:465
std::pair< FalseBool, std::set< std::string > > _keywords
Definition RepoInfo.cc:466
RepoVariablesReplacedUrlList & gpgKeyUrls()
Definition RepoInfo.cc:254
bool usesAutoMetadataPaths() const
Definition RepoInfo.cc:435
static const unsigned noPriority
Definition RepoInfo.cc:99
Impl(Impl &&)=delete
Repository type enumeration.
Definition RepoType.h:29
static const RepoType YAST2
Definition RepoType.h:31
const std::string & asString() const
Definition RepoType.cc:56
static const RepoType RPMMD
Definition RepoType.h:30
static const RepoType NONE
Definition RepoType.h:33
static const RepoType RPMPLAINDIR
Definition RepoType.h:32
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
#define _(MSG)
Definition Gettext.h:39
#define DBG
Definition Logger.h:99
#define MIL
Definition Logger.h:100
#define WAR
Definition Logger.h:101
Interface to gettext.