44 static const char * envp = getenv(
"YAST_IS_RUNNING" );
56 bool PackageProviderPolicy::queryInstalled(
const std::string & name_r,
58 const Arch & arch_r )
const 60 if ( _queryInstalledCB )
61 return _queryInstalledCB( name_r, ed_r, arch_r );
81 virtual ManagedFile providePackageFromCache()
const = 0;
84 virtual bool isCached()
const = 0;
91 template <
class TPackage>
100 : _policy( policy_r )
101 , _package( package_r )
119 if ( ! ( ret->empty() || _package->repoInfo().keepPackages() ) )
126 {
return ! doProvidePackageFromCache()->empty(); }
140 {
return ManagedFile( _package->cachedLocation() ); }
162 policy.
progressCB( bind( &Base::progressPackageDownload,
this, _1 ) );
163 return _access.provideFile( _package->repoInfo(), loc, policy );
173 {
return report()->progress( value, _package ); }
180 _target = getZYpp()->getTarget();
185 ret = _target->rpmDb().checkPackage( path_r, detail );
187 detail.push_back( RpmDb::CheckPackageDetail::value_type( ret,
"OOps. Target is not initialized!" ) );
189 userData.
set(
"CheckPackageResult", ret );
190 userData.
set(
"CheckPackageDetail", std::move(detail) );
205 WAR << _package->asUserString() <<
": " <<
"User requested to accept insecure file" << endl;
209 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
218 msg << _package->asUserString() <<
": " <<
_(
"Signature verification failed") <<
" " << ret;
219 if ( ! detail_r.empty() )
220 msg <<
"\n" << detail_r;
234 _report.reset(
new Report );
238 return shared_ptr<void>(
static_cast<void*
>(0),
239 bind( mem_fun_ref(
static_cast<void (shared_ptr<Report>::*)()
>(&shared_ptr<Report>::reset) ),
249 template <
class TPackage>
256 if ( ! ret->empty() )
258 MIL <<
"provided Package from cache " << _package <<
" at " << ret << endl;
259 report()->infoInCache( _package, ret );
264 RepoInfo info = _package->repoInfo();
272 if ( ! loc.checksum().empty() )
275 if ( pi.isExist() && loc.checksum() ==
CheckSum( loc.checksum().type(), std::ifstream( pi.c_str() ) ) )
277 report()->start( _package, pi.path().asFileUrl() );
278 const Pathname & dest( info.
packagesPath() / loc.filename() );
285 MIL <<
"provided Package from toplevel cache " << _package <<
" at " << ret << endl;
298 MIL <<
"provide Package " << _package << endl;
302 if ( ! ret->empty() )
307 report()->start( _package, url );
310 ret = doProvidePackage();
313 #warning bsc1037210 disabled SrcPackage signature check if YAST_IS_RUNNING - waiting for yast to be fixed 316 UserData userData(
"pkgGpgCheck" );
318 userData.
set(
"ResObject", roptr );
319 userData.
set(
"Package", roptr->asKind<
Package>() );
320 userData.
set(
"Localpath", ret.
value() );
323 report()->pkgGpgCheck( userData );
324 DBG <<
"CHK: " << res << endl;
326 if ( res != RpmDb::CHK_OK )
328 if ( userData.
hasvalue(
"Action" ) )
332 else if ( userData.
haskey(
"Action" ) )
334 defaultReportSignatureError( res );
343 case RpmDb::CHK_NOKEY:
344 case RpmDb::CHK_NOTFOUND:
345 case RpmDb::CHK_FAIL:
346 case RpmDb::CHK_NOTTRUSTED:
347 case RpmDb::CHK_ERROR:
359 ERR <<
"Failed to provide Package " << _package << endl;
365 ERR <<
"Failed to provide Package " << _package << endl;
368 const std::string & package_str = _package->asUserString();
376 ZYPP_THROW(SkipRequestException(
"User requested skip of corrupted file"));
379 ZYPP_THROW(AbortRequestException(
"User requested to abort"));
388 ERR <<
"Failed to provide Package " << _package << endl;
392 const std::string & package_str = _package->asUserString();
395 std::string detail_str(
str::form(
_(
"Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) );
404 ZYPP_THROW(SkipRequestException(
"User requested skip of file", excpt));
407 ZYPP_THROW(AbortRequestException(
"User requested to abort", excpt));
418 MIL <<
"provided Package " << _package <<
" at " << ret << endl;
435 , _deltas( deltas_r )
444 ManagedFile tryDelta(
const DeltaRpm & delta_r )
const;
447 {
return report()->progressDeltaDownload( value ); }
450 {
return report()->progressDeltaApply( value ); }
453 {
return _policy.queryInstalled( _package->name(), ed_r, _package->arch() ); }
463 RepoInfo info = _package->repoInfo();
474 std::list<DeltaRpm> deltaRpms;
475 _deltas.deltaRpms( _package ).swap( deltaRpms );
479 for_( it, deltaRpms.begin(), deltaRpms.end())
481 DBG <<
"tryDelta " << *it << endl;
483 if ( ! ret->empty() )
490 return Base::doProvidePackage();
493 ManagedFile RpmPackageProvider::tryDelta(
const DeltaRpm & delta_r )
const 508 policy.
progressCB( bind( &RpmPackageProvider::progressDeltaDownload,
this, _1 ) );
516 report()->finishDeltaDownload();
518 report()->startDeltaApply( delta );
521 report()->problemDeltaApply(
_(
"applydeltarpm check failed.") );
526 Pathname destination( _package->repoInfo().packagesPath() / _package->location().filename() );
529 bind( &RpmPackageProvider::progressDeltaApply,
this, _1 ) ) )
531 report()->problemDeltaApply(
_(
"applydeltarpm failed.") );
534 report()->finishDeltaApply();
578 : _pimpl( factory::
make( access_r, pi_r, deltas_r, policy_r ) )
583 :
_pimpl( factory::
make( access_r, pi_r, policy_r ) )
591 :
_pimpl( factory::
make( access_r, package_r, deltas_r, policy_r ) )
PackageProvider implementation interface.
virtual bool isCached() const
Whether the package is cached.
Candidate delta and patches for a package.
virtual ManagedFile providePackageFromCache() const
Provide the package if it is cached.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
RepoInfo info() const
Return any associated RepoInfo.
Interface to the rpm program.
const Repository & repository() const
#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
bool isCached() const
Whether the package is cached.
callback::SendReport< repo::DownloadResolvableReport > Report
void reset()
Reset to default Ctor values.
virtual ~PackageProviderImpl()
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
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.
ScopedGuard newReport() const
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]
bool progressPackageDownload(int value) const
Redirect ProvideFilePolicy package download progress to this.
void progressDeltaApply(int value) const
TraitsType::constPtrType constPtr
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
RepoMediaAccess & _access
bool isKind(const ResKind &kind_r) const
Pathname packagesPath() const
Path where this repo packages are cached.
virtual ManagedFile providePackage() const =0
Provide the package.
Report & report() const
Access to the DownloadResolvableReport.
bool queryInstalled(const Edition &ed_r=Edition()) const
PackageProvider implementation for Package and SrcPackage.
TPackage::constPtr TPackagePtr
virtual bool isCached() const =0
Whether the package is cached.
PackageProvider(RepoMediaAccess &access, const PoolItem &pi_r, const PackageProviderPolicy &policy_r=PackageProviderPolicy())
Ctor taking the package to provide.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
RW_pointer< Impl > _pimpl
Implementation class.
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
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.
shared_ptr< Report > _report
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).
PackageProviderImpl(RepoMediaAccess &access_r, const TPackagePtr &package_r, const PackageProviderPolicy &policy_r)
Ctor taking the Package to provide.
ManagedFile doProvidePackageFromCache() const
Lookup the final rpm in cache.
PackageProviderImpl< TPackage > Base
Detailed rpm signature check log messages A single multiline message if CHK_OK.
const Edition & edition() const
virtual ManagedFile providePackageFromCache() const =0
Provide the package if it is cached.
ResTraits< TRes >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
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)
reference value() const
Reference to the Tp object.
void defaultReportSignatureError(RpmDb::CheckPackageResult ret, const std::string &detail_r=std::string()) const
Default signature verification error handling.
const OnMediaLocation & location() const
callback::UserData UserData
virtual ManagedFile doProvidePackage() const
Actually provide the final rpm.
bool baseUrlsEmpty() const
whether repository urls are available
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
shared_ptr< void > ScopedGuard
const std::string & sequenceinfo() const
Base class for Exception.
ProvideFilePolicy & progressCB(ProgressCB progressCB_r)
Set callback.
void resolveSignatureErrorAction(repo::DownloadResolvableReport::Action action_r) const
React on signature verification error user action.
ManagedFile providePackage() const
Provide the package.
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...
shared_ptr< MediaSetAccess > _access
RPM PackageProvider implementation (with deltarpm processing).
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 haskey(const std::string &key_r) const
Whether key_r is in data.
Combining sat::Solvable and ResStatus.
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.
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.
std::string asUserString() const
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.