rpm  4.5
Data Structures | Defines | Typedefs | Functions | Variables
lib/depends.c File Reference
#include "system.h"
#include "rpmio_internal.h"
#include <rpmcli.h>
#include <rpmmacro.h>
#include <envvar.h>
#include <ugid.h>
#include "rpmdb.h"
#include "rpmds.h"
#include "rpmfi.h"
#include "rpmte.h"
#include "rpmts.h"
#include "debug.h"
Include dependency graph for depends.c:

Go to the source code of this file.

Data Structures

struct  orderListIndex_s
struct  badDeps_s

Defines

#define CACHE_DEPENDENCY_RESULT   1
#define _RPMDB_INTERNAL
#define _RPMEVR_INTERNAL
#define _RPMTE_INTERNAL
#define _RPMTS_INTERNAL
#define isAuto(_x)   (1)

Typedefs

typedef struct orderListIndex_sorderListIndex

Functions

static int intcmp (const void *a, const void *b)
 Compare removed package instances (qsort/bsearch).
static int removePackage (rpmts ts, Header h, int dboffset, int *indexp, alKey depends)
 Add removed package instance to ordered transaction set.
static int rpmHeadersIdentical (Header first, Header second)
 Are two headers identical?
static int rpmtsAddUpgrades (rpmts ts, rpmte p, uint32_t hcolor, Header h)
 Add upgrade erasures to a transaction set.
static int rpmtsAddObsoletes (rpmts ts, rpmte p, uint32_t hcolor)
 Add Obsoletes: erasures to a transaction set.
int rpmtsAddInstallElement (rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
 Add package to be installed to transaction set.
int rpmtsAddEraseElement (rpmts ts, Header h, int dboffset)
 Add package to be erased to transaction set.
static int unsatisfiedDepend (rpmts ts, rpmds dep, int adding)
 Check dep for an unsatisfied dependency.
static int checkPackageDeps (rpmts ts, const char *pkgNEVRA, rpmds requires, rpmds conflicts, rpmds dirnames, rpmds linktos, const char *depName, uint_32 tscolor, int adding)
 Check added requires/conflicts against against installed+added packages.
static int checkPackageSet (rpmts ts, const char *depName, rpmdbMatchIterator mi, int adding)
 Check dependency against installed packages.
static int checkDependentPackages (rpmts ts, const char *depName)
 Check to-be-erased dependencies against installed requires.
static int checkDependentConflicts (rpmts ts, const char *depName)
 Check to-be-added dependencies against installed conflicts.
static void freeBadDeps (void)
static int ignoreDep (const rpmts ts, const rpmte p, const rpmte q)
 Check for dependency relations to be ignored.
static void markLoop (tsortInfo tsi, rpmte q)
 Recursively mark all nodes with their predecessors.
static const char * identifyDepend (int_32 f)
static const char * zapRelation (rpmte q, rpmte p, int zap, int *nzaps, int msglvl)
 Find (and eliminate co-requisites) "q <- p" relation in dependency loop.
static int addRelation (rpmts ts, rpmte p, unsigned char *selected, rpmds requires)
 Record next "q <- p" relation (i.e.
static int orderListIndexCmp (const void *one, const void *two)
 Compare ordered list entries by index (qsort/bsearch).
static void addQ (rpmte p, rpmte *qp, rpmte *rp, uint_32 prefcolor)
 Add element to list sorting by tsi_qcnt.
int rpmtsOrder (rpmts ts)
 Determine package order in a transaction set according to dependencies.
int rpmtsCheck (rpmts ts)
 Check that all dependencies can be resolved.

Variables

int _cacheDependsRC = 1
const char * rpmNAME = PACKAGE
const char * rpmEVR = VERSION
int rpmFLAGS = RPMSENSE_EQUAL
static rpmTag _upgrade_tag
static rpmTag _obsolete_tag
static int badDepsInitialized = 0
static struct badDeps_sbadDeps = NULL
static uint32_t _autobits = 0xffffffff

Detailed Description

Definition in file depends.c.


Define Documentation

#define _RPMDB_INTERNAL

Definition at line 17 of file depends.c.

#define _RPMEVR_INTERNAL

Definition at line 21 of file depends.c.

#define _RPMTE_INTERNAL

Definition at line 25 of file depends.c.

#define _RPMTS_INTERNAL

Definition at line 28 of file depends.c.

#define CACHE_DEPENDENCY_RESULT   1

Definition at line 15 of file depends.c.

#define isAuto (   _x)    (1)

Definition at line 2062 of file depends.c.

Referenced by rpmtsOrder().


Typedef Documentation

Definition at line 42 of file depends.c.


Function Documentation

static void addQ ( rpmte  p,
rpmte qp,
rpmte rp,
uint_32  prefcolor 
) [static]

Add element to list sorting by tsi_qcnt.

Parameters:
pnew element
Return values:
*qpfirst element
*rplast element
Parameters:
prefcolorpreferred color

Definition at line 2004 of file depends.c.

References rpmteColor(), rpmteTSI(), rpmteType(), and TR_REMOVED.

Referenced by rpmtsOrder().

static int addRelation ( rpmts  ts,
rpmte  p,
unsigned char *  selected,
rpmds  requires 
) [inline, static]

Record next "q <- p" relation (i.e.

"p" requires "q").

Parameters:
tstransaction set
ppredecessor (i.e. package that "Requires: q")
selectedboolean package selected array
requiresrelation
Returns:
0 always

Definition at line 1871 of file depends.c.

References ignoreDep(), RPMAL_NOMATCH, rpmalSatisfiesDepend(), rpmdsIx(), rpmdsN(), rpmdsNSType(), rpmdsTagN(), RPMNS_TYPE_ACCESS, RPMNS_TYPE_CPUINFO, RPMNS_TYPE_DIGEST, RPMNS_TYPE_DISKSPACE, RPMNS_TYPE_ENVVAR, RPMNS_TYPE_GETCONF, RPMNS_TYPE_GNUPG, RPMNS_TYPE_GROUP, RPMNS_TYPE_MACRO, RPMNS_TYPE_MOUNTED, RPMNS_TYPE_RPMLIB, RPMNS_TYPE_RUNNING, RPMNS_TYPE_SONAME, RPMNS_TYPE_UNAME, RPMNS_TYPE_USER, rpmteAddedKey(), rpmteDepth(), rpmteSetDepth(), rpmteTSI(), rpmteType(), rpmtsiFree(), rpmtsiInit(), rpmtsiNext(), TR_ADDED, TR_REMOVED, and xcalloc().

Referenced by rpmtsOrder().

static int checkDependentConflicts ( rpmts  ts,
const char *  depName 
) [static]

Check to-be-added dependencies against installed conflicts.

Parameters:
tstransaction set
depNameconflicts name
Returns:
0 no problems found

Definition at line 1592 of file depends.c.

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

Referenced by rpmtsCheck().

static int checkDependentPackages ( rpmts  ts,
const char *  depName 
) [static]

Check to-be-erased dependencies against installed requires.

Parameters:
tstransaction set
depNamerequires name
Returns:
0 no problems found

Definition at line 1571 of file depends.c.

References checkPackageSet(), 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,
uint_32  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 no problems found

Definition at line 1310 of file depends.c.

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

Referenced by checkPackageSet(), and rpmtsCheck().

static int checkPackageSet ( rpmts  ts,
const char *  depName,
rpmdbMatchIterator  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 1509 of file depends.c.

References _free(), _rpmds_nopromote, checkPackageDeps(), hGetNEVRA(), rpmdbFreeIterator(), rpmdbNextIterator(), rpmdbPruneIterator(), RPMDEPS_FLAG_NOCONFLICTS, RPMDEPS_FLAG_NOLINKTOS, RPMDEPS_FLAG_NOPARENTDIRS, RPMDEPS_FLAG_NOREQUIRES, rpmdsFree(), rpmdsNew(), rpmdsSetNoPromote(), rpmtsColor(), and rpmtsDFlags().

Referenced by checkDependentConflicts(), and checkDependentPackages().

static void freeBadDeps ( void  ) [static]

Definition at line 1655 of file depends.c.

References _free(), badDeps_s::pname, and badDeps_s::qname.

Referenced by rpmtsOrder().

static const char* identifyDepend ( int_32  f) [inline, static]

Definition at line 1766 of file depends.c.

Referenced by zapRelation().

static int ignoreDep ( const rpmts  ts,
const rpmte  p,
const rpmte  q 
) [static]

Check for dependency relations to be ignored.

Parameters:
tstransaction set
psuccessor element (i.e. with Requires: )
qpredecessor element (i.e. with Provides: )
Returns:
1 if dependency is to be ignored.

Definition at line 1678 of file depends.c.

References _, _free(), badDeps_s::pname, badDeps_s::qname, RPMDEPS_FLAG_ANACONDA, RPMDEPS_FLAG_DEPLOOPS, rpmExpand(), RPMMESS_DEBUG, RPMMESS_WARNING, rpmMessage, rpmteN(), rpmtsDFlags(), xcalloc(), and xstrdup().

Referenced by addRelation().

static int intcmp ( 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 73 of file depends.c.

Referenced by removePackage().

static void markLoop ( tsortInfo  tsi,
rpmte  q 
) [static]

Recursively mark all nodes with their predecessors.

Parameters:
tsisuccessor chain
qpredecessor

Definition at line 1740 of file depends.c.

References rpmteTSI().

Referenced by rpmtsOrder().

static int orderListIndexCmp ( const void *  one,
const void *  two 
) [static]

Compare ordered list entries by index (qsort/bsearch).

Parameters:
one1st ordered list entry
two2nd ordered list entry
Returns:
result of comparison

Definition at line 1986 of file depends.c.

Referenced by rpmtsOrder().

static int removePackage ( rpmts  ts,
Header  h,
int  dboffset,
int *  indexp,
alKey  depends 
) [static]

Add removed package instance to ordered transaction set.

Parameters:
tstransaction set
hheader
dboffsetrpm 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 91 of file depends.c.

References intcmp(), rpmteNew(), TR_REMOVED, and xrealloc().

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

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 156 of file depends.c.

References headerGetEntry(), rpmdsCompare(), rpmdsFree(), rpmdsThis(), RPMSENSE_EQUAL, and RPMTAG_HDRID.

Referenced by rpmtsAddUpgrades().

static int rpmtsAddObsoletes ( rpmts  ts,
rpmte  p,
uint32_t  hcolor 
) [static]
static int rpmtsAddUpgrades ( rpmts  ts,
rpmte  p,
uint32_t  hcolor,
Header  h 
) [static]

Add upgrade erasures to a transaction set.

Parameters:
tstransaction set
ptransaction element
hcolorheader color
hheader
Returns:
0 on success

Definition at line 201 of file depends.c.

References _free(), _upgrade_tag, alloca(), _HE_s::c, D_, hGetColor(), _HE_s::p, rpmDataType_u::ptr, removePackage(), rpmdbFreeIterator(), rpmdbGetIteratorOffset(), rpmdbNextIterator(), rpmExpand(), rpmHeadersIdentical(), rpmlog(), RPMLOG_DEBUG, rpmteAddedKey(), rpmteChain(), rpmteN(), rpmteNEVRA(), rpmtsColor(), rpmtsInitIterator(), _HE_s::tag, and rpmDataType_u::ui32p.

Referenced by rpmtsAddInstallElement().

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 741 of file depends.c.

References _, _cacheDependsRC, _free(), _rpmds_nopromote, alloca(), dbiOpen(), errno, Fclose(), Ferror(), Fopen(), Fread(), gidToGname(), gnameToGid(), PGPHASHALGO_MD5, R_OK, rpmalMakeIndex(), rpmalSatisfiesDepend(), rpmdbFreeIterator(), RPMDBI_DEPENDS, rpmdbNextIterator(), rpmdbPruneIterator(), 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(), 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_SONAME, RPMNS_TYPE_UNAME, RPMNS_TYPE_USER, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, RPMSENSE_NOTEQUAL, RPMSENSE_SENSEMASK, rpmtsDFlags(), rpmtsGetRdb(), rpmtsInitDSI(), rpmtsInitIterator(), uidToUname(), unameToUid(), X_OK, and xisdigit().

Referenced by checkPackageDeps().

static const char* zapRelation ( rpmte  q,
rpmte  p,
int  zap,
int *  nzaps,
int  msglvl 
) [static]

Find (and eliminate co-requisites) "q <- p" relation in dependency loop.

Search all successors of q for instance of p. Format the specific relation, (e.g. p contains "Requires: q"). Unlink and free co-requisite (i.e. pure Requires: dependencies) successor node(s).

Parameters:
qsucessor (i.e. package required by p)
ppredecessor (i.e. package that "Requires: q")
zapmax. no. of co-requisites to remove (-1 is all)?
Return values:
nzapsaddress of no. of relations removed
Parameters:
msglvlmessage level at which to spew
Returns:
(possibly NULL) formatted "q <- p" releation (malloc'ed)

Definition at line 1802 of file depends.c.

References _, _free(), identifyDepend(), rpmdsFlags(), rpmdsNewDNEVR(), rpmdsSetIx(), rpmMessage, rpmteDS(), rpmteNEVRA(), rpmteTSI(), rpmteType(), and TR_REMOVED.

Referenced by rpmtsOrder().


Variable Documentation

uint32_t _autobits = 0xffffffff [static]

Definition at line 2061 of file depends.c.

int _cacheDependsRC = 1

Definition at line 55 of file depends.c.

Referenced by rpmtsCheck(), and unsatisfiedDepend().

Definition at line 191 of file depends.c.

Referenced by rpmtsAddObsoletes().

rpmTag _upgrade_tag [static]

Definition at line 185 of file depends.c.

Referenced by rpmtsAddUpgrades().

struct badDeps_s* badDeps = NULL [static]

Definition at line 1649 of file depends.c.

int badDepsInitialized = 0 [static]

Definition at line 1646 of file depends.c.

const char* rpmEVR = VERSION

Definition at line 62 of file depends.c.

Referenced by printVersion().

int rpmFLAGS = RPMSENSE_EQUAL

Definition at line 65 of file depends.c.

const char* rpmNAME = PACKAGE

Definition at line 59 of file depends.c.