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