depends.c File Reference
RPMTS Transaction Set API.
`#include "system.h"`
`#include <rpmio.h>`
`#include <rpmiotypes.h>`
`#include <rpmcb.h>`
`#include <rpmmacro.h>`
`#include <envvar.h>`
`#include <ugid.h>`
`#include <rpmtag.h>`
`#include <rpmdb.h>`
`#include <rpmte.h>`
`#include <rpmcli.h>`
`#include <rpmds.h>`
`#include <rpmfi.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

## Macros

#define | _RPMDB_INTERNAL /* XXX response cache needs dbiOpen et al. */
#define | _RPMTE_INTERNAL
#define | _RPMTS_INTERNAL
#define | _RPMEVR_INTERNAL
#define | isAuto(_x) ((_x) & _autobits)

## Typedefs

typedef struct orderListIndex_s * | orderListIndex

## Functions

static int | intcmp (const void *a, const void *b)
| Compare removed package instances (qsort/bsearch). More...
static int | removePackage (rpmts ts, Header h, int dboffset, 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, int dboffset)
| 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, rpmuint32_t tscolor, int adding)
| Check added requires/conflicts against against installed+added packages. More...
static int | checkPackageSet (rpmts ts, const char *depName, rpmmi mi, int adding)
| Check dependency against installed packages. More...
static int | checkDependentPackages (rpmts ts, const char *depName)
| Check to-be-erased dependencies against installed requires. More...
static int | checkDependentConflicts (rpmts ts, const char *depName)
| Check to-be-added dependencies against installed conflicts. More...
static void | freeBadDeps (void)
static int | ignoreDep (const rpmts ts, const rpmte p, const rpmte q)
| Check for dependency relations to be ignored. More...
static void | markLoop (tsortInfo tsi, rpmte q)
| Recursively mark all nodes with their predecessors. More...
static const char * | identifyDepend (rpmuint32_t 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. More...
static int | addRelation (rpmts ts, rpmte p, unsigned char *selected, rpmds requires)
| Record next "q <- p" relation (i.e. More...
static int | orderListIndexCmp (const void *one, const void *two)
| Compare ordered list entries by index (qsort/bsearch). More...
static void | addQ (rpmte p, rpmte *qp, rpmte *rp, rpmuint32_t prefcolor)
| Add element to list sorting by tsi_qcnt. More...
static int | countSlashes (const char *dn)
int | rpmtsOrder (rpmts ts)
| Determine package order in a transaction set according to dependencies. More...
int | rpmtsCheck (rpmts ts)
| Perform dependency resolution on the transaction set. More...

## Variables

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
static int | badDepsInitialized = 0
static struct badDeps_s * | badDeps = NULL
static rpmuint32_t | _autobits = 0xffffffff
static int | slashDepth = 100

## Macro Definition Documentation

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

Definition at line 15 of file depends.c.

#define _RPMEVR_INTERNAL

Definition at line 23 of file depends.c.

#define _RPMTE_INTERNAL

Definition at line 18 of file depends.c.

#define _RPMTS_INTERNAL

Definition at line 20 of file depends.c.

#define isAuto | ( |  | _x | ) | ((_x) & _autobits)

Definition at line 2269 of file depends.c.

Referenced by rpmtsOrder().

## Typedef Documentation

typedef struct orderListIndex_s* orderListIndex

Definition at line 38 of file depends.c.

## Function Documentation

static void addQ | ( | rpmte | p,
|  | rpmte * | qp,
|  | rpmte * | rp,
|  | rpmuint32_t | prefcolor
| ) |  |

static

Add element to list sorting by tsi_qcnt.

Parameters

  p | new element

Return values

  *qp | first element
  *rp | last element

Parameters

  prefcolor | preferred color

Definition at line 2212 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

  ts | transaction set
  p | predecessor (i.e. package that "Requires: q")
  selected | boolean package selected array
  requires | relation

Returns
  0 always

Definition at line 2087 of file depends.c.

References ignoreDep(), RPMAL_NOMATCH, rpmalSatisfiesDepend(), rpmdsIx(), rpmdsNSType(), rpmdsTagN(), RPMNS_TYPE_ACCESS, RPMNS_TYPE_CONFIG, 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_SANITY, RPMNS_TYPE_SIGNATURE, RPMNS_TYPE_SONAME, RPMNS_TYPE_UNAME, RPMNS_TYPE_USER, RPMNS_TYPE_VCHECK, 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

  ts | transaction set
  depName | conflicts name

Returns
  0 no problems found

Definition at line 1838 of file depends.c.

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

Referenced by rpmtsCheck().

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

static

Check to-be-erased dependencies against installed requires.

Parameters

  ts | transaction set
  depName | requires name

Returns
  0 no problems found

Definition at line 1817 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,
|  | rpmuint32_t | tscolor,
|  | int | adding
| ) |  |

static

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

Parameters

  ts | transaction set
  pkgNEVRA | package name-version-release.arch
  requires | Requires: dependencies (or NULL)
  conflicts | Conflicts: dependencies (or NULL)
  dirnames | Dirnames: dependencies (or NULL)
  linktos | Filelinktos: dependencies (or NULL)
  depName | dependency name to filter (or NULL)
  tscolor | color bits for transaction set (0 disables)
  adding | dependency is from added package set?

Returns
  0 = deps ok, 1 = dep problems, 2 = error

Definition at line 1537 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,
|  | 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

  ts | transaction set
  depName | dependency name
  mi | rpm database iterator
  adding | dependency is from added package set?

Returns
  0 no problems found

Definition at line 1744 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
| ) |  |

inline static

Check string for a suffix.

Parameters

  fn | string
  suffix | suffix

Returns
  1 if string ends with suffix

Definition at line 311 of file depends.c.

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

static int countSlashes | ( | const char * | dn | ) |

static

Definition at line 2274 of file depends.c.

Referenced by rpmtsOrder().

static void freeBadDeps | ( | void |  | ) |

static

Definition at line 1879 of file depends.c.

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

Referenced by rpmtsOrder().

static const char* identifyDepend | ( | rpmuint32_t | f | ) |

inline static

Definition at line 1986 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

  ts | transaction set
  p | successor element (i.e. with Requires: )
  q | predecessor element (i.e. with Provides: )

Returns
  1 if dependency is to be ignored.

Definition at line 1901 of file depends.c.

References _, _free(), badDeps_s::pname, badDeps_s::qname, RPMDEPS_FLAG_ANACONDA, RPMDEPS_FLAG_DEPLOOPS, rpmExpand(), rpmlog(), RPMLOG_DEBUG, RPMLOG_WARNING, 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

  a | 1st instance address
  b | 2nd instance address

Returns
  result of comparison

Definition at line 69 of file depends.c.

Referenced by removePackage().

static void markLoop | ( | tsortInfo | tsi,
|  | rpmte | q
| ) |  |

static

Recursively mark all nodes with their predecessors.

Parameters

  tsi | successor chain
  q | predecessor

Definition at line 1962 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

  one | 1st ordered list entry
  two | 2nd ordered list entry

Returns
  result of comparison

Definition at line 2195 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

  ts | transaction set
  h | header
  dboffset | rpm database instance

Return values

  *indexp | removed element index (if not NULL)

Parameters

  depends | installed package of pair (or RPMAL_NOMATCH on erase)

Returns
  0 on success

Definition at line 87 of file depends.c.

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

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

static int rpmHeadersIdentical | ( | Header | first,
|  | Header | second
| ) |  |

static

Are two headers identical?

Parameters

  first | first header
  second | second header

Returns
  1 if headers are identical, 0 otherwise

Definition at line 146 of file depends.c.

References _free(), alloca(), headerGet(), _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 830 of file depends.c.

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

Referenced by rpmcliFini().

static int rpmtsAddObsoletes | ( | rpmts | ts,
|  | rpmte | p,
|  | rpmuint32_t | hcolor
| ) |  |

static

Add Obsoletes: erasures to a transaction set.

Parameters

  ts | transaction set
  p | transaction element
  hcolor | header color

Returns
  0 on success

Definition at line 415 of file depends.c.

References _free(), _obsolete_tag, _rpmds_nopromote, D_, hGetColor(), removePackage(), rpmdsAnyMatchesDep(), rpmdsColor(), rpmdsDNEVR(), rpmdsEVR(), rpmdsFree(), rpmdsInit(), rpmdsLink(), rpmdsN(), rpmdsNext(), rpmExpand(), rpmlog(), RPMLOG_DEBUG, rpmmiFree(), rpmmiInstance(), rpmmiNext(), rpmmiPrune(), RPMTAG_BASENAMES, RPMTAG_NAME, RPMTAG_OBSOLETENAME, RPMTAG_PROVIDENAME, rpmteAddedKey(), rpmteChain(), rpmteDS(), rpmteN(), rpmteNEVRA(), rpmtsColor(), and rpmtsInitIterator().

Referenced by rpmtsAddInstallElement().

static int rpmtsAddUpgrades | ( | rpmts | ts,
|  | rpmte | p,
|  | rpmuint32_t | hcolor,
|  | Header | h
| ) |  |

static

Add upgrade erasures to a transaction set.

Parameters

  ts | transaction set
  p | transaction element
  hcolor | header color
  h | header

Returns
  0 on success

Definition at line 198 of file depends.c.

References _free(), _upgrade_tag, alloca(), _HE_s::c, D_, headerGet(), hGetColor(), _HE_s::p, rpmDataType_u::ptr, removePackage(), rpmExpand(), rpmHeadersIdentical(), rpmlog(), RPMLOG_DEBUG, rpmmiFree(), rpmmiInstance(), rpmmiNext(), RPMTAG_ARCH, RPMTAG_NAME, RPMTAG_ORIGINTID, RPMTAG_ORIGINTIME, RPMTAG_PROVIDENAME, rpmteAddedKey(), rpmteChain(), rpmteN(), rpmteNEVRA(), rpmtsColor(), rpmtsInitIterator(), rpmDataType_u::str, _HE_s::tag, and rpmDataType_u::ui32p.

Referenced by rpmtsAddInstallElement().

static int rpmtsEraseDebuginfo | ( | rpmts | ts,
|  | rpmte | p,
|  | Header | h,
|  | alKey | pkgKey
| ) |  |

static

Add unreferenced debuginfo erasures to a transaction set.

Parameters

  ts | transaction set
  p | transaction element
  h | header
  pkgKey | added package key (erasure uses RPMAL_NOKEY)

Returns
  no. of references from build set

Definition at line 327 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 unsatisfiedDepend | ( | rpmts | ts,
|  | rpmds | dep,
|  | int | adding
| ) |  |

static

Check dep for an unsatisfied dependency.

Parameters

  ts | transaction set
  dep | dependency
  adding | dependency is from added package set?

Returns
  0 if satisfied, 1 if not satisfied, 2 if error

Definition at line 855 of file depends.c.

References _, _free(), _rpmds_nopromote, alloca(), argvAdd(), argvFree(), argvSplit(), __db_dbt::data, DB_SET, DB_WRITECURSOR, dbiOpen(), errno, Fclose(), Ferror(), Fopen(), Fread(), gidToGname(), gnameToGid(), headerIsEntry(), PGPHASHALGO_ERROR, PGPHASHALGO_MD5, pgpHashAlgoStringToNumber(), rpmQVKArguments_s::qva_flags, rpmQVKArguments_s::qva_mode, R_OK, rpmalMakeIndex(), rpmalSatisfiesDepend(), RPMDBI_DEPENDS, 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().

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

  q | sucessor (i.e. package required by p)
  p | predecessor (i.e. package that "Requires: q")
  zap | max. no. of co-requisites to remove (-1 is all)?

Return values

  nzaps | address of no. of relations removed

Parameters

  msglvl | message level at which to spew

Returns
  (possibly NULL) formatted "q <- p" releation (malloc'ed)

Definition at line 2021 of file depends.c.

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

Referenced by rpmtsOrder().

## Variable Documentation

rpmuint32_t _autobits = 0xffffffff

static

Definition at line 2267 of file depends.c.

rpmTag _debuginfo_tag

static

Definition at line 186 of file depends.c.

Referenced by rpmtsEraseDebuginfo().

rpmTag _obsolete_tag

static

Definition at line 188 of file depends.c.

Referenced by rpmtsAddObsoletes().

rpmTag _upgrade_tag

static

Definition at line 184 of file depends.c.

Referenced by rpmtsAddUpgrades().

struct badDeps_s* badDeps = NULL

static

Definition at line 1873 of file depends.c.

int badDepsInitialized = 0

static

Definition at line 1870 of file depends.c.

rpmds cpuinfoP = NULL

Definition at line 824 of file depends.c.

Referenced by rpmShowRC().

rpmds getconfP = NULL

static

Definition at line 826 of file depends.c.

const char* rpmEVR = VERSION

Definition at line 58 of file depends.c.

Referenced by printVersion().

int rpmFLAGS = RPMSENSE_EQUAL

Definition at line 61 of file depends.c.

rpmds rpmlibP = NULL

static

Definition at line 822 of file depends.c.

const char* rpmNAME = PACKAGE

Definition at line 55 of file depends.c.

int slashDepth = 100

static

Definition at line 2272 of file depends.c.

char* sysinfo_path = NULL

static

Definition at line 819 of file depends.c.

rpmds unameP = NULL

static

Definition at line 828 of file depends.c.