rpm  5.4.10
rpmbuild.h
Go to the documentation of this file.
1 #ifndef _H_RPMBUILD_
2 #define _H_RPMBUILD_
3 
9 #include <rpmiotypes.h>
10 #include <rpmmacro.h>
11 #include <rpmtypes.h>
12 #include <rpmtag.h>
13 
14 #include <rpmfi.h>
15 
16 #include <rpmcli.h>
17 
18 #include "rpmspec.h"
19 
23 /*@-typeuse@*/
24 typedef enum rpmBuildFlags_e {
25 /*@-enummemuse@*/
27 /*@=enummemuse@*/
28  RPMBUILD_PREP = (1 << 0),
29  RPMBUILD_BUILD = (1 << 1),
30  RPMBUILD_INSTALL = (1 << 2),
31  RPMBUILD_CHECK = (1 << 3),
32  RPMBUILD_CLEAN = (1 << 4),
33  RPMBUILD_FILECHECK = (1 << 5),
36  RPMBUILD_RMSOURCE = (1 << 8),
37  RPMBUILD_RMBUILD = (1 << 9),
38  RPMBUILD_STRINGBUF = (1 << 10),
39  RPMBUILD_TRACK = (1 << 11),
40  RPMBUILD_RMSPEC = (1 << 12),
43 /*@=typeuse@*/
44 
45 #define SKIPSPACE(s) { while (*(s) && xisspace(*(s))) (s)++; }
46 #define SKIPNONSPACE(s) { while (*(s) && !xisspace(*(s))) (s)++; }
47 
48 #define PART_SUBNAME 0
49 #define PART_NAME 1
50 
54 #define PART_BASE 100
55 typedef enum rpmParseState_e {
57  /* leave room for RPMRC_NOTFOUND returns. */
83  /* support "%sanitycheck" script */
88 
92 typedef enum rpmStripFlags_e {
94  STRIP_TRAILINGSPACE = (1 << 0),
95  STRIP_COMMENTS = (1 << 1),
96  STRIP_NOEXPAND = (1 << 2)
98 
99 /*@unchecked@*/
100 extern int _rpmbuildFlags;
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 /*@-redecl@*/
106 
110 void freeNames(void)
111  /*@globals internalState@*/
112  /*@modifies internalState */;
113 
120 extern /*@observer@*/ const char * getUname(uid_t uid)
121  /*@globals internalState @*/
122  /*@modifies internalState @*/;
123 
130 extern /*@observer@*/ const char * getUnameS(const char * uname)
131  /*@globals internalState @*/
132  /*@modifies internalState @*/;
133 
140 uid_t getUidS(const char * uname)
141  /*@globals internalState @*/
142  /*@modifies internalState @*/;
143 
150 extern /*@observer@*/ const char * getGname(gid_t gid)
151  /*@globals internalState @*/
152  /*@modifies internalState @*/;
153 
160 extern /*@observer@*/ const char * getGnameS(const char * gname)
161  /*@globals internalState @*/
162  /*@modifies internalState @*/;
163 
170 gid_t getGidS(const char * gname)
171  /*@globals internalState @*/
172  /*@modifies internalState @*/;
173 
178 /*@observer@*/
179 extern const char * buildHost(void)
180  /*@*/;
181 
186 /*@observer@*/
187 extern rpmuint32_t * getBuildTime(void)
188  /*@*/;
189 
196 int readLine(Spec spec, rpmStripFlags strip)
197  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
198  /*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
199  spec->lbufPtr,
200  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
201  rpmGlobalMacroContext, fileSystem, internalState @*/;
202 
207 void closeSpec(/*@partial@*/ Spec spec)
208  /*@globals fileSystem, internalState @*/
209  /*@modifies spec->fileStack, fileSystem, internalState @*/;
210 
215 void handleComments(char * s)
216  /*@modifies s @*/;
217 
223 rpmParseState isPart(Spec spec)
224  /*@modifies spec->foo, spec->nfoo @*/;
225 
232 int parseNum(/*@null@*/ const char * line, /*@null@*/ /*@out@*/rpmuint32_t * res)
233  /*@modifies *res @*/;
234 
243 void addChangelogEntry(Header h, time_t time, const char * name,
244  const char * text)
245  /*@modifies h @*/;
246 
253 int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
254  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
255  /*@modifies spec->build, spec->install, spec->check, spec->clean,
256  spec->macros, spec->foo, spec->nfoo, spec->lbufPtr,
257  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
258  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
259  rpmGlobalMacroContext, fileSystem, internalState @*/;
260 
266 int parseChangelog(Spec spec)
267  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
268  /*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
269  spec->foo, spec->nfoo, spec->lbufPtr,
270  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
271  spec->packages->header,
272  rpmGlobalMacroContext, fileSystem, internalState @*/;
273 
279 int parseDescription(Spec spec)
280  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
281  /*@modifies spec->packages,
282  spec->foo, spec->nfoo, spec->lbufPtr,
283  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
284  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
285  spec->st,
286  rpmGlobalMacroContext, fileSystem, internalState @*/;
287 
293 int parseFiles(Spec spec)
294  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
295  /*@modifies spec->packages,
296  spec->foo, spec->nfoo, spec->lbufPtr,
297  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
298  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
299  rpmGlobalMacroContext, fileSystem, internalState @*/;
300 
307 int parsePreamble(Spec spec, int initialPackage)
308  /*@globals rpmGlobalMacroContext, h_errno,
309  fileSystem, internalState @*/
310  /*@modifies spec->packages,
311  spec->foo, spec->nfoo, spec->lbufPtr,
312  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
313  spec->buildSubdir,
314  spec->macros, spec->st,
315  spec->sources, spec->numSources, spec->noSource,
316  spec->sourceHeader, spec->BANames, spec->BACount,
317  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
318  rpmGlobalMacroContext, fileSystem, internalState @*/;
319 
326 int parsePrep(Spec spec, int verify)
327  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
328  /*@modifies spec->prep, spec->buildSubdir, spec->macros,
329  spec->foo, spec->nfoo, spec->lbufPtr,
330  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
331  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
332  spec->packages->header,
333  rpmGlobalMacroContext, fileSystem, internalState @*/;
334 
345 rpmRC parseRCPOT(Spec spec, Package pkg, const char * field, rpmTag tagN,
346  rpmuint32_t index, rpmsenseFlags tagflags)
347  /*@globals internalState @*/
348  /*@modifies internalState @*/;
349 
356 int parseScript(Spec spec, int parsePart)
357  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
358  /*@modifies spec->packages,
359  spec->foo, spec->nfoo, spec->lbufPtr,
360  spec->fileStack, spec->readStack, spec->line, spec->lineNum,
361  spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
362  rpmGlobalMacroContext, fileSystem, internalState @*/;
363 
370 int parseExpressionBoolean(Spec spec, const char * expr)
371  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
372  /*@modifies rpmGlobalMacroContext, internalState @*/;
373 
380 /*@unused@*/ /*@null@*/
381 char * parseExpressionString(Spec spec, const char * expr)
382  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
383  /*@modifies rpmGlobalMacroContext, internalState @*/;
384 
395 rpmRC doScript(Spec spec, int what, /*@null@*/ const char * name,
396  /*@null@*/ rpmiob iob, int test)
397  /*@globals rpmGlobalMacroContext, h_errno,
398  fileSystem, internalState @*/
399  /*@modifies spec->macros,
400  rpmGlobalMacroContext, fileSystem, internalState @*/;
401 
410 rpmRC lookupPackage(Spec spec, /*@null@*/ const char * name, int flag,
411  /*@out@*/ Package * pkg)
412  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
413  /*@modifies spec->packages, *pkg, rpmGlobalMacroContext,
414  internalState @*/;
415 
421 /*@null@*/
422 Package freePackages(/*@only@*/ /*@null@*/ Package packages)
423  /*@globals fileSystem @*/
424  /*@modifies packages, fileSystem @*/;
425 
432 /*@null@*/
433 Package freePackage(/*@killref@*/ /*@null@*/ Package pkg)
434  /*@globals fileSystem @*/
435  /*@modifies pkg, fileSystem @*/;
436 #define freePackage(_pkg) \
437  ((Package)rpmioFreePoolItem((rpmioItem)(_pkg), __FUNCTION__, __FILE__, __LINE__))
438 
444 /*@only@*/
445 Package newPackage(Spec spec)
446  /*@modifies spec->packages, spec->packages->next @*/;
447 
459 int addReqProv(/*@unused@*/Spec spec, Header h, rpmTag tagN,
460  const char * N, const char * EVR, rpmsenseFlags Flags,
461  rpmuint32_t index)
462  /*@globals internalState @*/
463  /*@modifies h, internalState @*/;
464 
472  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
473  /*@modifies pkg->header, rpmGlobalMacroContext,
474  fileSystem, internalState @*/;
475 
482  /*@globals internalState @*/
483  /*@modifies h, internalState @*/;
484 
492 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
493  /*@globals internalState @*/
494  /*@modifies h, internalState @*/;
495 
503 rpmRC processBinaryFiles(Spec spec, int installSpecialDoc, int test)
504  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
505  /*@modifies spec->macros, *spec->packages,
506  spec->packages->fi, spec->packages->fileList,
507  spec->packages->specialDoc, spec->packages->header,
508  rpmGlobalMacroContext, fileSystem, internalState @*/;
509 
516 int initSourceHeader(Spec spec, /*@null@*/ rpmiob *sfp)
517  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
518  /*@modifies spec->sourceHeader, spec->sourceHdrInit,
519  spec->BANames, *sfp,
520  spec->packages->header,
521  rpmGlobalMacroContext, internalState @*/;
522 
528 int processSourceFiles(Spec spec)
529  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
530  /*@modifies spec->sourceHeader, spec->sourceCpioList,
531  spec->BANames, spec->sourceHdrInit,
532  spec->packages->header,
533  rpmGlobalMacroContext, fileSystem, internalState @*/;
534 
548 int parseSpec(rpmts ts, const char * specFile,
549  /*@null@*/ const char * rootURL,
550  int recursing,
551  /*@null@*/ const char * passPhrase,
552  /*@null@*/ const char * cookie,
553  int anyarch, int force, int verify)
554  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
555  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
556 
565 rpmRC buildSpec(rpmts ts, Spec spec, int what, int test)
566  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
567  /*@modifies spec->sourceHeader, spec->sourceCpioList, spec->cookie,
568  spec->sourceRpmName, spec->sourcePkgId, spec->sourceHdrInit,
569  spec->macros, spec->BASpecs,
570  spec->BANames, *spec->packages,
571  spec->packages->fi, spec->packages->fileList,
572  spec->packages->specialDoc, spec->packages->header,
573  rpmGlobalMacroContext, fileSystem, internalState @*/;
574 
581  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
582  /*@modifies spec->packages->header, spec->packages->fi,
583  spec->sourceRpmName, spec->cookie, spec->sourcePkgId,
584  rpmGlobalMacroContext, fileSystem, internalState @*/;
585 
592  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
593  /*@modifies spec->sourceHeader, spec->cookie, spec->sourceCpioList,
594  spec->sourceRpmName, spec->sourcePkgId, spec->packages->header,
595  rpmGlobalMacroContext, fileSystem, internalState @*/;
596 
597 /*@=redecl@*/
598 #ifdef __cplusplus
599 }
600 #endif
601 
602 #endif /* _H_RPMBUILD_ */
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
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
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:16
#define PART_BASE
Spec file parser states.
Definition: rpmbuild.h:54
enum rpmBuildFlags_e rpmBuildFlags
Bit(s) to control buildSpec() operation.
enum rpmStripFlags_e rpmStripFlags
Spec file parser stripping flags.
rpmuint32_t * getBuildTime(void)
Return build time stamp.
Definition: names.c:197
char * parseExpressionString(Spec spec, const char *expr)
Evaluate string expression.
Definition: expression.c:726
const char * getGname(gid_t gid)
Return cached group name from group id.
Definition: names.c:119
void freeNames(void)
Destroy uid/gid caches.
Definition: names.c:32
Package newPackage(Spec spec)
Create and initialize package control structure.
Definition: spec.c:208
Package freePackages(Package packages)
Destroy all packages associated with spec file.
Definition: spec.c:245
Structure(s) used for file info tag sets.
void handleComments(char *s)
Truncate comment lines.
Definition: parseSpec.c:144
The Header data structure.
rpmRC lookupPackage(Spec spec, const char *name, int flag, Package *pkg)
Find sub-package control structure by name.
Definition: spec.c:82
int parsePreamble(Spec spec, int initialPackage)
Parse tags from preamble of a spec file.
rpmRC packageSources(Spec spec)
Generate source package.
Definition: pack.c:1301
int processSourceFiles(Spec spec)
Post-build processing for source package.
Definition: files.c:2737
const char * getUname(uid_t uid)
Return cached user name from user id.
Definition: names.c:41
const char * buildHost(void)
Return build hostname.
Definition: names.c:206
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
Definition: parseSpec.c:68
unsigned int rpmuint32_t
Definition: rpmiotypes.h:25
rpmParseState_e
Definition: rpmbuild.h:55
void addChangelogEntry(Header h, time_t time, const char *name, const char *text)
Add changelog entry to header.
int parseDescription(Spec spec)
Parse %description section of a spec file.
int parseExpressionBoolean(Spec spec, const char *expr)
Evaluate boolean expression.
Definition: expression.c:679
rpmRC buildSpec(rpmts ts, Spec spec, int what, int test)
Build stages state machine driver.
Definition: build.c:338
gid_t getGidS(const char *gname)
Return cached group id.
Definition: names.c:170
int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
Parse %build/%install/%clean section(s) of a spec file.
enum evrFlags_e rpmsenseFlags
Definition: rpmevr.h:72
int parseScript(Spec spec, int parsePart)
Parse %pre et al scriptlets from a spec file.
Definition: parseScript.c:74
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:527
The structure used to store values parsed from a spec file.
Definition: rpmspec.h:108
void providePackageNVR(Header h)
Retrofit an explicit Provides: N = E:V-R dependency into package headers.
Definition: pack.c:452
rpmRC processScriptFiles(Spec spec, Package pkg)
Append files (if any) to scriptlet tags.
Definition: pack.c:212
rpmRC processBinaryFiles(Spec spec, int installSpecialDoc, int test)
Post-build processing for binary package(s).
Definition: files.c:3144
rpmBuildFlags_e
Bit(s) to control buildSpec() operation.
Definition: rpmbuild.h:24
enum rpmRC_e rpmRC
RPM return codes.
int _rpmbuildFlags
Definition: poptBT.c:53
int parseChangelog(Spec spec)
Parse %changelog section of a spec file.
int parseNum(const char *line, rpmuint32_t *res)
Parse a number.
Definition: misc.c:11
struct rpmts_s * rpmts
The RPM Transaction Set.
Definition: rpmtypes.h:14
struct rpmiob_s * rpmiob
Definition: rpmiotypes.h:57
rpmRC packageBinaries(Spec spec)
Generate binary package(s).
Definition: pack.c:1149
uid_t getUidS(const char *uname)
Return cached user id.
Definition: names.c:92
enum rpmParseState_e rpmParseState
int readLine(Spec spec, rpmStripFlags strip)
Read next line from spec file.
Definition: parseSpec.c:353
int initSourceHeader(Spec spec, rpmiob *sfp)
Create and initialize header for source package.
Definition: files.c:2552
int parsePrep(Spec spec, int verify)
Parse %prep section of a spec file.
Definition: parsePrep.c:887
#define freePackage(_pkg)
Definition: rpmbuild.h:436
static const char * name
int parseFiles(Spec spec)
Parse %files section of a spec file.
Definition: parseFiles.c:28
rpmStripFlags_e
Spec file parser stripping flags.
Definition: rpmbuild.h:92
The structure used to store values for a package.
Definition: rpmspec.h:207
The Spec and Package data structures used during build.
enum rpmTag_e rpmTag
Definition: rpmtag.h:471
int rpmlibNeedsFeature(Header h, const char *feature, const char *featureEVR)
Add rpmlib feature dependency.
Definition: reqprov.c:258
const char * getUnameS(const char *uname)
Return cached user name.
Definition: names.c:65
void closeSpec(Spec spec)
Stop reading from spec file, freeing resources.
Definition: parseSpec.c:484
const char * getGnameS(const char *gname)
Return cached group name.
Definition: names.c:143