libzypp: zypp/repo/PackageProvider.cc Source File

libzypp 17.38.5

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