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;
146 {
return report()->progress( value, _package ); }
153 _target = getZYpp()->getTarget();
158 ret = _target->rpmDb().checkPackage( path_r, detail );
160 detail.push_back( RpmDb::CheckPackageDetail::value_type( ret,
"OOps. Target is not initialized!" ) );
162 userData.
set(
"CheckPackageResult", ret );
163 userData.
set(
"CheckPackageDetail", std::move(detail) );
178 WAR << _package->asUserString() <<
": " <<
"User requested to accept insecure file" << endl;
182 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
191 msg << _package->asUserString() <<
": " <<
_(
"Signature verification failed") <<
" " << ret;
192 if ( ! detail_r.empty() )
193 msg <<
"\n" << detail_r;
208 _report.reset(
new Report );
212 return shared_ptr<void>(
static_cast<void*
>(0),
213 bind( mem_fun_ref(
static_cast<void (shared_ptr<Report>::*)()
>(&shared_ptr<Report>::reset) ),
234 policy.
progressCB( bind( &Base::progressPackageDownload,
this, _1 ) );
235 return _access.provideFile( _package->repoInfo(), loc, policy );
246 if ( ! ret->empty() )
248 MIL <<
"provided Package from cache " << _package <<
" at " << ret << endl;
249 report()->infoInCache( _package, ret );
254 RepoInfo info = _package->repoInfo();
262 if ( ! loc.checksum().empty() )
265 if ( pi.isExist() && loc.checksum() ==
CheckSum( loc.checksum().type(), std::ifstream( pi.c_str() ) ) )
267 report()->start( _package, pi.path().asFileUrl() );
275 MIL <<
"provided Package from toplevel cache " << _package <<
" at " << ret << endl;
288 MIL <<
"provide Package " << _package << endl;
292 if ( ! ret->empty() )
297 report()->start( _package, url );
300 ret = doProvidePackage();
304 UserData userData(
"pkgGpgCheck" );
305 userData.
set(
"Package", _package );
306 userData.
set(
"Localpath", ret.
value() );
309 report()->pkgGpgCheck( userData );
310 USR <<
"CHK: " << res << endl;
311 if ( res != RpmDb::CHK_OK )
313 if ( userData.
hasvalue(
"Action" ) )
317 else if ( userData.
haskey(
"Action" ) )
319 defaultReportSignatureError( res );
328 case RpmDb::CHK_NOKEY:
329 case RpmDb::CHK_NOTFOUND:
330 case RpmDb::CHK_FAIL:
331 case RpmDb::CHK_NOTTRUSTED:
332 case RpmDb::CHK_ERROR:
344 ERR <<
"Failed to provide Package " << _package << endl;
350 ERR <<
"Failed to provide Package " << _package << endl;
353 const std::string & package_str = _package->asUserString();
361 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
364 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
373 ERR <<
"Failed to provide Package " << _package << endl;
377 const std::string & package_str = _package->asUserString();
380 std::string detail_str(
str::form(
_(
"Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
389 ZYPP_THROW(SkipRequestException(
"User requested skip of file", excpt));
392 ZYPP_THROW(AbortRequestException(
"User requested to abort", excpt));
403 MIL <<
"provided Package " << _package <<
" at " << ret << endl;
423 virtual ManagedFile doProvidePackageFromCache()
const;
430 ManagedFile tryDelta(
const DeltaRpm & delta_r )
const;
433 {
return report()->progressDeltaDownload( value ); }
436 {
return report()->progressDeltaApply( value ); }
439 {
return _policy.queryInstalled( _package->name(), ed_r, _package->arch() ); }
451 RepoInfo info = _package->repoInfo();
462 std::list<DeltaRpm> deltaRpms;
463 _deltas.deltaRpms( _package ).swap( deltaRpms );
467 for_( it, deltaRpms.begin(), deltaRpms.end())
469 DBG <<
"tryDelta " << *it << endl;
471 if ( ! ret->empty() )
478 return Base::doProvidePackage();
504 report()->finishDeltaDownload();
506 report()->startDeltaApply( delta );
509 report()->problemDeltaApply(
_(
"applydeltarpm check failed.") );
514 Pathname destination( _package->repoInfo().packagesPath() / _package->location().filename() );
519 report()->problemDeltaApply(
_(
"applydeltarpm failed.") );
522 report()->finishDeltaApply();
538 PluginPackageProvider(
const std::string & stem_r,
543 : Base( access_r, package_r, deltas_r, policy_r )
547 virtual ManagedFile doProvidePackageFromCache()
const 549 return Base::doProvidePackageFromCache();
554 return Base::doProvidePackage();
576 : _pimpl(
Impl::factoryMake( access_r, package_r, deltas_r, policy_r ) )
Candidate delta and patches for a package.
const BaseVersion & baseversion() const
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Interface to the rpm program.
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verification error handling.
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
PackageProvider implementation.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
static ZConfig & instance()
Singleton ctor.
ManagedFile providePackage() const
Provide the package.
virtual ManagedFile doProvidePackageFromCache() const
Lookup the final rpm in cache.
Helper filtering the files offered by a RepomdFileReader.
void reset()
Reset to default Ctor values.
Report & report() const
Access to the DownloadResolvableReport.
bool isCached() const
Whether the package is cached.
callback::SendReport< repo::DownloadResolvableReport > Report
Policies and options for PackageProvider.
bool isCached() const
Whether the package is cached.
ManagedFile tryDelta(const DeltaRpm &delta_r) const
bool haveApplydeltarpm()
Test whether an execuatble applydeltarpm program is available.
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]
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.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
bool baseUrlsEmpty() const
whether repository urls are available
QueryInstalledCB _queryInstalledCB
shared_ptr< Report > _report
ManagedFile providePackageFromCache() const
Provide the package if it is cached.
#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.
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...
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).
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.
Detailed rpm signature check log messages A single multiline message if CHK_OK.
const Edition & edition() const
RepoInfo info() const
Return any associated RepoInfo.
callback::UserData UserData
bool queryInstalled(const Edition &ed_r=Edition()) const
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
RpmDb::CheckPackageResult packageSigCheck(const Pathname &path_r, UserData &userData) const
RpmPackageProvider(RepoMediaAccess &access_r, const Package::constPtr &package_r, const DeltaCandidates &deltas_r, const PackageProviderPolicy &policy_r)
void resolveSignatureErrorAction(repo::DownloadResolvableReport::Action action_r) const
React on signature verification error user action.
RepoMediaAccess & _access
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
ScopedGuard newReport() const
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
PackageProvider::Impl Base
virtual ManagedFile doProvidePackageFromCache() const =0
Lookup the final rpm in cache.
Base class for Exception.
ProvideFilePolicy & progressCB(ProgressCB progressCB_r)
Set callback.
PackageProviderPolicy _policy
Provide a package from a Repo.
reference value() const
Reference to the Tp object.
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
Impl(RepoMediaAccess &access_r, const Package::constPtr &package_r, const DeltaCandidates &deltas_r, const PackageProviderPolicy &policy_r)
Ctor taking the Package to provide.
Typesafe passing of user data via callbacks.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
bool progressDeltaDownload(int value) const
shared_ptr< MediaSetAccess > _access
RPM PackageProvider implementation.
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
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 =0
Actually provide the final rpm.
bool queryInstalled(const std::string &name_r, const Edition &ed_r, const Arch &arch_r) const
Evaluate callback.
bool progressPackageDownload(int value) const
Redirect ProvideFilePolicy package download progress to this.
Base for exceptions caused by explicit user request.
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
bool hasvalue(const std::string &key_r) const
Whether key_r is in data and value is not empty.
Easy-to use interface to the ZYPP dependency resolver.
Package::constPtr _package
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.
const Repository & repository() const
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.