19 #include <zypp-core/base/UserRequestException> 75 const Arch & arch_r )
const 112 template <
class TPackage>
145 if ( ! ( ret->
empty() ||
_package->repoInfo().effectiveKeepPackages() ) )
188 policy.
progressCB( bind( &Base::progressPackageDownload,
this, _1 ) );
189 policy.
fileChecker( bind( &Base::rpmSigFileChecker,
this, _1 ) );
224 userData.
set(
"ResObject", roptr );
225 userData.
set(
"Package", roptr->asKind<
Package>() );
226 userData.
set(
"Localpath", file_r );
233 report()->pkgGpgCheck( userData );
244 WAR <<
"Unable to read package header from " << hr << endl;
248 std::string keyID = hr->signatureKeyID();
249 if ( keyID.length() > 0 ) {
256 WAR <<
"packageSigCheck returned without setting providing missing key information" << endl;
264 if ( userData.
hasvalue(
"Action" ) )
268 else if ( userData.
haskey(
"Action" ) )
307 ret =
_target->rpmDb().checkPackageSignature( path_r, detail );
310 WAR <<
"Relax CHK_NOSIG: Config says unsigned packages are OK" << endl;
315 detail.push_back( RpmDb::CheckPackageDetail::value_type( ret,
"OOps. Target is not initialized!" ) );
317 userData.
set(
"CheckPackageResult", ret );
318 userData.
set(
"CheckPackageDetail", std::move(detail) );
330 WAR <<
_package->asUserString() <<
": " <<
"User requested to accept insecure file" << endl;
344 msg <<
_package->asUserString() <<
": " <<
_(
"Signature verification failed") <<
" " << ret;
345 if ( ! detail_r.empty() )
346 msg <<
"\n" << detail_r;
365 return shared_ptr<void>(
static_cast<void*
>(0),
366 std::bind( std::mem_fn(
static_cast<void (shared_ptr<Report>::*)()
>(&shared_ptr<Report>::reset)),
376 template <
class TPackage>
383 if ( ! ret->
empty() )
385 MIL <<
"provided Package from cache " << _package <<
" at " << ret << endl;
386 report()->infoInCache( _package, ret );
391 RepoInfo info = _package->repoInfo();
399 if ( ! loc.checksum().empty() )
402 if ( pi.isExist() && loc.checksum() ==
CheckSum( loc.checksum().type(), std::ifstream( pi.c_str() ) ) )
404 report()->start( _package, pi.path().asFileUrl() );
412 MIL <<
"provided Package from toplevel cache " << _package <<
" at " << ret << endl;
424 MIL <<
"provide Package " << _package << endl;
429 if ( ! ret->
empty() )
434 report()->start( _package, url );
437 ret = doProvidePackage();
441 ERR <<
"Failed to provide Package " << _package << endl;
447 ERR <<
"Failed to provide Package " << _package << endl;
458 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
462 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
469 ERR <<
"Failed to provide Package " << _package << endl;
472 const std::string & package_str = _package->asUserString();
480 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
484 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
491 ERR <<
"Failed to provide Package " << _package << endl;
495 const std::string & package_str = _package->asUserString();
498 std::string detail_str(
str::form(
_(
"Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
507 ZYPP_THROW(SkipRequestException(
"User requested skip of file", excpt));
511 ZYPP_THROW(AbortRequestException(
"User requested to abort", excpt));
519 if ( ! ret->
empty() )
525 MIL <<
"provided Package " << _package <<
" at " << ret << endl;
554 {
return report()->progressDeltaDownload( value ); }
557 {
return report()->progressDeltaApply( value ); }
574 std::list<DeltaRpm> deltaRpms;
579 for_( it, deltaRpms.begin(), deltaRpms.end())
581 DBG <<
"tryDelta " << *it << endl;
583 if ( ! ret->
empty() )
615 report()->problemDeltaApply(
_(
"download deltarpm: not found") );
624 report()->finishDeltaDownload();
626 report()->startDeltaApply( delta );
629 report()->problemDeltaApply(
_(
"applydeltarpm check failed.") );
635 Pathname builddest( cachedest.extend(
".drpm" ) );
640 report()->problemDeltaApply(
_(
"applydeltarpm failed.") );
644 report()->finishDeltaApply();
689 {
return new RpmPackageProvider( access_r, std::move(package_r), std::move(deltas_r), std::move(policy_r) ); }
697 : _pimpl( factory::
make( access_r, pi_r,
std::move(deltas_r),
std::move(policy_r) ) )
702 : _pimpl( factory::
make( access_r, pi_r,
std::move(policy_r) ) )
710 : _pimpl( factory::
make( access_r,
std::move(package_r),
std::move(deltas_r),
std::move(policy_r) ) )
PackageProvider implementation interface.
Candidate delta and patches for a package.
const BaseVersion & baseversion() const
Pathname path() const
Repository path.
Interface to the rpm program.
TraitsType::constPtrType constPtr
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
shared_ptr< void > ScopedGuard
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
RpmPackageProvider(RepoMediaAccess &access_r, Package::constPtr &&package_r, DeltaCandidates &&deltas_r, PackageProviderPolicy &&policy_r)
Impl & operator=(const Impl &)=delete
MaybeAwaitable< bool > provideAndImportKeyFromRepository(ContextRef ctx, std::string id_r, zypp::RepoInfo info_r)
Try to find the id in key cache or repository specified in info.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static ZConfig & instance()
Singleton ctor.
~PackageProviderImpl() override
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.
ManagedFile providePackageFromCache() const override
Provide the package if it is cached.
typename Package ::constPtr TPackagePtr
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
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.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Edition represents [epoch:]version[-release]
std::string basename() const
Return the last component of this path.
ManagedFile providePackage() const
Provide the package.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
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.
RepoMediaAccess & _access
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.
PackageProvider implementation for Package and SrcPackage.
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
void rpmSigFileChecker(const Pathname &file_r) const
Policy for provideFile and RepoMediaAccess.
QueryInstalledCB _queryInstalledCB
bool empty() const
Test for an empty path.
zypp::callback::UserData UserData
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
RW_pointer< Impl > _pimpl
Implementation class.
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.
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
bool isExist() const
Return whether valid stat info exists.
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.
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
bool repoOriginsEmpty() const
whether repo origins are available
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.
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
static ContextRef defaultContext()
int unlink(const Pathname &path)
Like 'unlink'.
ScopedGuard newReport() const
void resetDispose()
Set no dispose function.
std::string asUserString() const
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
ZYpp::Ptr getZYpp()
relates: ZYppFactory Convenience to get the Pointer to the ZYpp instance.
ManagedFile doProvidePackage() const override
Actually provide the final rpm.
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.
Url location() const
Returns the location URL for the repository, this is either the first configured baseUrl or a configu...
virtual ManagedFile providePackageFromCache() const =0
Provide the package if it is cached.
Typesafe passing of user data via callbacks.
PackageProviderPolicy _policy
bool progressDeltaDownload(int value) const
RPM PackageProvider implementation (with deltarpm processing).
Pathname repoPackagesCachePath
Pathname packagesPath() const
packagesPath Checks if the effective user is allowed to write into the system package cache...
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.
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.
PackageProviderImpl & operator=(const PackageProviderImpl &)=delete
Easy-to use interface to the ZYPP dependency resolver.
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
bool effectiveKeepPackages() const
keepPackages unless the package cache itself enforces keeping the packages.
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.
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
const Repository & repository() const
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
PackageProvider(RepoMediaAccess &access, const PoolItem &pi_r, PackageProviderPolicy policy_r=PackageProviderPolicy())
Ctor taking the package to provide.