rpmbuild.h
Go to the documentation of this file.
#ifndef _H_RPMBUILD_
#define _H_RPMBUILD_
#include <rpmiotypes.h>
#include <rpmmacro.h>
#include <rpmtypes.h>
#include <rpmtag.h>
#include <rpmfi.h>
#include <rpmcli.h>
#include "rpmspec.h"
/*@-typeuse@*/
typedef enum rpmBuildFlags_e {
/*@-enummemuse@*/
RPMBUILD_NONE = 0,
/*@=enummemuse@*/
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_TRACK = (1 << 11),
RPMBUILD_RMSPEC = (1 << 12),
RPMBUILD_FETCHSOURCE= (1 << 13)
} rpmBuildFlags;
/*@=typeuse@*/
#define SKIPSPACE(s) { while (*(s) && xisspace(*(s))) (s)++; }
#define SKIPNONSPACE(s) { while (*(s) && !xisspace(*(s))) (s)++; }
#define PART_SUBNAME 0
#define PART_NAME 1
#define PART_BASE 100
typedef enum rpmParseState_e {
PART_NONE = 0+PART_BASE,
/* leave room for RPMRC_NOTFOUND returns. */
PART_PREAMBLE = 11+PART_BASE,
PART_PREP = 12+PART_BASE,
PART_BUILD = 13+PART_BASE,
PART_INSTALL = 14+PART_BASE,
PART_CHECK = 15+PART_BASE,
PART_CLEAN = 16+PART_BASE,
PART_FILES = 17+PART_BASE,
PART_PRE = 18+PART_BASE,
PART_POST = 19+PART_BASE,
PART_PREUN = 20+PART_BASE,
PART_POSTUN = 21+PART_BASE,
PART_PRETRANS = 22+PART_BASE,
PART_POSTTRANS = 23+PART_BASE,
PART_DESCRIPTION = 24+PART_BASE,
PART_CHANGELOG = 25+PART_BASE,
PART_TRIGGERIN = 26+PART_BASE,
PART_TRIGGERUN = 27+PART_BASE,
PART_VERIFYSCRIPT = 28+PART_BASE,
PART_BUILDARCHITECTURES= 29+PART_BASE,
PART_TRIGGERPOSTUN = 30+PART_BASE,
PART_TRIGGERPREIN = 31+PART_BASE,
/* support "%sanitycheck" script */
PART_SANITYCHECK = 32+PART_BASE,
PART_ARBITRARY = 33+PART_BASE,
PART_LAST = 34+PART_BASE
} rpmParseState;
typedef enum rpmStripFlags_e {
STRIP_NOTHING = 0,
STRIP_TRAILINGSPACE = (1 << 0),
STRIP_COMMENTS = (1 << 1),
STRIP_NOEXPAND = (1 << 2)
} rpmStripFlags;
/*@unchecked@*/
extern int _rpmbuildFlags;
#ifdef __cplusplus
extern "C" {
#endif
/*@-redecl@*/
void freeNames(void)
/*@globals internalState@*/
/*@modifies internalState */;
extern /*@observer@*/ const char * getUname(uid_t uid)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern /*@observer@*/ const char * getUnameS(const char * uname)
/*@globals internalState @*/
/*@modifies internalState @*/;
uid_t getUidS(const char * uname)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern /*@observer@*/ const char * getGname(gid_t gid)
/*@globals internalState @*/
/*@modifies internalState @*/;
extern /*@observer@*/ const char * getGnameS(const char * gname)
/*@globals internalState @*/
/*@modifies internalState @*/;
gid_t getGidS(const char * gname)
/*@globals internalState @*/
/*@modifies internalState @*/;
/*@observer@*/
extern const char * buildHost(void)
/*@*/;
/*@observer@*/
extern rpmuint32_t * getBuildTime(void)
/*@*/;
int readLine(Spec spec, rpmStripFlags strip)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->lbufPtr,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
rpmGlobalMacroContext, fileSystem, internalState @*/;
void closeSpec(/*@partial@*/ Spec spec)
/*@globals fileSystem, internalState @*/
/*@modifies spec->fileStack, fileSystem, internalState @*/;
void handleComments(char * s)
/*@modifies s @*/;
rpmParseState isPart(Spec spec)
/*@modifies spec->foo, spec->nfoo @*/;
int parseNum(/*@null@*/ const char * line, /*@null@*/ /*@out@*/ rpmuint32_t * res)
/*@modifies *res @*/;
void addChangelogEntry(Header h, time_t time, const char * name,
const char * text)
/*@modifies h @*/;
int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->build, spec->install, spec->check, spec->clean,
spec->macros, spec->foo, spec->nfoo, spec->lbufPtr,
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int parseChangelog(Spec spec)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->foo, spec->nfoo, spec->lbufPtr,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
spec->packages->header,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int parseDescription(Spec spec)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->packages,
spec->foo, spec->nfoo, spec->lbufPtr,
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
spec->st,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int parseFiles(Spec spec)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->packages,
spec->foo, spec->nfoo, spec->lbufPtr,
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int parsePreamble(Spec spec, int initialPackage)
/*@globals rpmGlobalMacroContext, h_errno,
fileSystem, internalState @*/
/*@modifies spec->packages,
spec->foo, spec->nfoo, spec->lbufPtr,
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->buildSubdir,
spec->macros, spec->st,
spec->sources, spec->numSources, spec->noSource,
spec->sourceHeader, spec->BANames, spec->BACount,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int parsePrep(Spec spec, int verify)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->prep, spec->buildSubdir, spec->macros,
spec->foo, spec->nfoo, spec->lbufPtr,
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
spec->packages->header,
rpmGlobalMacroContext, fileSystem, internalState @*/;
rpmRC parseRCPOT(Spec spec, Package pkg, const char * field, rpmTag tagN,
rpmuint32_t index, rpmsenseFlags tagflags)
/*@globals internalState @*/
/*@modifies internalState @*/;
int parseScript(Spec spec, int parsePart)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->packages,
spec->foo, spec->nfoo, spec->lbufPtr,
spec->fileStack, spec->readStack, spec->line, spec->lineNum,
spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int parseExpressionBoolean(Spec spec, const char * expr)
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
/*@modifies rpmGlobalMacroContext, internalState @*/;
/*@unused@*/ /*@null@*/
char * parseExpressionString(Spec spec, const char * expr)
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
/*@modifies rpmGlobalMacroContext, internalState @*/;
rpmRC doScript(Spec spec, int what, /*@null@*/ const char * name,
/*@null@*/ rpmiob iob, int test)
/*@globals rpmGlobalMacroContext, h_errno,
fileSystem, internalState @*/
/*@modifies spec->macros,
rpmGlobalMacroContext, fileSystem, internalState @*/;
rpmRC lookupPackage(Spec spec, /*@null@*/ const char * name, int flag,
/*@out@*/ Package * pkg)
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
/*@modifies spec->packages, *pkg, rpmGlobalMacroContext,
internalState @*/;
/*@only@*/
Package newPackage(Spec spec)
/*@modifies spec->packages, spec->packages->next @*/;
/*@null@*/
Package freePackages(/*@only@*/ /*@null@*/ Package packages)
/*@globals fileSystem @*/
/*@modifies packages, fileSystem @*/;
/*@null@*/
Package freePackage(/*@only@*/ /*@null@*/ Package pkg)
/*@globals fileSystem @*/
/*@modifies pkg, fileSystem @*/;
int addReqProv(/*@unused@*/ Spec spec, Header h, rpmTag tagN,
const char * N, const char * EVR, rpmsenseFlags Flags,
rpmuint32_t index)
/*@globals internalState @*/
/*@modifies h, internalState @*/;
rpmRC processScriptFiles(Spec spec, Package pkg)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies pkg->header, rpmGlobalMacroContext,
fileSystem, internalState @*/;
void providePackageNVR(Header h)
/*@globals internalState @*/
/*@modifies h, internalState @*/;
int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
/*@globals internalState @*/
/*@modifies h, internalState @*/;
rpmRC processBinaryFiles(Spec spec, int installSpecialDoc, int test)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->macros, *spec->packages,
spec->packages->cpioList, spec->packages->fileList,
spec->packages->specialDoc, spec->packages->header,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int initSourceHeader(Spec spec, /*@null@*/ rpmiob *sfp)
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
/*@modifies spec->sourceHeader, spec->sourceHdrInit,
spec->BANames, *sfp,
spec->packages->header,
rpmGlobalMacroContext, internalState @*/;
int processSourceFiles(Spec spec)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->sourceHeader, spec->sourceCpioList,
spec->BANames, spec->sourceHdrInit,
spec->packages->header,
rpmGlobalMacroContext, fileSystem, internalState @*/;
int parseSpec(rpmts ts, const char * specFile,
/*@null@*/ const char * rootURL,
int recursing,
/*@null@*/ const char * passPhrase,
/*@null@*/ const char * cookie,
int anyarch, int force, int verify)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
rpmRC buildSpec(rpmts ts, Spec spec, int what, int test)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->sourceHeader, spec->sourceCpioList, spec->cookie,
spec->sourceRpmName, spec->sourcePkgId, spec->sourceHdrInit,
spec->macros, spec->BASpecs,
spec->BANames, *spec->packages,
spec->packages->cpioList, spec->packages->fileList,
spec->packages->specialDoc, spec->packages->header,
rpmGlobalMacroContext, fileSystem, internalState @*/;
rpmRC packageBinaries(Spec spec)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->packages->header, spec->packages->cpioList,
spec->sourceRpmName, spec->cookie, spec->sourcePkgId,
rpmGlobalMacroContext, fileSystem, internalState @*/;
rpmRC packageSources(Spec spec)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies spec->sourceHeader, spec->cookie, spec->sourceCpioList,
spec->sourceRpmName, spec->sourcePkgId, spec->packages->header,
rpmGlobalMacroContext, fileSystem, internalState @*/;
/*@=redecl@*/
#ifdef __cplusplus
}
#endif
#endif /* _H_RPMBUILD_ */