rpm  5.4.14
Data Structures | Macros | Typedefs | Functions | Variables
rpmfc.c File Reference
#include "system.h"
#include <signal.h>
#include <rpmio.h>
#include <rpmiotypes.h>
#include <rpmlog.h>
#include <rpmurl.h>
#include <rpmmg.h>
#include <argv.h>
#include <mire.h>
#include <rpmtag.h>
#include <rpmbuild.h>
#include <rpmns.h>
#include <rpmfc.h>
#include <rpmds.h>
#include <rpmfi.h>
#include "debug.h"
Include dependency graph for rpmfc.c:

Go to the source code of this file.

Data Structures

struct  rpmfcApplyTbl_s
 
struct  DepMsg_s
 

Macros

#define _MIRE_INTERNAL
 
#define _RPMEVR_INTERNAL
 
#define _RPMNS_INTERNAL
 
#define _RPMFC_INTERNAL
 
#define _RPMDS_INTERNAL
 
#define _suffix(_s, _x)   (slen >= sizeof(_x) && !strcmp((_s)+slen-(sizeof(_x)-1), (_x)))
 

Typedefs

typedef struct rpmfcApplyTbl_srpmfcApplyTbl
 
typedef struct DepMsg_sDepMsg_t
 

Functions

static int rpmfcExpandAppend (ARGV_t *argvp, const ARGV_t av)
 
static rpmiob getOutputFrom (const char *dir, ARGV_t argv, const char *writePtr, size_t writeBytesLeft, int failNonZero)
 Return output from helper script. More...
 
int rpmfcExec (ARGV_t av, rpmiob iob_stdin, rpmiob *iob_stdoutp, int failnonzero)
 
static int rpmfcSaveArg (ARGV_t *argvp, const char *key)
 
static char * rpmfcFileDep (char *buf, size_t ix, rpmds ds)
 
static voidrpmfcExpandRegexps (const char *str, int *nmirep)
 
static int rpmfcMatchRegexps (void *_mire, int nmire, const char *str, char deptype)
 
static voidrpmfcFreeRegexps (void *_mire, int nmire)
 
static int rpmfcHelper (rpmfc fc, unsigned char deptype, const char *nsdep)
 Run per-interpreter dependency helper. More...
 
int rpmfcColoring (const char *fmstr)
 Return file color given file(1) string. More...
 
void rpmfcPrint (const char *msg, rpmfc fc, FILE *fp)
 Print results of file classification. More...
 
static int rpmfcSCRIPT (rpmfc fc)
 Extract script dependencies. More...
 
static int rpmfcMergePR (void *context, rpmds ds)
 Merge provides/requires dependencies into a rpmfc container. More...
 
static int rpmfcELF (rpmfc fc)
 Extract Elf dependencies. More...
 
rpmRC rpmfcApply (rpmfc fc)
 Build file/package dependency dictionary and mappings. More...
 
rpmRC rpmfcClassify (rpmfc fc, ARGV_t argv, rpmuint16_t *fmode)
 
static void printDeps (Header h)
 Print dependencies in a header. More...
 
static rpmRC rpmfcGenerateDependsHelper (const Spec spec, Package pkg, rpmfi fi)
 
static int rpmfcGenerateScriptletDeps (const Spec spec, Package pkg)
 
static unsigned removeSillyDeps (Header h, rpmfc fc)
 
rpmRC rpmfcGenerateDepends (void *_spec, void *_pkg)
 Generate package dependencies. More...
 
static void rpmfcFini (void *_fc)
 
static rpmfc rpmfcGetPool (rpmioPool pool)
 
rpmfc rpmfcNew (void)
 Create a file classifier. More...
 

Variables

static int _filter_values = 1
 
static int _filter_execs = 1
 
static struct rpmfcTokens_s rpmfcTokens []
 
static struct rpmfcApplyTbl_s rpmfcApplyTable []
 XXX Having two entries for rpmfcSCRIPT may be unnecessary duplication. More...
 
static struct DepMsg_s depMsgs []
 
static DepMsg_t DepMsgs = depMsgs
 
static struct DepMsg_s scriptMsgs []
 
static DepMsg_t ScriptMsgs = scriptMsgs
 
rpmioPool _rpmfcPool = NULL
 

Macro Definition Documentation

#define _MIRE_INTERNAL

Definition at line 11 of file rpmfc.c.

#define _RPMDS_INTERNAL

Definition at line 24 of file rpmfc.c.

#define _RPMEVR_INTERNAL

Definition at line 15 of file rpmfc.c.

#define _RPMFC_INTERNAL

Definition at line 21 of file rpmfc.c.

#define _RPMNS_INTERNAL

Definition at line 18 of file rpmfc.c.

#define _suffix (   _s,
  _x 
)    (slen >= sizeof(_x) && !strcmp((_s)+slen-(sizeof(_x)-1), (_x)))

Referenced by rpmfcClassify().

Typedef Documentation

typedef struct DepMsg_s* DepMsg_t

Definition at line 1471 of file rpmfc.c.

typedef struct rpmfcApplyTbl_s * rpmfcApplyTbl

Function Documentation

static rpmiob getOutputFrom ( const char *  dir,
ARGV_t  argv,
const char *  writePtr,
size_t  writeBytesLeft,
int  failNonZero 
)
static

Return output from helper script.

Todo:
Use poll(2) rather than select(2), if available.
Parameters
dirdirectory to run in (or NULL)
argvprogram and arguments to run
writePtrbytes to feed to script on stdin (or NULL)
writeBytesLeftno. of bytes to feed to script on stdin
failNonZerois script failure an error?
Returns
buffered stdout from script, NULL on error

Definition at line 79 of file rpmfc.c.

References _, _free(), argv, argvJoin(), buf, Chdir(), D_, errno, exit, EXIT_FAILURE, NULL, rc, rpmiobAppend(), rpmiobFree(), rpmiobNew(), rpmlog(), RPMLOG_DEBUG, RPMLOG_ERR, status, unsetenv(), and void.

Referenced by rpmfcExec().

static void printDeps ( Header  h)
static

Print dependencies in a header.

Parameters
hheader

Definition at line 1536 of file rpmfc.c.

References ds, Flags, DepMsg_s::ftag, DepMsg_s::mask, DepMsg_s::msg, DepMsg_s::ntag, NULL, rpmdsDNEVR(), rpmdsFlags(), rpmdsFree(), rpmdsInit(), rpmdsNew(), rpmdsNext(), rpmlog(), RPMLOG_NOTICE, DepMsg_s::toggle, and void.

Referenced by rpmfcGenerateDepends().

static unsigned removeSillyDeps ( Header  h,
rpmfc  fc 
)
static
rpmRC rpmfcApply ( rpmfc  fc)
rpmRC rpmfcClassify ( rpmfc  fc,
ARGV_t  argv,
rpmuint16_t fmode 
)
int rpmfcColoring ( const char *  fmstr)

Return file color given file(1) string.

Parameters
fmstrfile(1) string
Returns
file color

Definition at line 679 of file rpmfc.c.

References NULL, RPMFC_BLACK, and RPMFC_INCLUDE.

Referenced by rpmfcClassify().

static int rpmfcELF ( rpmfc  fc)
static

Extract Elf dependencies.

Parameters
fcfile classifier
Returns
0 on success

Definition at line 1026 of file rpmfc.c.

References flags, fn, rpmdsELF(), RPMELF_FLAG_SKIPPROVIDES, RPMELF_FLAG_SKIPREQUIRES, and rpmfcMergePR().

int rpmfcExec ( ARGV_t  av,
rpmiob  iob_stdin,
rpmiob iob_stdoutp,
int  failnonzero 
)
static int rpmfcExpandAppend ( ARGV_t argvp,
const ARGV_t  av 
)
static

Definition at line 45 of file rpmfc.c.

References ac, argv, argvCount(), i, NULL, rpmExpand(), and xrealloc.

Referenced by rpmfcExec().

static void* rpmfcExpandRegexps ( const char *  str,
int nmirep 
)
static

Definition at line 334 of file rpmfc.c.

References _, _free(), ac, av, exit, i, mireAppend(), mireFree(), NULL, rpmExpand(), rpmlog(), RPMLOG_NOTICE, RPMMIRE_REGEX, s, and xx.

Referenced by rpmfcApply().

static char* rpmfcFileDep ( char *  buf,
size_t  ix,
rpmds  ds 
)
static
static void rpmfcFini ( void _fc)
static

Definition at line 2152 of file rpmfc.c.

References argiFree(), argvFree(), NULL, rpmdsFree(), rpmiobFree(), and void.

Referenced by rpmfcGetPool().

static void* rpmfcFreeRegexps ( void _mire,
int  nmire 
)
static

Definition at line 398 of file rpmfc.c.

References mireFreeAll().

Referenced by rpmfcApply().

rpmRC rpmfcGenerateDepends ( void _spec,
void _pkg 
)
static rpmRC rpmfcGenerateDependsHelper ( const Spec  spec,
Package  pkg,
rpmfi  fi 
)
static
static int rpmfcGenerateScriptletDeps ( const Spec  spec,
Package  pkg 
)
static
static rpmfc rpmfcGetPool ( rpmioPool  pool)
static

Definition at line 2181 of file rpmfc.c.

References _rpmfc_debug, _rpmfcPool, memset(), NULL, rpmfcFini(), rpmioGetPool(), and rpmioNewPool().

Referenced by rpmfcNew().

static int rpmfcHelper ( rpmfc  fc,
unsigned char  deptype,
const char *  nsdep 
)
static

Run per-interpreter dependency helper.

Parameters
fcfile classifier
deptype'P' == Provides:, 'R' == Requires:, helper
nsdepclass name for interpreter (e.g. "perl")
Returns
0 on success

Definition at line 414 of file rpmfc.c.

References _, argvCount(), argvFree(), argvSplit(), assert(), av, buf, ds, EVR, Flags, fn, i, if(), ix, N, NULL, rpmdsEVR(), rpmdsFlags(), rpmdsFree(), rpmdsMerge(), rpmdsSearch(), rpmdsSetIx(), rpmdsSingle(), rpmEVRcompare(), rpmEVRfree(), rpmEVRnew(), rpmEVRparse(), rpmfcExec(), rpmfcFileDep(), rpmfcMatchRegexps(), rpmfcSaveArg(), rpmiobAppend(), rpmiobFree(), rpmiobNew(), rpmiobStr(), rpmlog(), RPMLOG_ERR, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME, s, snprintf(), void, and xx.

Referenced by rpmfcSCRIPT().

static int rpmfcMatchRegexps ( void _mire,
int  nmire,
const char *  str,
char  deptype 
)
static

Definition at line 377 of file rpmfc.c.

References _, D_, i, mireRegexec(), rpmlog(), RPMLOG_DEBUG, RPMLOG_NOTICE, and xx.

Referenced by rpmfcHelper(), rpmfcMergePR(), and rpmfcSCRIPT().

static int rpmfcMergePR ( void context,
rpmds  ds 
)
static

Merge provides/requires dependencies into a rpmfc container.

Parameters
contextmerge dependency set(s) container
dsdependency set to merge
Returns
0 on success

Definition at line 977 of file rpmfc.c.

References _rpmfc_debug, buf, fprintf(), rc, rpmdsMerge(), rpmdsTagN(), rpmfcFileDep(), rpmfcMatchRegexps(), rpmfcSaveArg(), RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME, and tagName().

Referenced by rpmfcELF().

rpmfc rpmfcNew ( void  )

Create a file classifier.

Returns
new file classifier

Definition at line 2197 of file rpmfc.c.

References rpmfcGetPool(), rpmfcLink(), and xcalloc().

Referenced by main(), and rpmfcGenerateDepends().

void rpmfcPrint ( const char *  msg,
rpmfc  fc,
FILE *  fp 
)

Print results of file classification.

Todo:
Remove debugging routine.
Parameters
msgmessage prefix (NULL for none)
fcfile classifier
fpoutput file handle (NULL for stderr)

Definition at line 694 of file rpmfc.c.

References assert(), fprintf(), ix, NULL, rpmdsCount(), rpmdsDNEVR(), rpmdsNext(), rpmdsSetIx(), RPMFC_BLACK, and void.

Referenced by main(), and rpmfcGenerateDepends().

static int rpmfcSaveArg ( ARGV_t argvp,
const char *  key 
)
static

Definition at line 289 of file rpmfc.c.

References argvAdd(), argvSearch(), argvSort(), NULL, and rc.

Referenced by rpmfcClassify(), rpmfcHelper(), rpmfcMergePR(), and rpmfcSCRIPT().

static int rpmfcSCRIPT ( rpmfc  fc)
static

Variable Documentation

int _filter_execs = 1
static

Definition at line 41 of file rpmfc.c.

int _filter_values = 1
static

Definition at line 39 of file rpmfc.c.

rpmioPool _rpmfcPool = NULL

Definition at line 2179 of file rpmfc.c.

Referenced by rpmfcGetPool().

struct DepMsg_s depMsgs[]
static

Definition at line 1491 of file rpmfc.c.

DepMsg_t DepMsgs = depMsgs
static

Definition at line 1530 of file rpmfc.c.

struct rpmfcApplyTbl_s rpmfcApplyTable[]
static
Initial value:
= {
{ NULL, 0 }
}
static int rpmfcELF(rpmfc fc)
Extract Elf dependencies.
Definition: rpmfc.c:1026
static int rpmfcSCRIPT(rpmfc fc)
Extract script dependencies.
Definition: rpmfc.c:776
return NULL
Definition: poptALL.c:613
#define RPMFC_ELF
Definition: rpmfc.h:24

XXX Having two entries for rpmfcSCRIPT may be unnecessary duplication.

Definition at line 1082 of file rpmfc.c.

struct rpmfcTokens_s rpmfcTokens[]
static

Definition at line 572 of file rpmfc.c.

struct DepMsg_s scriptMsgs[]
static
Initial value:
= {
{ "Requires(pre)", { "%{?__scriptlet_requires}", NULL, NULL, NULL },
RPMSENSE_SCRIPT_PRE, 0 },
{ "Requires(post)", { "%{?__scriptlet_requires}", NULL, NULL, NULL },
RPMSENSE_SCRIPT_POST, 0 },
{ "Requires(preun)", { "%{?__scriptlet_requires}", NULL, NULL, NULL },
RPMSENSE_SCRIPT_PREUN, 0 },
{ "Requires(postun)", { "%{?__scriptlet_requires}", NULL, NULL, NULL },
RPMSENSE_SCRIPT_POSTUN, 0 },
{ NULL, { NULL, NULL, NULL, NULL }, (rpmTag)0, (rpmTag)0, (rpmTag)0, 0, 0 }
}
enum rpmTag_e rpmTag
Definition: rpmtag.h:468
return NULL
Definition: poptALL.c:613

Definition at line 1667 of file rpmfc.c.

DepMsg_t ScriptMsgs = scriptMsgs
static

Definition at line 1685 of file rpmfc.c.