20#include <zypp-core/base/UserRequestException>
74 const Arch & arch_r )
const
111 template <
class TPackage>
144 if ( ! ( ret->
empty() ||
_package->repoInfo().effectiveKeepPackages() ) )
187 policy.
progressCB( bind( &Base::progressPackageDownload,
this, _1 ) );
188 policy.
fileChecker( bind( &Base::rpmSigFileChecker,
this, _1 ) );
223 userData.
set(
"ResObject", roptr );
224 userData.
set(
"Package", roptr->asKind<
Package>() );
225 userData.
set(
"Localpath", file_r );
232 report()->pkgGpgCheck( userData );
243 WAR <<
"Unable to read package header from " << hr << endl;
247 std::string keyID = hr->signatureKeyID();
248 if ( keyID.length() > 0 ) {
255 WAR <<
"packageSigCheck returned without setting providing missing key information" << endl;
263 if ( userData.
hasvalue(
"Action" ) )
267 else if ( userData.
haskey(
"Action" ) )
306 ret =
_target->rpmDb().checkPackageSignature( path_r,
detail );
309 WAR <<
"Relax CHK_NOSIG: Config says unsigned packages are OK" << endl;
314 detail.push_back( RpmDb::CheckPackageDetail::value_type( ret,
"OOps. Target is not initialized!" ) );
316 userData.
set(
"CheckPackageResult", ret );
317 userData.
set(
"CheckPackageDetail", std::move(
detail) );
329 WAR <<
_package->asUserString() <<
": " <<
"User requested to accept insecure file" << endl;
343 msg <<
_package->asUserString() <<
": " <<
_(
"Signature verification failed") <<
" " << ret;
344 if ( ! detail_r.empty() )
345 msg <<
"\n" << detail_r;
375 template <
class TPackage>
382 if ( ! ret->
empty() )
384 MIL <<
"provided Package from cache " <<
_package <<
" at " << ret << endl;
411 MIL <<
"provided Package from toplevel cache " <<
_package <<
" at " << ret << endl;
428 if ( ! ret->
empty() )
440 ERR <<
"Failed to provide Package " <<
_package << endl;
446 ERR <<
"Failed to provide Package " <<
_package << endl;
451 switch ( excpt.action() )
457 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
461 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
468 ERR <<
"Failed to provide Package " <<
_package << endl;
471 const std::string & package_str =
_package->asUserString();
479 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
483 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
490 ERR <<
"Failed to provide Package " <<
_package << endl;
494 const std::string & package_str =
_package->asUserString();
497 std::string detail_str(
str::form(
_(
"Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
506 ZYPP_THROW(SkipRequestException(
"User requested skip of file", excpt));
510 ZYPP_THROW(AbortRequestException(
"User requested to abort", excpt));
518 if ( ! ret->
empty() )
524 MIL <<
"provided Package " <<
_package <<
" at " << ret << endl;
553 {
return report()->progressDeltaDownload( value ); }
556 {
return report()->progressDeltaApply( value ); }
573 std::list<DeltaRpm> deltaRpms;
578 for_( it, deltaRpms.begin(), deltaRpms.end())
580 DBG <<
"tryDelta " << *it << endl;
582 if ( ! ret->
empty() )
612 if ( not
PathInfo(delta).isExist() ) {
614 report()->problemDeltaApply(
_(
"download deltarpm: not found") );
623 report()->finishDeltaDownload();
625 report()->startDeltaApply( delta );
628 report()->problemDeltaApply(
_(
"applydeltarpm check failed.") );
639 report()->problemDeltaApply(
_(
"applydeltarpm failed.") );
643 report()->finishDeltaApply();
688 {
return new RpmPackageProvider( access_r, std::move(package_r), std::move(deltas_r), std::move(policy_r) ); }
716 {
return _pimpl->providePackage(); }
719 {
return _pimpl->providePackageFromCache(); }
722 {
return _pimpl->isCached(); }
void resetDispose()
Set no dispose function.
void reset()
Reset to default Ctor values.
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Edition represents [epoch:]version[-release]
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Base class for Exception.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
FileCheckException(std::string msg)
TraitsType::constPtrType constPtr
Combining sat::Solvable and ResStatus.
Policy for provideFile and RepoMediaAccess.
ProvideFilePolicy & fileChecker(FileChecker fileChecker_r)
Add a FileCecker passed down to the Fetcher.
ProvideFilePolicy & progressCB(ProgressCB progressCB_r)
Set callback.
What is known about a repository.
Url location() const
Returns the location URL for the repository, this is either the first configured baseUrl or a configu...
bool effectiveKeepPackages() const
keepPackages unless the package cache itself enforces keeping the packages.
Pathname path() const
Repository path.
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
Pathname packagesPath() const
Path where this repo packages are cached.
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
bool repoOriginsEmpty() const
whether repo origins are available
RepoInfo info() const
Return any associated RepoInfo.
TraitsType::constPtrType constPtr
Base for exceptions caused by explicit user request.
static ZConfig & instance()
Singleton ctor.
ZYpp::Ptr getZYpp()
Convenience to get the Pointer to the ZYpp instance.
Typesafe passing of user data via callbacks.
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
bool hasvalue(const std::string &key_r) const
Whether key_r is in data and value is not empty.
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
bool haskey(const std::string &key_r) const
Whether key_r is in data.
Wrapper class for stat/lstat.
const Pathname & path() const
Return current Pathname.
bool isExist() const
Return whether valid stat info exists.
const char * c_str() const
Return current Pathname as C-string.
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
Pathname dirname() const
Return all but the last component od this path.
std::string basename() const
Return the last component of this path.
bool empty() const
Test for an empty path.
const Edition & edition() const
const std::string & sequenceinfo() const
const OnMediaLocation & location() const
const Repository & repository() const
const BaseVersion & baseversion() const
Candidate delta and patches for a package.
PackageProviderImpl(const PackageProviderImpl &)=delete
ManagedFile doProvidePackageFromCache() const
Lookup the final rpm in cache.
PackageProviderImpl(RepoMediaAccess &access_r, TPackagePtr &&package_r, PackageProviderPolicy &&policy_r)
Ctor taking the Package to provide.
void rpmSigFileChecker(const Pathname &file_r) const
PackageProviderPolicy _policy
shared_ptr< Report > _report
bool isCached() const override
Whether the package is cached.
PackageProviderImpl(PackageProviderImpl &&)=delete
PackageProviderImpl & operator=(PackageProviderImpl &&)=delete
typename TPackage::constPtr TPackagePtr
PackageProviderImpl< TPackage > Base
callback::SendReport< repo::DownloadResolvableReport > Report
~PackageProviderImpl() override
bool progressPackageDownload(int value) const
Redirect ProvideFilePolicy package download progress to this.
ManagedFile providePackage() const override
Provide the package.
ManagedFile providePackageFromCache() const override
Provide the package if it is cached.
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verification error handling.
shared_ptr< void > ScopedGuard
RepoMediaAccess & _access
RpmDb::CheckPackageResult packageSigCheck(const Pathname &path_r, bool isMandatory_r, UserData &userData) const
Actual rpm package signature check.
callback::UserData UserData
ScopedGuard newReport() const
void resolveSignatureErrorAction(repo::DownloadResolvableReport::Action action_r) const
React on signature verification error user action.
Report & report() const
Access to the DownloadResolvableReport.
PackageProviderImpl & operator=(const PackageProviderImpl &)=delete
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
Policies and options for PackageProvider.
bool queryInstalled(const std::string &name_r, const Edition &ed_r, const Arch &arch_r) const
Evaluate callback.
QueryInstalledCB _queryInstalledCB
RW_pointer< Impl > _pimpl
Implementation class.
PackageProvider(RepoMediaAccess &access, const PoolItem &pi_r, PackageProviderPolicy policy_r=PackageProviderPolicy())
Ctor taking the package to provide.
ManagedFile providePackage() const
Provide the package.
bool isCached() const
Whether the package is cached.
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
RPM PackageProvider implementation (with deltarpm processing).
packagedelta::DeltaRpm DeltaRpm
ManagedFile tryDelta(const DeltaRpm &delta_r) const
void progressDeltaApply(int value) const
bool progressDeltaDownload(int value) const
RpmPackageProvider(RepoMediaAccess &access_r, Package::constPtr &&package_r, DeltaCandidates &&deltas_r, PackageProviderPolicy &&policy_r)
bool queryInstalled(const Edition &ed_r=Edition()) const
ManagedFile doProvidePackage() const override
Actually provide the final rpm.
Exception thrown by PackageProviderImpl::rpmSigFileChecker.
repo::DownloadResolvableReport::Action _action
RpmSigCheckException(repo::DownloadResolvableReport::Action action_r, std::string msg_r="RpmSigCheckException")
const repo::DownloadResolvableReport::Action & action() const
Users final decision how to proceed.
Interface to the rpm program.
CheckPackageResult
checkPackage result
static SyncContextRef defaultContext()
bool haveApplydeltarpm()
Test whether an execuatble applydeltarpm program is available.
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.
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.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
int unlink(const Pathname &path)
Like 'unlink'.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
PackageProvider::Impl * make(RepoMediaAccess &access_r, const PoolItem &pi_r, DeltaCandidates &&deltas_r, PackageProviderPolicy &&policy_r)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
ResTraits< TRes >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
bool provideAndImportKeyFromRepository(SyncContextRef ctx, std::string id_r, zypp::RepoInfo info_r)
Try to find the id in key cache or repository specified in info.
Pathname repoPackagesCachePath
PackageProvider implementation interface.
virtual bool isCached() const =0
Whether the package is cached.
virtual ManagedFile providePackageFromCache() const =0
Provide the package if it is cached.
virtual ManagedFile providePackage() const =0
Provide the package.
Impl(const Impl &)=delete
Impl & operator=(Impl &&)=delete
Impl & operator=(const Impl &)=delete
std::string asUserString() const
bool isKind(const SolvableType< Derived > &solvable_r)
Test whether the Solvable is of a certain ResKind.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Detailed rpm signature check log messages A single multiline message if CHK_OK.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.