libzypp  17.35.19
PackageProvider.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
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>
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>
38 
39 using std::endl;
40 
42 namespace zypp
43 {
45  namespace repo
46  {
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 
61  { return _action; }
62 
63  private:
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 
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>
113  {
114  using TPackagePtr = typename TPackage::constPtr; // Package or SrcPackage
116  public:
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;
130 
131  ~PackageProviderImpl() override {}
132 
133  public:
138  ManagedFile providePackage() const override;
139 
142  {
144  if ( ! ( ret->empty() || _package->repoInfo().effectiveKeepPackages() ) )
146  return ret;
147  }
148 
150  bool isCached() const override
151  { return ! doProvidePackageFromCache()->empty(); }
152 
153  protected:
156 
165  { return ManagedFile( _package->cachedLocation() ); }
166 
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 
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 
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 ) {
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  {
266  }
267  else if ( userData.haskey( "Action" ) ) // pkgGpgCheck requests the default problem report (wo. details)
268  {
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 
295 
297  RpmDb::CheckPackageResult packageSigCheck( const Pathname & path_r, bool isMandatory_r, UserData & userData ) const
298  {
299  if ( !_target )
300  _target = getZYpp()->getTarget();
301 
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 
325  {
326  switch ( action_r )
327  {
329  WAR << _package->asUserString() << ": " << "User requested to accept insecure file" << endl;
330  break;
331  default:
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;
347  }
349 
350  protected:
354 
355  private:
356  using ScopedGuard = shared_ptr<void>;
357 
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;
372  };
374 
375  template <class TPackage>
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() )
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  // FIXME we only support the first url for now.
421  if ( info.baseUrlsEmpty() )
422  ZYPP_THROW(Exception("No url in repository."));
423 
424  MIL << "provide Package " << _package << endl;
425  Url url = * info.baseUrlsBegin();
426  try {
427  do {
428  _retry = false;
429  if ( ! ret->empty() )
430  {
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  {
455  _retry = true;
456  break;
458  ZYPP_THROW(SkipRequestException("User requested skip of corrupted file"));
459  break;
460  default:
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  {
477  _retry = true;
478  break;
480  ZYPP_THROW(SkipRequestException("User requested skip of corrupted file"));
481  break;
482  default:
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  {
504  _retry = true;
505  break;
507  ZYPP_THROW(SkipRequestException("User requested skip of file", excpt));
508  break;
509  default:
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() )
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:
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:
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:
564  };
566 
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 
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  }
611  catch ( const Exception & excpt )
612  {
613  report()->problemDeltaDownload( excpt.asUserHistory() );
614  return ManagedFile();
615  }
616  report()->finishDeltaDownload();
617 
618  report()->startDeltaApply( delta );
619  if ( ! applydeltarpm::check( delta_r.baseversion().sequenceinfo() ) )
620  {
621  report()->problemDeltaApply( _("applydeltarpm check failed.") );
622  return ManagedFile();
623  }
624 
625  // Build the package
626  Pathname cachedest( _package->repoInfo().packagesPath() / _package->repoInfo().path() / _package->location().filename() );
627  Pathname builddest( cachedest.extend( ".drpm" ) );
628 
629  if ( ! applydeltarpm::provide( delta, builddest,
630  bind( &RpmPackageProvider::progressDeltaApply, this, _1 ) ) )
631  {
632  report()->problemDeltaApply( _("applydeltarpm failed.") );
633  return ManagedFile();
634  }
635  ManagedFile builddestCleanup( builddest, filesystem::unlink );
636  report()->finishDeltaApply();
637 
638  // Check and move it into the cache
639  // Here the rpm itself is ready. If the packages sigcheck fails, it
640  // makes no sense to return a ManagedFile() and fallback to download the
641  // full rpm. It won't be different. So let the exceptions escape...
642  rpmSigFileChecker( builddest );
643  if ( filesystem::hardlinkCopy( builddest, cachedest ) != 0 )
644  ZYPP_THROW( Exception( str::Str() << "Can't hardlink/copy " << builddest << " to " << cachedest ) );
645 
646  return ManagedFile( cachedest, filesystem::unlink );
647  }
648 
650  // class PackageProvider
652  namespace factory
653  {
654  inline PackageProvider::Impl * make( RepoMediaAccess & access_r, const PoolItem & pi_r,
655  DeltaCandidates &&deltas_r,
656  PackageProviderPolicy &&policy_r )
657  {
658  if ( pi_r.isKind<Package>() )
659  return new RpmPackageProvider( access_r, pi_r->asKind<Package>(), std::move(deltas_r), std::move(policy_r) );
660  else if ( pi_r.isKind<SrcPackage>() )
661  return new PackageProviderImpl<SrcPackage>( access_r, pi_r->asKind<SrcPackage>(), std::move(policy_r) );
662  else
663  ZYPP_THROW( Exception( str::Str() << "Don't know how to cache non-package " << pi_r.asUserString() ) );
664  }
665 
666  inline PackageProvider::Impl * make( RepoMediaAccess & access_r, const PoolItem & pi_r,
667  PackageProviderPolicy &&policy_r )
668  {
669  if ( pi_r.isKind<Package>() )
670  return new PackageProviderImpl<Package>( access_r, pi_r->asKind<Package>(), std::move(policy_r) );
671  else if ( pi_r.isKind<SrcPackage>() )
672  return new PackageProviderImpl<SrcPackage>( access_r, pi_r->asKind<SrcPackage>(), std::move(policy_r) );
673  else
674  ZYPP_THROW( Exception( str::Str() << "Don't know how to cache non-package " << pi_r.asUserString() ) );
675  }
676 
678  Package::constPtr &&package_r,
679  DeltaCandidates &&deltas_r,
680  PackageProviderPolicy &&policy_r )
681  { return new RpmPackageProvider( access_r, std::move(package_r), std::move(deltas_r), std::move(policy_r) ); }
682 
683  } // namespace factory
685 
687  DeltaCandidates deltas_r, PackageProviderPolicy policy_r )
688 
689  : _pimpl( factory::make( access_r, pi_r, std::move(deltas_r), std::move(policy_r) ) )
690  {}
691 
693  PackageProviderPolicy policy_r )
694  : _pimpl( factory::make( access_r, pi_r, std::move(policy_r) ) )
695  {}
696 
697  /* legacy */
699  Package::constPtr package_r,
700  DeltaCandidates deltas_r,
701  PackageProviderPolicy policy_r )
702  : _pimpl( factory::make( access_r, std::move(package_r), std::move(deltas_r), std::move(policy_r) ) )
703  {}
704 
706  {}
707 
709  { return _pimpl->providePackage(); }
710 
712  { return _pimpl->providePackageFromCache(); }
713 
715  { return _pimpl->isCached(); }
716 
717  } // namespace repo
719 } // namespace zypp
PackageProvider implementation interface.
Candidate delta and patches for a package.
const BaseVersion & baseversion() const
Definition: PackageDelta.h:69
Pathname path() const
Repository path.
Definition: RepoInfo.cc:638
Interface to gettext.
Interface to the rpm program.
Definition: RpmDb.h:50
#define MIL
Definition: Logger.h:100
TraitsType::constPtrType constPtr
Definition: Package.h:39
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
Definition: ZConfig.cc:1179
std::string str() const
Definition: String.h:222
int assert_dir(const Pathname &path, unsigned mode)
Like &#39;mkdir -p&#39;.
Definition: PathInfo.cc:324
RpmPackageProvider(RepoMediaAccess &access_r, Package::constPtr &&package_r, DeltaCandidates &&deltas_r, PackageProviderPolicy &&policy_r)
#define _(MSG)
Definition: Gettext.h:39
intrusive_ptr< const RpmHeader > constPtr
Definition: RpmHeader.h:65
Impl & operator=(const Impl &)=delete
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:424
Describes a resource file located on a medium.
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:925
Architecture.
Definition: Arch.h:36
void reset()
Reset to default Ctor values.
Definition: AutoDispose.h:150
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verification error handling.
ManagedFile providePackageFromCache() const override
Provide the package if it is cached.
bool isCached() const
Whether the package is cached.
const repo::DownloadResolvableReport::Action & action() const
Users final decision how to proceed.
Policies and options for PackageProvider.
ManagedFile tryDelta(const DeltaRpm &delta_r) const
static SyncContextRef defaultContext()
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
bool haveApplydeltarpm()
Test whether an execuatble applydeltarpm program is available.
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Definition: RepoInfo.cc:439
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:101
void progressDeltaApply(int value) const
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
Definition: Arch.h:363
What is known about a repository.
Definition: RepoInfo.h:71
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
std::string basename() const
Return the last component of this path.
Definition: Pathname.h:130
ManagedFile providePackage() const
Provide the package.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:37
PackageProvider::Impl * make(RepoMediaAccess &access_r, const PoolItem &pi_r, DeltaCandidates &&deltas_r, PackageProviderPolicy &&policy_r)
RpmDb::CheckPackageResult packageSigCheck(const Pathname &path_r, bool isMandatory_r, UserData &userData) const
Actual rpm package signature check.
RpmSigCheckException(repo::DownloadResolvableReport::Action action_r, std::string msg_r="RpmSigCheckException")
std::list< packagedelta::DeltaRpm > deltaRpms(const Package::constPtr &package) const
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:888
#define ERR
Definition: Logger.h:102
PackageProvider implementation for Package and SrcPackage.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:650
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition: ManagedFile.h:27
void rpmSigFileChecker(const Pathname &file_r) const
Repo manager settings.
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:659
Policy for provideFile and RepoMediaAccess.
bool empty() const
Test for an empty path.
Definition: Pathname.h:116
zypp::callback::UserData UserData
Definition: userrequest.h:18
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
Definition: Exception.h:444
RW_pointer< Impl > _pimpl
Implementation class.
virtual bool isCached() const =0
Whether the package is cached.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:211
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:436
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
Definition: UserData.h:119
const OnMediaLocation & location() const
Definition: PackageDelta.h:68
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Definition: Exception.cc:127
Package interface.
Definition: Package.h:33
const ByteCount & downloadSize() const
The size of the resource on the server.
Pathname dirname() const
Return all but the last component od this path.
Definition: Pathname.h:126
#define WAR
Definition: Logger.h:101
void resolveSignatureErrorAction(repo::DownloadResolvableReport::Action action_r) const
React on signature verification error user action.
Detailed rpm signature check log messages A single multiline message if CHK_OK.
Definition: RpmDb.h:391
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:274
Exception thrown by PackageProviderImpl::rpmSigFileChecker.
bool queryInstalled(const Edition &ed_r=Edition()) const
ResTraits< TRes >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:118
ProvideFilePolicy & fileChecker(FileChecker fileChecker_r)
Add a FileCecker passed down to the Fetcher.
bool isCached() const override
Whether the package is cached.
bool progressPackageDownload(int value) const
Redirect ProvideFilePolicy package download progress to this.
Report & report() const
Access to the DownloadResolvableReport.
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
static RpmHeader::constPtr readPackage(const Pathname &path, VERIFICATION verification=VERIFY)
Get an accessible packages data from disk.
Definition: RpmHeader.cc:212
const Pathname & filename() const
The path to the resource on the medium.
int unlink(const Pathname &path)
Like &#39;unlink&#39;.
Definition: PathInfo.cc:705
Provides files from different repos.
ManagedFile provideFile(const RepoInfo &repo_r, const OnMediaLocation &loc_r, const ProvideFilePolicy &policy_r)
Provide a file from a Repository.
std::string asUserString() const
Definition: SolvableType.h:95
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Definition: AutoDispose.h:167
SrcPackage interface.
Definition: SrcPackage.h:29
ManagedFile doProvidePackage() const override
Actually provide the final rpm.
Base class for Exception.
Definition: Exception.h:146
ProvideFilePolicy & progressCB(ProgressCB progressCB_r)
Set callback.
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
Definition: UserData.h:176
virtual ManagedFile providePackageFromCache() const =0
Provide the package if it is cached.
Typesafe passing of user data via callbacks.
Definition: UserData.h:39
bool progressDeltaDownload(int value) const
RPM PackageProvider implementation (with deltarpm processing).
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:599
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:225
bool haskey(const std::string &key_r) const
Whether key_r is in data.
Definition: UserData.h:98
CheckPackageResult
checkPackage result
Definition: RpmDb.h:376
repo::DownloadResolvableReport::Action _action
bool quickcheck(const std::string &sequenceinfo_r)
Quick via check sequence info.
Definition: Applydeltarpm.h:48
bool check(const std::string &sequenceinfo_r, bool quick_r)
Check via sequence info.
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
virtual ManagedFile providePackage() const =0
Provide the package.
bool queryInstalled(const std::string &name_r, const Edition &ed_r, const Arch &arch_r) const
Evaluate callback.
bool isKind(const ResKind &kind_r) const
Definition: SolvableType.h:64
Base for exceptions caused by explicit user request.
bool hasvalue(const std::string &key_r) const
Whether key_r is in data and value is not empty.
Definition: UserData.h:102
PackageProviderImpl & operator=(const PackageProviderImpl &)=delete
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
PackageProviderImpl(RepoMediaAccess &access_r, TPackagePtr &&package_r, PackageProviderPolicy &&policy_r)
Ctor taking the Package to provide.
ManagedFile doProvidePackageFromCache() const
Lookup the final rpm in cache.
ManagedFile providePackage() const override
Provide the package.
const std::string & sequenceinfo() const
Definition: PackageDelta.h:46
bool effectiveKeepPackages() const
keepPackages unless the package cache itself enforces keeping the packages.
Definition: RepoInfo.cc:593
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.
Url manipulation class.
Definition: Url.h:92
#define DBG
Definition: Logger.h:99
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Definition: Edition.h:73
const Repository & repository() const
Definition: PackageDelta.h:70
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
PackageProvider(RepoMediaAccess &access, const PoolItem &pi_r, PackageProviderPolicy policy_r=PackageProviderPolicy())
Ctor taking the package to provide.