rpm  5.4.10
Macros | Functions | Variables
spec.c File Reference

Handle spec data structure. More...

#include "system.h"
#include <rpmio.h>
#include <rpmiotypes.h>
#include <rpmlog.h>
#include <rpmpgp.h>
#include "buildio.h"
#include "rpmds.h"
#include "rpmfi.h"
#include "rpmts.h"
#include "rpmlua.h"
#include "debug.h"
Include dependency graph for spec.c:

Go to the source code of this file.

Macros

#define SKIPWHITE(_x)   {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
 
#define SKIPNONWHITE(_x)   {while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}
 

Functions

static struct TriggerFileEntryfreeTriggerFiles (struct TriggerFileEntry *p)
 
static struct SourcefreeSources (struct Source *s)
 Destroy source component chain. More...
 
rpmRC lookupPackage (Spec spec, const char *name, int flag, Package *pkgp)
 Find sub-package control structure by name. More...
 
static void pkgFini (void *_pkg)
 
static Package pkgGetPool (rpmioPool pool)
 
Package newPackage (Spec spec)
 Create and initialize package control structure. More...
 
Package freePackages (Package packages)
 Destroy all packages associated with spec file. More...
 
static struct SourcefindSource (Spec spec, rpmuint32_t num, int flag)
 
int SpecSourceCount (Spec spec)
 Return the count of source set in specfile. More...
 
SpecSource getSource (Spec spec, int num)
 Return a source control structure. More...
 
const char * specSourceName (SpecSource source)
 Return a ptr to the source file name. More...
 
const char * specFullSourceName (SpecSource source)
 Return a ptr to the full url of the source. More...
 
int specSourceNum (SpecSource source)
 Return the spec or source patch number. More...
 
int specSourceFlags (SpecSource source)
 Return flags set for the source. More...
 
int parseNoSource (Spec spec, const char *field, rpmTag tag)
 parseNoSource. More...
 
int addSource (Spec spec, Package pkg, const char *field, rpmTag tag)
 addSource. More...
 
static speclines newSl (void)
 
static speclines freeSl (speclines sl)
 
static spectags newSt (void)
 
static spectags freeSt (spectags st)
 
static void specFini (void *_spec)
 
static Spec specGetPool (rpmioPool pool)
 
Spec newSpec (void)
 Create and initialize Spec structure. More...
 
struct OpenFileInfonewOpenFileInfo (void)
 
static void printNewSpecfile (Spec spec)
 Print copy of spec file, filling in Group/Description/Summary from specspo. More...
 
static void printParsedSpecfile (Spec spec)
 Print parsed copy of spec file with expanded macros. More...
 
static int initSourceHeaderScriptlet (Header h, rpmTag progTag, rpmTag scriptTag, rpmiob iob)
 Add expanded build scriptlet to srpm header. More...
 
static int initSourceHeaderScriptlets (Spec spec)
 Add expanded build scriptlets to srpm header. More...
 
static int _specQuery (rpmts ts, QVA_t qva, const char *specName, const char *target)
 Parse a spec file, and query the resultant header. More...
 
int rpmspecQuery (rpmts ts, QVA_t qva, const char *arg)
 Function to query spec file(s). More...
 

Variables

int _pkg_debug
 
int _spec_debug
 
int specedit
 
int printspec
 
rpmioPool _pkgPool
 
rpmioPool _specPool
 

Detailed Description

Handle spec data structure.

Definition in file spec.c.

Macro Definition Documentation

§ SKIPNONWHITE

#define SKIPNONWHITE (   _x)    {while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;}

Definition at line 37 of file spec.c.

Referenced by parseNoSource().

§ SKIPWHITE

#define SKIPWHITE (   _x)    {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}

Definition at line 36 of file spec.c.

Referenced by parseNoSource().

Function Documentation

§ _specQuery()

static int _specQuery ( rpmts  ts,
QVA_t  qva,
const char *  specName,
const char *  target 
)
static

Parse a spec file, and query the resultant header.

Parameters
tsrpm transaction
qvaquery args
specNamespecfile to parse
targetcpu-vender-os platform for query (NULL is current)
Returns
0 on success

Definition at line 941 of file spec.c.

References _, Package_s::fileList, freeSpec(), Package_s::header, initSourceHeader(), initSourceHeaderScriptlets(), Package_s::next, Spec_s::packages, parseSpec(), printNewSpecfile(), printParsedSpecfile(), printspec, rpmQVKArguments_s::qva_showPackage, rpmQVKArguments_s::qva_source, rpmlog(), RPMLOG_ERR, RPMQV_SPECFILE, RPMQV_SPECSRPM, rpmtsSetSpec(), Spec_s::sourceHeader, and specedit.

Referenced by rpmspecQuery().

§ addSource()

int addSource ( Spec  spec,
Package  pkg,
const char *  field,
rpmTag  tag 
)

§ findSource()

static struct Source* findSource ( Spec  spec,
rpmuint32_t  num,
int  flag 
)
static

Definition at line 259 of file spec.c.

References Source::flags, Source::next, Source::num, and Spec_s::sources.

Referenced by parseNoSource().

§ freePackages()

Package freePackages ( Package  packages)

Destroy all packages associated with spec file.

Parameters
packagespackage control structure chain
Returns
NULL

Definition at line 245 of file spec.c.

References freePackage(), and Package_s::next.

Referenced by parsePreamble(), and specFini().

§ freeSl()

static speclines freeSl ( speclines  sl)
inlinestatic

Definition at line 507 of file spec.c.

References _free(), speclines_s::sl_lines, and speclines_s::sl_nlines.

Referenced by specFini().

§ freeSources()

static struct Source* freeSources ( struct Source s)
static

Destroy source component chain.

Parameters
ssource component chain
Returns
NULL always

Definition at line 68 of file spec.c.

References _free(), Source::fullSource, and Source::next.

Referenced by specFini().

§ freeSt()

static spectags freeSt ( spectags  st)
inlinestatic

Definition at line 537 of file spec.c.

References _free(), spectags_s::st_ntags, spectags_s::st_t, spectag_s::t_lang, and spectag_s::t_msgid.

Referenced by specFini().

§ freeTriggerFiles()

static struct TriggerFileEntry* freeTriggerFiles ( struct TriggerFileEntry p)
static
Parameters
ptrigger entry chain
Returns
NULL always

Definition at line 46 of file spec.c.

References _free(), TriggerFileEntry::fileName, TriggerFileEntry::next, TriggerFileEntry::prog, and TriggerFileEntry::script.

Referenced by pkgFini().

§ getSource()

SpecSource getSource ( Spec  spec,
int  num 
)

Return a source control structure.

Parameters
specspec file control structure
numthe number of the wanted source (starting from 0)
Returns
a SpecSource structure, NULL if not found

Definition at line 279 of file spec.c.

References Source::next, Source::num, and Spec_s::sources.

§ initSourceHeaderScriptlet()

static int initSourceHeaderScriptlet ( Header  h,
rpmTag  progTag,
rpmTag  scriptTag,
rpmiob  iob 
)
static

Add expanded build scriptlet to srpm header.

Parameters
hsrpm header
progTaginterpreter tag (0 disables)
scriptTagscript tag (0 disables)
iobscript body sting buf (NULL disables)
Returns
0 always

Definition at line 878 of file spec.c.

References alloca(), _HE_s::c, headerPut(), _HE_s::p, prog, RPM_STRING_TYPE, rpmiobStr(), rpmDataType_u::str, _HE_s::t, and _HE_s::tag.

Referenced by initSourceHeaderScriptlets().

§ initSourceHeaderScriptlets()

static int initSourceHeaderScriptlets ( Spec  spec)
static

Add expanded build scriptlets to srpm header.

Parameters
specspec file control structure
Returns
0 always

Definition at line 909 of file spec.c.

References Spec_s::build, Spec_s::check, Spec_s::clean, initSourceHeaderScriptlet(), Spec_s::install, Spec_s::prep, Spec_s::sourceHeader, and tagValue().

Referenced by _specQuery().

§ lookupPackage()

rpmRC lookupPackage ( Spec  spec,
const char *  name,
int  flag,
Package pkg 
)

Find sub-package control structure by name.

Parameters
specspec file control structure
name(sub-)package name
flagif PART_SUBNAME, then 1st package name is prepended
Return values
pkgpackage control structure
Returns
RPMRC_OK on success

Definition at line 82 of file spec.c.

References _free(), alloca(), Package_s::header, headerGet(), Package_s::next, _HE_s::p, Spec_s::packages, PART_SUBNAME, rpmDataType_u::ptr, rpmExpand(), RPMRC_FAIL, RPMRC_OK, RPMTAG_NAME, RPMTAG_VERSION, rpmDataType_u::str, _HE_s::tag, xisdigit(), and xstrdup().

Referenced by parseDescription(), parseFiles(), parsePreamble(), and parseScript().

§ newOpenFileInfo()

struct OpenFileInfo* newOpenFileInfo ( void  )

§ newPackage()

Package newPackage ( Spec  spec)

§ newSl()

static speclines newSl ( void  )
inlinestatic

Definition at line 492 of file spec.c.

References printspec, speclines_s::sl_lines, speclines_s::sl_nalloc, speclines_s::sl_nlines, specedit, and xmalloc.

Referenced by newSpec().

§ newSpec()

Spec newSpec ( void  )

§ newSt()

static spectags newSt ( void  )
inlinestatic

Definition at line 522 of file spec.c.

References specedit, spectags_s::st_nalloc, spectags_s::st_ntags, spectags_s::st_t, and xmalloc.

Referenced by newSpec().

§ parseNoSource()

int parseNoSource ( Spec  spec,
const char *  field,
rpmTag  tag 
)

parseNoSource.

Parameters
specspec file control structure
fieldfield to parse
tagtag
Returns
0 on success

Definition at line 321 of file spec.c.

References _, findSource(), Source::flags, Spec_s::lineNum, name, Source::num, parseNum(), RPMFILE_GHOST, RPMFILE_PATCH, RPMFILE_SOURCE, rpmlog(), RPMLOG_ERR, RPMRC_FAIL, RPMRC_OK, RPMTAG_NOSOURCE, SKIPNONWHITE, and SKIPWHITE.

Referenced by handlePreambleTag().

§ pkgFini()

static void pkgFini ( void *  _pkg)
static

§ pkgGetPool()

static Package pkgGetPool ( rpmioPool  pool)
static

Definition at line 194 of file spec.c.

References Package_s::_item, _pkg_debug, _pkgPool, pkgFini(), rpmioGetPool(), and rpmioNewPool().

Referenced by newPackage().

§ printNewSpecfile()

static void printNewSpecfile ( Spec  spec)
static

§ printParsedSpecfile()

static void printParsedSpecfile ( Spec  spec)
static

Print parsed copy of spec file with expanded macros.

Parameters
specspec file control structure

Definition at line 847 of file spec.c.

References _free(), Spec_s::macros, rpmMCExpand(), Spec_s::sl, speclines_s::sl_lines, and speclines_s::sl_nlines.

Referenced by _specQuery().

§ rpmspecQuery()

int rpmspecQuery ( rpmts  ts,
QVA_t  qva,
const char *  arg 
)

Function to query spec file(s).

Parameters
tstransaction set
qvaparsed query/verify options
argquery argument
Returns
0 on success, else no. of failures

Definition at line 1003 of file spec.c.

References _, _specQuery(), alloca(), rpmQVKArguments_s::qva_showPackage, rpmcliTargets, rpmFreeMacros(), rpmFreeRpmrc(), rpmlog(), RPMLOG_DEBUG, and rpmReadConfigFiles().

Referenced by main().

§ specFini()

static void specFini ( void *  _spec)
static

§ specFullSourceName()

const char* specFullSourceName ( SpecSource  source)

Return a ptr to the full url of the source.

Parameters
sourceSpecSource control structure
Returns
ptr to url

Definition at line 302 of file spec.c.

References Source::fullSource.

§ specGetPool()

static Spec specGetPool ( rpmioPool  pool)
static

Definition at line 631 of file spec.c.

References Spec_s::_item, _spec_debug, _specPool, rpmioGetPool(), rpmioNewPool(), and specFini().

Referenced by newSpec().

§ SpecSourceCount()

int SpecSourceCount ( Spec  spec)

Return the count of source set in specfile.

Parameters
specspec file control structure
Returns
the count of source

Definition at line 272 of file spec.c.

References Spec_s::numSources.

§ specSourceFlags()

int specSourceFlags ( SpecSource  source)

Return flags set for the source.

Parameters
sourceSpecSource control structure
Returns
flags

Definition at line 316 of file spec.c.

References Source::flags.

§ specSourceName()

const char* specSourceName ( SpecSource  source)

Return a ptr to the source file name.

Parameters
sourceSpecSource control structure
Returns
ptr to filename

Definition at line 295 of file spec.c.

References Source::source.

§ specSourceNum()

int specSourceNum ( SpecSource  source)

Return the spec or source patch number.

Parameters
sourceSpecSource control structure
Returns
the number of the source

Definition at line 309 of file spec.c.

References Source::num.

Variable Documentation

§ _pkg_debug

int _pkg_debug

Definition at line 23 of file spec.c.

Referenced by pkgGetPool().

§ _pkgPool

rpmioPool _pkgPool

Definition at line 192 of file spec.c.

Referenced by main(), and pkgGetPool().

§ _spec_debug

int _spec_debug

Definition at line 26 of file spec.c.

Referenced by specGetPool().

§ _specPool

rpmioPool _specPool

Definition at line 629 of file spec.c.

Referenced by main(), and specGetPool().

§ printspec

int printspec

Definition at line 25 of file poptQV.c.

Referenced by _specQuery(), and newSl().

§ specedit

int specedit

Definition at line 22 of file poptQV.c.

Referenced by _specQuery(), newSl(), and newSt().