libzypp 17.37.17
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 ( !mirrorUrls().empty() ){
148 return RepoVariablesReplacedUrl( _mirrorUrls.raw().front(), _mirrorUrls.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 resetMirrorUrls() const {
165 _mirrorUrls.clear ();
166 _lastMirrorUrlsUpdate = std::chrono::steady_clock::time_point::min();
167 }
168
175 {
176 // do not change order of calculation, using std::chrono::steady_clock::now() - _lastMirrorUrlsUpdate
177 // will overflow the internal counter if _lastMirrorUrlsUpdate is still time_point::min and result
178 // in a negative value.
179 if ( ( std::chrono::steady_clock::now() - std::chrono::hours(1) ) < _lastMirrorUrlsUpdate )
180 return _mirrorUrls;
181
182 _mirrorUrls.clear();
183 _lastMirrorUrlsUpdate = std::chrono::steady_clock::now();
184
185 bool isAutoMirrorList = false; // bsc#1243901 Allows mirrorlist parsing to fail if automatically switched on
186
187 Url mlurl( mirrorListUrl().transformed() ); // Variables replaced!
188 if ( mlurl.asString().empty()
189 && _baseUrls.raw().size() == 1
190 && repo::RepoMirrorList::urlSupportsMirrorLink( *_baseUrls.transformedBegin() ) ) {
191
192 mlurl = *_baseUrls.transformedBegin ();
193 if ( !path.emptyOrRoot () )
194 mlurl.setPathName(path);
196 mlurl.setQueryParam("mirrorlist", std::string() );
197
198 MIL << "Detected opensuse.org baseUrl with no mirrors, requesting them from : " << mlurl.asString() << std::endl;
199 isAutoMirrorList = true;
200 }
201
202 if ( !mlurl.asString().empty() ) {
203 try {
204 DBG << "MetadataPath: " << metadataPath() << endl;
205 repo::RepoMirrorList rmurls( mlurl, metadataPath() );
206
207 // propagate internally used URL params like 'proxy' to the mirrors
208 const auto &tf = [urlTemplate =mirrorListUrl().transformed()]( const zypp::Url &in ){
209 return internal::propagateQueryParams ( in , urlTemplate );
210 };
211
212 _mirrorUrls.raw().insert( _mirrorUrls.raw().end(), make_transform_iterator( rmurls.getUrls().begin(), tf ), make_transform_iterator( rmurls.getUrls().end(), tf ) );
213 } catch ( const zypp::Exception & e ) {
214 // failed to fetch the mirrorlist/metalink, if we still have a baseUrl we can go on, otherwise this is a error
215 MIL << "Mirrorlist failed, repo either returns invalid data or has no mirrors at all!" << std::endl;
216 if ( !isAutoMirrorList ) {
218 data.set("error", e );
219 JobReport::warning( _("Failed to fetch mirrorlist/metalink data."), data );
220
221 // in case of error, we want to try again asap
222 _lastMirrorUrlsUpdate = std::chrono::steady_clock::time_point::min();
223 }
224 }
225 }
226 return _mirrorUrls;
227 }
228
230 {
231 MirroredOriginSet origins;
232 origins.addEndpoints( _baseUrls.transformedBegin(), _baseUrls.transformedEnd() );
233
234 const auto &mirrs = mirrorUrls ();
235 origins.addEndpoints( mirrs.transformedBegin(), mirrs.transformedEnd() );
236
237 return origins;
238 }
239
242
243 bool baseurl2dump() const
244 { return !_baseUrls.empty(); }
245
246
248 { return _gpgKeyUrls; }
249
252
253 std::string repoStatusString() const
254 {
255 if ( mirrorListUrl().transformed().isValid() )
256 return mirrorListUrl().transformed().asString();
257 if ( !baseUrls().empty() )
258 return (*baseUrls().transformedBegin()).asString();
259 return std::string();
260 }
261
262 const std::set<std::string> & contentKeywords() const
263 { hasContent()/*init if not yet done*/; return _keywords.second; }
264
265 void addContent( const std::string & keyword_r )
266 { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
267
268 bool hasContent() const
269 {
270 if ( !_keywords.first && ! metadataPath().empty() )
271 {
272 // HACK directly check master index file until RepoManager offers
273 // some content probing and zypper uses it.
275 MIL << "Empty keywords...." << metadataPath() << endl;
276 Pathname master;
277 if ( PathInfo( (master=metadataPath()/"/repodata/repomd.xml") ).isFile() )
278 {
279 //MIL << "GO repomd.." << endl;
280 xml::Reader reader( master );
281 while ( reader.seekToNode( 2, "content" ) )
282 {
283 _keywords.second.insert( reader.nodeText().asString() );
284 reader.seekToEndNode( 2, "content" );
285 }
286 _keywords.first = true; // valid content in _keywords even if empty
287 }
288 else if ( PathInfo( (master=metadataPath()/"/content") ).isFile() )
289 {
290 //MIL << "GO content.." << endl;
292 [this]( int num_r, const std::string& line_r )->bool
293 {
294 if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
295 {
296 std::vector<std::string> words;
297 if ( str::split( line_r, std::back_inserter(words) ) > 1
298 && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
299 {
300 this->_keywords.second.insert( ++words.begin(), words.end() );
301 }
302 return true; // mult. occurrances are ok.
303 }
304 return( ! str::startsWith( line_r, "META " ) ); // no need to parse into META section.
305 } );
306 _keywords.first = true; // valid content in _keywords even if empty
307 }
309 }
310 return _keywords.first;
311 }
312
313 bool hasContent( const std::string & keyword_r ) const
314 { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
315
321 {
323 return _validRepoSignature;
324 // check metadata:
325 if ( ! metadataPath().empty() )
326 {
327 // A missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
328 TriBool linkval = triBoolFromPath( metadataPath() / ".repo_gpgcheck" );
329 return linkval;
330 }
331 return indeterminate;
332 }
333
335 {
336 if ( PathInfo(metadataPath()).isDir() )
337 {
338 Pathname gpgcheckFile( metadataPath() / ".repo_gpgcheck" );
339 if ( PathInfo(gpgcheckFile).isExist() )
340 {
341 TriBool linkval( indeterminate );
342 if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
343 return; // existing symlink fits value_r
344 else
345 filesystem::unlink( gpgcheckFile ); // will write a new one
346 }
347 filesystem::symlink( asString(value_r), gpgcheckFile );
348 }
349 _validRepoSignature = value_r;
350 }
351
357 {
358 TriBool linkval( true ); // want to see it being switched to indeterminate
359 return triBoolFromPath( metadataPath() / ".repo_gpgcheck", linkval ) && indeterminate(linkval);
360 }
361
362 bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
363 {
364 static const Pathname truePath( "true" );
365 static const Pathname falsePath( "false" );
366 static const Pathname indeterminatePath( "indeterminate" );
367
368 // Quiet readlink;
369 static const ssize_t bufsiz = 63;
370 static char buf[bufsiz+1];
371 ssize_t ret = ::readlink( path_r.c_str(), buf, bufsiz );
372 buf[ret == -1 ? 0 : ret] = '\0';
373
374 Pathname linkval( buf );
375
376 bool known = true;
377 if ( linkval == truePath )
378 ret_r = true;
379 else if ( linkval == falsePath )
380 ret_r = false;
381 else if ( linkval == indeterminatePath )
382 ret_r = indeterminate;
383 else
384 known = false;
385 return known;
386 }
387
388 TriBool triBoolFromPath( const Pathname & path_r ) const
389 { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
390
392
393 private:
397
398 public:
399 TriBool rawGpgCheck() const { return _rawGpgCheck; }
402
403 void rawGpgCheck( TriBool val_r ) { _rawGpgCheck = val_r; }
404 void rawRepoGpgCheck( TriBool val_r ) { _rawRepoGpgCheck = val_r; }
405 void rawPkgGpgCheck( TriBool val_r ) { _rawPkgGpgCheck = val_r; }
406
413
414 private:
417
418 private:
421 public:
424 { return _cfgMirrorlistUrl.transformed().isValid() ? _cfgMirrorlistUrl : _cfgMetalinkUrl; }
425
426 void setMirrorlistUrl( const Url & url_r ) // Raw
427 { _cfgMirrorlistUrl.raw() = url_r; }
428
429 void setMetalinkUrl( const Url & url_r ) // Raw
430 { _cfgMetalinkUrl.raw() = url_r; }
431
435
438
439 public:
442 std::string service;
443 std::string targetDistro;
444
445 void metadataPath( Pathname new_r )
446 { _metadataPath = std::move( new_r ); }
447
448 void packagesPath( Pathname new_r )
449 { _packagesPath = std::move( new_r ); }
450
452 { return str::hasSuffix( _metadataPath.asString(), "/%AUTO%" ); }
453
455 {
456 if ( usesAutoMetadataPaths() )
457 return _metadataPath.dirname() / "%RAW%";
458 return _metadataPath;
459 }
460
462 {
463 if ( _packagesPath.empty() && usesAutoMetadataPaths() )
464 return _metadataPath.dirname() / "%PKG%";
465 return _packagesPath;
466 }
467
469 {
470 return packagesPath() / ".preload";
471 }
472
474
475 private:
478
479 mutable RepoVariablesReplacedUrlList _baseUrls; //< baseUrls as configured
480
481 mutable RepoVariablesReplacedUrlList _mirrorUrls; //< possible mirrors as fetched via mirrorlist or metalink
482 mutable std::chrono::steady_clock::time_point _lastMirrorUrlsUpdate = std::chrono::steady_clock::time_point::min();
483 mutable std::vector<MirroredOrigin> _repoOrigins;
484
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->resetMirrorUrls ();
682 }
683
685 {
686 _pimpl->baseUrls().raw().clear();
687 _pimpl->resetMirrorUrls ();
688 _pimpl->baseUrls().raw().push_back( std::move(url_r) );
689 }
690
692 {
693 _pimpl->resetMirrorUrls ();
694 _pimpl->baseUrls().raw().swap( urls );
695 }
696
698 {
699 return _pimpl->repoOrigins();
700 }
701
703 {
704 return ( _pimpl->baseUrls().empty () && _pimpl->mirrorUrls().empty() );
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
799 { return _pimpl->baseUrls().transformedBegin(); }
800
802 { return _pimpl->baseUrls().transformedEnd(); }
803
805 { return _pimpl->baseUrls().size(); }
806
808 { return _pimpl->baseUrls().empty(); }
809
811 { return _pimpl->baseurl2dump(); }
812
814 {
815 return _pimpl->baseUrl().transformed();
816 }
817
818 const std::set<std::string> & RepoInfo::contentKeywords() const
819 { return _pimpl->contentKeywords(); }
820
821 void RepoInfo::addContent( const std::string & keyword_r )
822 { _pimpl->addContent( keyword_r ); }
823
825 { return _pimpl->hasContent(); }
826
827 bool RepoInfo::hasContent( const std::string & keyword_r ) const
828 { return _pimpl->hasContent( keyword_r ); }
829
831
833 { return hasLicense( std::string() ); }
834
835 bool RepoInfo::hasLicense( const std::string & name_r ) const
836 { return !_pimpl->licenseTgz( name_r ).empty(); }
837
838
840 { return needToAcceptLicense( std::string() ); }
841
842 bool RepoInfo::needToAcceptLicense( const std::string & name_r ) const
843 {
844 const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
845 if ( licenseTgz.empty() )
846 return false; // no licenses at all
847
849 cmd.push_back( "tar" );
850 cmd.push_back( "-t" );
851 cmd.push_back( "-z" );
852 cmd.push_back( "-f" );
853 cmd.push_back( licenseTgz.asString() );
855
856 bool accept = true;
857 static const std::string noAcceptanceFile = "no-acceptance-needed\n";
858 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
859 {
860 if ( output == noAcceptanceFile )
861 {
862 accept = false;
863 }
864 }
865 prog.close();
866 MIL << "License(" << name_r << ") in " << name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
867 return accept;
868 }
869
870
871 std::string RepoInfo::getLicense( const Locale & lang_r )
872 { return const_cast<const RepoInfo *>(this)->getLicense( std::string(), lang_r ); }
873
874 std::string RepoInfo::getLicense( const Locale & lang_r ) const
875 { return getLicense( std::string(), lang_r ); }
876
877 std::string RepoInfo::getLicense( const std::string & name_r, const Locale & lang_r ) const
878 {
879 LocaleSet avlocales( getLicenseLocales( name_r ) );
880 if ( avlocales.empty() )
881 return std::string();
882
883 Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
884 if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
885 {
886 WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
887 // Using the fist locale instead of returning no text at all.
888 // So the user might recognize that there is a license, even if they
889 // can't read it.
890 getLang = *avlocales.begin();
891 }
892
893 // now extract the license file.
894 static const std::string licenseFileFallback( "license.txt" );
895 std::string licenseFile( !getLang ? licenseFileFallback
896 : str::form( "license.%s.txt", getLang.c_str() ) );
897
899 cmd.push_back( "tar" );
900 cmd.push_back( "-x" );
901 cmd.push_back( "-z" );
902 cmd.push_back( "-O" );
903 cmd.push_back( "-f" );
904 cmd.push_back( _pimpl->licenseTgz( name_r ).asString() ); // if it not exists, avlocales was empty.
905 cmd.push_back( licenseFile );
906
907 std::string ret;
909 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
910 {
911 ret += output;
912 }
913 prog.close();
914 return ret;
915 }
916
917
919 { return getLicenseLocales( std::string() ); }
920
921 LocaleSet RepoInfo::getLicenseLocales( const std::string & name_r ) const
922 {
923 const Pathname & licenseTgz( _pimpl->licenseTgz( name_r ) );
924 if ( licenseTgz.empty() )
925 return LocaleSet();
926
928 cmd.push_back( "tar" );
929 cmd.push_back( "-t" );
930 cmd.push_back( "-z" );
931 cmd.push_back( "-f" );
932 cmd.push_back( licenseTgz.asString() );
933
934 LocaleSet ret;
936 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
937 {
938 static const C_Str license( "license." );
939 static const C_Str dotTxt( ".txt\n" );
940 if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
941 {
942 if ( output.size() <= license.size() + dotTxt.size() ) // license.txt
943 ret.insert( Locale() );
944 else
945 ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
946 }
947 }
948 prog.close();
949 return ret;
950 }
951
953
954 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
955 {
956 RepoInfoBase::dumpOn(str);
957 if ( _pimpl->baseurl2dump() )
958 {
959 for ( const auto & url : _pimpl->baseUrls().raw() )
960 {
961 str << "- url : " << url << std::endl;
962 }
963 }
964
965 // print if non empty value
966 auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
967 if ( ! value_r.empty() )
968 str << tag_r << value_r << std::endl;
969 });
970
971 strif( "- mirrorlist : ", _pimpl->cfgMirrorlistUrl().raw().asString() );
972 strif( "- metalink : ", _pimpl->cfgMetalinkUrl().raw().asString() );
973 strif( "- path : ", path().asString() );
974 str << "- type : " << type() << std::endl;
975 str << "- priority : " << priority() << std::endl;
976
977 // Yes No Default(Y) Default(N)
978#define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
979 str << "- gpgcheck : " << OUTS(_pimpl->rawGpgCheck(),gpgCheck())
980 << " repo" << OUTS(_pimpl->rawRepoGpgCheck(),repoGpgCheck()) << (repoGpgCheckIsMandatory() ? "* ": " " )
981 << "sig" << asString( validRepoSignature(), "?", "Y", "N" )
982 << " pkg" << OUTS(_pimpl->rawPkgGpgCheck(),pkgGpgCheck()) << (pkgGpgCheckIsMandatory() ? "* ": " " )
983 << std::endl;
984#undef OUTS
985
986 for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
987 {
988 str << "- gpgkey : " << url << std::endl;
989 }
990
991 if ( ! indeterminate(_pimpl->keeppackages) )
992 str << "- keeppackages: " << keepPackages() << std::endl;
993
994 strif( "- service : ", service() );
995 strif( "- targetdistro: ", targetDistribution() );
996 strif( "- filePath: ", filepath().asString() );
997 strif( "- metadataPath: ", metadataPath().asString() );
998 strif( "- packagesPath: ", packagesPath().asString() );
999
1000 return str;
1001 }
1002
1003 std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
1004 {
1005 // libzypp/#638: Add a note to service maintained repo entries
1006 if( ! service().empty() ) {
1007 str << "# Repository '"<<alias()<<"' is maintained by the '"<<service()<<"' service." << endl;
1008 str << "# Manual changes may be overwritten by a service refresh." << endl;
1009 str << "# See also 'man zypper', section 'Services'." << endl;
1010 }
1011 RepoInfoBase::dumpAsIniOn(str);
1012
1013 if ( _pimpl->baseurl2dump() )
1014 {
1015 str << "baseurl=";
1016 std::string indent;
1017 for ( const auto & url : _pimpl->baseUrls().raw() )
1018 {
1019 str << indent << hotfix1050625::asString( url ) << endl;
1020 if ( indent.empty() ) indent = " "; // "baseurl="
1021 }
1022 }
1023
1024 if ( ! _pimpl->path.empty() )
1025 str << "path="<< path() << endl;
1026
1027 if ( ! _pimpl->cfgMirrorlistUrl().raw().asString().empty() )
1028 str << "mirrorlist=" << hotfix1050625::asString( _pimpl->cfgMirrorlistUrl().raw() ) << endl;
1029
1030 if ( ! _pimpl->cfgMetalinkUrl().raw().asString().empty() )
1031 str << "metalink=" << hotfix1050625::asString( _pimpl->cfgMetalinkUrl().raw() ) << endl;
1032
1033 if ( type() != repo::RepoType::NONE )
1034 str << "type=" << type().asString() << endl;
1035
1036 if ( priority() != defaultPriority() )
1037 str << "priority=" << priority() << endl;
1038
1039 if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1040 str << "gpgcheck=" << (_pimpl->rawGpgCheck() ? "1" : "0") << endl;
1041
1042 if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1043 str << "repo_gpgcheck=" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << endl;
1044
1045 if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1046 str << "pkg_gpgcheck=" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << endl;
1047
1048 {
1049 std::string indent( "gpgkey=");
1050 for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
1051 {
1052 str << indent << url << endl;
1053 if ( indent[0] != ' ' )
1054 indent = " ";
1055 }
1056 }
1057
1058 if (!indeterminate(_pimpl->keeppackages))
1059 str << "keeppackages=" << keepPackages() << endl;
1060
1061 if( ! service().empty() )
1062 str << "service=" << service() << endl;
1063
1064 return str;
1065 }
1066
1067 std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
1068 {
1069 std::string tmpstr;
1070 str
1071 << "<repo"
1072 << " alias=\"" << escape(alias()) << "\""
1073 << " name=\"" << escape(name()) << "\"";
1074 if (type() != repo::RepoType::NONE)
1075 str << " type=\"" << type().asString() << "\"";
1076 str
1077 << " priority=\"" << priority() << "\""
1078 << " enabled=\"" << enabled() << "\""
1079 << " autorefresh=\"" << autorefresh() << "\""
1080 << " gpgcheck=\"" << gpgCheck() << "\""
1081 << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
1082 << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
1083 if ( ! indeterminate(_pimpl->rawGpgCheck()) )
1084 str << " raw_gpgcheck=\"" << (_pimpl->rawGpgCheck() ? "1" : "0") << "\"";
1085 if ( ! indeterminate(_pimpl->rawRepoGpgCheck()) )
1086 str << " raw_repo_gpgcheck=\"" << (_pimpl->rawRepoGpgCheck() ? "1" : "0") << "\"";
1087 if ( ! indeterminate(_pimpl->rawPkgGpgCheck()) )
1088 str << " raw_pkg_gpgcheck=\"" << (_pimpl->rawPkgGpgCheck() ? "1" : "0") << "\"";
1089 if (!(tmpstr = gpgKeyUrl().asString()).empty())
1090 str << " gpgkey=\"" << escape(tmpstr) << "\"";
1091 if ( ! (tmpstr = _pimpl->cfgMirrorlistUrl().transformed().asString()).empty() )
1092 str << " mirrorlist=\"" << escape(tmpstr) << "\"";
1093 if ( ! (tmpstr = _pimpl->cfgMetalinkUrl().transformed().asString()).empty() )
1094 str << " metalink=\"" << escape(tmpstr) << "\"";
1095 str << ">" << endl;
1096
1097 if ( _pimpl->baseurl2dump() )
1098 {
1099 for_( it, baseUrlsBegin(), baseUrlsEnd() ) // !transform iterator replaces variables
1100 str << "<url>" << escape((*it).asString()) << "</url>" << endl;
1101 }
1102
1103 str << "</repo>" << endl;
1104 return str;
1105 }
1106
1107
1108 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
1109 {
1110 return obj.dumpOn(str);
1111 }
1112
1113 std::ostream & operator<<( std::ostream & str, const RepoInfo::GpgCheck & obj )
1114 {
1115 switch ( obj )
1116 {
1117#define OUTS( V ) case RepoInfo::V: return str << #V; break
1118 OUTS( GpgCheck::On );
1119 OUTS( GpgCheck::Strict );
1120 OUTS( GpgCheck::AllowUnsigned );
1121 OUTS( GpgCheck::AllowUnsignedRepo );
1122 OUTS( GpgCheck::AllowUnsignedPackage );
1123 OUTS( GpgCheck::Default );
1124 OUTS( GpgCheck::Off );
1125 OUTS( GpgCheck::indeterminate );
1126#undef OUTS
1127 }
1128 return str << "GpgCheck::UNKNOWN";
1129 }
1130
1132 {
1133 // We skip the check for downloading media unless a local copy of the
1134 // media file exists and states that there is more than one medium.
1135 const auto &origins = _pimpl->repoOrigins ();
1136 bool canSkipMediaCheck = std::all_of( origins.begin(), origins.end(), []( const MirroredOrigin &origin ) { return origin.authority().url().schemeIsDownloading(); });
1137 if ( canSkipMediaCheck ) {
1138 const auto &mDataPath = metadataPath();
1139 if ( not mDataPath.empty() ) {
1140 PathInfo mediafile { mDataPath/"media.1/media" };
1141 if ( mediafile.isExist() ) {
1142 repo::SUSEMediaVerifier lverifier { mediafile.path() };
1143 if ( lverifier && lverifier.totalMedia() > 1 ) {
1144 canSkipMediaCheck = false;
1145 }
1146 }
1147 }
1148 }
1149 if ( canSkipMediaCheck )
1150 DBG << "Can SKIP media.1/media check for status calc of repo " << alias() << endl;
1151 return not canSkipMediaCheck;
1152 }
1153
1155} // 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
A smart container that manages a collection of MirroredOrigin objects, automatically grouping endpoin...
void addEndpoints(InputIterator first, InputIterator last)
A convenience method to add multiple endpoints from a range.
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
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:1067
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:954
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:412
bool baseUrlsEmpty() const
whether repository urls are available
Definition RepoInfo.cc:807
Pathname predownloadPath() const
Path where this repo packages are predownloaded.
Definition RepoInfo.cc:723
bool hasContent() const
Check for content keywords.
Definition RepoInfo.cc:824
MirroredOriginSet repoOrigins() const
The repodata origins.
Definition RepoInfo.cc:697
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 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:804
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:813
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:818
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition RepoInfo.cc:801
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:874
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition RepoInfo.cc:810
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:918
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:1131
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:1003
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:839
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition RepoInfo.cc:526
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition RepoInfo.h:617
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition RepoInfo.cc:798
bool hasLicense() const
Whether there is a license associated with the repo.
Definition RepoInfo.cc:832
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Definition RepoInfo.cc:543
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:821
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
Url rawCfgMirrorlistUrl() const
The configured raw mirrorlist url.
Definition RepoInfo.cc:647
bool repoOriginsEmpty() const
whether repo origins are available
Definition RepoInfo.cc:702
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 setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
Definition Url.cc:782
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition Url.cc:894
void pathNameSetTrailingSlash(bool apply_r=true)
Apply or remove a trailing '/' from pathName.
Definition Url.cc:829
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
const Pathname & path() const
Return current Pathname.
Definition PathInfo.h:251
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.
media::MediaNr totalMedia() const
The total number of media in this set (or 0 if not known).
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
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
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:948
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)
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
RepoInfo implementation.
Definition RepoInfo.cc:79
repo::RepoType _type
Definition RepoInfo.cc:416
TriBool rawPkgGpgCheck() const
Definition RepoInfo.cc:401
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition RepoInfo.cc:395
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Definition RepoInfo.cc:320
std::string repoStatusString() const
Definition RepoInfo.cc:253
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
Definition RepoInfo.cc:362
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)?
Definition RepoInfo.cc:356
TriBool triBoolFromPath(const Pathname &path_r) const
Definition RepoInfo.cc:388
Impl(const Impl &)=default
void packagesPath(Pathname new_r)
Definition RepoInfo.cc:448
void rawRepoGpgCheck(TriBool val_r)
Definition RepoInfo.cc:404
RepoVariablesReplacedUrlList & mirrorUrls() const
Fetch the repo mirrors from the server.
Definition RepoInfo.cc:174
void rawPkgGpgCheck(TriBool val_r)
Definition RepoInfo.cc:405
Pathname predownloadPath() const
Definition RepoInfo.cc:468
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:454
DefaultIntegral< unsigned, defaultPriority > priority
Definition RepoInfo.cc:473
RepoVariablesReplacedUrl _cfgMetalinkUrl
Definition RepoInfo.cc:420
bool cfgGpgCheck() const
Definition RepoInfo.cc:407
void setMetalinkUrl(const Url &url_r)
Definition RepoInfo.cc:429
const RepoVariablesReplacedUrl & cfgMirrorlistUrl() const
Config file writing needs to tell them appart.
Definition RepoInfo.cc:433
void setMirrorlistUrl(const Url &url_r)
Definition RepoInfo.cc:426
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Stream output.
Definition RepoInfo.cc:497
RepoVariablesReplacedUrlList _mirrorUrls
Definition RepoInfo.cc:481
void setType(const repo::RepoType &t)
Definition RepoInfo.cc:100
friend Impl * rwcowClone(const Impl *rhs)
RepoVariablesReplacedUrl baseUrl() const
Definition RepoInfo.cc:143
std::chrono::steady_clock::time_point _lastMirrorUrlsUpdate
Definition RepoInfo.cc:482
bool hasContent(const std::string &keyword_r) const
Definition RepoInfo.cc:313
const std::set< std::string > & contentKeywords() const
Definition RepoInfo.cc:262
TriBool cfgPkgGpgCheck() const
Definition RepoInfo.cc:411
Url location() const
Definition RepoInfo.cc:158
bool baseurl2dump() const
Definition RepoInfo.cc:243
const RepoVariablesReplacedUrl & cfgMetalinkUrl() const
Config file writing needs to tell them appart.
Definition RepoInfo.cc:436
const RepoVariablesReplacedUrlList & baseUrls() const
Definition RepoInfo.cc:153
bool hasContent() const
Definition RepoInfo.cc:268
RepoVariablesReplacedUrlList _gpgKeyUrls
Definition RepoInfo.cc:487
RepoVariablesReplacedUrlList _baseUrls
Definition RepoInfo.cc:479
Impl & operator=(Impl &&)=delete
std::vector< MirroredOrigin > _repoOrigins
Definition RepoInfo.cc:483
std::string service
Definition RepoInfo.cc:442
void rawGpgCheck(TriBool val_r)
Definition RepoInfo.cc:403
void addContent(const std::string &keyword_r)
Definition RepoInfo.cc:265
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
Definition RepoInfo.cc:394
Pathname packagesPath() const
Definition RepoInfo.cc:461
const RepoVariablesReplacedUrl & mirrorListUrl() const
THE mirrorListUrl to work with (either_cfgMirrorlistUrl or _cfgMetalinkUrl)
Definition RepoInfo.cc:423
void metadataPath(Pathname new_r)
Definition RepoInfo.cc:445
TriBool rawGpgCheck() const
Definition RepoInfo.cc:399
TriBool rawRepoGpgCheck() const
Definition RepoInfo.cc:400
void internalSetValidRepoSignature(TriBool value_r)
Definition RepoInfo.cc:334
void resetMirrorUrls() const
Definition RepoInfo.cc:164
std::string targetDistro
Definition RepoInfo.cc:443
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Definition RepoInfo.cc:247
TriBool cfgRepoGpgCheck() const
Definition RepoInfo.cc:409
static const unsigned defaultPriority
Definition RepoInfo.cc:97
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
Definition RepoInfo.cc:396
void setProbedType(const repo::RepoType &t) const
Definition RepoInfo.cc:103
MirroredOriginSet repoOrigins() const
Definition RepoInfo.cc:229
RepoVariablesReplacedUrlList & baseUrls()
Definition RepoInfo.cc:240
TriBool _validRepoSignature
have signed and valid repo metadata
Definition RepoInfo.cc:415
repo::RepoType type() const
Definition RepoInfo.cc:109
Impl & operator=(const Impl &)=delete
RepoVariablesReplacedUrl _cfgMirrorlistUrl
Definition RepoInfo.cc:419
std::pair< FalseBool, std::set< std::string > > _keywords
Definition RepoInfo.cc:485
RepoVariablesReplacedUrlList & gpgKeyUrls()
Definition RepoInfo.cc:250
bool usesAutoMetadataPaths() const
Definition RepoInfo.cc:451
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.