14#include <zypp/base/Logger.h>
15#include <zypp/base/Gettext.h>
16#include <zypp/base/Exception.h>
19#include <zypp/base/Xml.h>
21#include <zypp/sat/detail/PoolImpl.h>
27#include <zypp-core/OnMediaLocation>
43 void _doSplit( IdString & _ident, ResKind & _kind, IdString & _name )
57 _ident = IdString(
str::form(
"%s:%s", _kind.c_str(), _ident.c_str() ) );
62 _name = IdString( ::strchr( _ident.c_str(),
':' )+1 );
109#define NO_SOLVABLE_RETURN( VAL ) \
110 detail::CSolvable * _solvable( get() ); \
111 if ( ! _solvable ) return VAL
122 if ( nextS && nextS->repo == _solvable->repo )
133 const char * s = ::solvable_lookup_str( _solvable,
attr.id() );
134 return s ? s : std::string();
143 s = ::solvable_lookup_str_poollang( _solvable,
attr.id() );
149 if ( (s = ::solvable_lookup_str_lang( _solvable,
attr.id(), l.c_str(), 0 )) )
153 s = ::solvable_lookup_str_lang( _solvable,
attr.id(), 0, 0 );
155 return s ? s : std::string();
161 return ::solvable_lookup_num( _solvable,
attr.id(), 0 );
167 return ::solvable_lookup_num( _solvable,
attr.id(), notfound_r );
173 return ::solvable_lookup_bool( _solvable,
attr.id() );
179 return ::solvable_lookup_id( _solvable,
attr.id() );
186 const char * s = ::solvable_lookup_checksum( _solvable,
attr.id(), &chksumtype );
189 switch ( chksumtype )
198 return CheckSum( std::string(), s );
206 static const SolvAttr susetagsDatadir(
"susetags:datadir" );
211 if ( ! datadir.empty() )
215 LookupAttr datadir( susetagsDatadir, repor_r );
216 if ( ! datadir.empty() )
229 const char * file = ::solvable_lookup_location( _solvable, &medianr );
238 switch (
repository().info().type().toEnum() )
243 if ( ! path.
empty() )
279 switch ( _solvable->arch )
294 const char * sep = ::strchr(
ident,
':' );
307 switch ( _solvable->arch )
319 return( ::strchr(
ident,
':' ) == 0 );
324 unsigned ksize = ::strlen(
kind );
325 return( ::strncmp(
ident,
kind, ksize ) == 0
326 &&
ident[ksize] ==
':' );
333 const char * sep = ::strchr(
ident,
':' );
334 return( sep ? sep+1 :
ident );
340 return Edition( _solvable->evr );
346 switch ( _solvable->arch )
360 return IdString( _solvable->vendor );
407 if ( isKind<Package>() )
409 if ( isKind<Patch>() )
471 return rhssolvable && ( _solvable == rhssolvable || ::solvable_identical( _solvable, rhssolvable ) );
487 return _getCapabilities( _solvable->repo->idarraydata, _solvable->provides );
492 return _getCapabilities( _solvable->repo->idarraydata, _solvable->requires );
497 return _getCapabilities( _solvable->repo->idarraydata, _solvable->conflicts );
502 return _getCapabilities( _solvable->repo->idarraydata, _solvable->obsoletes );
507 return _getCapabilities( _solvable->repo->idarraydata, _solvable->recommends );
512 return _getCapabilities( _solvable->repo->idarraydata, _solvable->suggests );
517 return _getCapabilities( _solvable->repo->idarraydata, _solvable->enhances );
522 return _getCapabilities( _solvable->repo->idarraydata, _solvable->supplements );
528 ::Offset offs = _solvable->requires;
557 std::string value( caprep.
name().
c_str()+namespace_r.size()+1 );
558 value[value.size()-1] =
'\0';
568 int res = solvable_matchessolvable(
get(),
attr.id(),
static_cast<Id
>( solv.
id() ), capQueue, 0 );
571 if ( capQueue.
size() )
572 std::for_each( capQueue.
begin(), capQueue.
end(), [ &caps ](
auto cap ){ caps.insert( Capability(cap) );});
574 return std::make_pair( res == 1, std::move(caps) );
584 int invokeOnEachSupportedLocale(
Capability cap_r, function<
bool (
const Locale &)> fnc_r )
589 switch ( detail.capRel() )
595 int res = invokeOnEachSupportedLocale( detail.lhs(), fnc_r );
598 int res2 = invokeOnEachSupportedLocale( detail.rhs(), fnc_r );
606 if ( detail.lhs().id() == NAMESPACE_LANGUAGE )
608 return ( !fnc_r || fnc_r(
Locale(
IdString(detail.rhs().id()) ) ) ) ? 1 : -1;
623 inline int invokeOnEachSupportedLocale( Capabilities cap_r, function<
bool (Locale)> fnc_r )
626 for_( cit, cap_r.begin(), cap_r.end() )
628 int res = invokeOnEachSupportedLocale( *cit, fnc_r );
642 bool operator()(
const Locale & locale_r )
const
661 return invokeOnEachSupportedLocale(
supplements(), bind( std::not_equal_to<Locale>(), locale_r, _1 ) ) < 0;
666 if ( locales_r.empty() )
669 return invokeOnEachSupportedLocale(
supplements(), NoMatchIn(locales_r) ) < 0;
678 invokeOnEachSupportedLocale(
supplements(), functor::collector( std::inserter( ret, ret.begin() ) ) );
692 unsigned medianr = 0U;
693 const char * file = ::solvable_lookup_location( _solvable, &medianr );
696 else if ( ! medianr )
747 if ( ret.empty() && isKind<Product>() )
750 std::string riname(
name() );
763 if ( isKind<Product>() )
766 std::string riname(
name() );
779 return str << (obj.
isSystem() ?
"systemSolvable" :
"noSolvable" );
781 return str <<
"(" << obj.
id() <<
")"
783 <<
'-' << obj.
edition() <<
'.' << obj.
arch() <<
"("
792#define OUTS(X) if ( ! obj[Dep::X].empty() ) str << endl << " " #X " " << obj[Dep::X]
const LocaleSet & _locales
#define NO_SOLVABLE_RETURN(VAL)
Store and operate with byte count.
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Helper providing more detailed information about a Capability.
Container of Capability (currently read only).
const_iterator begin() const
Iterator pointing to the first Capability.
const_iterator end() const
Iterator pointing behind the last Capability.
static CheckSum md5(const std::string &checksum)
static CheckSum sha384(const std::string &checksum)
static CheckSum sha1(const std::string &checksum)
static CheckSum sha512(const std::string &checksum)
static CheckSum sha256(const std::string &checksum)
static CheckSum sha224(const std::string &checksum)
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
static constexpr NoThrowType noThrow
Indicator argument for non-trowing ctor.
Store and operate on date (time_t).
Edition represents [epoch:]version[-release]
const char * c_str() const
Access to the sat-pools string space.
const char * c_str() const
Conversion to const char *
std::string asString() const
Conversion to std::string
'Language[_Country]' codes.
Locale fallback() const
Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
What is known about a repository.
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects.
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
bool hasLicense() const
Whether there is a license associated with the repo.
static const Repository noRepository
Represents no Repository.
std::string alias() const
Short unique string to identify a repo.
RepoInfo info() const
Return any associated RepoInfo.
static const ResKind srcpackage
static ResKind explicitBuiltin(const char *str_r)
Return the builtin kind if str_r explicitly prefixed.
static const ResKind package
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
Lightweight attribute value lookup.
Lightweight repository attribute value lookup.
Libsolv Id queue wrapper.
const_iterator end() const
const_iterator begin() const
static const SolvAttr cpeid
static const SolvAttr buildtime
static const SolvAttr distribution
static const SolvAttr description
static const SolvAttr delnotify
static const SolvAttr installsize
static const SolvAttr downloadsize
static const SolvAttr insnotify
static const SolvAttr summary
static const SolvAttr checksum
static const SolvAttr updateStatus
static const SolvAttr installtime
static const SolvAttr eula
A Solvable object within the sat Pool.
Capabilities suggests() const
IdType id() const
Expert backdoor.
bool isPtfPackage() const
Subset of isPtf (provides ptfPackageToken).
std::ostream & dumpOn(std::ostream &str, const Solvable &obj)
More verbose stream output including dependencies.
bool isNeedreboot() const
Whether this solvable triggers the reboot-needed hint if installed/updated.
bool identIsAutoInstalled() const
Whether an installed solvable with the same ident is flagged as AutoInstalled.
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
IdString vendor() const
The vendor.
ByteCount installSize() const
Installed (unpacked) size.
Date buildtime() const
The items build time.
bool needToAcceptLicense() const
True except for well known exceptions (i.e show license but no need to accept it).
ResKind kind() const
The Solvables ResKind.
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides 'namespace([value])[ op edition]' of this Solvable.
static const Solvable noSolvable
Represents no Solvable.
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
std::string distribution() const
The distribution string.
unsigned mediaNr() const
Media number the solvable is located on (0 if no media access required).
bool isBlacklisted() const
Whether this solvable is blacklisted (retracted,ptf,...).
unsigned long long lookupNumAttribute(const SolvAttr &attr) const
returns the numeric attribute value for attr or 0 if it does not exists.
std::string lookupStrAttribute(const SolvAttr &attr) const
returns the string attribute value for attr or an empty string if it does not exists.
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
CpeId cpeId() const
The solvables CpeId if available.
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Date installtime() const
The items install time (false if not installed).
Edition edition() const
The edition (version-release).
static const IdString ptfMasterToken
Indicator provides ptf()
Capabilities prerequires() const
bool isPtfMaster() const
Subset of isPtf (provides ptfMasterToken).
Solvable()
Default ctor creates noSolvable.
Capabilities enhances() const
LocaleSet getSupportedLocales() const
Return the supported locales.
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
detail::CSolvable * get() const
Expert backdoor.
Arch arch() const
The architecture.
static const IdString ptfPackageToken
Indicator provides ptf-package()
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept before installing the solvable (opt.
bool supportsLocales() const
Whether this Solvable claims to support locales.
std::ostream & operator<<(std::ostream &str, const Solvable &obj)
Stream output.
Capabilities provides() const
std::string asUserString() const
String representation "ident-edition.arch(repo)" or "noSolvable".
static const IdString retractedToken
Indicator provides retracted-patch-package()
std::string summary(const Locale &lang_r=Locale()) const
Short (singleline) text describing the solvable (opt.
Capabilities conflicts() const
Capabilities obsoletes() const
detail::IdType lookupIdAttribute(const SolvAttr &attr) const
returns the id attribute value for attr or detail::noId if it does not exists.
std::pair< bool, CapabilitySet > matchesSolvable(const SolvAttr &attr, const sat::Solvable &solv) const
std::string name() const
The name (without any ResKind prefix).
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Capabilities supplements() const
ByteCount downloadSize() const
Download size.
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
bool onSystemByAuto() const
Whether this is known to be automatically installed (as dependency of a user request package).
std::string delnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for uninstall (opt.
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return 'value[ op edition]' for namespaced provides 'namespace(value)[ op edition]'.
IdString ident() const
The identifier.
std::ostream & dumpAsXmlOn(std::ostream &str, const Solvable &obj)
XML output.
CheckSum lookupCheckSumAttribute(const SolvAttr &attr) const
returns the CheckSum attribute value for attr or an empty CheckSum if ir does not exist.
std::string description(const Locale &lang_r=Locale()) const
Long (multiline) text describing the solvable (opt.
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Capabilities recommends() const
RepoInfo repoInfo() const
The repositories RepoInfo.
Repository repository() const
The Repository this Solvable belongs to.
bool isPtf() const
Whether this solvable belongs to a PTF (provides ptfMasterToken or ptfPackageToken).
bool isRetracted() const
Whether this solvable is retracted (provides retractedToken).
bool isKind() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::string insnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for install (opt.
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
bool isPtfMaster(const Solvable &solv_r) const
bool isSystemRepo(CRepo *repo_r) const
bool isPtfPackage(const Solvable &solv_r) const
bool isNeedreboot(const Solvable &solv_r) const
Whether solv_r matches the spec.
bool isOnSystemByAuto(IdString ident_r) const
bool isRetracted(const Solvable &solv_r) const
CSolvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
bool isMultiversion(const Solvable &solv_r) const
bool isOnSystemByUser(IdString ident_r) const
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
String related utilities and Regular expression matching.
False false_c()
Convenience function for creating a False.
static const IdType solvablePrereqMarker(15)
Internal ids satlib includes in dependencies.
static const IdType noId(0)
int IdType
Generic Id type.
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
static const SolvableIdType systemSolvableId(1)
Id to denote the usually hidden Solvable::systemSolvable.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_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.
std::unordered_set< Capability > CapabilitySet
std::unordered_set< Locale > LocaleSet
static PoolImpl & myPool()
RAII writing a nodes start/end tag.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.