rpm  5.4.14
rpmbuild.h
Go to the documentation of this file.
1 #ifndef _H_RPMBUILD_
2 #define _H_RPMBUILD_
3 
9 #include <rpmiotypes.h>
10 #include <rpmio.h> /* XXX FD_t typedef */
11 #include <rpmmacro.h>
12 #include <rpmtypes.h>
13 #include <rpmtag.h>
14 
15 #include <rpmfi.h>
16 
17 #include <rpmcli.h>
18 
19 #include "rpmspec.h"
20 
24 /*@-typeuse@*/
25 typedef enum rpmBuildFlags_e {
26 /*@-enummemuse@*/
28 /*@=enummemuse@*/
29  RPMBUILD_PREP = (1 << 0),
30  RPMBUILD_BUILD = (1 << 1),
31  RPMBUILD_INSTALL = (1 << 2),
32  RPMBUILD_CHECK = (1 << 3),
33  RPMBUILD_CLEAN = (1 << 4),
34  RPMBUILD_FILECHECK = (1 << 5),
37  RPMBUILD_RMSOURCE = (1 << 8),
38  RPMBUILD_RMBUILD = (1 << 9),
39  RPMBUILD_STRINGBUF = (1 << 10),
40  RPMBUILD_TRACK = (1 << 11),
41  RPMBUILD_RMSPEC = (1 << 12),
44 /*@=typeuse@*/
45 
46 #define SKIPSPACE(s) { while (*(s) && xisspace(*(s))) (s)++; }
47 #define SKIPNONSPACE(s) { while (*(s) && !xisspace(*(s))) (s)++; }
48 
49 #define PART_SUBNAME 0
50 #define PART_NAME 1
51 
55 #define PART_BASE 100
56 typedef enum rpmParseState_e {
58  /* leave room for RPMRC_NOTFOUND returns. */
80  /* support "%sanitycheck" script */
85 
89 typedef enum rpmStripFlags_e {
91  STRIP_TRAILINGSPACE = (1 << 0),
92  STRIP_COMMENTS = (1 << 1),
93  STRIP_NOEXPAND = (1 << 2)
95 
96 /*@unchecked@*/
97 extern int _rpmbuildFlags;
98 
99 #ifdef __cplusplus
100 extern "C" {
101 #endif
102 /*@-redecl@*/
103 
107 void freeNames(void)
108  /*@globals internalState@*/
109  /*@modifies internalState */;
110 
117 extern /*@observer@*/ const char * getUname(uid_t uid)
118  /*@globals internalState @*/
119  /*@modifies internalState @*/;
120 
127 extern /*@observer@*/ const char * getUnameS(const char * uname)
128  /*@globals internalState @*/
129  /*@modifies internalState @*/;
130 
137 uid_t getUidS(const char * uname)
138  /*@globals internalState @*/
139  /*@modifies internalState @*/;
140 
147 extern /*@observer@*/ const char * getGname(gid_t gid)
148  /*@globals internalState @*/
149  /*@modifies internalState @*/;
150 
157 extern /*@observer@*/ const char * getGnameS(const char * gname)
158  /*@globals internalState @*/
159  /*@modifies internalState @*/;
160 
167 gid_t getGidS(const char * gname)
168  /*@globals internalState @*/
169  /*@modifies internalState @*/;
170 
175 /*@observer@*/
176 extern const char * buildHost(void)
177  /*@*/;
178 
183 /*@observer@*/
184 extern rpmuint32_t * getBuildTime(void)
185  /*@*/;
186 
193 int readLine(Spec spec, rpmStripFlags strip)
194  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
195  /*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
196  spec->lbufPtr,
197  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
198  rpmGlobalMacroContext, fileSystem, internalState @*/;
199 
204 void closeSpec(/*@partial@*/ Spec spec)
205  /*@globals fileSystem, internalState @*/
206  /*@modifies spec->fileStack, fileSystem, internalState @*/;
207 
212 void handleComments(char * s)
213  /*@modifies s @*/;
214 
221  /*@modifies spec->foo, spec->nfoo @*/;
222 
229 int parseNum(/*@null@*/ const char * line, /*@null@*/ /*@out@*/rpmuint32_t * res)
230  /*@modifies *res @*/;
231 
240 void addChangelogEntry(Header h, time_t time, const char * name,
241  const char * text)
242  /*@modifies h @*/;
243 
250 int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
251  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
252  /*@modifies spec->build, spec->install, spec->check, spec->clean,
253  spec->macros, spec->foo, spec->nfoo, spec->lbufPtr,
254  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
255  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
256  rpmGlobalMacroContext, fileSystem, internalState @*/;
257 
263 int parseChangelog(Spec spec)
264  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
265  /*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
266  spec->foo, spec->nfoo, spec->lbufPtr,
267  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
268  spec->packages->header,
269  rpmGlobalMacroContext, fileSystem, internalState @*/;
270 
276 int parseDescription(Spec spec)
277  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
278  /*@modifies spec->packages,
279  spec->foo, spec->nfoo, spec->lbufPtr,
280  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
281  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
282  spec->st,
283  rpmGlobalMacroContext, fileSystem, internalState @*/;
284 
290 int parseFiles(Spec spec)
291  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
292  /*@modifies spec->packages,
293  spec->foo, spec->nfoo, spec->lbufPtr,
294  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
295  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
296  rpmGlobalMacroContext, fileSystem, internalState @*/;
297 
304 int parsePreamble(Spec spec, int initialPackage)
305  /*@globals rpmGlobalMacroContext, h_errno,
306  fileSystem, internalState @*/
307  /*@modifies spec->packages,
308  spec->foo, spec->nfoo, spec->lbufPtr,
309  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
310  spec->buildSubdir,
311  spec->macros, spec->st,
312  spec->sources, spec->numSources, spec->noSource,
313  spec->sourceHeader, spec->BANames, spec->BACount,
314  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
315  rpmGlobalMacroContext, fileSystem, internalState @*/;
316 
323 int parsePrep(Spec spec, int verify)
324  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
325  /*@modifies spec->prep, spec->buildSubdir, spec->macros,
326  spec->foo, spec->nfoo, spec->lbufPtr,
327  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
328  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
329  spec->packages->header,
330  rpmGlobalMacroContext, fileSystem, internalState @*/;
331 
342 rpmRC parseRCPOT(Spec spec, Package pkg, const char * field, rpmTag tagN,
343  rpmuint32_t index, rpmsenseFlags tagflags)
344  /*@globals internalState @*/
345  /*@modifies internalState @*/;
346 
353 int parseScript(Spec spec, int parsePart)
354  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
355  /*@modifies spec->packages,
356  spec->foo, spec->nfoo, spec->lbufPtr,
357  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
358  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
359  rpmGlobalMacroContext, fileSystem, internalState @*/;
360 
367 int parseExpressionBoolean(Spec spec, const char * expr)
368  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
369  /*@modifies rpmGlobalMacroContext, internalState @*/;
370 
377 /*@unused@*/ /*@null@*/
378 char * parseExpressionString(Spec spec, const char * expr)
379  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
380  /*@modifies rpmGlobalMacroContext, internalState @*/;
381 
392 rpmRC doScript(Spec spec, int what, /*@null@*/ const char * name,
393  /*@null@*/ rpmiob iob, int test)
394  /*@globals rpmGlobalMacroContext, h_errno,
395  fileSystem, internalState @*/
396  /*@modifies spec->macros,
397  rpmGlobalMacroContext, fileSystem, internalState @*/;
398 
407 rpmRC lookupPackage(Spec spec, /*@null@*/ const char * name, int flag,
408  /*@out@*/ Package * pkg)
409  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
410  /*@modifies spec->packages, *pkg, rpmGlobalMacroContext,
411  internalState @*/;
412 
418 /*@null@*/
419 Package freePackages(/*@only@*/ /*@null@*/ Package packages)
420  /*@globals fileSystem @*/
421  /*@modifies packages, fileSystem @*/;
422 
429 /*@null@*/
430 Package freePackage(/*@killref@*/ /*@null@*/ Package pkg)
431  /*@globals fileSystem @*/
432  /*@modifies pkg, fileSystem @*/;
433 #define freePackage(_pkg) \
434  ((Package)rpmioFreePoolItem((rpmioItem)(_pkg), __FUNCTION__, __FILE__, __LINE__))
435 
441 /*@only@*/
442 Package newPackage(Spec spec)
443  /*@modifies spec->packages, spec->packages->next @*/;
444 
456 int addReqProv(/*@unused@*/Spec spec, Header h, rpmTag tagN,
457  const char * N, const char * EVR, rpmsenseFlags Flags,
458  rpmuint32_t index)
459  /*@globals internalState @*/
460  /*@modifies h, internalState @*/;
461 
469  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
470  /*@modifies pkg->header, rpmGlobalMacroContext,
471  fileSystem, internalState @*/;
472 
479  /*@globals internalState @*/
480  /*@modifies h, internalState @*/;
481 
489 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
490  /*@globals internalState @*/
491  /*@modifies h, internalState @*/;
492 
500 rpmRC processBinaryFiles(Spec spec, int installSpecialDoc, int test)
501  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
502  /*@modifies spec->macros, *spec->packages,
503  spec->packages->fi, spec->packages->fileList,
504  spec->packages->specialDoc, spec->packages->header,
505  rpmGlobalMacroContext, fileSystem, internalState @*/;
506 
513 int initSourceHeader(Spec spec, /*@null@*/ rpmiob *sfp)
514  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
515  /*@modifies spec->sourceHeader, spec->sourceHdrInit,
516  spec->BANames, *sfp,
517  spec->packages->header,
518  rpmGlobalMacroContext, internalState @*/;
519 
525 int processSourceFiles(Spec spec)
526  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
527  /*@modifies spec->sourceHeader, spec->sourceCpioList,
528  spec->BANames, spec->sourceHdrInit,
529  spec->packages->header,
530  rpmGlobalMacroContext, fileSystem, internalState @*/;
531 
545 int parseSpec(rpmts ts, const char * specFile,
546  /*@null@*/ const char * rootURL,
547  int recursing,
548  /*@null@*/ const char * passPhrase,
549  /*@null@*/ const char * cookie,
550  int anyarch, int force, int verify)
551  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
552  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
553 
562 rpmRC buildSpec(rpmts ts, Spec spec, int what, int test)
563  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
564  /*@modifies spec->sourceHeader, spec->sourceCpioList, spec->cookie,
565  spec->sourceRpmName, spec->sourcePkgId, spec->sourceHdrInit,
566  spec->macros, spec->BASpecs,
567  spec->BANames, *spec->packages,
568  spec->packages->fi, spec->packages->fileList,
569  spec->packages->specialDoc, spec->packages->header,
570  rpmGlobalMacroContext, fileSystem, internalState @*/;
571 
578  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
579  /*@modifies spec->packages->header, spec->packages->fi,
580  spec->sourceRpmName, spec->cookie, spec->sourcePkgId,
581  rpmGlobalMacroContext, fileSystem, internalState @*/;
582 
589  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
590  /*@modifies spec->sourceHeader, spec->cookie, spec->sourceCpioList,
591  spec->sourceRpmName, spec->sourcePkgId, spec->packages->header,
592  rpmGlobalMacroContext, fileSystem, internalState @*/;
593 
594 /*@=redecl@*/
595 #ifdef __cplusplus
596 }
597 #endif
598 
599 #endif /* _H_RPMBUILD_ */
char * cookie
Definition: rpmts-py.c:1341
gid_t getGidS(const char *gname)
Return cached group id.
Definition: names.c:170
enum rpmBuildFlags_e rpmBuildFlags
Bit(s) to control buildSpec() operation.
void addChangelogEntry(Header h, time_t time, const char *name, const char *text)
Add changelog entry to header.
void handleComments(char *s)
Truncate comment lines.
Definition: parseSpec.c:142
rpmRC doScript(Spec spec, int what, const char *name, rpmiob iob, int test)
Run a build script, assembled from spec file scriptlet section.
Definition: build.c:89
int verify
Definition: rpmts-py.c:1343
enum rpmStripFlags_e rpmStripFlags
Spec file parser stripping flags.
char * parseExpressionString(Spec spec, const char *expr)
Evaluate string expression.
Definition: expression.c:754
int parseNum(const char *line, rpmuint32_t *res)
Parse a number.
Definition: misc.c:11
int _rpmbuildFlags
Definition: poptBT.c:53
int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
Parse %build/%install/%clean section(s) of a spec file.
const char * getGnameS(const char *gname)
Return cached group name.
Definition: names.c:143
int anyarch
Definition: rpmts-py.c:1342
Structure(s) used for file info tag sets.
struct rpmts_s * rpmts
The RPM Transaction Set.
Definition: rpmtypes.h:14
int parseExpressionBoolean(Spec spec, const char *expr)
Evaluate boolean expression.
Definition: expression.c:707
const char * buildHost(void)
Return build hostname.
Definition: names.c:206
The Header data structure.
rpmBuildFlags_e
Bit(s) to control buildSpec() operation.
Definition: rpmbuild.h:25
const char * getUname(uid_t uid)
Return cached user name from user id.
Definition: names.c:41
rpmRC lookupPackage(Spec spec, const char *name, int flag, Package *pkg)
Find sub-package control structure by name.
Definition: spec.c:78
enum rpmTag_e rpmTag
Definition: rpmtag.h:468
rpmStripFlags_e
Spec file parser stripping flags.
Definition: rpmbuild.h:89
int parsePrep(Spec spec, int verify)
Parse %prep section of a spec file.
Definition: parsePrep.c:892
Header h
Definition: spec.c:739
int processSourceFiles(Spec spec)
Post-build processing for source package.
Definition: files.c:2751
uid_t getUidS(const char *uname)
Return cached user id.
Definition: names.c:92
int addReqProv(Spec spec, Header h, rpmTag tagN, const char *N, const char *EVR, rpmsenseFlags Flags, rpmuint32_t index)
Add dependency to header, filtering duplicates.
Definition: reqprov.c:14
struct rpmiob_s * rpmiob
Definition: rpmiotypes.h:60
char * passPhrase
Definition: rpmts-py.c:1340
rpmRC res
Definition: signature.c:584
const char * N
Definition: rpmds.c:2714
rpmRC packageBinaries(Spec spec)
Generate binary package(s).
Definition: pack.c:1156
int parseSpec(rpmts ts, const char *specFile, const char *rootURL, int recursing, const char *passPhrase, const char *cookie, int anyarch, int force, int verify)
Parse spec file into spec control structure.
Definition: parseSpec.c:530
enum rpmRC_e rpmRC
RPM return codes.
Definition: signature.c:616
int parsePreamble(Spec spec, int initialPackage)
Parse tags from preamble of a spec file.
unsigned int rpmuint32_t
Definition: rpmiotypes.h:28
Package newPackage(Spec spec)
Create and initialize package control structure.
Definition: spec.c:204
rpmParseState_e
Definition: rpmbuild.h:56
#define PART_BASE
Spec file parser states.
Definition: rpmbuild.h:55
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
Definition: parseSpec.c:64
int initSourceHeader(Spec spec, rpmiob *sfp)
Create and initialize header for source package.
Definition: files.c:2566
enum evrFlags_e rpmsenseFlags
Definition: rpmevr.h:74
rpmuint32_t * getBuildTime(void)
Return build time stamp.
Definition: names.c:197
int parseChangelog(Spec spec)
Parse %changelog section of a spec file.
rpmRC processBinaryFiles(Spec spec, int installSpecialDoc, int test)
Post-build processing for binary package(s).
Definition: files.c:3174
The structure used to store values parsed from a spec file.
Definition: rpmspec.h:113
void freeNames(void)
Destroy uid/gid caches.
Definition: names.c:32
int parseScript(Spec spec, int parsePart)
Parse %pre et al scriptlets from a spec file.
Definition: parseScript.c:74
void closeSpec(Spec spec)
Stop reading from spec file, freeing resources.
Definition: parseSpec.c:487
int recursing
Definition: rpmts-py.c:1339
const char * s
Definition: poptALL.c:734
int parseDescription(Spec spec)
Parse %description section of a spec file.
int force
Definition: rpmts-py.c:1344
rpmRC packageSources(Spec spec)
Generate source package.
Definition: pack.c:1308
Package freePackages(Package packages)
Destroy all packages associated with spec file.
Definition: spec.c:241
rpmRC processScriptFiles(Spec spec, Package pkg)
Append files (if any) to scriptlet tags.
Definition: pack.c:214
enum rpmParseState_e rpmParseState
const char * getUnameS(const char *uname)
Return cached user name.
Definition: names.c:65
#define freePackage(_pkg)
Definition: rpmbuild.h:433
static const char * name
rpmRC parseRCPOT(Spec spec, Package pkg, const char *field, rpmTag tagN, rpmuint32_t index, rpmsenseFlags tagflags)
Parse dependency relations from spec file and/or autogenerated output buffer.
Definition: parseReqs.c:20
The structure used to store values for a package.
Definition: rpmspec.h:214
int parseFiles(Spec spec)
Parse %files section of a spec file.
Definition: parseFiles.c:28
The Spec and Package data structures used during build.
char * EVR
Definition: rpmds.c:2715
const char * getGname(gid_t gid)
Return cached group name from group id.
Definition: names.c:119
int rpmlibNeedsFeature(Header h, const char *feature, const char *featureEVR)
Add rpmlib feature dependency.
Definition: reqprov.c:212
int readLine(Spec spec, rpmStripFlags strip)
Read next line from spec file.
Definition: parseSpec.c:351
evrFlags Flags
Definition: rpmds.c:2717
void providePackageNVR(Header h)
Retrofit an explicit Provides: N = E:V-R dependency into package headers.
Definition: pack.c:454
rpmRC buildSpec(rpmts ts, Spec spec, int what, int test)
Build stages state machine driver.
Definition: build.c:338
Spec spec
Definition: spec-py.c:121