rpm  5.4.15
Macros | Functions | Variables
depends.c File Reference
#include "system.h"
#include <rpmio.h>
#include <rpmiotypes.h>
#include <rpmcb.h>
#include <rpmbf.h>
#include <rpmmacro.h>
#include <envvar.h>
#include <ugid.h>
#include <rpmtag.h>
#include <rpmdb.h>
#include <rpmds.h>
#include <rpmfi.h>
#include <rpmte.h>
#include <rpmcli.h>
#include "debug.h"
Include dependency graph for depends.c:

Go to the source code of this file.

Macros

#define _RPMDB_INTERNAL   /* XXX response cache needs dbiOpen et al. */
 
#define _RPMDS_INTERNAL
 
#define _RPMEVR_INTERNAL
 
#define _RPMTE_INTERNAL
 
#define _RPMTS_INTERNAL
 
#define CACHE_DEPENDENCY_RESULT   1
 

Functions

static int uintcmp (const void *a, const void *b)
 Compare removed package instances (qsort/bsearch). More...
 
static int removePackage (rpmts ts, Header h, uint32_t hdrNum, int *indexp, alKey depends)
 Add removed package instance to ordered transaction set. More...
 
static int rpmHeadersIdentical (Header first, Header second)
 Are two headers identical? More...
 
static int rpmtsAddUpgrades (rpmts ts, rpmte p, rpmuint32_t hcolor, Header h)
 Add upgrade erasures to a transaction set. More...
 
static int chkSuffix (const char *fn, const char *suffix)
 Check string for a suffix. More...
 
static int rpmtsEraseDebuginfo (rpmts ts, rpmte p, Header h, alKey pkgKey)
 Add unreferenced debuginfo erasures to a transaction set. More...
 
static int rpmtsAddObsoletes (rpmts ts, rpmte p, rpmuint32_t hcolor)
 Add Obsoletes: erasures to a transaction set. More...
 
int rpmtsAddInstallElement (rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
 Add package to be installed to transaction set. More...
 
int rpmtsAddEraseElement (rpmts ts, Header h, uint32_t hdrNum)
 Add package to be erased to transaction set. More...
 
void rpmnsClean (void)
 Clean global name space dependency sets. More...
 
static int unsatisfiedDepend (rpmts ts, rpmds dep, int adding)
 Check dep for an unsatisfied dependency. More...
 
static int checkPackageDeps (rpmts ts, const char *pkgNEVRA, rpmds requires, rpmds conflicts, rpmds dirnames, rpmds linktos, const char *depName, nsType depNS, rpmuint32_t tscolor, int adding)
 Check added requires/conflicts against against installed+added packages. More...
 
static int checkPackageSet (rpmts ts, const char *depName, nsType depNS, rpmmi mi, int adding)
 Check dependency against installed packages. More...
 
static int checkDependentPackages (rpmts ts, const char *depName, nsType depNS)
 Check to-be-erased dependencies against installed requires. More...
 
static int checkDependentConflicts (rpmts ts, const char *depName, nsType depNS)
 Check to-be-added dependencies against installed conflicts. More...
 
int _rpmtsCheck (rpmts ts)
 

Variables

int _cacheDependsRC = 1
 
const char * rpmNAME = PACKAGE
 
const char * rpmEVR = VERSION
 
int rpmFLAGS = RPMSENSE_EQUAL
 
static rpmTag _upgrade_tag
 
static rpmTag _debuginfo_tag
 
static rpmTag _obsolete_tag
 
static char * sysinfo_path = NULL
 
static rpmds rpmlibP = NULL
 
rpmds cpuinfoP = NULL
 
static rpmds getconfP = NULL
 
static rpmds unameP = NULL
 
int(* rpmtsCheck )(rpmts ts) = _rpmtsCheck
 Perform dependency resolution on the transaction set. More...
 

Macro Definition Documentation

#define _RPMDB_INTERNAL   /* XXX response cache needs dbiOpen et al. */

Definition at line 16 of file depends.c.

#define _RPMDS_INTERNAL

Definition at line 19 of file depends.c.

#define _RPMEVR_INTERNAL

Definition at line 20 of file depends.c.

#define _RPMTE_INTERNAL

Definition at line 24 of file depends.c.

#define _RPMTS_INTERNAL

Definition at line 26 of file depends.c.

#define CACHE_DEPENDENCY_RESULT   1

Definition at line 36 of file depends.c.

Function Documentation

int _rpmtsCheck ( rpmts  ts)
static int checkDependentConflicts ( rpmts  ts,
const char *  depName,
nsType  depNS 
)
static

Check to-be-added dependencies against installed conflicts.

Parameters
tstransaction set
depNameconflicts name
Returns
0 no problems found

Definition at line 1892 of file depends.c.

References checkPackageSet(), RPMTAG_CONFLICTNAME, rpmtsGetRdb(), and rpmtsInitIterator().

Referenced by _rpmtsCheck().

static int checkDependentPackages ( rpmts  ts,
const char *  depName,
nsType  depNS 
)
static

Check to-be-erased dependencies against installed requires.

Parameters
tstransaction set
depNamerequires name
Returns
0 no problems found

Definition at line 1871 of file depends.c.

References checkPackageSet(), RPMTAG_REQUIRENAME, rpmtsGetRdb(), and rpmtsInitIterator().

Referenced by _rpmtsCheck().

static int checkPackageDeps ( rpmts  ts,
const char *  pkgNEVRA,
rpmds  requires,
rpmds  conflicts,
rpmds  dirnames,
rpmds  linktos,
const char *  depName,
nsType  depNS,
rpmuint32_t  tscolor,
int  adding 
)
static

Check added requires/conflicts against against installed+added packages.

Parameters
tstransaction set
pkgNEVRApackage name-version-release.arch
requiresRequires: dependencies (or NULL)
conflictsConflicts: dependencies (or NULL)
dirnamesDirnames: dependencies (or NULL)
linktosFilelinktos: dependencies (or NULL)
depNamedependency name to filter (or NULL)
tscolorcolor bits for transaction set (0 disables)
addingdependency is from added package set?
Returns
0 = deps ok, 1 = dep problems, 2 = error

Definition at line 1569 of file depends.c.

References rpmalAllSatisfiesDepend(), rpmdsColor(), rpmdsInit(), rpmdsN(), rpmdsNext(), rpmdsNSType(), rpmdsProblem(), rpmExpandNumeric(), RPMNS_TYPE_UNKNOWN, rpmpsFree(), rpmtsProblems(), and unsatisfiedDepend().

Referenced by _rpmtsCheck(), and checkPackageSet().

static int checkPackageSet ( rpmts  ts,
const char *  depName,
nsType  depNS,
rpmmi  mi,
int  adding 
)
static

Check dependency against installed packages.

Adding: check name/provides dep against each conflict match, Erasing: check name/provides/filename dep against each requiredby match.

Parameters
tstransaction set
depNamedependency name
mirpm database iterator
addingdependency is from added package set?
Returns
0 no problems found

Definition at line 1798 of file depends.c.

References _free(), _rpmds_nopromote, alloca(), checkPackageDeps(), headerGet(), _HE_s::p, RPMDEPS_FLAG_NOCONFLICTS, RPMDEPS_FLAG_NOLINKTOS, RPMDEPS_FLAG_NOPARENTDIRS, RPMDEPS_FLAG_NOREQUIRES, rpmdsFree(), rpmdsNew(), rpmdsSetNoPromote(), rpmmiFree(), rpmmiNext(), rpmmiPrune(), RPMTAG_CONFLICTNAME, RPMTAG_DIRNAMES, RPMTAG_FILELINKTOS, RPMTAG_NVRA, RPMTAG_REQUIRENAME, rpmtsColor(), rpmtsDFlags(), rpmDataType_u::str, and _HE_s::tag.

Referenced by checkDependentConflicts(), and checkDependentPackages().

static int chkSuffix ( const char *  fn,
const char *  suffix 
)
inlinestatic

Check string for a suffix.

Parameters
fnstring
suffixsuffix
Returns
1 if string ends with suffix

Definition at line 313 of file depends.c.

Referenced by mtreeCWalk(), mtreeVWalk(), rpmtsAddInstallElement(), and rpmtsEraseDebuginfo().

static int removePackage ( rpmts  ts,
Header  h,
uint32_t  hdrNum,
int *  indexp,
alKey  depends 
)
static

Add removed package instance to ordered transaction set.

Parameters
tstransaction set
hheader
hdrNumrpm database instance
Return values
*indexpremoved element index (if not NULL)
Parameters
dependsinstalled package of pair (or RPMAL_NOMATCH on erase)
Returns
0 on success

Definition at line 75 of file depends.c.

References rpmbfAdd(), rpmbfNew(), rpmbfParams(), rpmfiFC(), RPMTAG_BASENAMES, rpmteFI(), rpmteNew(), TR_REMOVED, uintcmp(), and xrealloc.

Referenced by rpmtsAddEraseElement(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), and rpmtsEraseDebuginfo().

static int rpmHeadersIdentical ( Header  first,
Header  second 
)
static

Are two headers identical?

Parameters
firstfirst header
secondsecond header
Returns
1 if headers are identical, 0 otherwise

Definition at line 148 of file depends.c.

References _free(), alloca(), headerGet(), one, _HE_s::p, rpmdsCompare(), rpmdsFree(), rpmdsThis(), RPMSENSE_EQUAL, RPMTAG_HDRID, RPMTAG_REQUIRENAME, rpmDataType_u::str, and _HE_s::tag.

Referenced by rpmtsAddUpgrades(), and rpmtsEraseDebuginfo().

void rpmnsClean ( void  )

Clean global name space dependency sets.

Definition at line 858 of file depends.c.

References _free(), _sysinfo_path, and rpmdsFree().

Referenced by rpmcliFini().

int rpmtsAddEraseElement ( rpmts  ts,
Header  h,
uint32_t  hdrNum 
)

Add package to be erased to transaction set.

Parameters
tstransaction set
hheader
hdrNumrpm database instance
Returns
0 on success

Definition at line 834 of file depends.c.

References removePackage(), RPMAL_NOMATCH, and rpmtsEraseDebuginfo().

Referenced by findErases(), rpmcliEraseElement(), rpmErase(), rpmgiNext(), rpmts_AddErase(), and verifyDependencies().

int rpmtsAddInstallElement ( rpmts  ts,
Header  h,
const fnpyKey  key,
int  upgrade,
rpmRelocation  relocs 
)

Add package to be installed to transaction set.

The transaction set is checked for duplicate package names. If found, the package with the "newest" EVR will be replaced.

Parameters
tstransaction set
hheader
keypackage retrieval key (e.g. file name)
upgradeis package being upgraded?
relocspackage file relocations
Returns
0 on success, 1 on I/O error, 2 needs capabilities

Definition at line 547 of file depends.c.

References _, _free(), alloca(), chkSuffix(), headerGet(), headerIsEntry(), hGetColor(), nplatpat, _HE_s::p, platform, platpat, rpmDataType_u::ptr, RPMAL_NOMATCH, rpmalAdd(), rpmcliPackagesTotal, RPMDEPS_FLAG_NOOBSOLETES, RPMDEPS_FLAG_NOUPGRADE, rpmdsCompare(), rpmdsDNEVR(), rpmdsFree(), rpmdsThis(), rpmExpand(), rpmExpandNumeric(), rpmfiFC(), rpmIsVerbose, rpmlog(), RPMLOG_WARNING, rpmPlatformScore(), RPMPROB_BADPLATFORM, rpmProblemString(), rpmpsAppend(), rpmpsFree(), rpmpsGetProblem(), RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, RPMTAG_ARCH, RPMTAG_BASENAMES, RPMTAG_NAME, RPMTAG_NVRA, RPMTAG_OS, RPMTAG_PLATFORM, RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME, RPMTAG_SOURCERPM, rpmteA(), rpmteAddedKey(), rpmteDS(), rpmteFI(), rpmteFree(), rpmteIsSource(), rpmteKey(), rpmteN(), rpmteNew(), rpmteO(), rpmteSetAddedKey(), rpmteSetHeader(), rpmteType(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsColor(), rpmtsDBMode(), rpmtsDFlags(), rpmtsEraseDebuginfo(), rpmtsGetRdb(), rpmtsiFree(), rpmtsiInit(), rpmtsiNext(), rpmtsOpenDB(), rpmtsProblems(), rpmDataType_u::str, _HE_s::tag, TR_ADDED, TR_REMOVED, and xrealloc.

Referenced by rpmcliInstall(), rpmgiNext(), rpmInstallSourcePackage(), rpmRollback(), rpmts_AddInstall(), rpmtsSolve(), and verifyDependencies().

static int rpmtsAddObsoletes ( rpmts  ts,
rpmte  p,
rpmuint32_t  hcolor 
)
static
static int rpmtsAddUpgrades ( rpmts  ts,
rpmte  p,
rpmuint32_t  hcolor,
Header  h 
)
static
static int rpmtsEraseDebuginfo ( rpmts  ts,
rpmte  p,
Header  h,
alKey  pkgKey 
)
static

Add unreferenced debuginfo erasures to a transaction set.

Parameters
tstransaction set
ptransaction element
hheader
pkgKeyadded package key (erasure uses RPMAL_NOKEY)
Returns
no. of references from build set

Definition at line 329 of file depends.c.

References _debuginfo_tag, _free(), alloca(), chkSuffix(), D_, headerFree(), headerGet(), headerLink(), _HE_s::p, removePackage(), RPMAL_NOMATCH, rpmExpand(), rpmHeadersIdentical(), rpmlog(), RPMLOG_DEBUG, rpmmiFree(), rpmmiInstance(), rpmmiNext(), rpmmiPrune(), RPMTAG_NAME, RPMTAG_SOURCEPKGID, RPMTAG_SOURCERPM, rpmteChain(), rpmteNEVRA(), rpmteSourcerpm(), rpmtsInitIterator(), rpmDataType_u::str, and _HE_s::tag.

Referenced by rpmtsAddEraseElement(), and rpmtsAddInstallElement().

static int uintcmp ( const void *  a,
const void *  b 
)
static

Compare removed package instances (qsort/bsearch).

Parameters
a1st instance address
b2nd instance address
Returns
result of comparison

Definition at line 57 of file depends.c.

Referenced by removePackage().

static int unsatisfiedDepend ( rpmts  ts,
rpmds  dep,
int  adding 
)
static

Check dep for an unsatisfied dependency.

Parameters
tstransaction set
depdependency
addingdependency is from added package set?
Returns
0 if satisfied, 1 if not satisfied, 2 if error

Definition at line 883 of file depends.c.

References _, _cacheDependsRC, _free(), _rpmds_nopromote, alloca(), argvAdd(), argvFree(), argvSplit(), b, __db_dbt::data, data, DB_SET, DB_WRITECURSOR, dbiOpen(), envGet(), errno, Fclose(), OpenFileInfo::fd, Ferror(), flags, Fopen(), Fread(), gidToGname(), gnameToGid(), headerIsEntry(), i, key, PGPHASHALGO_ERROR, PGPHASHALGO_MD5, pgpHashAlgoStringToNumber(), rpmQVKArguments_s::qva_flags, rpmQVKArguments_s::qva_mode, R_OK, rpmalMakeIndex(), rpmalSatisfiesDepend(), RPMDBI_DEPCACHE, RPMDBI_PACKAGES, RPMDEPS_FLAG_NOSUGGEST, RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), rpmDigestUpdate(), rpmdsAnyMatchesDep(), rpmdsCpuinfo(), rpmdsDNEVR(), rpmdsELF(), rpmdsEVR(), rpmdsFlags(), rpmdsFree(), rpmdsFreePRCO(), rpmdsFromPRCO(), rpmdsGetconf(), rpmdsMergePRCO(), rpmdsN(), rpmdsNegateRC(), rpmdsNewPRCO(), rpmdsNotify(), rpmdsNSType(), rpmdsRpmlib(), rpmdsSearch(), rpmdsSingle(), rpmdsTagN(), rpmdsUname(), rpmExpand(), rpmExpandNumeric(), rpmGetPath(), rpmioAccess(), rpmmiFree(), rpmmiNext(), rpmmiPrune(), RPMNS_TYPE_ACCESS, RPMNS_TYPE_CPUINFO, RPMNS_TYPE_DIGEST, RPMNS_TYPE_DISKSPACE, RPMNS_TYPE_ENVVAR, RPMNS_TYPE_FUNCTION, RPMNS_TYPE_GETCONF, RPMNS_TYPE_GNUPG, RPMNS_TYPE_GROUP, RPMNS_TYPE_MACRO, RPMNS_TYPE_MOUNTED, RPMNS_TYPE_RPMLIB, RPMNS_TYPE_RUNNING, RPMNS_TYPE_SANITY, RPMNS_TYPE_SIGNATURE, RPMNS_TYPE_SONAME, RPMNS_TYPE_UNAME, RPMNS_TYPE_USER, RPMNS_TYPE_VCHECK, RPMNS_TYPE_VERIFY, rpmnsProbeSignature(), RPMRC_OK, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, RPMSENSE_NOTEQUAL, RPMSENSE_SENSEMASK, RPMTAG_BASENAMES, RPMTAG_DIRNAMES, RPMTAG_PROVIDENAME, RPMTAG_SANITYCHECK, RPMTAG_TRACK, rpmtsDFlags(), rpmtsGetRdb(), rpmtsInitDSI(), rpmtsInitIterator(), rpmtsPRCO(), showVerifyPackage(), __db_dbt::size, SYSCONFIGDIR, uidToUname(), unameToUid(), VERIFY_ALL, VERIFY_DEPS, VERIFY_SCRIPT, X_OK, xisdigit(), and xstrdup().

Referenced by checkPackageDeps().

Variable Documentation

int _cacheDependsRC = 1

Definition at line 39 of file depends.c.

Referenced by _rpmtsCheck(), and unsatisfiedDepend().

rpmTag _debuginfo_tag
static

Definition at line 188 of file depends.c.

Referenced by rpmtsEraseDebuginfo().

rpmTag _obsolete_tag
static

Definition at line 190 of file depends.c.

Referenced by rpmtsAddObsoletes().

rpmTag _upgrade_tag
static

Definition at line 186 of file depends.c.

Referenced by rpmtsAddUpgrades().

rpmds cpuinfoP = NULL

Definition at line 852 of file depends.c.

Referenced by rpmShowRC().

rpmds getconfP = NULL
static

Definition at line 854 of file depends.c.

const char* rpmEVR = VERSION

Definition at line 46 of file depends.c.

Referenced by printVersion().

int rpmFLAGS = RPMSENSE_EQUAL

Definition at line 49 of file depends.c.

rpmds rpmlibP = NULL
static

Definition at line 850 of file depends.c.

const char* rpmNAME = PACKAGE

Definition at line 43 of file depends.c.

int(* rpmtsCheck)(rpmts ts) = _rpmtsCheck

Perform dependency resolution on the transaction set.

Any problems found by rpmtsCheck() can be examined by retrieving the problem set with rpmtsProblems(), success here only means that the resolution was successfully attempted for all packages in the set.

Parameters
tstransaction set
Returns
0 = deps ok, 1 = dep problems, 2 = error

Definition at line 2097 of file depends.c.

Referenced by rpmcliInstallCheck(), rpmts_Check(), and verifyDependencies().

char* sysinfo_path = NULL
static

Definition at line 847 of file depends.c.

rpmds unameP = NULL
static

Definition at line 856 of file depends.c.