rpm  4.5
Data Structures | Macros | Typedefs | Functions | Variables
rpmrc.c File Reference
#include "system.h"
#include <stdarg.h>
#include "rpmio_internal.h"
#include <rpmcli.h>
#include <rpmmacro.h>
#include <rpmlua.h>
#include <rpmds.h>
#include <mire.h>
#include "misc.h"
#include "debug.h"
Include dependency graph for rpmrc.c:

Go to the source code of this file.

Data Structures

struct  machCacheEntry_s
 
struct  machCache_s
 
struct  machEquivInfo_s
 
struct  machEquivTable_s
 
struct  rpmvarValue
 
struct  rpmOption
 
struct  defaultEntry_s
 
struct  canonEntry_s
 
struct  tableType_s
 
struct  cpu_vendor_os_gnu
 

Macros

#define __power_pc()   0
 
#define _MIRE_INTERNAL
 
#define RPMVAR_OPTFLAGS   3
 
#define RPMVAR_INCLUDE   43
 
#define RPMVAR_MACROFILES   49
 
#define RPMVAR_NUM   55 /* number of RPMVAR entries */
 
#define OS   0
 
#define ARCH   1
 
#define _TOPDIRMACRO   "%{_topdir}/"
 

Typedefs

typedef const char * cptr_t
 
typedef struct machCacheEntry_smachCacheEntry
 
typedef struct machCache_smachCache
 
typedef struct machEquivInfo_smachEquivInfo
 
typedef struct machEquivTable_smachEquivTable
 
typedef struct defaultEntry_sdefaultEntry
 
typedef struct canonEntry_scanonEntry
 
typedef struct tableType_stableType
 
typedef struct cpu_vendor_os_gnuCVOG_t
 

Functions

static void rpmRebuildTargetVars (const char **target, const char **canontarget)
 
static int optionCompare (const void *a, const void *b)
 
static machCacheEntry machCacheFindEntry (const machCache cache, const char *key)
 
static int machCompatCacheAdd (char *name, const char *fn, int linenum, machCache cache)
 
static machEquivInfo machEquivSearch (const machEquivTable table, const char *name)
 
static void machAddEquiv (machEquivTable table, const char *name, int distance)
 
static void machCacheEntryVisit (machCache cache, machEquivTable table, const char *name, int distance)
 
static void rebuildCompatTables (int type, const char *name)
 
static int addCanon (canonEntry *table, int *tableLen, char *line, const char *fn, int lineNum)
 
static int addDefault (defaultEntry *table, int *tableLen, char *line, const char *fn, int lineNum)
 
static canonEntry lookupInCanonTable (const char *name, const canonEntry table, int tableLen)
 
static const char * lookupInDefaultTable (const char *name, const defaultEntry table, int tableLen)
 
static const char * rpmGetVarArch (int var, const char *arch)
 
static void freeRpmVar (struct rpmvarValue *orig)
 
static void rpmSetVar (int var, const char *val)
 Set value of an rpmrc variable. More...
 
static void setVarDefault (int var, const char *macroname, const char *val, const char *body)
 
static void setPathDefault (int var, const char *macroname, const char *subdir)
 
static void setDefaults (void)
 
static void rpmSetVarArch (int var, const char *val, const char *arch)
 
static int doReadRC (FD_t fd, const char *urlfn)
 
static int parseCVOG (const char *str, CVOG_t *cvogp)
 
static void * mireFreeAll (miRE mire, int nre)
 Destroy platform patterns. More...
 
int mireAppend (rpmMireMode mode, int tag, const char *pattern, miRE *mi_rep, int *mi_nrep)
 Append pattern to array. More...
 
static int rpmPlatform (const char *platform)
 Read and configure /etc/rpm/platform patterns. More...
 
int rpmPlatformScore (const char *platform, void *mi_re, int mi_nre)
 Return score of a platform string. More...
 
static void defaultMachine (const char **arch, const char **os)
 
void rpmSetTables (int archTable, int osTable)
 
int rpmMachineScore (int type, const char *name)
 
void rpmGetMachine (const char **arch, const char **os)
 
void rpmSetMachine (const char *arch, const char *os)
 Set current arch/os names. More...
 
static void getMachineInfo (int type, const char **name, int *num)
 
void rpmGetArchInfo (const char **name, int *num)
 
void rpmGetOsInfo (const char **name, int *num)
 
void rpmFreeRpmrc (void)
 Destroy rpmrc arch/os compatibility tables. More...
 
static int rpmReadRC (const char *rcfiles)
 Read rpmrc (and macro) configuration file(s). More...
 
int rpmReadConfigFiles (const char *file, const char *target)
 Read macro configuration file(s) for a target. More...
 
int rpmShowRC (FILE *fp)
 Display current rpmrc (and macro) configuration. More...
 

Variables

const char * rpmRcfiles = RPMRCFILES
 The default rpmrc files to be read. More...
 
static const char * configTarget = NULL
 
static const char * platform = "/etc/rpm/platform"
 
void * platpat = NULL
 
int nplatpat = 0
 
static struct tableType_s tables [4]
 
static struct rpmOption optionTable []
 
static int optionTableSize = sizeof(optionTable) / sizeof(*optionTable)
 
static cptr_t current [2]
 
static int currTables [2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH }
 
static struct rpmvarValue values [55]
 
static int defaultsInitialized = 0
 
static const char * ___build_pre
 

Macro Definition Documentation

#define __power_pc ( )    0

Definition at line 12 of file rpmrc.c.

Referenced by defaultMachine().

#define _MIRE_INTERNAL

Definition at line 21 of file rpmrc.c.

#define _TOPDIRMACRO   "%{_topdir}/"

Referenced by setPathDefault().

#define ARCH   1
#define OS   0
#define RPMVAR_INCLUDE   43

Definition at line 121 of file rpmrc.c.

Referenced by doReadRC().

#define RPMVAR_MACROFILES   49

Definition at line 122 of file rpmrc.c.

Referenced by doReadRC(), and rpmReadRC().

#define RPMVAR_NUM   55 /* number of RPMVAR entries */

Definition at line 124 of file rpmrc.c.

Referenced by rpmFreeRpmrc().

#define RPMVAR_OPTFLAGS   3

Definition at line 120 of file rpmrc.c.

Referenced by rpmRebuildTargetVars(), and setDefaults().

Typedef Documentation

typedef struct canonEntry_s * canonEntry
typedef const char* cptr_t

Definition at line 40 of file rpmrc.c.

typedef struct cpu_vendor_os_gnu * CVOG_t
typedef struct defaultEntry_s * defaultEntry
typedef struct machCache_s * machCache
typedef struct machCacheEntry_s * machCacheEntry
typedef struct machEquivInfo_s * machEquivInfo
typedef struct machEquivTable_s * machEquivTable
typedef struct tableType_s * tableType

Function Documentation

static int addCanon ( canonEntry table,
int *  tableLen,
char *  line,
const char *  fn,
int  lineNum 
)
static
static int addDefault ( defaultEntry table,
int *  tableLen,
char *  line,
const char *  fn,
int  lineNum 
)
static

Definition at line 393 of file rpmrc.c.

References _, defaultEntry_s::defName, defaultEntry_s::name, RPMERR_RPMRC, rpmError, xrealloc(), and xstrdup().

Referenced by doReadRC().

static void defaultMachine ( const char **  arch,
const char **  os 
)
static
static int doReadRC ( FD_t  fd,
const char *  urlfn 
)
static
static void freeRpmVar ( struct rpmvarValue orig)
static

Definition at line 481 of file rpmrc.c.

References _free(), rpmvarValue::arch, next, rpmvarValue::next, and rpmvarValue::value.

Referenced by rpmSetVar().

static void getMachineInfo ( int  type,
const char **  name,
int *  num 
)
static
static canonEntry lookupInCanonTable ( const char *  name,
const canonEntry  table,
int  tableLen 
)
static

Definition at line 428 of file rpmrc.c.

Referenced by defaultMachine(), and getMachineInfo().

static const char* lookupInDefaultTable ( const char *  name,
const defaultEntry  table,
int  tableLen 
)
static

Definition at line 445 of file rpmrc.c.

References defaultEntry_s::defName, and name.

Referenced by rpmSetMachine().

static void machAddEquiv ( machEquivTable  table,
const char *  name,
int  distance 
)
static
static void machCacheEntryVisit ( machCache  cache,
machEquivTable  table,
const char *  name,
int  distance 
)
static
static machCacheEntry machCacheFindEntry ( const machCache  cache,
const char *  key 
)
static

Definition at line 165 of file rpmrc.c.

References machCache_s::cache, machCacheEntry_s::name, and machCache_s::size.

Referenced by machCacheEntryVisit(), and machCompatCacheAdd().

static int machCompatCacheAdd ( char *  name,
const char *  fn,
int  linenum,
machCache  cache 
)
static
static machEquivInfo machEquivSearch ( const machEquivTable  table,
const char *  name 
)
static
int mireAppend ( rpmMireMode  mode,
int  tag,
const char *  pattern,
miRE *  mi_rep,
int *  mi_nrep 
)

Append pattern to array.

Parameters
modetype of pattern match
tagidentifier (like an rpmTag)
patternpattern to compile
Return values
*mi_repplatform pattern array
*mi_nrepno. of patterns in array

Definition at line 962 of file rpmrc.c.

References xrealloc().

Referenced by rpmPlatform().

static void* mireFreeAll ( miRE  mire,
int  nre 
)
static

Destroy platform patterns.

Parameters
mireplatform pattern array
nreno of patterns in array
Returns
NULL always

Definition at line 941 of file rpmrc.c.

References _free().

Referenced by rpmFreeRpmrc(), and rpmPlatform().

static int optionCompare ( const void *  a,
const void *  b 
)
static

Definition at line 157 of file rpmrc.c.

References name, and xstrcasecmp().

Referenced by doReadRC().

static int parseCVOG ( const char *  str,
CVOG_t cvogp 
)
static
static void rebuildCompatTables ( int  type,
const char *  name 
)
static
void rpmGetMachine ( const char **  arch,
const char **  os 
)

Definition at line 1640 of file rpmrc.c.

References ARCH, and OS.

static const char* rpmGetVarArch ( int  var,
const char *  arch 
)
static
static int rpmPlatform ( const char *  platform)
static

Read and configure /etc/rpm/platform patterns.

Parameters
platformpath to platform patterns
Returns
0 on success

Definition at line 985 of file rpmrc.c.

References _free(), addMacro(), cpu_vendor_os_gnu::cpu, cpu_vendor_os_gnu::gnu, mireAppend(), mireFreeAll(), nplatpat, cpu_vendor_os_gnu::os, parseCVOG(), platpat, rpmExpand(), rpmioSlurp(), cpu_vendor_os_gnu::str, cpu_vendor_os_gnu::vendor, and xisspace().

Referenced by defaultMachine().

static void rpmRebuildTargetVars ( const char **  target,
const char **  canontarget 
)
static
static void rpmSetVarArch ( int  var,
const char *  val,
const char *  arch 
)
static

Definition at line 615 of file rpmrc.c.

References _free(), rpmvarValue::arch, next, rpmvarValue::next, rpmvarValue::value, values, xmalloc(), and xstrdup().

Referenced by doReadRC().

static void setDefaults ( void  )
static

Definition at line 577 of file rpmrc.c.

References addMacro(), RMIL_DEFAULT, RPMVAR_OPTFLAGS, setPathDefault(), and setVarDefault().

Referenced by rpmReadRC().

static void setPathDefault ( int  var,
const char *  macroname,
const char *  subdir 
)
static

Definition at line 526 of file rpmrc.c.

References _free(), _TOPDIRMACRO, addMacro(), alloca(), body(), RMIL_DEFAULT, rpmGetPath(), rpmGetVarArch(), and rpmSetVar().

Referenced by setDefaults().

static void setVarDefault ( int  var,
const char *  macroname,
const char *  val,
const char *  body 
)
static

Definition at line 512 of file rpmrc.c.

References addMacro(), RMIL_DEFAULT, rpmGetVarArch(), and rpmSetVar().

Referenced by setDefaults().

Variable Documentation

const char* ___build_pre
static
Initial value:
= "\n\
RPM_SOURCE_DIR=\"%{_sourcedir}\"\n\
RPM_BUILD_DIR=\"%{_builddir}\"\n\
RPM_OPT_FLAGS=\"%{optflags}\"\n\
RPM_ARCH=\"%{_arch}\"\n\
RPM_OS=\"%{_os}\"\n\
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\n\
RPM_DOC_DIR=\"%{_docdir}\"\n\
export RPM_DOC_DIR\n\
RPM_PACKAGE_NAME=\"%{name}\"\n\
RPM_PACKAGE_VERSION=\"%{version}\"\n\
RPM_PACKAGE_RELEASE=\"%{release}\"\n\
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\n\
%{?buildroot:RPM_BUILD_ROOT=\"%{buildroot}\"\n\
export RPM_BUILD_ROOT\n}\
"

Definition at line 560 of file rpmrc.c.

const char* configTarget = NULL
static

Definition at line 31 of file rpmrc.c.

Referenced by defaultMachine(), and rpmReadConfigFiles().

cptr_t current[2]
static

Definition at line 140 of file rpmrc.c.

int currTables[2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH }
static

Definition at line 143 of file rpmrc.c.

int defaultsInitialized = 0
static

Definition at line 149 of file rpmrc.c.

int nplatpat = 0

Definition at line 38 of file rpmrc.c.

Referenced by rpmFreeRpmrc(), rpmPlatform(), rpmPlatformScore(), and rpmtsAddInstallElement().

struct rpmOption optionTable[]
static
Initial value:
= {
{ "include", 43 , 0, 1, 0, 2 },
{ "macrofiles", 49 , 0, 0, 0, 1 },
{ "optflags", 3 , 1, 0, 1, 0 },
}

Definition at line 126 of file rpmrc.c.

int optionTableSize = sizeof(optionTable) / sizeof(*optionTable)
static

Definition at line 134 of file rpmrc.c.

Referenced by doReadRC(), and rpmShowRC().

const char* platform = "/etc/rpm/platform"
static

Definition at line 34 of file rpmrc.c.

Referenced by archScore(), defaultMachine(), parseSpec(), platformScore(), and rpmtsAddInstallElement().

void* platpat = NULL

Definition at line 36 of file rpmrc.c.

Referenced by rpmFreeRpmrc(), rpmPlatform(), rpmPlatformScore(), and rpmtsAddInstallElement().

struct tableType_s tables[4]
static
Initial value:
= {
{ "arch", 1, 0 },
{ "os", 1, 0 },
{ "buildarch", 0, 1 },
{ "buildos", 0, 1 }
}

Definition at line 110 of file rpmrc.c.

struct rpmvarValue values[55]
static

Definition at line 146 of file rpmrc.c.

Referenced by rpmFreeRpmrc(), rpmGetVarArch(), rpmSetVar(), and rpmSetVarArch().