libzypp  17.6.2
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  const ZConfig &conf = ZConfig::instance();
238  Pathname cacheDir = conf.repoManagerRoot() / conf.pubkeyCachePath();
239 
240  Pathname myKey = info.provideKey ( keyID, cacheDir );
241  if ( myKey.empty() )
242  // if we did not find any keys, there is no point in checking again, break
243  break;
244 
246 
247  PublicKey key;
248  try {
249  key = PublicKey( myKey );
250  } catch ( const Exception &e ) {
251  ZYPP_CAUGHT(e);
252  break;
253  }
254 
255  if ( !key.isValid() ) {
256  ERR << "Key [" << keyID << "] from cache: " << cacheDir << " is not valid" << endl;
257  break;
258  }
259 
260  MIL << "Key [" << keyID << "] " << key.name() << " loaded from cache" << endl;
261 
262  KeyContext context;
263  context.setRepoInfo( info );
264  if ( ! report->askUserToAcceptPackageKey( key, context ) ) {
265  break;
266  }
267 
268  MIL << "User wants to import key [" << keyID << "] " << key.name() << " from cache" << endl;
269  KeyRing_Ptr theKeyRing = getZYpp()->keyRing();
270  try {
271  theKeyRing->importKey( key, true );
272  } catch ( const KeyRingException &e ) {
273  ZYPP_CAUGHT(e);
274  ERR << "Failed to import key: "<<keyID;
275  break;
276  }
277  } else {
278  // we did not find any information about the key in the header
279  // this should never happen
280  WAR << "packageSigCheck returned without setting providing missing key information" << endl;
281  break;
282  }
283  }
284  }
285 
286  if ( res != RpmDb::CHK_OK )
287  {
288  if ( userData.hasvalue( "Action" ) ) // pkgGpgCheck report provided an user error action
289  {
291  }
292  else if ( userData.haskey( "Action" ) ) // pkgGpgCheck requests the default problem report (wo. details)
293  {
295  }
296  else // no advice from user => usedefaults
297  {
298  switch ( res )
299  {
300  case RpmDb::CHK_OK: // Signature is OK
301  break;
302 
303  case RpmDb::CHK_NOKEY: // Public key is unavailable
304  case RpmDb::CHK_NOTFOUND: // Signature is unknown type
305  case RpmDb::CHK_FAIL: // Signature does not verify
306  case RpmDb::CHK_NOTTRUSTED: // Signature is OK, but key is not trusted
307  case RpmDb::CHK_ERROR: // File does not exist or can't be opened
308  case RpmDb::CHK_NOSIG: // File is unsigned
309  default:
310  // report problem (w. details), throw if to abort, else retry/ignore
311  defaultReportSignatureError( res, str::Str() << userData.get<RpmDb::CheckPackageDetail>( "CheckPackageDetail" ) );
312  break;
313  }
314  }
315  }
316  }
317  }
318 
320 
322  RpmDb::CheckPackageResult packageSigCheck( const Pathname & path_r, bool isMandatory_r, UserData & userData ) const
323  {
324  if ( !_target )
325  _target = getZYpp()->getTarget();
326 
329  if ( _target )
330  {
331  ret = _target->rpmDb().checkPackageSignature( path_r, detail );
332  if ( ret == RpmDb::CHK_NOSIG && !isMandatory_r )
333  {
334  WAR << "Relax CHK_NOSIG: Config says unsigned packages are OK" << endl;
335  ret = RpmDb::CHK_OK;
336  }
337  }
338  else
339  detail.push_back( RpmDb::CheckPackageDetail::value_type( ret, "OOps. Target is not initialized!" ) );
340 
341  userData.set( "CheckPackageResult", ret );
342  userData.set( "CheckPackageDetail", std::move(detail) );
343  return ret;
344  }
345 
350  {
351  switch ( action_r )
352  {
354  WAR << _package->asUserString() << ": " << "User requested to accept insecure file" << endl;
355  break;
356  default:
359  ZYPP_THROW(RpmSigCheckException(action_r,"Signature verification failed"));
360  break;
361  }
362  }
363 
365  void defaultReportSignatureError( RpmDb::CheckPackageResult ret, const std::string & detail_r = std::string() ) const
366  {
367  str::Str msg;
368  msg << _package->asUserString() << ": " << _("Signature verification failed") << " " << ret;
369  if ( ! detail_r.empty() )
370  msg << "\n" << detail_r;
372  }
374 
375  protected:
379 
380  private:
381  typedef shared_ptr<void> ScopedGuard;
382 
384  {
385  _report.reset( new Report );
386  // Use a custom deleter calling _report.reset() when guard goes out of
387  // scope (cast required as reset is overloaded). We want report to end
388  // when leaving providePackage and not wait for *this going out of scope.
389  return shared_ptr<void>( static_cast<void*>(0),
390  bind( mem_fun_ref( static_cast<void (shared_ptr<Report>::*)()>(&shared_ptr<Report>::reset) ),
391  ref(_report) ) );
392  }
393 
394  mutable bool _retry;
395  mutable shared_ptr<Report> _report;
397  };
399 
400  template <class TPackage>
402  {
403  ScopedGuard guardReport( newReport() );
404 
405  // check for cache hit:
406  ManagedFile ret( providePackageFromCache() );
407  if ( ! ret->empty() )
408  {
409  MIL << "provided Package from cache " << _package << " at " << ret << endl;
410  report()->infoInCache( _package, ret );
411  return ret; // <-- cache hit
412  }
413 
414  // HERE: cache misss, check toplevel cache or do download:
415  RepoInfo info = _package->repoInfo();
416 
417  // Check toplevel cache
418  {
419  RepoManagerOptions topCache;
420  if ( info.packagesPath().dirname() != topCache.repoPackagesCachePath ) // not using toplevel cache
421  {
422  const OnMediaLocation & loc( _package->location() );
423  if ( ! loc.checksum().empty() ) // no cache hit without checksum
424  {
425  PathInfo pi( topCache.repoPackagesCachePath / info.packagesPath().basename() / info.path() / loc.filename() );
426  if ( pi.isExist() && loc.checksum() == CheckSum( loc.checksum().type(), std::ifstream( pi.c_str() ) ) )
427  {
428  report()->start( _package, pi.path().asFileUrl() );
429  const Pathname & dest( info.packagesPath() / info.path() / loc.filename() );
430  if ( filesystem::assert_dir( dest.dirname() ) == 0 && filesystem::hardlinkCopy( pi.path(), dest ) == 0 )
431  {
432  ret = ManagedFile( dest );
433  if ( ! info.keepPackages() )
435 
436  MIL << "provided Package from toplevel cache " << _package << " at " << ret << endl;
437  report()->finish( _package, repo::DownloadResolvableReport::NO_ERROR, std::string() );
438  return ret; // <-- toplevel cache hit
439  }
440  }
441  }
442  }
443  }
444 
445  // FIXME we only support the first url for now.
446  if ( info.baseUrlsEmpty() )
447  ZYPP_THROW(Exception("No url in repository."));
448 
449  MIL << "provide Package " << _package << endl;
450  Url url = * info.baseUrlsBegin();
451  try {
452  do {
453  _retry = false;
454  if ( ! ret->empty() )
455  {
457  ret.reset();
458  }
459  report()->start( _package, url );
460  try
461  {
462  ret = doProvidePackage();
463  }
464  catch ( const UserRequestException & excpt )
465  {
466  ERR << "Failed to provide Package " << _package << endl;
467  if ( ! _retry )
468  ZYPP_RETHROW( excpt );
469  }
470  catch ( const RpmSigCheckException & excpt )
471  {
472  ERR << "Failed to provide Package " << _package << endl;
473  if ( ! _retry )
474  {
475  // Signature verification error was already reported by the
476  // rpmSigFileChecker. Just handle the users action decision:
477  switch ( excpt.action() )
478  {
480  _retry = true;
481  break;
483  ZYPP_THROW(SkipRequestException("User requested skip of corrupted file"));
484  break;
485  default:
487  ZYPP_THROW(AbortRequestException("User requested to abort"));
488  break;
489  }
490  }
491  }
492  catch ( const FileCheckException & excpt )
493  {
494  ERR << "Failed to provide Package " << _package << endl;
495  if ( ! _retry )
496  {
497  const std::string & package_str = _package->asUserString();
498  // TranslatorExplanation %s = package being checked for integrity
499  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() ) ) )
500  {
502  _retry = true;
503  break;
505  ZYPP_THROW(SkipRequestException("User requested skip of corrupted file"));
506  break;
507  default:
509  ZYPP_THROW(AbortRequestException("User requested to abort"));
510  break;
511  }
512  }
513  }
514  catch ( const Exception & excpt )
515  {
516  ERR << "Failed to provide Package " << _package << endl;
517  if ( ! _retry )
518  {
519  // Aything else gets reported
520  const std::string & package_str = _package->asUserString();
521 
522  // TranslatorExplanation %s = name of the package being processed.
523  std::string detail_str( str::form(_("Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
524  detail_str += str::form( "\n\n%s", excpt.asUserHistory().c_str() );
525 
526  switch ( report()->problem( _package, repo::DownloadResolvableReport::IO, detail_str.c_str() ) )
527  {
529  _retry = true;
530  break;
532  ZYPP_THROW(SkipRequestException("User requested skip of file", excpt));
533  break;
534  default:
536  ZYPP_THROW(AbortRequestException("User requested to abort", excpt));
537  break;
538  }
539  }
540  }
541  } while ( _retry );
542  } catch(...){
543  // bsc#1045735: Be sure no invalid files stay in the cache!
544  if ( ! ret->empty() )
546  throw;
547  }
548 
549  report()->finish( _package, repo::DownloadResolvableReport::NO_ERROR, std::string() );
550  MIL << "provided Package " << _package << " at " << ret << endl;
551  return ret;
552  }
553 
554 
559  class RpmPackageProvider : public PackageProviderImpl<Package>
560  {
561  public:
563  const Package::constPtr & package_r,
564  const DeltaCandidates & deltas_r,
565  const PackageProviderPolicy & policy_r )
566  : PackageProviderImpl<Package>( access_r, package_r, policy_r )
567  , _deltas( deltas_r )
568  {}
569 
570  protected:
571  virtual ManagedFile doProvidePackage() const;
572 
573  private:
575 
576  ManagedFile tryDelta( const DeltaRpm & delta_r ) const;
577 
578  bool progressDeltaDownload( int value ) const
579  { return report()->progressDeltaDownload( value ); }
580 
581  void progressDeltaApply( int value ) const
582  { return report()->progressDeltaApply( value ); }
583 
584  bool queryInstalled( const Edition & ed_r = Edition() ) const
585  { return _policy.queryInstalled( _package->name(), ed_r, _package->arch() ); }
586 
587  private:
589  };
591 
593  {
594  // check whether to process patch/delta rpms
595  // FIXME we only check the first url for now.
596  if ( ZConfig::instance().download_use_deltarpm()
597  && ( _package->repoInfo().url().schemeIsDownloading() || ZConfig::instance().download_use_deltarpm_always() ) )
598  {
599  std::list<DeltaRpm> deltaRpms;
600  _deltas.deltaRpms( _package ).swap( deltaRpms );
601 
602  if ( ! deltaRpms.empty() && queryInstalled() && applydeltarpm::haveApplydeltarpm() )
603  {
604  for_( it, deltaRpms.begin(), deltaRpms.end())
605  {
606  DBG << "tryDelta " << *it << endl;
607  ManagedFile ret( tryDelta( *it ) );
608  if ( ! ret->empty() )
609  return ret;
610  }
611  }
612  }
613 
614  // no patch/delta -> provide full package
615  return Base::doProvidePackage();
616  }
617 
619  {
620  if ( delta_r.baseversion().edition() != Edition::noedition
621  && ! queryInstalled( delta_r.baseversion().edition() ) )
622  return ManagedFile();
623 
624  if ( ! applydeltarpm::quickcheck( delta_r.baseversion().sequenceinfo() ) )
625  return ManagedFile();
626 
627  report()->startDeltaDownload( delta_r.location().filename(),
628  delta_r.location().downloadSize() );
629  ManagedFile delta;
630  try
631  {
632  ProvideFilePolicy policy;
633  policy.progressCB( bind( &RpmPackageProvider::progressDeltaDownload, this, _1 ) );
634  delta = _access.provideFile( delta_r.repository().info(), delta_r.location(), policy );
635  }
636  catch ( const Exception & excpt )
637  {
638  report()->problemDeltaDownload( excpt.asUserHistory() );
639  return ManagedFile();
640  }
641  report()->finishDeltaDownload();
642 
643  report()->startDeltaApply( delta );
644  if ( ! applydeltarpm::check( delta_r.baseversion().sequenceinfo() ) )
645  {
646  report()->problemDeltaApply( _("applydeltarpm check failed.") );
647  return ManagedFile();
648  }
649 
650  // Build the package
651  Pathname cachedest( _package->repoInfo().packagesPath() / _package->repoInfo().path() / _package->location().filename() );
652  Pathname builddest( cachedest.extend( ".drpm" ) );
653 
654  if ( ! applydeltarpm::provide( delta, builddest,
655  bind( &RpmPackageProvider::progressDeltaApply, this, _1 ) ) )
656  {
657  report()->problemDeltaApply( _("applydeltarpm failed.") );
658  return ManagedFile();
659  }
660  ManagedFile builddestCleanup( builddest, filesystem::unlink );
661  report()->finishDeltaApply();
662 
663  // Check and move it into the cache
664  // Here the rpm itself is ready. If the packages sigcheck fails, it
665  // makes no sense to return a ManagedFile() and fallback to download the
666  // full rpm. It won't be different. So let the exceptions escape...
667  rpmSigFileChecker( builddest );
668  if ( filesystem::hardlinkCopy( builddest, cachedest ) != 0 )
669  ZYPP_THROW( Exception( str::Str() << "Can't hardlink/copy " << builddest << " to " << cachedest ) );
670 
671  return ManagedFile( cachedest, filesystem::unlink );
672  }
673 
675  // class PackageProvider
677  namespace factory
678  {
679  inline PackageProvider::Impl * make( RepoMediaAccess & access_r, const PoolItem & pi_r,
680  const DeltaCandidates & deltas_r,
681  const PackageProviderPolicy & policy_r )
682  {
683  if ( pi_r.isKind<Package>() )
684  return new RpmPackageProvider( access_r, pi_r->asKind<Package>(), deltas_r, policy_r );
685  else if ( pi_r.isKind<SrcPackage>() )
686  return new PackageProviderImpl<SrcPackage>( access_r, pi_r->asKind<SrcPackage>(), policy_r );
687  else
688  ZYPP_THROW( Exception( str::Str() << "Don't know how to cache non-package " << pi_r.asUserString() ) );
689  }
690 
691  inline PackageProvider::Impl * make( RepoMediaAccess & access_r, const PoolItem & pi_r,
692  const PackageProviderPolicy & policy_r )
693  {
694  if ( pi_r.isKind<Package>() )
695  return new PackageProviderImpl<Package>( access_r, pi_r->asKind<Package>(), policy_r );
696  else if ( pi_r.isKind<SrcPackage>() )
697  return new PackageProviderImpl<SrcPackage>( access_r, pi_r->asKind<SrcPackage>(), policy_r );
698  else
699  ZYPP_THROW( Exception( str::Str() << "Don't know how to cache non-package " << pi_r.asUserString() ) );
700  }
701 
702  inline PackageProvider::Impl * make( RepoMediaAccess & access_r, const Package::constPtr & package_r,
703  const DeltaCandidates & deltas_r,
704  const PackageProviderPolicy & policy_r )
705  { return new RpmPackageProvider( access_r, package_r, deltas_r, policy_r ); }
706 
707  } // namespace factory
709 
711  const DeltaCandidates & deltas_r, const PackageProviderPolicy & policy_r )
712 
713  : _pimpl( factory::make( access_r, pi_r, deltas_r, policy_r ) )
714  {}
715 
717  const PackageProviderPolicy & policy_r )
718  : _pimpl( factory::make( access_r, pi_r, policy_r ) )
719  {}
720 
721  /* legacy */
723  const Package::constPtr & package_r,
724  const DeltaCandidates & deltas_r,
725  const PackageProviderPolicy & policy_r )
726  : _pimpl( factory::make( access_r, package_r, deltas_r, policy_r ) )
727  {}
728 
730  {}
731 
733  { return _pimpl->providePackage(); }
734 
736  { return _pimpl->providePackageFromCache(); }
737 
739  { return _pimpl->isCached(); }
740 
741  } // namespace repo
743 } // namespace zypp
PackageProvider implementation interface.
Candidate delta and patches for a package.
const BaseVersion & baseversion() const
Definition: PackageDelta.h:69
int assert_dir(const Pathname &path, unsigned mode)
Like &#39;mkdir -p&#39;.
Definition: PathInfo.cc:320
Pathname path() const
Repository path.
Definition: RepoInfo.cc:687
Interface to gettext.
Interface to the rpm program.
Definition: RpmDb.h:47
#define MIL
Definition: Logger.h:64
intrusive_ptr< const RpmHeader > constPtr
Definition: RpmHeader.h:64
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
Definition: ZConfig.cc:1017
std::string str() const
Definition: String.h:221
ManagedFile provideFile(RepoInfo repo_r, const OnMediaLocation &loc_r, const ProvideFilePolicy &policy_r)
Provide a file from a Repository.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:392
Describes a path on a certain media amongs as the information required to download it...
std::string name() const
Definition: PublicKey.cc:517
static ZConfig & instance()
Singleton ctor.
Definition: Resolver.cc:125
callback::SendReport< repo::DownloadResolvableReport > Report
Architecture.
Definition: Arch.h:36
void reset()
Reset to default Ctor values.
Definition: AutoDispose.h:145
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verification error handling.
bool isCached() const
Whether the package is cached.
Pathname pubkeyCachePath() const
Path where the pubkey caches.
Definition: ZConfig.cc:915
const ByteCount & downloadSize() const
The size of the resource on the server.
const repo::DownloadResolvableReport::Action & action() const
Users final decision how to proceed.
Policies and options for PackageProvider.
ManagedFile tryDelta(const DeltaRpm &delta_r) const
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:406
void progressDeltaApply(int value) const
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
Definition: Arch.h:344
What is known about a repository.
Definition: RepoInfo.h:71
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition: ManagedFile.h:27
Url url
Definition: MediaCurl.cc:199
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
virtual ManagedFile providePackage() const
Provide the package.
std::string basename() const
Return the last component of this path.
Definition: Pathname.h:127
ManagedFile providePackage() const
Provide the package.
TraitsType::constPtrType constPtr
Definition: ResObject.h:44
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:36
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
#define ERR
Definition: Logger.h:66
PackageProvider implementation for Package and SrcPackage.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:699
void rpmSigFileChecker(const Pathname &file_r) const
Repo manager settings.
Definition: RepoManager.h:53
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:708
Policy for provideFile and RepoMediaAccess.
Pathname repoManagerRoot() const
The RepoManager root directory.
Definition: ZConfig.cc:823
PackageProvider(RepoMediaAccess &access, const PoolItem &pi_r, const PackageProviderPolicy &policy_r=PackageProviderPolicy())
Ctor taking the package to provide.
bool empty() const
Test for an empty path.
Definition: Pathname.h:113
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
Definition: Exception.h:400
RW_pointer< Impl > _pimpl
Implementation class.
packagedelta::DeltaRpm DeltaRpm
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:642
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:210
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:403
int unlink(const Pathname &path)
Like &#39;unlink&#39;.
Definition: PathInfo.cc:653
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
Definition: UserData.h:118
PackageProviderImpl(RepoMediaAccess &access_r, const TPackagePtr &package_r, const PackageProviderPolicy &policy_r)
Ctor taking the Package to provide.
const OnMediaLocation & location() const
Definition: PackageDelta.h:68
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Definition: Exception.cc:91
Package interface.
Definition: Package.h:32
Pathname dirname() const
Return all but the last component od this path.
Definition: Pathname.h:123
PackageProviderImpl< TPackage > Base
Interim helper class to collect global options and settings.
Definition: ZConfig.h:59
#define WAR
Definition: Logger.h:65
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:444
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:273
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:119
ProvideFilePolicy & fileChecker(FileChecker fileChecker_r)
Add a FileCecker passed down to the Fetcher.
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:836
bool progressPackageDownload(int value) const
Redirect ProvideFilePolicy package download progress to this.
Report & report() const
Access to the DownloadResolvableReport.
RpmPackageProvider(RepoMediaAccess &access_r, const Package::constPtr &package_r, const DeltaCandidates &deltas_r, const PackageProviderPolicy &policy_r)
#define _(MSG)
Definition: Gettext.h:29
static RpmHeader::constPtr readPackage(const Pathname &path, VERIFICATION verification=VERIFY)
Get an accessible packages data from disk.
Definition: RpmHeader.cc:208
virtual bool isCached() const
Whether the package is cached.
Provides files from different repos.
std::string asUserString() const
Definition: SolvableType.h:88
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Definition: AutoDispose.h:158
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition: Exception.h:396
const Pathname & filename() const
The path to the resource relatve to the url and path.
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
SrcPackage interface.
Definition: SrcPackage.h:29
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Definition: PublicKey.h:272
Base class for Exception.
Definition: Exception.h:145
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:175
callback::SendReport< DownloadProgressReport > * report
Definition: MediaCurl.cc:203
virtual ManagedFile providePackageFromCache() const =0
Provide the package if it is cached.
Typesafe passing of user data via callbacks.
Definition: UserData.h:38
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:92
bool progressDeltaDownload(int value) const
RPM PackageProvider implementation (with deltarpm processing).
Pathname repoPackagesCachePath
Definition: RepoManager.h:82
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:648
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:220
bool haskey(const std::string &key_r) const
Whether key_r is in data.
Definition: UserData.h:97
CheckPackageResult
checkPackage result
Definition: RpmDb.h:429
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.
Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r)
downloads all configured gpg keys into the defined directory
Definition: RepoInfo.cc:504
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:101
bool isValid() const
Definition: PublicKey.h:308
void setRepoInfo(const RepoInfo &repoinfo)
Definition: KeyContext.h:16
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
PackageProvider::Impl * make(RepoMediaAccess &access_r, const PoolItem &pi_r, const DeltaCandidates &deltas_r, const PackageProviderPolicy &policy_r)
ManagedFile doProvidePackageFromCache() const
Lookup the final rpm in cache.
const std::string & sequenceinfo() const
Definition: PackageDelta.h:46
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:87
TraitsType::constPtrType constPtr
Definition: Package.h:38
#define DBG
Definition: Logger.h:63
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Definition: Edition.h:73
virtual ManagedFile providePackageFromCache() const
Provide the package if it is cached.
const Repository & repository() const
Definition: PackageDelta.h:70