libzypp 17.36.7

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