71 const Arch & arch_r )
const 104 template <
class TPackage>
132 if ( ! ( ret->empty() ||
_package->repoInfo().keepPackages() ) )
175 policy.
progressCB( bind( &Base::progressPackageDownload,
this, _1 ) );
176 policy.
fileChecker( bind( &Base::rpmSigFileChecker,
this, _1 ) );
211 userData.
set(
"ResObject", roptr );
212 userData.
set(
"Package", roptr->asKind<
Package>() );
213 userData.
set(
"Localpath", file_r );
220 report()->pkgGpgCheck( userData );
231 WAR <<
"Unable to read package header from " << hr << endl;
235 std::string keyID = hr->signatureKeyID();
236 if ( keyID.length() > 0 ) {
256 ERR <<
"Key [" << keyID <<
"] from cache: " << cacheDir <<
" is not valid" << endl;
260 MIL <<
"Key [" << keyID <<
"] " << key.
name() <<
" loaded from cache" << endl;
264 if ( !
report->askUserToAcceptPackageKey( key, context ) ) {
268 MIL <<
"User wants to import key [" << keyID <<
"] " << key.
name() <<
" from cache" << endl;
269 KeyRing_Ptr theKeyRing = getZYpp()->keyRing();
271 theKeyRing->importKey( key,
true );
274 ERR <<
"Failed to import key: "<<keyID;
280 WAR <<
"packageSigCheck returned without setting providing missing key information" << endl;
288 if ( userData.
hasvalue(
"Action" ) )
292 else if ( userData.
haskey(
"Action" ) )
325 _target = getZYpp()->getTarget();
331 ret =
_target->rpmDb().checkPackageSignature( path_r, detail );
334 WAR <<
"Relax CHK_NOSIG: Config says unsigned packages are OK" << endl;
339 detail.push_back( RpmDb::CheckPackageDetail::value_type( ret,
"OOps. Target is not initialized!" ) );
341 userData.
set(
"CheckPackageResult", ret );
342 userData.
set(
"CheckPackageDetail", std::move(detail) );
354 WAR <<
_package->asUserString() <<
": " <<
"User requested to accept insecure file" << endl;
368 msg <<
_package->asUserString() <<
": " <<
_(
"Signature verification failed") <<
" " << ret;
369 if ( ! detail_r.empty() )
370 msg <<
"\n" << detail_r;
389 return shared_ptr<void>(
static_cast<void*
>(0),
390 bind( mem_fun_ref(
static_cast<void (shared_ptr<Report>::*)()
>(&shared_ptr<Report>::reset) ),
400 template <
class TPackage>
407 if ( ! ret->empty() )
409 MIL <<
"provided Package from cache " << _package <<
" at " << ret << endl;
410 report()->infoInCache( _package, ret );
415 RepoInfo info = _package->repoInfo();
423 if ( ! loc.checksum().empty() )
426 if ( pi.isExist() && loc.checksum() ==
CheckSum( loc.checksum().type(), std::ifstream( pi.c_str() ) ) )
428 report()->start( _package, pi.path().asFileUrl() );
436 MIL <<
"provided Package from toplevel cache " << _package <<
" at " << ret << endl;
449 MIL <<
"provide Package " << _package << endl;
454 if ( ! ret->empty() )
462 ret = doProvidePackage();
466 ERR <<
"Failed to provide Package " << _package << endl;
472 ERR <<
"Failed to provide Package " << _package << endl;
483 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
487 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
494 ERR <<
"Failed to provide Package " << _package << endl;
497 const std::string & package_str = _package->asUserString();
505 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
509 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
516 ERR <<
"Failed to provide Package " << _package << endl;
520 const std::string & package_str = _package->asUserString();
523 std::string detail_str(
str::form(
_(
"Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
532 ZYPP_THROW(SkipRequestException(
"User requested skip of file", excpt));
536 ZYPP_THROW(AbortRequestException(
"User requested to abort", excpt));
544 if ( ! ret->empty() )
550 MIL <<
"provided Package " << _package <<
" at " << ret << endl;
579 {
return report()->progressDeltaDownload( value ); }
582 {
return report()->progressDeltaApply( value ); }
599 std::list<DeltaRpm> deltaRpms;
604 for_( it, deltaRpms.begin(), deltaRpms.end())
606 DBG <<
"tryDelta " << *it << endl;
608 if ( ! ret->empty() )
641 report()->finishDeltaDownload();
643 report()->startDeltaApply( delta );
646 report()->problemDeltaApply(
_(
"applydeltarpm check failed.") );
652 Pathname builddest( cachedest.extend(
".drpm" ) );
657 report()->problemDeltaApply(
_(
"applydeltarpm failed.") );
661 report()->finishDeltaApply();
713 : _pimpl( factory::
make( access_r, pi_r, deltas_r, policy_r ) )
718 : _pimpl( factory::
make( access_r, pi_r, policy_r ) )
726 : _pimpl( factory::
make( access_r, package_r, deltas_r, policy_r ) )
PackageProvider implementation interface.
Candidate delta and patches for a package.
const BaseVersion & baseversion() const
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Pathname path() const
Repository path.
Interface to the rpm program.
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static ZConfig & instance()
Singleton ctor.
callback::SendReport< repo::DownloadResolvableReport > Report
void reset()
Reset to default Ctor values.
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verification error handling.
virtual ~PackageProviderImpl()
bool isCached() const
Whether the package is cached.
Pathname pubkeyCachePath() const
Path where the pubkey caches.
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.
void progressDeltaApply(int value) const
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
What is known about a repository.
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Edition represents [epoch:]version[-release]
virtual ManagedFile providePackage() const
Provide the package.
std::string basename() const
Return the last component of this path.
ManagedFile providePackage() const
Provide the package.
TraitsType::constPtrType constPtr
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
RpmDb::CheckPackageResult packageSigCheck(const Pathname &path_r, bool isMandatory_r, UserData &userData) const
Actual rpm package signature check.
RepoMediaAccess & _access
RpmSigCheckException(repo::DownloadResolvableReport::Action action_r, std::string msg_r="RpmSigCheckException")
std::list< packagedelta::DeltaRpm > deltaRpms(const Package::constPtr &package) const
PackageProvider implementation for Package and SrcPackage.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
TPackage::constPtr TPackagePtr
void rpmSigFileChecker(const Pathname &file_r) const
bool baseUrlsEmpty() const
whether repository urls are available
Policy for provideFile and RepoMediaAccess.
QueryInstalledCB _queryInstalledCB
Pathname repoManagerRoot() const
The RepoManager root directory.
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.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
RW_pointer< Impl > _pimpl
Implementation class.
packagedelta::DeltaRpm DeltaRpm
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
virtual bool isCached() const =0
Whether the package is cached.
shared_ptr< Report > _report
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
int unlink(const Pathname &path)
Like 'unlink'.
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
PackageProviderImpl(RepoMediaAccess &access_r, const TPackagePtr &package_r, const PackageProviderPolicy &policy_r)
Ctor taking the Package to provide.
const OnMediaLocation & location() const
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Pathname dirname() const
Return all but the last component od this path.
PackageProviderImpl< TPackage > Base
Interim helper class to collect global options and settings.
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.
const Edition & edition() const
RepoInfo info() const
Return any associated RepoInfo.
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.
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.
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)
callback::UserData UserData
ScopedGuard newReport() const
virtual bool isCached() const
Whether the package is cached.
std::string asUserString() const
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
shared_ptr< void > ScopedGuard
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
Base class for Exception.
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.
virtual ManagedFile providePackageFromCache() const =0
Provide the package if it is cached.
Typesafe passing of user data via callbacks.
PackageProviderPolicy _policy
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
bool progressDeltaDownload(int value) const
RPM PackageProvider implementation (with deltarpm processing).
Pathname repoPackagesCachePath
Pathname packagesPath() const
Path where this repo packages are cached.
Wrapper class for ::stat/::lstat.
bool haskey(const std::string &key_r) const
Whether key_r is in data.
CheckPackageResult
checkPackage result
repo::DownloadResolvableReport::Action _action
bool quickcheck(const std::string &sequenceinfo_r)
Quick via check sequence info.
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.
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
bool isKind(const ResKind &kind_r) const
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.
void setRepoInfo(const RepoInfo &repoinfo)
Easy-to use interface to the ZYPP dependency resolver.
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
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.
TraitsType::constPtrType constPtr
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
virtual ManagedFile providePackageFromCache() const
Provide the package if it is cached.
const Repository & repository() const