libzypp 17.37.10

PackageProvider.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 <fstream>
15#include <sstream>
16#include <zypp/repo/PackageDelta.h>
17#include <zypp/base/Logger.h>
18#include <zypp/base/Gettext.h>
19#include <utility>
20#include <zypp-core/base/UserRequestException>
21#include <zypp/base/NonCopyable.h>
22#include <zypp/repo/PackageProvider.h>
23#include <zypp/repo/Applydeltarpm.h>
24#include <zypp/repo/PackageDelta.h>
25
26#include <zypp/TmpPath.h>
27#include <zypp/ZConfig.h>
28#include <zypp/RepoInfo.h>
29#include <zypp/RepoManager.h>
30#include <zypp/SrcPackage.h>
31
32#include <zypp/ZYppFactory.h>
33#include <zypp/Target.h>
34#include <zypp/target/rpm/RpmDb.h>
35#include <zypp/FileChecker.h>
36#include <zypp/target/rpm/RpmHeader.h>
37#include <zypp/ng/workflows/keyringwf.h>
38
39 using std::endl;
40
42 namespace zypp
43{
45 namespace repo
46 {
51 class RpmSigCheckException : public FileCheckException
52 {
53 public:
54 RpmSigCheckException( repo::DownloadResolvableReport::Action action_r, std::string msg_r = "RpmSigCheckException" )
55 : FileCheckException( std::move(msg_r) )
56 , _action( action_r )
57 {}
58
60 const repo::DownloadResolvableReport::Action & action() const
61 { return _action; }
62
63 private:
64 repo::DownloadResolvableReport::Action _action;
65 };
66
67
69 // class PackageProviderPolicy
71
72 bool PackageProviderPolicy::queryInstalled( const std::string & name_r,
73 const Edition & ed_r,
74 const Arch & arch_r ) const
75 {
76 if ( _queryInstalledCB )
77 return _queryInstalledCB( name_r, ed_r, arch_r );
78 return false;
79 }
80
85 struct PackageProvider::Impl : private base::NonCopyable
86 {
87 Impl() {}
88 Impl(const Impl &) = delete;
89 Impl(Impl &&) = delete;
90 Impl &operator=(const Impl &) = delete;
91 Impl &operator=(Impl &&) = delete;
92 virtual ~Impl() {}
93
98 virtual ManagedFile providePackage() const = 0;
99
101 virtual ManagedFile providePackageFromCache() const = 0;
102
104 virtual bool isCached() const = 0;
105 };
106
111 template <class TPackage>
112 class PackageProviderImpl : public PackageProvider::Impl
113 {
114 using TPackagePtr = typename TPackage::constPtr; // Package or SrcPackage
115 using UserData = callback::UserData;
116 public:
118 PackageProviderImpl( RepoMediaAccess &access_r, TPackagePtr &&package_r,
119 PackageProviderPolicy &&policy_r )
120 : _policy(std::move( policy_r ))
121 , _package(std::move( package_r ))
122 , _access( access_r )
123 , _retry(false)
124 {}
125
126 PackageProviderImpl(const PackageProviderImpl &) = delete;
127 PackageProviderImpl(PackageProviderImpl &&) = delete;
128 PackageProviderImpl &operator=(const PackageProviderImpl &) = delete;
129 PackageProviderImpl &operator=(PackageProviderImpl &&) = delete;
130
131 ~PackageProviderImpl() override {}
132
133 public:
138 ManagedFile providePackage() const override;
139
141 ManagedFile providePackageFromCache() const override
142 {
143 ManagedFile ret( doProvidePackageFromCache() );
144 if ( ! ( ret->empty() || _package->repoInfo().effectiveKeepPackages() ) )
145 ret.setDispose( filesystem::unlink );
146 return ret;
147 }
148
150 bool isCached() const override
151 { return ! doProvidePackageFromCache()->empty(); }
152
153 protected:
154 using Base = PackageProviderImpl<TPackage>;
155 using Report = callback::SendReport<repo::DownloadResolvableReport>;
156
164 ManagedFile doProvidePackageFromCache() const
165 { return ManagedFile( _package->cachedLocation() ); }
166
181 virtual ManagedFile doProvidePackage() const
182 {
183 ManagedFile ret;
184 OnMediaLocation loc = _package->location();
185
186 ProvideFilePolicy policy;
187 policy.progressCB( bind( &Base::progressPackageDownload, this, _1 ) );
188 policy.fileChecker( bind( &Base::rpmSigFileChecker, this, _1 ) );
189 return _access.provideFile( _package->repoInfo(), loc, policy );
190 }
191
192 protected:
194 Report & report() const
195 { return *_report; }
196
198 bool progressPackageDownload( int value ) const
199 { return report()->progress( value, _package ); }
200
201
216 void rpmSigFileChecker( const Pathname & file_r ) const
217 {
218 RepoInfo info = _package->repoInfo();
219 if ( info.pkgGpgCheck() )
220 {
221 UserData userData( "pkgGpgCheck" );
222 ResObject::constPtr roptr( _package ); // gcc6 needs it more explcit. Has problem deducing
223 userData.set( "ResObject", roptr ); // a type for '_package->asKind<ResObject>()'...
224 /*legacy:*/userData.set( "Package", roptr->asKind<Package>() );
225 userData.set( "Localpath", file_r );
226
227 RpmDb::CheckPackageResult res = RpmDb::CHK_NOKEY;
228 while ( res == RpmDb::CHK_NOKEY ) {
229 res = packageSigCheck( file_r, info.pkgGpgCheckIsMandatory(), userData );
230
231 // publish the checkresult, even if it is OK. Apps may want to report something...
232 report()->pkgGpgCheck( userData );
233
234 if ( res == RpmDb::CHK_NOKEY ) {
235 // if the check fails because we don't know the key
236 // we try to resolv it with gpgkey urls from the
237 // repository, if available
238
239 target::rpm::RpmHeader::constPtr hr = target::rpm::RpmHeader::readPackage( file_r );
240 if ( !hr ) {
241 // we did not find any information about the key in the header
242 // this should never happen
243 WAR << "Unable to read package header from " << hr << endl;
244 break;
245 }
246
247 std::string keyID = hr->signatureKeyID();
248 if ( keyID.length() > 0 ) {
249 if ( !zyppng::KeyRingWorkflow::provideAndImportKeyFromRepository ( zyppng::SyncContext::defaultContext(), keyID, info ) )
250 break;
251
252 } else {
253 // we did not find any information about the key in the header
254 // this should never happen
255 WAR << "packageSigCheck returned without setting providing missing key information" << endl;
256 break;
257 }
258 }
259 }
260
261 if ( res != RpmDb::CHK_OK )
262 {
263 if ( userData.hasvalue( "Action" ) ) // pkgGpgCheck report provided an user error action
264 {
265 resolveSignatureErrorAction( userData.get( "Action", repo::DownloadResolvableReport::ABORT ) );
266 }
267 else if ( userData.haskey( "Action" ) ) // pkgGpgCheck requests the default problem report (wo. details)
268 {
269 defaultReportSignatureError( res );
270 }
271 else // no advice from user => usedefaults
272 {
273 switch ( res )
274 {
275 case RpmDb::CHK_OK: // Signature is OK
276 break;
277
278 case RpmDb::CHK_NOKEY: // Public key is unavailable
279 case RpmDb::CHK_NOTFOUND: // Signature is unknown type
280 case RpmDb::CHK_FAIL: // Signature does not verify
281 case RpmDb::CHK_NOTTRUSTED: // Signature is OK, but key is not trusted
282 case RpmDb::CHK_ERROR: // File does not exist or can't be opened
283 case RpmDb::CHK_NOSIG: // File is unsigned
284 default:
285 // report problem (w. details), throw if to abort, else retry/ignore
286 defaultReportSignatureError( res, str::Str() << userData.get<RpmDb::CheckPackageDetail>( "CheckPackageDetail" ) );
287 break;
288 }
289 }
290 }
291 }
292 }
293
294 using RpmDb = target::rpm::RpmDb;
295
297 RpmDb::CheckPackageResult packageSigCheck( const Pathname & path_r, bool isMandatory_r, UserData & userData ) const
298 {
299 if ( !_target )
300 _target = getZYpp()->getTarget();
301
302 RpmDb::CheckPackageResult ret = RpmDb::CHK_ERROR;
303 RpmDb::CheckPackageDetail detail;
304 if ( _target )
305 {
306 ret = _target->rpmDb().checkPackageSignature( path_r, detail );
307 if ( ret == RpmDb::CHK_NOSIG && !isMandatory_r )
308 {
309 WAR << "Relax CHK_NOSIG: Config says unsigned packages are OK" << endl;
310 ret = RpmDb::CHK_OK;
311 }
312 }
313 else
314 detail.push_back( RpmDb::CheckPackageDetail::value_type( ret, "OOps. Target is not initialized!" ) );
315
316 userData.set( "CheckPackageResult", ret );
317 userData.set( "CheckPackageDetail", std::move(detail) );
318 return ret;
319 }
320
324 void resolveSignatureErrorAction( repo::DownloadResolvableReport::Action action_r ) const
325 {
326 switch ( action_r )
327 {
328 case repo::DownloadResolvableReport::IGNORE:
329 WAR << _package->asUserString() << ": " << "User requested to accept insecure file" << endl;
330 break;
331 default:
332 case repo::DownloadResolvableReport::RETRY:
333 case repo::DownloadResolvableReport::ABORT:
334 ZYPP_THROW(RpmSigCheckException(action_r,"Signature verification failed"));
335 break;
336 }
337 }
338
340 void defaultReportSignatureError( RpmDb::CheckPackageResult ret, const std::string & detail_r = std::string() ) const
341 {
342 str::Str msg;
343 msg << _package->asUserString() << ": " << _("Signature verification failed") << " " << ret;
344 if ( ! detail_r.empty() )
345 msg << "\n" << detail_r;
346 resolveSignatureErrorAction( report()->problem( _package, repo::DownloadResolvableReport::INVALID, msg.str() ) );
347 }
348
349
350 protected:
351 PackageProviderPolicy _policy;
352 TPackagePtr _package;
353 RepoMediaAccess & _access;
354
355 private:
356 using ScopedGuard = shared_ptr<void>;
357
358 ScopedGuard newReport() const
359 {
360 _report.reset( new Report );
361 // Use a custom deleter calling _report.reset() when guard goes out of
362 // scope (cast required as reset is overloaded). We want report to end
363 // when leaving providePackage and not wait for *this going out of scope.
364 return shared_ptr<void>( static_cast<void*>(0),
365 std::bind( std::mem_fn(static_cast<void (shared_ptr<Report>::*)()>(&shared_ptr<Report>::reset)),
366 std::ref(_report) ) );
367 }
368
369 mutable bool _retry;
370 mutable shared_ptr<Report> _report;
371 mutable Target_Ptr _target;
372 };
374
375 template <class TPackage>
376 ManagedFile PackageProviderImpl<TPackage>::providePackage() const
377 {
378 ScopedGuard guardReport( newReport() );
379
380 // check for cache hit:
381 ManagedFile ret( providePackageFromCache() );
382 if ( ! ret->empty() )
383 {
384 MIL << "provided Package from cache " << _package << " at " << ret << endl;
385 report()->infoInCache( _package, ret );
386 return ret; // <-- cache hit
387 }
388
389 // HERE: cache misss, check toplevel cache or do download:
390 RepoInfo info = _package->repoInfo();
391
392 // Check toplevel cache
393 {
394 RepoManagerOptions topCache;
395 if ( info.packagesPath().dirname() != topCache.repoPackagesCachePath ) // not using toplevel cache
396 {
397 const OnMediaLocation & loc( _package->location() );
398 if ( ! loc.checksum().empty() ) // no cache hit without checksum
399 {
400 PathInfo pi( topCache.repoPackagesCachePath / info.packagesPath().basename() / info.path() / loc.filename() );
401 if ( pi.isExist() && loc.checksum() == CheckSum( loc.checksum().type(), std::ifstream( pi.c_str() ) ) )
402 {
403 report()->start( _package, pi.path().asFileUrl() );
404 const Pathname & dest( info.packagesPath() / info.path() / loc.filename() );
405 if ( filesystem::assert_dir( dest.dirname() ) == 0 && filesystem::hardlinkCopy( pi.path(), dest ) == 0 )
406 {
407 ret = ManagedFile( dest );
408 if ( ! info.effectiveKeepPackages() )
409 ret.setDispose( filesystem::unlink );
410
411 MIL << "provided Package from toplevel cache " << _package << " at " << ret << endl;
412 report()->finish( _package, repo::DownloadResolvableReport::NO_ERROR, std::string() );
413 return ret; // <-- toplevel cache hit
414 }
415 }
416 }
417 }
418 }
419
420 if ( info.repoOriginsEmpty() )
421 ZYPP_THROW(Exception("No url in repository."));
422
423 MIL << "provide Package " << _package << endl;
424 Url url = info.location();
425 try {
426 do {
427 _retry = false;
428 if ( ! ret->empty() )
429 {
430 ret.setDispose( filesystem::unlink );
431 ret.reset();
432 }
433 report()->start( _package, url );
434 try
435 {
436 ret = doProvidePackage();
437 }
438 catch ( const UserRequestException & excpt )
439 {
440 ERR << "Failed to provide Package " << _package << endl;
441 if ( ! _retry )
442 ZYPP_RETHROW( excpt );
443 }
444 catch ( const RpmSigCheckException & excpt )
445 {
446 ERR << "Failed to provide Package " << _package << endl;
447 if ( ! _retry )
448 {
449 // Signature verification error was already reported by the
450 // rpmSigFileChecker. Just handle the users action decision:
451 switch ( excpt.action() )
452 {
453 case repo::DownloadResolvableReport::RETRY:
454 _retry = true;
455 break;
456 case repo::DownloadResolvableReport::IGNORE:
457 ZYPP_THROW(SkipRequestException("User requested skip of corrupted file"));
458 break;
459 default:
460 case repo::DownloadResolvableReport::ABORT:
461 ZYPP_THROW(AbortRequestException("User requested to abort"));
462 break;
463 }
464 }
465 }
466 catch ( const FileCheckException & excpt )
467 {
468 ERR << "Failed to provide Package " << _package << endl;
469 if ( ! _retry )
470 {
471 const std::string & package_str = _package->asUserString();
472 // TranslatorExplanation %s = package being checked for integrity
473 switch ( report()->problem( _package, repo::DownloadResolvableReport::INVALID, str::form(_("Package %s seems to be corrupted during transfer. Do you want to retry retrieval?"), package_str.c_str() ) ) )
474 {
475 case repo::DownloadResolvableReport::RETRY:
476 _retry = true;
477 break;
478 case repo::DownloadResolvableReport::IGNORE:
479 ZYPP_THROW(SkipRequestException("User requested skip of corrupted file"));
480 break;
481 default:
482 case repo::DownloadResolvableReport::ABORT:
483 ZYPP_THROW(AbortRequestException("User requested to abort"));
484 break;
485 }
486 }
487 }
488 catch ( const Exception & excpt )
489 {
490 ERR << "Failed to provide Package " << _package << endl;
491 if ( ! _retry )
492 {
493 // Aything else gets reported
494 const std::string & package_str = _package->asUserString();
495
496 // TranslatorExplanation %s = name of the package being processed.
497 std::string detail_str( str::form(_("Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
498 detail_str += str::form( "\n\n%s", excpt.asUserHistory().c_str() );
499
500 switch ( report()->problem( _package, repo::DownloadResolvableReport::IO, detail_str.c_str() ) )
501 {
502 case repo::DownloadResolvableReport::RETRY:
503 _retry = true;
504 break;
505 case repo::DownloadResolvableReport::IGNORE:
506 ZYPP_THROW(SkipRequestException("User requested skip of file", excpt));
507 break;
508 default:
509 case repo::DownloadResolvableReport::ABORT:
510 ZYPP_THROW(AbortRequestException("User requested to abort", excpt));
511 break;
512 }
513 }
514 }
515 } while ( _retry );
516 } catch(...){
517 // bsc#1045735: Be sure no invalid files stay in the cache!
518 if ( ! ret->empty() )
519 ret.setDispose( filesystem::unlink );
520 throw;
521 }
522
523 report()->finish( _package, repo::DownloadResolvableReport::NO_ERROR, std::string() );
524 MIL << "provided Package " << _package << " at " << ret << endl;
525 return ret;
526 }
527
528
533 class RpmPackageProvider : public PackageProviderImpl<Package>
534 {
535 public:
536 RpmPackageProvider( RepoMediaAccess & access_r,
537 Package::constPtr &&package_r,
538 DeltaCandidates &&deltas_r,
539 PackageProviderPolicy &&policy_r )
540 : PackageProviderImpl<Package>( access_r, std::move(package_r), std::move(policy_r) )
541 , _deltas( std::move(deltas_r) )
542 {}
543
544 protected:
545 ManagedFile doProvidePackage() const override;
546
547 private:
548 using DeltaRpm = packagedelta::DeltaRpm;
549
550 ManagedFile tryDelta( const DeltaRpm & delta_r ) const;
551
552 bool progressDeltaDownload( int value ) const
553 { return report()->progressDeltaDownload( value ); }
554
555 void progressDeltaApply( int value ) const
556 { return report()->progressDeltaApply( value ); }
557
558 bool queryInstalled( const Edition & ed_r = Edition() ) const
559 { return _policy.queryInstalled( _package->name(), ed_r, _package->arch() ); }
560
561 private:
562 DeltaCandidates _deltas;
563 };
564
565
566 ManagedFile RpmPackageProvider::doProvidePackage() const
567 {
568 // check whether to process patch/delta rpms
569 // FIXME we only check the first url for now.
570 if ( ZConfig::instance().download_use_deltarpm()
571 && ( _package->repoInfo().url().schemeIsDownloading() || ZConfig::instance().download_use_deltarpm_always() ) )
572 {
573 std::list<DeltaRpm> deltaRpms;
574 _deltas.deltaRpms( _package ).swap( deltaRpms );
575
576 if ( ! deltaRpms.empty() && queryInstalled() && applydeltarpm::haveApplydeltarpm() )
577 {
578 for_( it, deltaRpms.begin(), deltaRpms.end())
579 {
580 DBG << "tryDelta " << *it << endl;
581 ManagedFile ret( tryDelta( *it ) );
582 if ( ! ret->empty() )
583 return ret;
584 }
585 }
586 }
587
588 // no patch/delta -> provide full package
589 return Base::doProvidePackage();
590 }
591
592 ManagedFile RpmPackageProvider::tryDelta( const DeltaRpm & delta_r ) const
593 {
594 if ( delta_r.baseversion().edition() != Edition::noedition
595 && ! queryInstalled( delta_r.baseversion().edition() ) )
596 return ManagedFile();
597
598 if ( ! applydeltarpm::quickcheck( delta_r.baseversion().sequenceinfo() ) )
599 return ManagedFile();
600
601 report()->startDeltaDownload( delta_r.location().filename(),
602 delta_r.location().downloadSize() );
603 ManagedFile delta;
604 try
605 {
606 ProvideFilePolicy policy;
607 policy.progressCB( bind( &RpmPackageProvider::progressDeltaDownload, this, _1 ) );
608 delta = _access.provideFile( delta_r.repository().info(), delta_r.location(), policy );
609 // bsc#1245672: delta rpms are optional resources.
610 // ProvideFile however always returns a managed file if no Exception occurred.
611 // So the caller has to check whether the optional file actually exists.
612 if ( not PathInfo(delta).isExist() ) {
613 delta.resetDispose();
614 report()->problemDeltaApply( _("download deltarpm: not found") );
615 return ManagedFile();
616 }
617 }
618 catch ( const Exception & excpt )
619 {
620 report()->problemDeltaDownload( excpt.asUserHistory() );
621 return ManagedFile();
622 }
623 report()->finishDeltaDownload();
624
625 report()->startDeltaApply( delta );
626 if ( ! applydeltarpm::check( delta_r.baseversion().sequenceinfo() ) )
627 {
628 report()->problemDeltaApply( _("applydeltarpm check failed.") );
629 return ManagedFile();
630 }
631
632 // Build the package
633 Pathname cachedest( _package->repoInfo().packagesPath() / _package->repoInfo().path() / _package->location().filename() );
634 Pathname builddest( cachedest.extend( ".drpm" ) );
635
636 if ( ! applydeltarpm::provide( delta, builddest,
637 bind( &RpmPackageProvider::progressDeltaApply, this, _1 ) ) )
638 {
639 report()->problemDeltaApply( _("applydeltarpm failed.") );
640 return ManagedFile();
641 }
642 ManagedFile builddestCleanup( builddest, filesystem::unlink );
643 report()->finishDeltaApply();
644
645 // Check and move it into the cache
646 // Here the rpm itself is ready. If the packages sigcheck fails, it
647 // makes no sense to return a ManagedFile() and fallback to download the
648 // full rpm. It won't be different. So let the exceptions escape...
649 rpmSigFileChecker( builddest );
650 if ( filesystem::hardlinkCopy( builddest, cachedest ) != 0 )
651 ZYPP_THROW( Exception( str::Str() << "Can't hardlink/copy " << builddest << " to " << cachedest ) );
652
653 return ManagedFile( cachedest, filesystem::unlink );
654 }
655
657 // class PackageProvider
659 namespace factory
660 {
661 inline PackageProvider::Impl * make( RepoMediaAccess & access_r, const PoolItem & pi_r,
662 DeltaCandidates &&deltas_r,
663 PackageProviderPolicy &&policy_r )
664 {
665 if ( pi_r.isKind<Package>() )
666 return new RpmPackageProvider( access_r, pi_r->asKind<Package>(), std::move(deltas_r), std::move(policy_r) );
667 else if ( pi_r.isKind<SrcPackage>() )
668 return new PackageProviderImpl<SrcPackage>( access_r, pi_r->asKind<SrcPackage>(), std::move(policy_r) );
669 else
670 ZYPP_THROW( Exception( str::Str() << "Don't know how to cache non-package " << pi_r.asUserString() ) );
671 }
672
673 inline PackageProvider::Impl * make( RepoMediaAccess & access_r, const PoolItem & pi_r,
674 PackageProviderPolicy &&policy_r )
675 {
676 if ( pi_r.isKind<Package>() )
677 return new PackageProviderImpl<Package>( access_r, pi_r->asKind<Package>(), std::move(policy_r) );
678 else if ( pi_r.isKind<SrcPackage>() )
679 return new PackageProviderImpl<SrcPackage>( access_r, pi_r->asKind<SrcPackage>(), std::move(policy_r) );
680 else
681 ZYPP_THROW( Exception( str::Str() << "Don't know how to cache non-package " << pi_r.asUserString() ) );
682 }
683
684 inline PackageProvider::Impl * make( RepoMediaAccess & access_r,
685 Package::constPtr &&package_r,
686 DeltaCandidates &&deltas_r,
687 PackageProviderPolicy &&policy_r )
688 { return new RpmPackageProvider( access_r, std::move(package_r), std::move(deltas_r), std::move(policy_r) ); }
689
690 } // namespace factory
691
692
693 PackageProvider::PackageProvider( RepoMediaAccess & access_r, const PoolItem & pi_r,
694 DeltaCandidates deltas_r, PackageProviderPolicy policy_r )
695
696 : _pimpl( factory::make( access_r, pi_r, std::move(deltas_r), std::move(policy_r) ) )
697 {}
698
699 PackageProvider::PackageProvider( RepoMediaAccess & access_r, const PoolItem & pi_r,
700 PackageProviderPolicy policy_r )
701 : _pimpl( factory::make( access_r, pi_r, std::move(policy_r) ) )
702 {}
703
704 /* legacy */
705 PackageProvider::PackageProvider( RepoMediaAccess & access_r,
706 Package::constPtr package_r,
707 DeltaCandidates deltas_r,
708 PackageProviderPolicy policy_r )
709 : _pimpl( factory::make( access_r, std::move(package_r), std::move(deltas_r), std::move(policy_r) ) )
710 {}
711
712 PackageProvider::~PackageProvider()
713 {}
714
715 ManagedFile PackageProvider::providePackage() const
716 { return _pimpl->providePackage(); }
717
718 ManagedFile PackageProvider::providePackageFromCache() const
719 { return _pimpl->providePackageFromCache(); }
720
721 bool PackageProvider::isCached() const
722 { return _pimpl->isCached(); }
723
724 } // namespace repo
726} // namespace zypp
Applydeltarpm.h
FileChecker.h
PackageDelta.h
PackageProvider.h
RepoInfo.h
RepoManager.h
RpmDb.h
RpmHeader.h
SrcPackage.h
Target.h
ZConfig.h
ZYppFactory.h
Target_Ptr
shared_ptr
zypp::Arch
Architecture.
Definition Arch.h:37
zypp::AutoDispose::resetDispose
void resetDispose()
Set no dispose function.
Definition AutoDispose.h:171
zypp::AutoDispose::reset
void reset()
Reset to default Ctor values.
Definition AutoDispose.h:150
zypp::AutoDispose::setDispose
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Definition AutoDispose.h:167
zypp::CheckSum
Definition CheckSum.h:34
zypp::CheckSum::empty
bool empty() const
Definition CheckSum.cc:173
zypp::CheckSum::type
std::string type() const
Definition CheckSum.cc:167
zypp::Edition
Edition represents [epoch:]version[-release]
Definition Edition.h:61
zypp::Edition::noedition
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Definition Edition.h:73
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::Exception::asUserHistory
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Definition Exception.cc:140
zypp::FileCheckException
Definition filecheckexception.h:18
zypp::FileCheckException::FileCheckException
FileCheckException(std::string msg)
Definition filecheckexception.h:20
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition onmedialocation.h:37
zypp::OnMediaLocation::downloadSize
const ByteCount & downloadSize() const
The size of the resource on the server.
Definition onmedialocation.cc:117
zypp::OnMediaLocation::filename
const Pathname & filename() const
The path to the resource on the medium.
Definition onmedialocation.cc:90
zypp::OnMediaLocation::checksum
const CheckSum & checksum() const
The checksum of the resource on the server.
Definition onmedialocation.cc:123
zypp::Package
Package interface.
Definition Package.h:34
zypp::Package::constPtr
TraitsType::constPtrType constPtr
Definition Package.h:39
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
zypp::ProvideFilePolicy
Policy for provideFile and RepoMediaAccess.
Definition ProvideFilePolicy.h:31
zypp::ProvideFilePolicy::fileChecker
ProvideFilePolicy & fileChecker(FileChecker fileChecker_r)
Add a FileCecker passed down to the Fetcher.
Definition ProvideFilePolicy.h:45
zypp::ProvideFilePolicy::progressCB
ProvideFilePolicy & progressCB(ProgressCB progressCB_r)
Set callback.
Definition ProvideFilePolicy.h:37
zypp::RepoInfo
What is known about a repository.
Definition RepoInfo.h:72
zypp::RepoInfo::location
Url location() const
Returns the location URL for the repository, this is either the first configured baseUrl or a configu...
Definition RepoInfo.cc:787
zypp::RepoInfo::effectiveKeepPackages
bool effectiveKeepPackages() const
keepPackages unless the package cache itself enforces keeping the packages.
Definition RepoInfo.cc:730
zypp::RepoInfo::path
Pathname path() const
Repository path.
Definition RepoInfo.cc:775
zypp::RepoInfo::pkgGpgCheckIsMandatory
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition RepoInfo.cc:550
zypp::RepoInfo::packagesPath
Pathname packagesPath() const
Path where this repo packages are cached.
Definition RepoInfo.cc:736
zypp::RepoInfo::pkgGpgCheck
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition RepoInfo.cc:547
zypp::RepoInfo::repoOriginsEmpty
bool repoOriginsEmpty() const
whether repo origins are available
Definition RepoInfo.cc:694
zypp::Repository::info
RepoInfo info() const
Return any associated RepoInfo.
Definition Repository.cc:274
zypp::ResObject::constPtr
TraitsType::constPtrType constPtr
Definition ResObject.h:43
zypp::SrcPackage
SrcPackage interface.
Definition SrcPackage.h:30
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::UserRequestException
Base for exceptions caused by explicit user request.
Definition userrequestexception.h:65
zypp::ZConfig::instance
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:940
zypp::ZYppFactory::getZYpp
ZYpp::Ptr getZYpp()
Convenience to get the Pointer to the ZYpp instance.
Definition ZYppFactory.h:77
zypp::callback::UserData
Typesafe passing of user data via callbacks.
Definition UserData.h:40
zypp::callback::UserData::get
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
Definition UserData.h:176
zypp::callback::UserData::hasvalue
bool hasvalue(const std::string &key_r) const
Whether key_r is in data and value is not empty.
Definition UserData.h:102
zypp::callback::UserData::set
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
Definition UserData.h:119
zypp::callback::UserData::haskey
bool haskey(const std::string &key_r) const
Whether key_r is in data.
Definition UserData.h:98
zypp::filesystem::PathInfo
Wrapper class for stat/lstat.
Definition PathInfo.h:226
zypp::filesystem::PathInfo::path
const Pathname & path() const
Return current Pathname.
Definition PathInfo.h:251
zypp::filesystem::PathInfo::isExist
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:286
zypp::filesystem::PathInfo::c_str
const char * c_str() const
Return current Pathname as C-string.
Definition PathInfo.h:255
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::filesystem::Pathname::extend
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
Definition Pathname.h:175
zypp::filesystem::Pathname::dirname
Pathname dirname() const
Return all but the last component od this path.
Definition Pathname.h:126
zypp::filesystem::Pathname::asFileUrl
Url asFileUrl() const
Definition Pathname.cc:186
zypp::filesystem::Pathname::basename
std::string basename() const
Return the last component of this path.
Definition Pathname.h:130
zypp::filesystem::Pathname::empty
bool empty() const
Test for an empty path.
Definition Pathname.h:116
zypp::packagedelta::DeltaRpm::BaseVersion::edition
const Edition & edition() const
Definition PackageDelta.h:45
zypp::packagedelta::DeltaRpm::BaseVersion::sequenceinfo
const std::string & sequenceinfo() const
Definition PackageDelta.h:46
zypp::packagedelta::DeltaRpm
Definition PackageDelta.h:36
zypp::packagedelta::DeltaRpm::location
const OnMediaLocation & location() const
Definition PackageDelta.h:68
zypp::packagedelta::DeltaRpm::repository
const Repository & repository() const
Definition PackageDelta.h:70
zypp::packagedelta::DeltaRpm::baseversion
const BaseVersion & baseversion() const
Definition PackageDelta.h:69
zypp::repo::DeltaCandidates
Candidate delta and patches for a package.
Definition DeltaCandidates.h:37
zypp::repo::PackageProviderImpl
Definition PackageProvider.cc:113
zypp::repo::PackageProviderImpl::PackageProviderImpl
PackageProviderImpl(const PackageProviderImpl &)=delete
zypp::repo::PackageProviderImpl::doProvidePackageFromCache
ManagedFile doProvidePackageFromCache() const
Lookup the final rpm in cache.
Definition PackageProvider.cc:164
zypp::repo::PackageProviderImpl::PackageProviderImpl
PackageProviderImpl(RepoMediaAccess &access_r, TPackagePtr &&package_r, PackageProviderPolicy &&policy_r)
Ctor taking the Package to provide.
Definition PackageProvider.cc:118
zypp::repo::PackageProviderImpl::rpmSigFileChecker
void rpmSigFileChecker(const Pathname &file_r) const
Definition PackageProvider.cc:216
zypp::repo::PackageProviderImpl::_policy
PackageProviderPolicy _policy
Definition PackageProvider.cc:351
zypp::repo::PackageProviderImpl::_report
shared_ptr< Report > _report
Definition PackageProvider.cc:370
zypp::repo::PackageProviderImpl::isCached
bool isCached() const override
Whether the package is cached.
Definition PackageProvider.cc:150
zypp::repo::PackageProviderImpl::PackageProviderImpl
PackageProviderImpl(PackageProviderImpl &&)=delete
zypp::repo::PackageProviderImpl::operator=
PackageProviderImpl & operator=(PackageProviderImpl &&)=delete
zypp::repo::PackageProviderImpl::TPackagePtr
typename TPackage::constPtr TPackagePtr
Definition PackageProvider.cc:114
zypp::repo::PackageProviderImpl::Base
PackageProviderImpl< TPackage > Base
Definition PackageProvider.cc:154
zypp::repo::PackageProviderImpl::Report
callback::SendReport< repo::DownloadResolvableReport > Report
Definition PackageProvider.cc:155
zypp::repo::PackageProviderImpl::~PackageProviderImpl
~PackageProviderImpl() override
Definition PackageProvider.cc:131
zypp::repo::PackageProviderImpl::progressPackageDownload
bool progressPackageDownload(int value) const
Redirect ProvideFilePolicy package download progress to this.
Definition PackageProvider.cc:198
zypp::repo::PackageProviderImpl::providePackage
ManagedFile providePackage() const override
Provide the package.
Definition PackageProvider.cc:376
zypp::repo::PackageProviderImpl::providePackageFromCache
ManagedFile providePackageFromCache() const override
Provide the package if it is cached.
Definition PackageProvider.cc:141
zypp::repo::PackageProviderImpl::defaultReportSignatureError
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verification error handling.
Definition PackageProvider.cc:340
zypp::repo::PackageProviderImpl::_target
Target_Ptr _target
Definition PackageProvider.cc:371
zypp::repo::PackageProviderImpl::ScopedGuard
shared_ptr< void > ScopedGuard
Definition PackageProvider.cc:356
zypp::repo::PackageProviderImpl::_access
RepoMediaAccess & _access
Definition PackageProvider.cc:353
zypp::repo::PackageProviderImpl::RpmDb
target::rpm::RpmDb RpmDb
Definition PackageProvider.cc:294
zypp::repo::PackageProviderImpl::packageSigCheck
RpmDb::CheckPackageResult packageSigCheck(const Pathname &path_r, bool isMandatory_r, UserData &userData) const
Actual rpm package signature check.
Definition PackageProvider.cc:297
zypp::repo::PackageProviderImpl::UserData
callback::UserData UserData
Definition PackageProvider.cc:115
zypp::repo::PackageProviderImpl::newReport
ScopedGuard newReport() const
Definition PackageProvider.cc:358
zypp::repo::PackageProviderImpl::resolveSignatureErrorAction
void resolveSignatureErrorAction(repo::DownloadResolvableReport::Action action_r) const
React on signature verification error user action.
Definition PackageProvider.cc:324
zypp::repo::PackageProviderImpl::report
Report & report() const
Access to the DownloadResolvableReport.
Definition PackageProvider.cc:194
zypp::repo::PackageProviderImpl::_retry
bool _retry
Definition PackageProvider.cc:369
zypp::repo::PackageProviderImpl::operator=
PackageProviderImpl & operator=(const PackageProviderImpl &)=delete
zypp::repo::PackageProviderImpl::doProvidePackage
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
Definition PackageProvider.cc:181
zypp::repo::PackageProviderImpl::_package
TPackagePtr _package
Definition PackageProvider.cc:352
zypp::repo::PackageProviderPolicy
Policies and options for PackageProvider.
Definition PackageProvider.h:35
zypp::repo::PackageProviderPolicy::queryInstalled
bool queryInstalled(const std::string &name_r, const Edition &ed_r, const Arch &arch_r) const
Evaluate callback.
Definition PackageProvider.cc:72
zypp::repo::PackageProviderPolicy::_queryInstalledCB
QueryInstalledCB _queryInstalledCB
Definition PackageProvider.h:50
zypp::repo::PackageProvider::_pimpl
RW_pointer< Impl > _pimpl
Implementation class.
Definition PackageProvider.h:99
zypp::repo::PackageProvider::PackageProvider
PackageProvider(RepoMediaAccess &access, const PoolItem &pi_r, PackageProviderPolicy policy_r=PackageProviderPolicy())
Ctor taking the package to provide.
Definition PackageProvider.cc:699
zypp::repo::PackageProvider::providePackage
ManagedFile providePackage() const
Provide the package.
Definition PackageProvider.cc:715
zypp::repo::PackageProvider::~PackageProvider
~PackageProvider()
Definition PackageProvider.cc:712
zypp::repo::PackageProvider::isCached
bool isCached() const
Whether the package is cached.
Definition PackageProvider.cc:721
zypp::repo::PackageProvider::providePackageFromCache
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
Definition PackageProvider.cc:718
zypp::repo::RepoMediaAccess
Provides files from different repos.
Definition RepoProvideFile.h:62
zypp::repo::RpmPackageProvider
RPM PackageProvider implementation (with deltarpm processing).
Definition PackageProvider.cc:534
zypp::repo::RpmPackageProvider::_deltas
DeltaCandidates _deltas
Definition PackageProvider.cc:562
zypp::repo::RpmPackageProvider::DeltaRpm
packagedelta::DeltaRpm DeltaRpm
Definition PackageProvider.cc:548
zypp::repo::RpmPackageProvider::tryDelta
ManagedFile tryDelta(const DeltaRpm &delta_r) const
Definition PackageProvider.cc:592
zypp::repo::RpmPackageProvider::progressDeltaApply
void progressDeltaApply(int value) const
Definition PackageProvider.cc:555
zypp::repo::RpmPackageProvider::progressDeltaDownload
bool progressDeltaDownload(int value) const
Definition PackageProvider.cc:552
zypp::repo::RpmPackageProvider::RpmPackageProvider
RpmPackageProvider(RepoMediaAccess &access_r, Package::constPtr &&package_r, DeltaCandidates &&deltas_r, PackageProviderPolicy &&policy_r)
Definition PackageProvider.cc:536
zypp::repo::RpmPackageProvider::queryInstalled
bool queryInstalled(const Edition &ed_r=Edition()) const
Definition PackageProvider.cc:558
zypp::repo::RpmPackageProvider::doProvidePackage
ManagedFile doProvidePackage() const override
Actually provide the final rpm.
Definition PackageProvider.cc:566
zypp::repo::RpmSigCheckException
Exception thrown by PackageProviderImpl::rpmSigFileChecker.
Definition PackageProvider.cc:52
zypp::repo::RpmSigCheckException::_action
repo::DownloadResolvableReport::Action _action
Definition PackageProvider.cc:64
zypp::repo::RpmSigCheckException::RpmSigCheckException
RpmSigCheckException(repo::DownloadResolvableReport::Action action_r, std::string msg_r="RpmSigCheckException")
Definition PackageProvider.cc:54
zypp::repo::RpmSigCheckException::action
const repo::DownloadResolvableReport::Action & action() const
Users final decision how to proceed.
Definition PackageProvider.cc:60
zypp::target::rpm::RpmDb
Interface to the rpm program.
Definition RpmDb.h:51
zypp::target::rpm::RpmDb::CheckPackageResult
CheckPackageResult
checkPackage result
Definition RpmDb.h:377
zypp::target::rpm::RpmDb::CHK_ERROR
@ CHK_ERROR
Definition RpmDb.h:383
zypp::target::rpm::RpmDb::CHK_NOTTRUSTED
@ CHK_NOTTRUSTED
Definition RpmDb.h:381
zypp::target::rpm::RpmDb::CHK_NOSIG
@ CHK_NOSIG
Definition RpmDb.h:384
zypp::target::rpm::RpmDb::CHK_NOKEY
@ CHK_NOKEY
Definition RpmDb.h:382
zypp::target::rpm::RpmDb::CHK_FAIL
@ CHK_FAIL
Definition RpmDb.h:380
zypp::target::rpm::RpmDb::CHK_NOTFOUND
@ CHK_NOTFOUND
Definition RpmDb.h:379
zypp::target::rpm::RpmDb::CHK_OK
@ CHK_OK
Definition RpmDb.h:378
zypp::target::rpm::RpmHeader::constPtr
intrusive_ptr< const RpmHeader > constPtr
Definition RpmHeader.h:65
zypp::target::rpm::RpmHeader::readPackage
static RpmHeader::constPtr readPackage(const Pathname &path, VERIFICATION verification=VERIFY)
Get an accessible packages data from disk.
Definition RpmHeader.cc:212
zyppng::SyncContext::defaultContext
static SyncContextRef defaultContext()
Definition contextfacade.cc:26
contextfacade.h
keyringwf.h
std
Definition Arch.h:364
zypp::applydeltarpm::haveApplydeltarpm
bool haveApplydeltarpm()
Test whether an execuatble applydeltarpm program is available.
Definition Applydeltarpm.cc:69
zypp::applydeltarpm::provide
bool provide(const Pathname &delta_r, const Pathname &new_r, const Progress &report_r)
Apply a binary delta to on-disk data to re-create a new rpm.
Definition Applydeltarpm.cc:133
zypp::applydeltarpm::quickcheck
bool quickcheck(const std::string &sequenceinfo_r)
Quick via check sequence info.
Definition Applydeltarpm.h:48
zypp::applydeltarpm::check
bool check(const std::string &sequenceinfo_r, bool quick_r)
Check via sequence info.
Definition Applydeltarpm.cc:93
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::filesystem::hardlinkCopy
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition PathInfo.cc:888
zypp::filesystem::unlink
int unlink(const Pathname &path)
Like 'unlink'.
Definition PathInfo.cc:705
zypp::filesystem::assert_dir
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition PathInfo.cc:324
zypp::repo::factory
Definition PackageProvider.cc:660
zypp::repo::factory::make
PackageProvider::Impl * make(RepoMediaAccess &access_r, const PoolItem &pi_r, DeltaCandidates &&deltas_r, PackageProviderPolicy &&policy_r)
Definition PackageProvider.cc:661
zypp::repo
Definition DeltaCandidates.cc:30
zypp::solver::detail
Definition PoolImpl.h:110
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::ManagedFile
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
zypp::make
ResTraits< TRes >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition ResObject.h:118
zyppng::KeyRingWorkflow::provideAndImportKeyFromRepository
bool provideAndImportKeyFromRepository(SyncContextRef ctx, std::string id_r, zypp::RepoInfo info_r)
Try to find the id in key cache or repository specified in info.
Definition keyringwf.cc:122
zypp::RepoManagerOptions
Repo manager settings.
Definition RepoManagerOptions.h:26
zypp::RepoManagerOptions::repoPackagesCachePath
Pathname repoPackagesCachePath
Definition RepoManagerOptions.h:54
zypp::callback::SendReport
Definition Callback.h:237
zypp::repo::DownloadResolvableReport::Action
Action
Definition ZYppCallbacks.h:105
zypp::repo::DownloadResolvableReport::RETRY
@ RETRY
Definition ZYppCallbacks.h:107
zypp::repo::DownloadResolvableReport::ABORT
@ ABORT
Definition ZYppCallbacks.h:106
zypp::repo::DownloadResolvableReport::IGNORE
@ IGNORE
Definition ZYppCallbacks.h:108
zypp::repo::DownloadResolvableReport::NO_ERROR
@ NO_ERROR
Definition ZYppCallbacks.h:112
zypp::repo::DownloadResolvableReport::IO
@ IO
Definition ZYppCallbacks.h:114
zypp::repo::DownloadResolvableReport::INVALID
@ INVALID
Definition ZYppCallbacks.h:115
zypp::repo::PackageProvider::Impl
PackageProvider implementation interface.
Definition PackageProvider.cc:86
zypp::repo::PackageProvider::Impl::~Impl
virtual ~Impl()
Definition PackageProvider.cc:92
zypp::repo::PackageProvider::Impl::isCached
virtual bool isCached() const =0
Whether the package is cached.
zypp::repo::PackageProvider::Impl::providePackageFromCache
virtual ManagedFile providePackageFromCache() const =0
Provide the package if it is cached.
zypp::repo::PackageProvider::Impl::Impl
Impl()
Definition PackageProvider.cc:87
zypp::repo::PackageProvider::Impl::providePackage
virtual ManagedFile providePackage() const =0
Provide the package.
zypp::repo::PackageProvider::Impl::Impl
Impl(const Impl &)=delete
zypp::repo::PackageProvider::Impl::operator=
Impl & operator=(Impl &&)=delete
zypp::repo::PackageProvider::Impl::operator=
Impl & operator=(const Impl &)=delete
zypp::repo::PackageProvider::Impl::Impl
Impl(Impl &&)=delete
zypp::sat::SolvableType::asUserString
std::string asUserString() const
Definition SolvableType.h:95
zypp::sat::SolvableType::isKind
bool isKind(const SolvableType< Derived > &solvable_r)
Test whether the Solvable is of a certain ResKind.
Definition SolvableType.h:223
zypp::str::Str
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213
zypp::str::Str::str
std::string str() const
Definition String.h:223
zypp::target::rpm::RpmDb::CheckPackageDetail
Detailed rpm signature check log messages A single multiline message if CHK_OK.
Definition RpmDb.h:392
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
ZYPP_RETHROW
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
Definition Exception.h:479
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
_
#define _(MSG)
Definition Gettext.h:39
DBG
#define DBG
Definition Logger.h:99
MIL
#define MIL
Definition Logger.h:100
ERR
#define ERR
Definition Logger.h:102
WAR
#define WAR
Definition Logger.h:101
TmpPath.h
Gettext.h
Interface to gettext.
Logger.h
NonCopyable.h