rpm  4.8.1
Macros | Typedefs | Enumerations | Functions
rpmbuild.h File Reference

This is the only module users of librpmbuild should need to include. More...

#include <rpm/rpmcli.h>
#include <rpm/rpmds.h>
#include <rpm/rpmstring.h>
#include <rpm/rpmspec.h>
Include dependency graph for rpmbuild.h:

Go to the source code of this file.

Macros

#define PART_SUBNAME   0
 
#define PART_NAME   1
 
#define PART_BASE   0
 rpmSpec file parser states. More...
 
#define STRIP_NOTHING   0
 
#define STRIP_TRAILINGSPACE   (1 << 0)
 
#define STRIP_COMMENTS   (1 << 1)
 

Typedefs

typedef enum rpmBuildFlags_e rpmBuildFlags
 Bit(s) to control buildSpec() operation. More...
 
typedef enum rpmParseState_e rpmParseState
 

Enumerations

enum  rpmBuildFlags_e {
  RPMBUILD_NONE = 0, RPMBUILD_PREP = (1 << 0), RPMBUILD_BUILD = (1 << 1), RPMBUILD_INSTALL = (1 << 2),
  RPMBUILD_CHECK = (1 << 3), RPMBUILD_CLEAN = (1 << 4), RPMBUILD_FILECHECK = (1 << 5), RPMBUILD_PACKAGESOURCE = (1 << 6),
  RPMBUILD_PACKAGEBINARY = (1 << 7), RPMBUILD_RMSOURCE = (1 << 8), RPMBUILD_RMBUILD = (1 << 9), RPMBUILD_STRINGBUF = (1 << 10),
  RPMBUILD_RMSPEC = (1 << 11)
}
 Bit(s) to control buildSpec() operation. More...
 
enum  rpmParseState_e {
  PART_ERROR = -1, PART_NONE = 0+ 0, PART_PREAMBLE = 11+ 0, PART_PREP = 12+ 0,
  PART_BUILD = 13+ 0, PART_INSTALL = 14+ 0, PART_CHECK = 15+ 0, PART_CLEAN = 16+ 0,
  PART_FILES = 17+ 0, PART_PRE = 18+ 0, PART_POST = 19+ 0, PART_PREUN = 20+ 0,
  PART_POSTUN = 21+ 0, PART_PRETRANS = 22+ 0, PART_POSTTRANS = 23+ 0, PART_DESCRIPTION = 24+ 0,
  PART_CHANGELOG = 25+ 0, PART_TRIGGERIN = 26+ 0, PART_TRIGGERUN = 27+ 0, PART_VERIFYSCRIPT = 28+ 0,
  PART_BUILDARCHITECTURES = 29+ 0, PART_TRIGGERPOSTUN = 30+ 0, PART_TRIGGERPREIN = 31+ 0, PART_LAST = 32+ 0
}
 

Functions

void freeNames (void)
 Destroy uid/gid caches. More...
 
const char * getUname (uid_t uid)
 Return cached user name from user id. More...
 
const char * getUnameS (const char *uname)
 Return cached user name. More...
 
uid_t getUidS (const char *uname)
 Return cached user id. More...
 
const char * getGname (gid_t gid)
 Return cached group name from group id. More...
 
const char * getGnameS (const char *gname)
 Return cached group name. More...
 
gid_t getGidS (const char *gname)
 Return cached group id. More...
 
const char * buildHost (void)
 Return build hostname. More...
 
rpm_time_tgetBuildTime (void)
 Return build time stamp. More...
 
int readLine (rpmSpec spec, int strip)
 Read next line from spec file. More...
 
void closeSpec (rpmSpec spec)
 Stop reading from spec file, freeing resources. More...
 
void handleComments (char *s)
 Truncate comment lines. More...
 
rpmParseState isPart (const char *line)
 Check line for section separator, return next parser state. More...
 
uint32_t parseUnsignedNum (const char *line, uint32_t *res)
 Parse an unsigned number. More...
 
void addChangelogEntry (Header h, time_t time, const char *name, const char *text)
 Add changelog entry to header. More...
 
int parseBuildInstallClean (rpmSpec spec, rpmParseState parsePart)
 Parse %build/%install/%clean section(s) of a spec file. More...
 
int parseChangelog (rpmSpec spec)
 Parse %changelog section of a spec file. More...
 
int parseDescription (rpmSpec spec)
 Parse %description section of a spec file. More...
 
int parseFiles (rpmSpec spec)
 Parse %files section of a spec file. More...
 
int parsePreamble (rpmSpec spec, int initialPackage)
 Parse tags from preamble of a spec file. More...
 
int parsePrep (rpmSpec spec)
 Parse %prep section of a spec file. More...
 
rpmRC rpmCharCheck (rpmSpec spec, char *field, size_t fsize, const char *whitelist)
 Check for inappropriate characters. More...
 
rpmRC parseRCPOT (rpmSpec spec, Package pkg, const char *field, rpmTag tagN, int index, rpmsenseFlags tagflags)
 Parse dependency relations from spec file and/or autogenerated output buffer. More...
 
int parseScript (rpmSpec spec, int parsePart)
 Parse %pre et al scriptlets from a spec file. More...
 
int parseExpressionBoolean (rpmSpec spec, const char *expr)
 Evaluate boolean expression. More...
 
char * parseExpressionString (rpmSpec spec, const char *expr)
 Evaluate string expression. More...
 
rpmRC doRmSource (rpmSpec spec)
 Remove all sources assigned to spec file. More...
 
rpmRC doScript (rpmSpec spec, rpmBuildFlags what, const char *name, StringBuf sb, int test)
 Run a build script, assembled from spec file scriptlet section. More...
 
rpmRC lookupPackage (rpmSpec spec, const char *name, int flag, Package *pkg)
 Find sub-package control structure by name. More...
 
Package newPackage (rpmSpec spec)
 Create and initialize package control structure. More...
 
Package freePackages (Package packages)
 Destroy all packages associated with spec file. More...
 
Package freePackage (Package pkg)
 Destroy package control structure. More...
 
int addReqProv (rpmSpec spec, Header h, rpmTag tagN, const char *N, const char *EVR, rpmsenseFlags Flags, uint32_t index)
 Add dependency to header, filtering duplicates. More...
 
int rpmlibNeedsFeature (Header h, const char *feature, const char *featureEVR)
 Add rpmlib feature dependency. More...
 
int processBinaryFiles (rpmSpec spec, int installSpecialDoc, int test)
 Post-build processing for binary package(s). More...
 
void initSourceHeader (rpmSpec spec)
 Create and initialize header for source package. More...
 
int processSourceFiles (rpmSpec spec)
 Post-build processing for source package. More...
 
int parseSpec (rpmts ts, const char *specFile, const char *rootDir, const char *buildRoot, int recursing, const char *passPhrase, const char *cookie, int anyarch, int force)
 Parse spec file into spec control structure. More...
 
rpmRC buildSpec (rpmts ts, rpmSpec spec, int what, int test)
 Build stages state machine driver. More...
 
rpmRC checkPackages (char *pkgcheck)
 Check package(s). More...
 
rpmRC packageBinaries (rpmSpec spec)
 Generate binary package(s). More...
 
rpmRC packageSources (rpmSpec spec)
 Generate source package. More...
 

Detailed Description

This is the only module users of librpmbuild should need to include.

Definition in file rpmbuild.h.

Macro Definition Documentation

◆ PART_BASE

#define PART_BASE   0

rpmSpec file parser states.

  • Spec file parser states.

Definition at line 50 of file rpmbuild.h.

◆ PART_NAME

#define PART_NAME   1

Definition at line 42 of file rpmbuild.h.

◆ PART_SUBNAME

#define PART_SUBNAME   0

Definition at line 41 of file rpmbuild.h.

◆ STRIP_COMMENTS

#define STRIP_COMMENTS   (1 << 1)

Definition at line 82 of file rpmbuild.h.

◆ STRIP_NOTHING

#define STRIP_NOTHING   0

Definition at line 80 of file rpmbuild.h.

◆ STRIP_TRAILINGSPACE

#define STRIP_TRAILINGSPACE   (1 << 0)

Definition at line 81 of file rpmbuild.h.

Typedef Documentation

◆ rpmBuildFlags

Bit(s) to control buildSpec() operation.

◆ rpmParseState

Enumeration Type Documentation

◆ rpmBuildFlags_e

Bit(s) to control buildSpec() operation.

Enumerator
RPMBUILD_NONE 
RPMBUILD_PREP 

Execute %prep.

RPMBUILD_BUILD 

Execute %build.

RPMBUILD_INSTALL 

Execute %install.

RPMBUILD_CHECK 

Execute %check.

RPMBUILD_CLEAN 

Execute %clean.

RPMBUILD_FILECHECK 

Check %files manifest.

RPMBUILD_PACKAGESOURCE 

Create source package.

RPMBUILD_PACKAGEBINARY 

Create binary package(s).

RPMBUILD_RMSOURCE 

Remove source(s) and patch(s).

RPMBUILD_RMBUILD 

Remove build sub-tree.

RPMBUILD_STRINGBUF 

only for doScript()

RPMBUILD_RMSPEC 

Remove spec file.

Definition at line 25 of file rpmbuild.h.

◆ rpmParseState_e

Enumerator
PART_ERROR 
PART_NONE 
PART_PREAMBLE 
PART_PREP 
PART_BUILD 
PART_INSTALL 
PART_CHECK 
PART_CLEAN 
PART_FILES 
PART_PRE 
PART_POST 
PART_PREUN 
PART_POSTUN 
PART_PRETRANS 
PART_POSTTRANS 
PART_DESCRIPTION 
PART_CHANGELOG 
PART_TRIGGERIN 
PART_TRIGGERUN 
PART_VERIFYSCRIPT 
PART_BUILDARCHITECTURES 
PART_TRIGGERPOSTUN 
PART_TRIGGERPREIN 
PART_LAST 

Definition at line 51 of file rpmbuild.h.

Function Documentation

◆ addChangelogEntry()

void addChangelogEntry ( Header  h,
time_t  time,
const char *  name,
const char *  text 
)

Add changelog entry to header.

Parameters
hheader
timetime of change
nameperson who made the change
textdescription of change

◆ addReqProv()

int addReqProv ( rpmSpec  spec,
Header  h,
rpmTag  tagN,
const char *  N,
const char *  EVR,
rpmsenseFlags  Flags,
uint32_t  index 
)

Add dependency to header, filtering duplicates.

Parameters
specspec file control structure
hheader
tagNtag, identifies type of dependency
N(e.g. Requires: foo < 0:1.2-3, "foo")
EVR(e.g. Requires: foo < 0:1.2-3, "0:1.2-3")
Flags(e.g. Requires: foo < 0:1.2-3, both "Requires:" and "<")
index(0 always)
Returns
0 on success, 1 on error

◆ buildHost()

const char* buildHost ( void  )

Return build hostname.

Returns
build hostname

◆ buildSpec()

rpmRC buildSpec ( rpmts  ts,
rpmSpec  spec,
int  what,
int  test 
)

Build stages state machine driver.

Parameters
tstransaction set
specspec file control structure
whatbit(s) to enable stages of build
testdon't execute scripts or package if testing
Returns
RPMRC_OK on success

Referenced by buildForTarget().

◆ checkPackages()

rpmRC checkPackages ( char *  pkgcheck)

Check package(s).

Parameters
pkgcheckprogram to run
Returns
RPMRC_OK on success

◆ closeSpec()

void closeSpec ( rpmSpec  spec)

Stop reading from spec file, freeing resources.

Parameters
specspec file control structure

◆ doRmSource()

rpmRC doRmSource ( rpmSpec  spec)

Remove all sources assigned to spec file.

Parameters
specspec file control structure
Returns
RPMRC_OK on success

Referenced by buildForTarget().

◆ doScript()

rpmRC doScript ( rpmSpec  spec,
rpmBuildFlags  what,
const char *  name,
StringBuf  sb,
int  test 
)

Run a build script, assembled from spec file scriptlet section.

Parameters
specspec file control structure
whattype of script
namename of scriptlet section
sblines that compose script body
testdon't execute scripts or package if testing
Returns
RPMRC_OK on success

◆ freeNames()

void freeNames ( void  )

Destroy uid/gid caches.

Referenced by main().

◆ freePackage()

Package freePackage ( Package  pkg)

Destroy package control structure.

Parameters
pkgpackage control structure
Returns
NULL

◆ freePackages()

Package freePackages ( Package  packages)

Destroy all packages associated with spec file.

Parameters
packagespackage control structure chain
Returns
NULL

◆ getBuildTime()

rpm_time_t* getBuildTime ( void  )

Return build time stamp.

Returns
build time stamp

◆ getGidS()

gid_t getGidS ( const char *  gname)

Return cached group id.

Todo:
Implement using hash.
Parameters
gnamegroup name
Returns
cached gid

◆ getGname()

const char* getGname ( gid_t  gid)

Return cached group name from group id.

Todo:
Implement using hash.
Parameters
gidgroup id
Returns
cached group name

◆ getGnameS()

const char* getGnameS ( const char *  gname)

Return cached group name.

Todo:
Implement using hash.
Parameters
gnamegroup name
Returns
cached group name

◆ getUidS()

uid_t getUidS ( const char *  uname)

Return cached user id.

Todo:
Implement using hash.
Parameters
unameuser name
Returns
cached uid

◆ getUname()

const char* getUname ( uid_t  uid)

Return cached user name from user id.

Todo:
Implement using hash.
Parameters
uiduser id
Returns
cached user name

◆ getUnameS()

const char* getUnameS ( const char *  uname)

Return cached user name.

Todo:
Implement using hash.
Parameters
unameuser name
Returns
cached user name

◆ handleComments()

void handleComments ( char *  s)

Truncate comment lines.

Parameters
sskip white space, truncate line at '#'

◆ initSourceHeader()

void initSourceHeader ( rpmSpec  spec)

Create and initialize header for source package.

Parameters
specspec file control structure

Referenced by buildForTarget().

◆ isPart()

rpmParseState isPart ( const char *  line)

Check line for section separator, return next parser state.

Parameters
linefrom spec file
Returns
next parser state

◆ lookupPackage()

rpmRC lookupPackage ( rpmSpec  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
0 on success, 1 on failure

◆ newPackage()

Package newPackage ( rpmSpec  spec)

Create and initialize package control structure.

Parameters
specspec file control structure
Returns
package control structure

◆ packageBinaries()

rpmRC packageBinaries ( rpmSpec  spec)

Generate binary package(s).

Parameters
specspec file control structure
Returns
RPMRC_OK on success

◆ packageSources()

rpmRC packageSources ( rpmSpec  spec)

Generate source package.

Parameters
specspec file control structure
Returns
RPMRC_OK on success

◆ parseBuildInstallClean()

int parseBuildInstallClean ( rpmSpec  spec,
rpmParseState  parsePart 
)

Parse %build/%install/%clean section(s) of a spec file.

Parameters
specspec file control structure
parsePartcurrent rpmParseState
Returns
>= 0 next rpmParseState, < 0 on error

◆ parseChangelog()

int parseChangelog ( rpmSpec  spec)

Parse %changelog section of a spec file.

Parameters
specspec file control structure
Returns
>= 0 next rpmParseState, < 0 on error

◆ parseDescription()

int parseDescription ( rpmSpec  spec)

Parse %description section of a spec file.

Parameters
specspec file control structure
Returns
>= 0 next rpmParseState, < 0 on error

◆ parseExpressionBoolean()

int parseExpressionBoolean ( rpmSpec  spec,
const char *  expr 
)

Evaluate boolean expression.

Parameters
specspec file control structure
exprexpression to parse
Returns

◆ parseExpressionString()

char* parseExpressionString ( rpmSpec  spec,
const char *  expr 
)

Evaluate string expression.

Parameters
specspec file control structure
exprexpression to parse
Returns

◆ parseFiles()

int parseFiles ( rpmSpec  spec)

Parse %files section of a spec file.

Parameters
specspec file control structure
Returns
>= 0 next rpmParseState, < 0 on error

◆ parsePreamble()

int parsePreamble ( rpmSpec  spec,
int  initialPackage 
)

Parse tags from preamble of a spec file.

Parameters
specspec file control structure
initialPackage
Returns
>= 0 next rpmParseState, < 0 on error

◆ parsePrep()

int parsePrep ( rpmSpec  spec)

Parse %prep section of a spec file.

Parameters
specspec file control structure
Returns
>= 0 next rpmParseState, < 0 on error

◆ parseRCPOT()

rpmRC parseRCPOT ( rpmSpec  spec,
Package  pkg,
const char *  field,
rpmTag  tagN,
int  index,
rpmsenseFlags  tagflags 
)

Parse dependency relations from spec file and/or autogenerated output buffer.

Parameters
specspec file control structure
pkgpackage control structure
fieldtext to parse (e.g. "foo < 0:1.2-3, bar = 5:6.7")
tagNtag, identifies type of dependency
index(0 always)
tagflagsdependency flags already known from context
Returns
RPMRC_OK on success, RPMRC_FAIL on failure

◆ parseScript()

int parseScript ( rpmSpec  spec,
int  parsePart 
)

Parse %pre et al scriptlets from a spec file.

Parameters
specspec file control structure
parsePartcurrent rpmParseState
Returns
>= 0 next rpmParseState, < 0 on error

◆ parseSpec()

int parseSpec ( rpmts  ts,
const char *  specFile,
const char *  rootDir,
const char *  buildRoot,
int  recursing,
const char *  passPhrase,
const char *  cookie,
int  anyarch,
int  force 
)

Parse spec file into spec control structure.

Parameters
tstransaction set (spec file control in ts->spec)
specFile
rootDir
buildRoot
recursingparse is recursive?
passPhrase
cookie
anyarch
force
Returns

Referenced by buildForTarget().

◆ parseUnsignedNum()

uint32_t parseUnsignedNum ( const char *  line,
uint32_t *  res 
)

Parse an unsigned number.

Parameters
linefrom spec file
Return values
respointer to uint32_t
Returns
0 on success, 1 on failure

◆ processBinaryFiles()

int processBinaryFiles ( rpmSpec  spec,
int  installSpecialDoc,
int  test 
)

Post-build processing for binary package(s).

Parameters
specspec file control structure
installSpecialDoc
testdon't execute scripts or package if testing
Returns
0 on success

◆ processSourceFiles()

int processSourceFiles ( rpmSpec  spec)

Post-build processing for source package.

Parameters
specspec file control structure
Returns
0 on success

◆ readLine()

int readLine ( rpmSpec  spec,
int  strip 
)

Read next line from spec file.

Parameters
specspec file control structure
striptruncate comments?
Returns
0 on success, 1 on EOF, <0 on error

◆ rpmCharCheck()

rpmRC rpmCharCheck ( rpmSpec  spec,
char *  field,
size_t  fsize,
const char *  whitelist 
)

Check for inappropriate characters.

All alphanums are considered sane.

Parameters
specspec
fieldstring to check
fsizesize of string to check
whiteliststring of permitted characters
Returns
RPMRC_OK if OK

◆ rpmlibNeedsFeature()

int rpmlibNeedsFeature ( Header  h,
const char *  feature,
const char *  featureEVR 
)

Add rpmlib feature dependency.

Parameters
hheader
featurerpm feature name (i.e. "rpmlib(Foo)" for feature Foo)
featureEVRrpm feature epoch/version/release
Returns
0 always