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