rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
rpmrc.c File Reference
`#include "system.h"`
`#include <stdarg.h>`
`#include <rpmio.h>`
`#include <rpmcb.h>`
`#include <mire.h>`
`#include <argv.h>`
`#include <rpmlua.h>`
`#include <rpmluaext.h>`
`#include <rpmmacro.h>`
`#include <rpmtypes.h>`
`#include <rpmtag.h>`
`#include <rpmevr.h>`
`#include <rpmds.h>`
`#include <rpmcli.h>`
`#include <rpmsyck.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 | defaultEntry_s
struct | canonEntry_s
struct | tableType_s
struct | cpu_vendor_os_gnu

## Macros
#define | __power_pc() 0
#define | _RPMIOB_INTERNAL /* XXX for rpmiobSlurp */
#define | _MIRE_INTERNAL
#define | _RPMEVR_INTERNAL
#define | _RPMDS_INTERNAL
#define | RPM_MACHTABLE_COUNT 4
#define | OS 0
#define | ARCH 1
#define | _TOPDIRMACRO "%{_topdir}/"

## Typedefs
typedef const char * | cptr_t
typedef struct machCacheEntry_s * | machCacheEntry
typedef struct machCache_s * | machCache
typedef struct machEquivInfo_s * | machEquivInfo
typedef struct machEquivTable_s * | machEquivTable
typedef struct defaultEntry_s * | defaultEntry
typedef struct canonEntry_s * | canonEntry
typedef struct tableType_s * | tableType
typedef struct cpu_vendor_os_gnu * | CVOG_t

## Enumerations
enum | rpm_machtable_e { RPM_MACHTABLE_INSTARCH = 0, RPM_MACHTABLE_INSTOS = 1, RPM_MACHTABLE_BUILDARCH = 2, RPM_MACHTABLE_BUILDOS = 3 }
| Build and install arch/os table identifiers. More...

## Functions
static void | rpmRebuildTargetVars (const char **target, const char **canontarget)
static machCacheEntry | machCacheFindEntry (const machCache cache, const char *key)
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 canonEntry | lookupInCanonTable (const char *name, const canonEntry table, int tableLen)
static const char * | lookupInDefaultTable (const char *name, const defaultEntry table, int tableLen)
static void | addMacroDefault (const char *macroname, const char *val, const char *body)
static void | setPathDefault (const char *macroname, const char *subdir)
static void | setDefaults (void)
static int | parseCVOG (const char *str, CVOG_t *cvogp)
static rpmRC | rpmPlatform (const char *platform)
| Read and configure /etc/rpm/platform patterns. More...
int | rpmPlatformScore (const char *platform, void *mi_re, int mi_nre)
static void | defaultMachine (const char **arch, const char **os)
static void | rpmSetTables (int archTable, int osTable)
static void | rpmSetMachine (const char *arch, const char *os)
static void | getMachineInfo (int type, const char **name, int *num)
void | rpmFreeRpmrc (void)
static int | rpmReadRC (const char *macrofiles)
| Read macro configuration file(s). More...
int | rpmReadConfigFiles (const char *file, const char *target)
int | rpmShowRC (FILE *fp)

## Variables
static const char * | configTarget = NULL
static const char * | platform = SYSCONFIGDIR "/platform"
void * | platpat = NULL
int | nplatpat = 0
rpmds | cpuinfoP
static struct tableType_s | tables [4]
static cptr_t | current [2]
static int | currTables [2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH }
static int | defaultsInitialized = 0
static const char * | ___build_pre

## Macro Definition Documentation

#define __power_pc | ( |  | ) | 0

Definition at line 8 of file rpmrc.c.

#define _MIRE_INTERNAL

Definition at line 14 of file rpmrc.c.

#define _RPMDS_INTERNAL

Definition at line 26 of file rpmrc.c.

#define _RPMEVR_INTERNAL

Definition at line 23 of file rpmrc.c.

#define _RPMIOB_INTERNAL /* XXX for rpmiobSlurp */

Definition at line 11 of file rpmrc.c.

#define _TOPDIRMACRO "%{_topdir}/"

Referenced by setPathDefault().

#define ARCH 1

Definition at line 127 of file rpmrc.c.

Referenced by getMachineInfo(), rpmFreeRpmrc(), rpmRebuildTargetVars(), rpmSetMachine(), rpmSetTables(), and rpmShowRC().

#define OS 0

Definition at line 126 of file rpmrc.c.

Referenced by rpmFreeRpmrc(), rpmRebuildTargetVars(), rpmSetMachine(), rpmSetTables(), and rpmShowRC().

#define RPM_MACHTABLE_COUNT 4

No. of arch/os tables.

Definition at line 63 of file rpmrc.c.

Referenced by rpmFreeRpmrc().

## Typedef Documentation

typedef struct canonEntry_s * canonEntry

typedef const char* cptr_t

Definition at line 65 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 void addMacroDefault | ( | const char * | macroname,
|  | const char * | val,
|  | const char * | body
| ) |  |
| static

Definition at line 266 of file rpmrc.c.

References addMacro(), and RMIL_DEFAULT.

Referenced by setDefaults().

static void defaultMachine | ( | const char ** | arch,
|  | const char ** | os
| ) |  |
| static

Definition at line 665 of file rpmrc.c.

References _free(), configTarget, cpu_vendor_os_gnu::cpu, cpu_vendor_os_gnu::os, parseCVOG(), platform, rpmExpand(), rpmGetPath(), rpmPlatform(), RPMRC_OK, and cpu_vendor_os_gnu::str.

Referenced by rpmRebuildTargetVars(), rpmSetMachine(), and rpmSetTables().

static void getMachineInfo | ( | int | type,
|  | const char ** | name,
|  | int * | num
| ) |  |
| static

Definition at line 869 of file rpmrc.c.

References _free(), ARCH, argvCount(), argvFree(), argvSplit(), current, currTables, lookupInCanonTable(), name, nplatpat, canonEntry_s::num, platpat, rpmExpand(), rpmPlatformScore(), and canonEntry_s::short_name.

Referenced by rpmRebuildTargetVars().

static canonEntry lookupInCanonTable | ( | const char * | name,
|  | const canonEntry | table,
|  | int | tableLen
| ) |  |
| static

Definition at line 236 of file rpmrc.c.

Referenced by getMachineInfo().

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

Definition at line 253 of file rpmrc.c.

References defaultEntry_s::defName, and name.

Referenced by rpmSetMachine().

static void machAddEquiv | ( | machEquivTable | table,
|  | const char * | name,
|  | int | distance
| ) |  |
| static

Definition at line 156 of file rpmrc.c.

References machEquivTable_s::count, tableType_s::equiv, machEquivTable_s::list, machEquivInfo_s::name, machEquivInfo_s::score, xmalloc(), xrealloc(), xstrcasecmp(), and xstrdup().

Referenced by machCacheEntryVisit(), and rebuildCompatTables().

static void machCacheEntryVisit | ( | machCache | cache,
|  | machEquivTable | table,
|  | const char * | name,
|  | int | distance
| ) |  |
| static

Definition at line 184 of file rpmrc.c.

References machCacheEntry_s::count, machCacheEntry_s::equivs, machAddEquiv(), machCacheFindEntry(), and machCacheEntry_s::visited.

Referenced by rebuildCompatTables().

static machCacheEntry machCacheFindEntry | ( | const machCache | cache,
|  | const char * | key
| ) |  |
| static

Definition at line 145 of file rpmrc.c.

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

Referenced by machCacheEntryVisit().

static int parseCVOG | ( | const char * | str,
|  | CVOG_t * | cvogp
| ) |  |
| static

Definition at line 374 of file rpmrc.c.

References _free(), cpu_vendor_os_gnu::cpu, cpu_vendor_os_gnu::gnu, cpu_vendor_os_gnu::os, cpu_vendor_os_gnu::str, cpu_vendor_os_gnu::vendor, xcalloc(), and xstrdup().

Referenced by defaultMachine(), and rpmPlatform().

static void rebuildCompatTables | ( | int | type,
|  | const char * | name
| ) |  |
| static

Definition at line 205 of file rpmrc.c.

References _free(), machCache_s::cache, tableType_s::cache, machEquivTable_s::count, currTables, tableType_s::equiv, tableType_s::key, machEquivTable_s::list, machAddEquiv(), machCacheEntryVisit(), name, machEquivInfo_s::name, machCache_s::size, and machCacheEntry_s::visited.

Referenced by rpmSetMachine(), and rpmSetTables().

void rpmFreeRpmrc | ( | void |  | ) |

< No. of arch/os tables.

Definition at line 1000 of file rpmrc.c.

References _free(), ARCH, machCache_s::cache, tableType_s::cache, tableType_s::canons, tableType_s::canonsLength, machCacheEntry_s::count, machEquivTable_s::count, current, tableType_s::defaults, defaultsInitialized, tableType_s::defaultsLength, defaultEntry_s::defName, tableType_s::equiv, machCacheEntry_s::equivs, machEquivTable_s::list, mireFreeAll(), machCacheEntry_s::name, machEquivInfo_s::name, defaultEntry_s::name, canonEntry_s::name, nplatpat, OS, platpat, RPM_MACHTABLE_COUNT, canonEntry_s::short_name, and machCache_s::size.

Referenced by main(), rpmcliFini(), and rpmspecQuery().

static rpmRC rpmPlatform | ( | const char * | platform | ) |
| static

Read and configure /etc/rpm/platform patterns.

Parameters

  platform | path to platform patterns

Returns
  RPMRC_OK on success

Definition at line 431 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(), rpmiobFree(), rpmiobSlurp(), RPMMIRE_REGEX, RPMMIRE_STRCMP, RPMRC_FAIL, RPMRC_OK, cpu_vendor_os_gnu::str, cpu_vendor_os_gnu::vendor, and xisspace().

Referenced by defaultMachine().

int rpmPlatformScore | ( | const char * | platform,
|  | void * | mi_re,
|  | int | mi_nre
| ) |  |

Definition at line 644 of file rpmrc.c.

References mireRegexec(), nplatpat, and platpat.

Referenced by archScore(), getMachineInfo(), platformScore(), and rpmtsAddInstallElement().

int rpmReadConfigFiles | ( | const char * | file,
|  | const char * | target
| ) |  |

Definition at line 1091 of file rpmrc.c.

References _free(), configTarget, rpmExpand(), rpmluaGetGlobalState(), rpmluaGetPrintBuffer(), rpmMacrofiles, rpmReadRC(), rpmRebuildTargetVars(), and rpmSetMachine().

Referenced by init_rpm(), main(), rpmcliConfigured(), and rpmspecQuery().

static void rpmRebuildTargetVars | ( | const char ** | target,
|  | const char ** | canontarget
| ) |  |
| static

Definition at line 913 of file rpmrc.c.

References _free(), addMacro(), ARCH, defaultMachine(), delMacro(), getMachineInfo(), OS, RMIL_RPMRC, RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS, RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS, rpmSetMachine(), rpmSetTables(), xmalloc(), xstrcasecmp(), xstrdup(), and xtolower().

Referenced by rpmReadConfigFiles().

static void rpmSetMachine | ( | const char * | arch,
|  | const char * | os
| ) |  |
| static

Definition at line 828 of file rpmrc.c.

References _free(), ARCH, current, currTables, defaultMachine(), lookupInDefaultTable(), OS, rebuildCompatTables(), and xstrdup().

Referenced by rpmReadConfigFiles(), and rpmRebuildTargetVars().

int rpmShowRC | ( | FILE * | fp | ) |

Definition at line 1141 of file rpmrc.c.

References _, _free(), _sysinfo_path, ARCH, machEquivTable_s::count, cpuinfoP, current, tableType_s::equiv, machEquivTable_s::list, machEquivInfo_s::name, nplatpat, OS, platpat, RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS, RPM_MACHTABLE_INSTOS, rpmdsCpuinfo(), rpmdsDNEVR(), rpmdsFree(), rpmdsFreePRCO(), rpmdsFromPRCO(), rpmdsGetconf(), rpmdsInit(), rpmdsNewPRCO(), rpmdsNext(), rpmdsRpmlib(), rpmdsSysinfo(), rpmdsUname(), rpmDumpMacroTable(), rpmExpand(), rpmIsDebug, rpmIsVerbose, rpmluaFiles, rpmluaPath, rpmMacrofiles, and RPMTAG_PROVIDENAME.

Referenced by rpmcliAllArgCallback().

static void setDefaults | ( | void |  | ) |
| static

Definition at line 315 of file rpmrc.c.

References ___build_pre, addMacro(), addMacroDefault(), RMIL_DEFAULT, setPathDefault(), USRPREFIX, and VARPREFIX.

Referenced by rpmReadRC().

static void setPathDefault | ( | const char * | macroname,
|  | const char * | subdir
| ) |  |
| static

Definition at line 276 of file rpmrc.c.

References _TOPDIRMACRO, addMacro(), alloca(), and RMIL_DEFAULT.

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 291 of file rpmrc.c.

Referenced by setDefaults().

const char* configTarget = NULL
| static

Definition at line 38 of file rpmrc.c.

Referenced by defaultMachine(), and rpmReadConfigFiles().

rpmds cpuinfoP

Definition at line 824 of file depends.c.

Referenced by rpmShowRC().

cptr_t current[2]
| static

Definition at line 130 of file rpmrc.c.

Referenced by getMachineInfo(), rpmFreeRpmrc(), rpmSetMachine(), and rpmShowRC().

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

Definition at line 133 of file rpmrc.c.

Referenced by getMachineInfo(), rebuildCompatTables(), rpmSetMachine(), and rpmSetTables().

int defaultsInitialized = 0
| static

Definition at line 136 of file rpmrc.c.

Referenced by rpmFreeRpmrc(), and rpmReadRC().

int nplatpat = 0

Definition at line 46 of file rpmrc.c.

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

const char* platform = SYSCONFIGDIR "/platform"
| static

Definition at line 41 of file rpmrc.c.

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

void* platpat = NULL

Definition at line 44 of file rpmrc.c.

Referenced by getMachineInfo(), rpmFreeRpmrc(), rpmPlatform(), rpmPlatformScore(), rpmShowRC(), 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 118 of file rpmrc.c.