rpm  4.5
Data Structures | Macros | Typedefs | Functions | Variables
rpmfc.c File Reference
#include "system.h"
#include <signal.h>
#include <rpmbuild.h>
#include <argv.h>
#include <rpmfc.h>
#include <rpmns.h>
#include <rpmds.h>
#include <rpmfi.h>
#include <rpmts.h>
#include <rpmdb.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 _RPMEVR_INTERNAL
 
#define _RPMFC_INTERNAL
 
#define _RPMNS_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 StringBuf getOutputFrom (const char *dir, ARGV_t argv, const char *writePtr, int writeBytesLeft, int failNonZero)
 Return output from helper script. More...
 
int rpmfcExec (ARGV_t av, StringBuf sb_stdin, StringBuf *sb_stdoutp, int failnonzero)
 Return helper output. More...
 
static int rpmfcSaveArg (ARGV_t *argvp, const char *key)
 
static char * rpmfcFileDep (char *buf, int ix, rpmds ds)
 
static regex_t * rpmfcExpandRegexps (const char *str, int *count)
 
static int rpmfcMatchRegexps (regex_t *regexps, int count, const char *str, char deptype)
 
static regex_t * rpmfcFreeRegexps (regex_t *regexps, int count)
 
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...
 
rpmfc rpmfcFree (rpmfc fc)
 Destroy a file classifier. More...
 
rpmfc rpmfcNew (void)
 Create a file classifier. 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 rpmfcMONO (rpmfc fc)
 Extract .NET dependencies. More...
 
static int rpmfcELF (rpmfc fc)
 Extract Elf dependencies. More...
 
static int rpmfcFindRequiredPackages (rpmfc fc)
 
int rpmfcApply (rpmfc fc)
 Build file/package dependency dictionary and mappings. More...
 
int rpmfcClassify (rpmfc fc, ARGV_t argv, int_16 *fmode)
 
static void printDeps (Header h)
 Print dependencies in a header. More...
 
static int rpmfcGenerateDependsHelper (const Spec spec, Package pkg, rpmfi fi)
 
static int rpmfcGenerateScriptletDeps (const Spec spec, Package pkg)
 
int rpmfcGenerateDepends (void *specp, void *pkgp)
 Generate package dependencies. More...
 

Variables

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
 

Macro Definition Documentation

#define _RPMDS_INTERNAL

Definition at line 15 of file rpmfc.c.

#define _RPMEVR_INTERNAL

Definition at line 5 of file rpmfc.c.

#define _RPMFC_INTERNAL

Definition at line 9 of file rpmfc.c.

#define _RPMNS_INTERNAL

Definition at line 12 of file rpmfc.c.

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

Referenced by rpmfcClassify(), and rpmInitMacros().

Typedef Documentation

typedef struct DepMsg_s* DepMsg_t

Definition at line 1445 of file rpmfc.c.

typedef struct rpmfcApplyTbl_s * rpmfcApplyTbl

Function Documentation

static void printDeps ( Header  h)
static

Print dependencies in a header.

Parameters
hheader

Definition at line 1508 of file rpmfc.c.

References DepMsg_s::ftag, DepMsg_s::mask, DepMsg_s::msg, DepMsg_s::ntag, rpmdsDNEVR(), rpmdsFlags(), rpmdsFree(), rpmdsInit(), rpmdsNew(), rpmdsNext(), RPMMESS_NORMAL, rpmMessage, and DepMsg_s::xor.

Referenced by rpmfcGenerateDepends().

int rpmfcApply ( rpmfc  fc)

Build file/package dependency dictionary and mappings.

Parameters
fcfile classifier
Returns
0 on success

Definition at line 1097 of file rpmfc.c.

References _, argiAdd(), argiCount(), argvCount(), rpmfcApplyTbl_s::colormask, rpmfcApplyTbl_s::func, rpmdsFind(), rpmdsFree(), rpmdsSingle(), rpmExpand(), RPMFC_PYTHON, rpmfcExpandRegexps(), rpmfcFindRequiredPackages(), rpmfcFreeRegexps(), RPMMESS_DEBUG, RPMMESS_NORMAL, rpmMessage, RPMTAG_PROVIDENAME, and RPMTAG_REQUIRENAME.

Referenced by main(), and rpmfcGenerateDepends().

int rpmfcClassify ( rpmfc  fc,
ARGV_t  argv,
int_16 fmode 
)
int rpmfcColoring ( const char *  fmstr)

Return file color given file(1) string.

Parameters
fmstrfile(1) string
Returns
file color

Definition at line 622 of file rpmfc.c.

References RPMFC_BLACK, RPMFC_INCLUDE, and rpmfcTokens.

Referenced by rpmfcClassify().

static int rpmfcELF ( rpmfc  fc)
static

Extract Elf dependencies.

Parameters
fcfile classifier
Returns
0 on success

Definition at line 961 of file rpmfc.c.

References rpmdsELF(), RPMELF_FLAG_SKIPPROVIDES, RPMELF_FLAG_SKIPREQUIRES, rpmfcHelper(), and rpmfcMergePR().

int rpmfcExec ( ARGV_t  av,
StringBuf  sb_stdin,
StringBuf sb_stdoutp,
int  failnonzero 
)

Return helper output.

Parameters
avhelper argv (with possible macros)
sb_stdinhelper input
Return values
*sb_stdoutphelper output
Parameters
failnonzeroIS non-zero helper exit status a failure?

Definition at line 209 of file rpmfc.c.

References _free(), argvAppend(), argvFree(), freeStringBuf(), getOutputFrom(), getStringBuf(), rpmExpand(), and rpmfcExpandAppend().

Referenced by checkFiles(), rpmfcGenerateDependsHelper(), rpmfcGenerateScriptletDeps(), and rpmfcHelper().

static int rpmfcExpandAppend ( ARGV_t argvp,
const ARGV_t  av 
)
static

Definition at line 27 of file rpmfc.c.

References argvCount(), rpmExpand(), and xrealloc().

Referenced by rpmfcExec().

static regex_t* rpmfcExpandRegexps ( const char *  str,
int *  count 
)
static

Definition at line 314 of file rpmfc.c.

References _, _free(), rpmExpand(), RPMMESS_NORMAL, and rpmMessage.

Referenced by rpmfcApply(), and rpmfcFindRequiredPackages().

static char* rpmfcFileDep ( char *  buf,
int  ix,
rpmds  ds 
)
static
static int rpmfcFindRequiredPackages ( rpmfc  fc)
static
rpmfc rpmfcFree ( rpmfc  fc)

Destroy a file classifier.

Parameters
fcfile classifier
Returns
NULL always

Definition at line 714 of file rpmfc.c.

References _free(), argiFree(), argvFree(), freeStringBuf(), and rpmdsFree().

Referenced by main(), and rpmfcGenerateDepends().

static regex_t* rpmfcFreeRegexps ( regex_t *  regexps,
int  count 
)
static

Definition at line 371 of file rpmfc.c.

References _free().

Referenced by rpmfcApply(), and rpmfcFindRequiredPackages().

int rpmfcGenerateDepends ( void *  specp,
void *  pkgp 
)
static int rpmfcGenerateDependsHelper ( const Spec  spec,
Package  pkg,
rpmfi  fi 
)
static
static int rpmfcGenerateScriptletDeps ( const Spec  spec,
Package  pkg 
)
static
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 387 of file rpmfc.c.

References _, appendLineStringBuf, argvCount(), argvFree(), argvSplit(), freeStringBuf(), getStringBuf(), newStringBuf(), rpmdsFree(), rpmdsMerge(), rpmdsSingle(), rpmfcExec(), rpmfcFileDep(), rpmfcMatchRegexps(), rpmfcSaveArg(), RPMMESS_ERROR, rpmMessage, RPMSENSE_EQUAL, RPMSENSE_GREATER, RPMSENSE_LESS, RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME, and snprintf().

Referenced by rpmfcELF(), rpmfcMONO(), and rpmfcSCRIPT().

static int rpmfcMatchRegexps ( regex_t *  regexps,
int  count,
const char *  str,
char  deptype 
)
static

Definition at line 356 of file rpmfc.c.

References _, RPMMESS_DEBUG, RPMMESS_NORMAL, and rpmMessage.

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 889 of file rpmfc.c.

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

Referenced by rpmfcELF().

static int rpmfcMONO ( rpmfc  fc)
static

Extract .NET dependencies.

Parameters
fcfile classifier
Returns
0 on success

Definition at line 934 of file rpmfc.c.

References rpmfcHelper().

rpmfc rpmfcNew ( void  )

Create a file classifier.

Returns
new file classifier

Definition at line 739 of file rpmfc.c.

References 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 637 of file rpmfc.c.

References rpmdsCount(), rpmdsDNEVR(), rpmdsNext(), rpmdsSetIx(), and RPMFC_BLACK.

Referenced by main(), and rpmfcGenerateDepends().

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

Definition at line 273 of file rpmfc.c.

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

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

static int rpmfcSCRIPT ( rpmfc  fc)
static

Extract script dependencies.

Parameters
fcfile classifier
Returns
0 on success

Definition at line 750 of file rpmfc.c.

References rpmdsFree(), rpmdsMerge(), rpmdsSingle(), RPMFC_BOURNE, RPMFC_DESKTOP_FILE, RPMFC_JAVA, RPMFC_LIBTOOL, RPMFC_MODULE, RPMFC_PERL, RPMFC_PHP, RPMFC_PKGCONFIG, RPMFC_PYTHON, rpmfcFileDep(), rpmfcHelper(), rpmfcMatchRegexps(), rpmfcSaveArg(), and RPMTAG_REQUIRENAME.

Variable Documentation

struct DepMsg_s depMsgs[]
static

Definition at line 1464 of file rpmfc.c.

DepMsg_t DepMsgs = depMsgs
static

Definition at line 1502 of file rpmfc.c.

struct rpmfcApplyTbl_s rpmfcApplyTable[]
static
Initial value:

XXX Having two entries for rpmfcSCRIPT may be unnecessary duplication.

Definition at line 987 of file rpmfc.c.

struct rpmfcTokens_s rpmfcTokens[]
static

Definition at line 518 of file rpmfc.c.

Referenced by rpmfcColoring().

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 }, 0, 0, 0, 0, 0 }
}

Definition at line 1637 of file rpmfc.c.

DepMsg_t ScriptMsgs = scriptMsgs
static

Definition at line 1654 of file rpmfc.c.