48 const Arch & arch_r )
const 70 , _package( package_r )
98 if ( ! ( ret->empty() || _package->repoInfo().keepPackages() ) )
105 {
return ! doProvidePackageFromCache()->empty(); }
121 virtual ManagedFile doProvidePackageFromCache()
const = 0;
149 {
return report()->progress( value, _package ); }
154 std::string package_str = _package->name() +
"-" + _package->edition().asString();
163 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
166 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
179 _target = getZYpp()->getTarget();
184 ret = _target->rpmDb().checkPackage( path_r, detail );
186 detail.push_back( RpmDb::CheckPackageDetail::value_type( ret,
"OOps. Target is not initialized!" ) );
188 userData.
set(
"CheckPackageResult", ret );
189 userData.
set(
"CheckPackageDetail", std::move(detail) );
203 WAR << _package->asUserString() <<
": " <<
"User requested skip of insecure file" << endl;
207 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
216 msg << _package->asUserString() <<
": " <<
_(
"Signature verification failed") <<
" " << ret;
217 if ( ! detail_r.empty() )
218 msg <<
"\n" << detail_r;
233 _report.reset(
new Report );
237 return shared_ptr<void>(
static_cast<void*
>(0),
238 bind( mem_fun_ref(
static_cast<void (shared_ptr<Report>::*)()
>(&shared_ptr<Report>::reset) ),
259 policy.
progressCB( bind( &Base::progressPackageDownload,
this, _1 ) );
261 return _access.provideFile( _package->repoInfo(), loc, policy );
272 if ( ! ret->empty() )
274 MIL <<
"provided Package from cache " << _package <<
" at " << ret << endl;
275 report()->infoInCache( _package, ret );
280 RepoInfo info = _package->repoInfo();
288 if ( ! loc.checksum().empty() )
291 if ( pi.isExist() && loc.checksum() ==
CheckSum( loc.checksum().type(), std::ifstream( pi.c_str() ) ) )
293 report()->start( _package, pi.path().asFileUrl() );
294 const Pathname & dest( info.
packagesPath() / loc.filename() );
301 MIL <<
"provided Package from toplevel cache " << _package <<
" at " << ret << endl;
314 MIL <<
"provide Package " << _package << endl;
318 if ( ! ret->empty() )
323 report()->start( _package, url );
326 ret = doProvidePackage();
330 UserData userData(
"pkgGpgCheck" );
331 userData.
set(
"Package", _package );
332 userData.
set(
"Localpath", ret.
value() );
335 report()->pkgGpgCheck( userData );
337 if ( res != RpmDb::CHK_OK )
339 if ( userData.
hasvalue(
"Action" ) )
343 else if ( userData.
haskey(
"Action" ) )
345 defaultReportSignatureError( res );
354 case RpmDb::CHK_NOKEY:
355 case RpmDb::CHK_NOTFOUND:
356 case RpmDb::CHK_FAIL:
357 case RpmDb::CHK_NOTTRUSTED:
358 case RpmDb::CHK_ERROR:
371 ERR <<
"Failed to provide Package " << _package << endl;
379 ERR <<
"Failed to provide Package " << _package << endl;
383 std::string package_str = _package->name() +
"-" + _package->edition().asString();
386 std::string detail_str(
str::form(
_(
"Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
395 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file", excpt));
398 ZYPP_THROW(AbortRequestException(
"User requested to abort", excpt));
409 MIL <<
"provided Package " << _package <<
" at " << ret << endl;
429 virtual ManagedFile doProvidePackageFromCache()
const;
436 ManagedFile tryDelta(
const DeltaRpm & delta_r )
const;
439 {
return report()->progressDeltaDownload( value ); }
442 {
return report()->progressDeltaApply( value ); }
445 {
return _policy.queryInstalled( _package->name(), ed_r, _package->arch() ); }
457 RepoInfo info = _package->repoInfo();
468 std::list<DeltaRpm> deltaRpms;
469 _deltas.deltaRpms( _package ).swap( deltaRpms );
473 for_( it, deltaRpms.begin(), deltaRpms.end())
475 DBG <<
"tryDelta " << *it << endl;
477 if ( ! ret->empty() )
484 return Base::doProvidePackage();
510 report()->finishDeltaDownload();
512 report()->startDeltaApply( delta );
515 report()->problemDeltaApply(
_(
"applydeltarpm check failed.") );
520 Pathname destination( _package->repoInfo().packagesPath() / _package->location().filename() );
525 report()->problemDeltaApply(
_(
"applydeltarpm failed.") );
528 report()->finishDeltaApply();
544 PluginPackageProvider(
const std::string & stem_r,
549 : Base( access_r, package_r, deltas_r, policy_r )
553 virtual ManagedFile doProvidePackageFromCache()
const 555 return Base::doProvidePackageFromCache();
560 return Base::doProvidePackage();
582 : _pimpl(
Impl::factoryMake( access_r, package_r, deltas_r, policy_r ) )
Candidate delta and patches for a package.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
RepoInfo info() const
Return any associated RepoInfo.
Interface to the rpm program.
bool failOnChecksumError() const
Redirect ProvideFilePolicy failOnChecksumError to this if needed.
virtual ManagedFile doProvidePackageFromCache() const
Lookup the final rpm in cache.
RpmDb::CheckPackageResult packageSigCheck(const Pathname &path_r, UserData &userData) const
const Repository & repository() const
PackageProvider implementation.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
bool hasvalue(const std::string &key_r) const
Whether key_r is in data and value is not empty.
static ZConfig & instance()
Singleton ctor.
const BaseVersion & baseversion() const
ManagedFile providePackage() const
Provide the package.
bool isCached() const
Whether the package is cached.
Helper filtering the files offered by a RepomdFileReader.
ManagedFile tryDelta(const DeltaRpm &delta_r) const
void reset()
Reset to default Ctor values.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
callback::SendReport< repo::DownloadResolvableReport > Report
bool isCached() const
Whether the package is cached.
Policies and options for PackageProvider.
bool haveApplydeltarpm()
Test whether an execuatble applydeltarpm program is available.
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
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]
void progressDeltaApply(int value) const
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Report & report() const
Access to the DownloadResolvableReport.
Pathname packagesPath() const
Path where this repo packages are cached.
bool queryInstalled(const Edition &ed_r=Edition()) const
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
QueryInstalledCB _queryInstalledCB
shared_ptr< Report > _report
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
RW_pointer< Impl > _pimpl
Implementation class.
PackageProvider(RepoMediaAccess &access, const Package::constPtr &package, const DeltaCandidates &deltas, const PackageProviderPolicy &policy_r=PackageProviderPolicy())
Ctor taking the Package to provide.
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
packagedelta::DeltaRpm DeltaRpm
shared_ptr< void > ScopedGuard
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
int unlink(const Pathname &path)
Like 'unlink'.
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
Detailed rpm signature check log messages A single multiline message if CHK_OK.
callback::UserData UserData
const Edition & edition() const
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.
RpmPackageProvider(RepoMediaAccess &access_r, const Package::constPtr &package_r, const DeltaCandidates &deltas_r, const PackageProviderPolicy &policy_r)
reference value() const
Reference to the Tp object.
const OnMediaLocation & location() const
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
RepoMediaAccess & _access
ScopedGuard newReport() const
bool baseUrlsEmpty() const
whether repository urls are available
ProvideFilePolicy & failOnChecksumErrorCB(FailOnChecksumErrorCB failOnChecksumErrorCB_r)
Set callback.
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
PackageProvider::Impl Base
virtual ManagedFile doProvidePackage() const =0
Actually provide the final rpm.
const std::string & sequenceinfo() const
Base class for Exception.
ProvideFilePolicy & progressCB(ProgressCB progressCB_r)
Set callback.
PackageProviderPolicy _policy
Provide a package from a Repo.
Impl(RepoMediaAccess &access_r, const Package::constPtr &package_r, const DeltaCandidates &deltas_r, const PackageProviderPolicy &policy_r)
Ctor taking the Package to provide.
ManagedFile providePackage() const
Provide the package.
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verrification error handling.
Typesafe passing of user data via callbacks.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
shared_ptr< MediaSetAccess > _access
RPM PackageProvider implementation.
Pathname repoPackagesCachePath
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
CheckPackageResult
checkPackage result
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.
bool queryInstalled(const std::string &name_r, const Edition &ed_r, const Arch &arch_r) const
Evaluate callback.
bool haskey(const std::string &key_r) const
Whether key_r is in data.
bool progressDeltaDownload(int value) const
Base for exceptions caused by explicit user request.
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
Easy-to use interface to the ZYPP dependency resolver.
void resolveSignatureErrorAction(repo::DownloadResolvableReport::Action action_r) const
React on signature verrification error user action.
Package::constPtr _package
virtual ManagedFile doProvidePackageFromCache() const =0
Lookup the final rpm in cache.
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
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
static Impl * factoryMake(RepoMediaAccess &access_r, const Package::constPtr &package_r, const DeltaCandidates &deltas_r, const PackageProviderPolicy &policy_r)
Factory method providing the appropriate implementation.