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