# lib/rpmds.c File Reference

`#include "system.h"`
`#include <rpmio_internal.h>`
`#include <rpmcb.h>`
`#include <rpmmacro.h>`
`#include <rpmlib.h>`
`#include <rpmds.h>`
`#include <argv.h>`
`#include "debug.h"`

Include dependency graph for rpmds.c:

Go to the source code of this file.

## Data Structures
struct | cpuinfo_s
struct | rpmlibProvides_s
struct | conf
## Defines
#define | DT_GNU_HASH 0x6ffffef5
#define | _RPMDS_INTERNAL
#define | _RPMEVR_INTERNAL
#define | _RPMPRCO_INTERNAL
#define | _isspace(_c) ((_c) == ' ' || (_c) == '\t' || (_c) == '\r' || (_c) == '\n')
#define | _PROC_CPUINFO "/proc/cpuinfo"
#define | _ETC_RPM_SYSINFO SYSCONFIGDIR "/sysinfo"
#define | _GETCONF_PATH "/"
#define | _SBIN_LDCONFIG_P "/sbin/ldconfig -p"
#define | _LD_SO_CACHE "/etc/ld.so.cache"
#define | _PERL_PROVIDES "/usr/bin/find /usr/lib/perl5 | /usr/lib/rpm/perl.prov"
## Functions
rpmds | XrpmdsUnlink (rpmds ds, const char *msg, const char *fn, unsigned ln)
rpmds | XrpmdsLink (rpmds ds, const char *msg, const char *fn, unsigned ln)
rpmds | rpmdsFree (rpmds ds)
| Destroy a dependency set.
static const char ** | rpmdsDupArgv (const char **argv, int argc)
rpmds | rpmdsNew (Header h, rpmTag tagN, int flags)
| Create and load a dependency set.
const char * | rpmdsNewN (rpmds ds)
| Return N string, expanded if necessary.
char * | rpmdsNewDNEVR (const char *dspfx, rpmds ds)
| Return new formatted dependency string.
rpmds | rpmdsThis (Header h, rpmTag tagN, evrFlags Flags)
| Create, load and initialize a dependency for this header.
rpmds | rpmdsSingle (rpmTag tagN, const char *N, const char *EVR, evrFlags Flags)
| Create, load and initialize a dependency set of size 1.
int | rpmdsCount (const rpmds ds)
| Return dependency set count.
int | rpmdsIx (const rpmds ds)
| Return dependency set index.
int | rpmdsSetIx (rpmds ds, int ix)
| Set dependency set index.
const char * | rpmdsDNEVR (const rpmds ds)
| Return current formatted dependency string.
const char * | rpmdsN (const rpmds ds)
| Return current dependency name.
const char * | rpmdsEVR (const rpmds ds)
| Return current dependency epoch-version-release.
evrFlags | rpmdsFlags (const rpmds ds)
| Return current dependency flags.
rpmTag | rpmdsTagN (const rpmds ds)
| Return current dependency type.
const char * | rpmdsA (const rpmds ds)
| Return current dependency arch.
time_t | rpmdsBT (const rpmds ds)
| Return dependency build time.
time_t | rpmdsSetBT (const rpmds ds, time_t BT)
| Set dependency build time.
nsType | rpmdsNSType (const rpmds ds)
| Return dependency class type.
int | rpmdsNoPromote (const rpmds ds)
| Return current "Don't promote Epoch:" flag.
int | rpmdsSetNoPromote (rpmds ds, int nopromote)
| Set "Don't promote Epoch:" flag.
void * | rpmdsSetEVRparse (rpmds ds, int(*EVRparse)(const char *evrstr, EVR_t evr))
void * | rpmdsSetEVRcmp (rpmds ds, int(*EVRcmp)(const char *a, const char *b))
| Set EVR comparison function.
uint32_t | rpmdsColor (const rpmds ds)
| Return current dependency color.
uint32_t | rpmdsSetColor (const rpmds ds, uint32_t color)
| Set current dependency color.
uint32_t | rpmdsRefs (const rpmds ds)
| Return current dependency file refs.
uint32_t | rpmdsSetRefs (const rpmds ds, uint32_t refs)
| Set current dependency file refs.
int32_t | rpmdsResult (const rpmds ds)
| Return current dependency comparison result.
int32_t | rpmdsSetResult (const rpmds ds, int32_t result)
| Set current dependency comparison result.
void | rpmdsNotify (rpmds ds, const char *where, int rc)
| Notify of results of dependency match.
int | rpmdsNext (rpmds ds)
| Return next dependency set iterator index.
rpmds | rpmdsInit (rpmds ds)
| Initialize dependency set iterator.
static rpmds | rpmdsDup (const rpmds ods)
int | rpmdsFind (rpmds ds, const rpmds ods)
| Find a dependency set element using binary search.
int | rpmdsMerge (rpmds *dsp, rpmds ods)
| Merge a dependency set maintaining (N,EVR,Flags) sorted order.
int | rpmdsSearch (rpmds ds, rpmds ods)
| Search a sorted dependency set for an element that overlaps.
static int | rpmdsCpuinfoCtagFlags (const char *name)
| Return dependency format to use for a cpuinfo line.
static void | rpmdsNSAdd (rpmds *dsp, const char *NS, const char *N, const char *EVR, evrFlags Flags)
| Merge a single provides, wrapping N as "NS(N)".
int | rpmdsCpuinfo (rpmds *dsp, const char *fn)
| Load /proc/cpuinfo provides into a dependency set.
int | rpmdsRpmlib (rpmds *dsp, void *tblp)
| Load rpmlib provides into a dependency set.
static int | rpmdsSysinfoFile (rpmPRCO PRCO, const char *fn, int tagN)
| Merge contents of a sysinfo tag file into sysinfo dependencies.
int | rpmdsSysinfo (rpmPRCO PRCO, const char *fn)
| Load sysinfo dependencies into a dependency set.
int | rpmdsGetconf (rpmds *dsp, const char *path)
| Load getconf provides into a dependency set.
int | rpmdsMergePRCO (void *context, rpmds ds)
| Merge provides/requires/conflicts/obsoletes dependencies.
rpmPRCO | rpmdsFreePRCO (rpmPRCO PRCO)
| Free dependency set(s) container.
rpmPRCO | rpmdsNewPRCO (Header h)
| Create dependency set(s) container.
rpmds | rpmdsFromPRCO (rpmPRCO PRCO, rpmTag tagN)
| Retrieve a dependency set from container.
int | rpmdsELF (const char *fn, int flags, int(*add)(void *context, rpmds ds), void *context)
| Return a soname dependency constructed from an elf string.
int | rpmdsLdconfig (rpmPRCO PRCO, const char *fn)
| Load /etc/ld.so.cache provides into a dependency set.
int | rpmdsUname (rpmds *dsp, const struct utsname *un)
int | rpmdsPipe (rpmds *dsp, rpmTag tagN, const char *cmd)
| Load provides from a pipe into a dependency set.
static int | rpmdsNAcmp (rpmds A, rpmds B)
int | rpmdsCompare (const rpmds A, const rpmds B)
| Compare two versioned dependency ranges, looking for overlap.
void | rpmdsProblem (rpmps ps, const char *pkgNEVR, const rpmds ds, const fnpyKey *suggestedKeys, int adding)
| Report a Requires: or Conflicts: dependency problem.
int | rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote)
| Compare package provides dependencies from header with a single dependency.
int | rpmdsNVRMatchesDep (const Header h, const rpmds req, int nopromote)
| Compare package name-version-release from header with a single dependency.
int | rpmdsNegateRC (const rpmds ds, int rc)
| Negate return code for negated comparisons.
## Variables
static int | _noisy_range_comparison_debug_message = 0
| Enable noisy range comparison debugging message?
int | _rpmds_debug = 0
int | _rpmds_nopromote = 1
int | _rpmds_unspecified_epoch_noise = 0
static struct cpuinfo_s | ctags []
static const char * | _cpuinfo_path = NULL
static struct rpmlibProvides_s | rpmlibProvides []
const char * | _sysinfo_path = NULL
static const char * | _sysinfo_tags []
static struct conf | vars []
static const char * | _getconf_path = NULL
static const char * | _ldconfig_cmd = "/sbin/ldconfig -p"
static const char * | _ldconfig_cache = NULL
static const char * | _perldeps_cmd = NULL

## Detailed Description

Definition in file rpmds.c.

## Define Documentation

#define _ETC_RPM_SYSINFO SYSCONFIGDIR "/sysinfo"

Definition at line 1548 of file rpmds.c.

Referenced by rpmdsSysinfo().

#define _GETCONF_PATH "/"

Definition at line 2517 of file rpmds.c.

Referenced by rpmdsGetconf().

#define _isspace | ( | _c |  | ) | ((_c) == ' ' || (_c) == '\t' || (_c) == '\r' || (_c) == '\n')

Definition at line 95 of file rpmds.c.

Referenced by rpmdsCpuinfo(), rpmdsLdconfig(), rpmdsPipe(), and rpmdsSysinfoFile().

#define _LD_SO_CACHE "/etc/ld.so.cache"

Definition at line 3036 of file rpmds.c.

Referenced by rpmdsLdconfig().

#define _PERL_PROVIDES "/usr/bin/find /usr/lib/perl5 | /usr/lib/rpm/perl.prov"

Definition at line 3382 of file rpmds.c.

Referenced by rpmdsPipe().

#define _PROC_CPUINFO "/proc/cpuinfo"

Definition at line 1211 of file rpmds.c.

Referenced by rpmdsCpuinfo().

#define _RPMDS_INTERNAL

Definition at line 83 of file rpmds.c.

#define _RPMEVR_INTERNAL

Definition at line 84 of file rpmds.c.

#define _RPMPRCO_INTERNAL

Definition at line 85 of file rpmds.c.

#define _SBIN_LDCONFIG_P "/sbin/ldconfig -p"

Definition at line 3032 of file rpmds.c.

Referenced by rpmdsLdconfig().

#define DT_GNU_HASH 0x6ffffef5

Definition at line 75 of file rpmds.c.

Referenced by rpmdsELF().

## Function Documentation

static int rpmdsCpuinfoCtagFlags | ( | const char * | name | ) | `[static]`

Return dependency format to use for a cpuinfo line.

Parameters:

  | name | field name

Returns:
  type of format (0 == ignore, -1 == not found)

Definition at line 1167 of file rpmds.c.

References cpuinfo_s::done, cpuinfo_s::flags, and cpuinfo_s::name.

Referenced by rpmdsCpuinfo().

static rpmds rpmdsDup | ( | const rpmds | ods | ) | `[static]`

Definition at line 913 of file rpmds.c.

References headerLink(), rpmdsDupArgv(), rpmdsLink, xcalloc(), and xmalloc().

Referenced by rpmdsMerge().

static const char** rpmdsDupArgv | ( | const char ** | argv,
|  | int | argc |
| ) |  |  | `[static]`

Definition at line 208 of file rpmds.c.

References stpcpy(), and xmalloc().

Referenced by rpmdsDup(), rpmdsMerge(), and rpmdsNew().

static int rpmdsNAcmp | ( | rpmds | A,
|  | rpmds | B |
| ) |  |  | `[static]`

Definition at line 3518 of file rpmds.c.

Referenced by rpmdsCompare().

static void rpmdsNSAdd | ( | rpmds * | dsp,
|  | const char * | NS,
|  | const char * | N,
|  | const char * | EVR,
|  | evrFlags | Flags |
| ) |  |  | `[static]`

Merge a single provides, wrapping N as "NS(N)".

Return values:

  | *dsp | (loaded) dependency set

Parameters:

  | NS | dependency name space
  | N | name
  | EVR | epoch:version-release
  | Flags | comparison/context flags

Definition at line 1194 of file rpmds.c.

References alloca(), rpmdsFree(), rpmdsMerge(), rpmdsSingle(), RPMTAG_PROVIDENAME, and stpcpy().

Referenced by rpmdsCpuinfo(), rpmdsGetconf(), and rpmdsUname().

void* rpmdsSetEVRparse | ( | rpmds | ds,
|  | int(*)(const char *evrstr, EVR_t evr) | EVRparse |
| ) |  |  |

Definition at line 745 of file rpmds.c.

static int rpmdsSysinfoFile | ( | rpmPRCO | PRCO,
|  | const char * | fn,
|  | int | tagN |
| ) |  |  | `[static]`

Merge contents of a sysinfo tag file into sysinfo dependencies.

Return values:

  | *PRCO | provides/requires/conflicts/obsoletes depedency set(s)

Parameters:

  | fn | path to file
  | tagN | dependency set tag

Returns:
  0 on success

Definition at line 1428 of file rpmds.c.

References _, _isspace, Fclose(), fdGetFILE, Ferror(), Fopen(), rpmdsFree(), rpmdsMergePRCO(), rpmdsSingle(), rpmEVRflags(), RPMTAG_DIRNAMES, RPMTAG_FILELINKTOS, RPMTAG_PROVIDENAME, and xisalnum().

Referenced by rpmdsSysinfo().

int rpmdsUname | ( | rpmds * | dsp,
|  | const struct utsname * | un |
| ) |  |  |

Definition at line 3342 of file rpmds.c.

References rpmdsNSAdd(), and RPMSENSE_EQUAL.

Referenced by main(), rpmds_Uname(), rpmShowRC(), and unsatisfiedDepend().

rpmds XrpmdsLink | ( | rpmds | ds,
|  | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln |
| ) |  |  |

Todo:
  Remove debugging entry from the ABI.

Definition at line 126 of file rpmds.c.

rpmds XrpmdsUnlink | ( | rpmds | ds,
|  | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln |
| ) |  |  |

Todo:
  Remove debugging entry from the ABI.

Definition at line 115 of file rpmds.c.

## Variable Documentation

const char* _cpuinfo_path = NULL`[static]`

Definition at line 1215 of file rpmds.c.

const char* _getconf_path = NULL`[static]`

Definition at line 2519 of file rpmds.c.

const char* _ldconfig_cache = NULL`[static]`

Definition at line 3038 of file rpmds.c.

const char* _ldconfig_cmd = "/sbin/ldconfig -p"`[static]`

Definition at line 3034 of file rpmds.c.

int _noisy_range_comparison_debug_message = 0`[static]`

Enable noisy range comparison debugging message?

Definition at line 102 of file rpmds.c.

const char* _perldeps_cmd = NULL`[static]`

Definition at line 3384 of file rpmds.c.

int _rpmds_unspecified_epoch_noise = 0

Definition at line 112 of file rpmds.c.

Referenced by showVerifyPackage().

const char* _sysinfo_tags[]`[static]`

Initial value:

     {
        "Providename",
        "Requirename",
        "Conflictname",
        "Obsoletename",
        "Dirnames",
        "Filelinktos",
        NULL
    }

Definition at line 1553 of file rpmds.c.

struct cpuinfo_s ctags[]`[static]`

Initial value:

     {
        { "processor",      0,  0 },
        { "vendor_id",      0,  0 },
        { "cpu_family",     0,  1 },
        { "model",          0,  1 },
        { "model_name",     0,  0 },
        { "stepping",       0,  1 },
        { "cpu_MHz",        0,  1 },
        { "cache_size",     0,  1 },
        { "physical_id",    0,  0 },
        { "siblings",       0,  0 },
        { "core_id",        0,  0 },
        { "cpu_cores",      0,  0 },
        { "fdiv_bug",       0,  3 },
        { "hlt_bug",        0,  3 },
        { "f00f_bug",       0,  3 },
        { "coma_bug",       0,  3 },
        { "fpu",            0,  0 },
        { "fpu_exception",  0,  3 },
        { "cpuid_level",    0,  0 },
        { "wp",             0,  3 },
        { "flags",          0,  4 },
        { "bogomips",       0,  1 },
        { NULL,             0, -1 }
    }

Definition at line 1136 of file rpmds.c.

struct rpmlibProvides_s rpmlibProvides[]`[static]`

Definition at line 1347 of file rpmds.c.

struct conf vars[]`[static]`

Definition at line 1629 of file rpmds.c.