rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

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@*/
26 RPMBUILD_NONE = 0,
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),
34 RPMBUILD_PACKAGESOURCE = (1 << 6),
35 RPMBUILD_PACKAGEBINARY = (1 << 7),
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),
41 RPMBUILD_FETCHSOURCE= (1 << 13)
42 } rpmBuildFlags;
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 {
56 PART_NONE = 0+PART_BASE,
57 /* leave room for RPMRC_NOTFOUND returns. */
58 PART_PREAMBLE = 11+PART_BASE,
59 PART_PREP = 12+PART_BASE,
60 PART_BUILD = 13+PART_BASE,
61 PART_INSTALL = 14+PART_BASE,
62 PART_CHECK = 15+PART_BASE,
63 PART_CLEAN = 16+PART_BASE,
64 PART_FILES = 17+PART_BASE,
65 PART_PRE = 18+PART_BASE,
66 PART_POST = 19+PART_BASE,
67 PART_PREUN = 20+PART_BASE,
68 PART_POSTUN = 21+PART_BASE,
69 PART_PRETRANS = 22+PART_BASE,
70 PART_POSTTRANS = 23+PART_BASE,
71 PART_DESCRIPTION = 24+PART_BASE,
72 PART_CHANGELOG = 25+PART_BASE,
73 PART_TRIGGERIN = 26+PART_BASE,
74 PART_TRIGGERUN = 27+PART_BASE,
75 PART_VERIFYSCRIPT = 28+PART_BASE,
76 PART_BUILDARCHITECTURES= 29+PART_BASE,
77 PART_TRIGGERPOSTUN = 30+PART_BASE,
78 PART_TRIGGERPREIN = 31+PART_BASE,
79 /* support "%sanitycheck" script */
80 PART_SANITYCHECK = 32+PART_BASE,
81 PART_ARBITRARY = 33+PART_BASE,
82 PART_LAST = 34+PART_BASE
83 } rpmParseState;
84
88 typedef enum rpmStripFlags_e {
89 STRIP_NOTHING = 0,
90 STRIP_TRAILINGSPACE = (1 << 0),
91 STRIP_COMMENTS = (1 << 1),
92 STRIP_NOEXPAND = (1 << 2)
93 } rpmStripFlags;
94
95 /*@unchecked@*/
96 extern int _rpmbuildFlags;
97
98 #ifdef __cplusplus
99 extern "C" {
100 #endif
101 /*@-redecl@*/
102
106 void freeNames(void)
107 /*@globals internalState@*/
108 /*@modifies internalState */;
109
116 extern /*@observer@*/ const char * getUname(uid_t uid)
117 /*@globals internalState @*/
118 /*@modifies internalState @*/;
119
126 extern /*@observer@*/ const char * getUnameS(const char * uname)
127 /*@globals internalState @*/
128 /*@modifies internalState @*/;
129
136 uid_t getUidS(const char * uname)
137 /*@globals internalState @*/
138 /*@modifies internalState @*/;
139
146 extern /*@observer@*/ const char * getGname(gid_t gid)
147 /*@globals internalState @*/
148 /*@modifies internalState @*/;
149
156 extern /*@observer@*/ const char * getGnameS(const char * gname)
157 /*@globals internalState @*/
158 /*@modifies internalState @*/;
159
166 gid_t getGidS(const char * gname)
167 /*@globals internalState @*/
168 /*@modifies internalState @*/;
169
174 /*@observer@*/
175 extern const char * buildHost(void)
176 /*@*/;
177
182 /*@observer@*/
183 extern rpmuint32_t * getBuildTime(void)
184 /*@*/;
185
192 int readLine(Spec spec, rpmStripFlags strip)
193 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
194 /*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
195 spec->lbufPtr,
196 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
197 rpmGlobalMacroContext, fileSystem, internalState @*/;
198
203 void closeSpec(/*@partial@*/ Spec spec)
204 /*@globals fileSystem, internalState @*/
205 /*@modifies spec->fileStack, fileSystem, internalState @*/;
206
211 void handleComments(char * s)
212 /*@modifies s @*/;
213
219 rpmParseState isPart(Spec spec)
220 /*@modifies spec->foo, spec->nfoo @*/;
221
228 int parseNum(/*@null@*/ const char * line, /*@null@*/ /*@out@*/rpmuint32_t * res)
229 /*@modifies *res @*/;
230
239 void addChangelogEntry(Header h, time_t time, const char * name,
240 const char * text)
241 /*@modifies h @*/;
242
249 int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
250 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
251 /*@modifies spec->build, spec->install, spec->check, spec->clean,
252 spec->macros, spec->foo, spec->nfoo, spec->lbufPtr,
253 spec->fileStack, spec->readStack, spec->line, spec->lineNum,
254 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
255 rpmGlobalMacroContext, fileSystem, internalState @*/;
256
262 int parseChangelog(Spec spec)
263 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
264 /*@modifies spec->fileStack, spec->readStack, spec->line, spec->lineNum,
265 spec->foo, spec->nfoo, spec->lbufPtr,
266 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
267 spec->packages->header,
268 rpmGlobalMacroContext, fileSystem, internalState @*/;
269
275 int parseDescription(Spec spec)
276 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
277 /*@modifies spec->packages,
278 spec->foo, spec->nfoo, spec->lbufPtr,
279 spec->fileStack, spec->readStack, spec->line, spec->lineNum,
280 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
281 spec->st,
282 rpmGlobalMacroContext, fileSystem, internalState @*/;
283
289 int parseFiles(Spec spec)
290 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
291 /*@modifies spec->packages,
292 spec->foo, spec->nfoo, spec->lbufPtr,
293 spec->fileStack, spec->readStack, spec->line, spec->lineNum,
294 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
295 rpmGlobalMacroContext, fileSystem, internalState @*/;
296
303 int parsePreamble(Spec spec, int initialPackage)
304 /*@globals rpmGlobalMacroContext, h_errno,
305 fileSystem, internalState @*/
306 /*@modifies spec->packages,
307 spec->foo, spec->nfoo, spec->lbufPtr,
308 spec->fileStack, spec->readStack, spec->line, spec->lineNum,
309 spec->buildSubdir,
310 spec->macros, spec->st,
311 spec->sources, spec->numSources, spec->noSource,
312 spec->sourceHeader, spec->BANames, spec->BACount,
313 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
314 rpmGlobalMacroContext, fileSystem, internalState @*/;
315
322 int parsePrep(Spec spec, int verify)
323 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
324 /*@modifies spec->prep, spec->buildSubdir, spec->macros,
325 spec->foo, spec->nfoo, spec->lbufPtr,
326 spec->fileStack, spec->readStack, spec->line, spec->lineNum,
327 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
328 spec->packages->header,
329 rpmGlobalMacroContext, fileSystem, internalState @*/;
330
341 rpmRC parseRCPOT(Spec spec, Package pkg, const char * field, rpmTag tagN,
342 rpmuint32_t index, rpmsenseFlags tagflags)
343 /*@globals internalState @*/
344 /*@modifies internalState @*/;
345
352 int parseScript(Spec spec, int parsePart)
353 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
354 /*@modifies spec->packages,
355 spec->foo, spec->nfoo, spec->lbufPtr,
356 spec->fileStack, spec->readStack, spec->line, spec->lineNum,
357 spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl,
358 rpmGlobalMacroContext, fileSystem, internalState @*/;
359
366 int parseExpressionBoolean(Spec spec, const char * expr)
367 /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
368 /*@modifies rpmGlobalMacroContext, internalState @*/;
369
376 /*@unused@*/ /*@null@*/
377 char * parseExpressionString(Spec spec, const char * expr)
378 /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
379 /*@modifies rpmGlobalMacroContext, internalState @*/;
380
391 rpmRC doScript(Spec spec, int what, /*@null@*/ const char * name,
392 /*@null@*/ rpmiob iob, int test)
393 /*@globals rpmGlobalMacroContext, h_errno,
394 fileSystem, internalState @*/
395 /*@modifies spec->macros,
396 rpmGlobalMacroContext, fileSystem, internalState @*/;
397
406 rpmRC lookupPackage(Spec spec, /*@null@*/ const char * name, int flag,
407 /*@out@*/ Package * pkg)
408 /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
409 /*@modifies spec->packages, *pkg, rpmGlobalMacroContext,
410 internalState @*/;
411
417 /*@only@*/
418 Package newPackage(Spec spec)
419 /*@modifies spec->packages, spec->packages->next @*/;
420
426 /*@null@*/
427 Package freePackages(/*@only@*/ /*@null@*/ Package packages)
428 /*@globals fileSystem @*/
429 /*@modifies packages, fileSystem @*/;
430
436 /*@null@*/
437 Package freePackage(/*@only@*/ /*@null@*/ Package pkg)
438 /*@globals fileSystem @*/
439 /*@modifies pkg, fileSystem @*/;
440
452 int addReqProv(/*@unused@*/Spec spec, Header h, rpmTag tagN,
453 const char * N, const char * EVR, rpmsenseFlags Flags,
454 rpmuint32_t index)
455 /*@globals internalState @*/
456 /*@modifies h, internalState @*/;
457
464 rpmRC processScriptFiles(Spec spec, Package pkg)
465 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
466 /*@modifies pkg->header, rpmGlobalMacroContext,
467 fileSystem, internalState @*/;
468
474 void providePackageNVR(Header h)
475 /*@globals internalState @*/
476 /*@modifies h, internalState @*/;
477
485 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
486 /*@globals internalState @*/
487 /*@modifies h, internalState @*/;
488
496 rpmRC processBinaryFiles(Spec spec, int installSpecialDoc, int test)
497 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
498 /*@modifies spec->macros, *spec->packages,
499 spec->packages->cpioList, spec->packages->fileList,
500 spec->packages->specialDoc, spec->packages->header,
501 rpmGlobalMacroContext, fileSystem, internalState @*/;
502
509 int initSourceHeader(Spec spec, /*@null@*/ rpmiob *sfp)
510 /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
511 /*@modifies spec->sourceHeader, spec->sourceHdrInit,
512 spec->BANames, *sfp,
513 spec->packages->header,
514 rpmGlobalMacroContext, internalState @*/;
515
521 int processSourceFiles(Spec spec)
522 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
523 /*@modifies spec->sourceHeader, spec->sourceCpioList,
524 spec->BANames, spec->sourceHdrInit,
525 spec->packages->header,
526 rpmGlobalMacroContext, fileSystem, internalState @*/;
527
541 int parseSpec(rpmts ts, const char * specFile,
542 /*@null@*/ const char * rootURL,
543 int recursing,
544 /*@null@*/ const char * passPhrase,
545 /*@null@*/ const char * cookie,
546 int anyarch, int force, int verify)
547 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
548 /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
549
558 rpmRC buildSpec(rpmts ts, Spec spec, int what, int test)
559 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
560 /*@modifies spec->sourceHeader, spec->sourceCpioList, spec->cookie,
561 spec->sourceRpmName, spec->sourcePkgId, spec->sourceHdrInit,
562 spec->macros, spec->BASpecs,
563 spec->BANames, *spec->packages,
564 spec->packages->cpioList, spec->packages->fileList,
565 spec->packages->specialDoc, spec->packages->header,
566 rpmGlobalMacroContext, fileSystem, internalState @*/;
567
573 rpmRC packageBinaries(Spec spec)
574 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
575 /*@modifies spec->packages->header, spec->packages->cpioList,
576 spec->sourceRpmName, spec->cookie, spec->sourcePkgId,
577 rpmGlobalMacroContext, fileSystem, internalState @*/;
578
584 rpmRC packageSources(Spec spec)
585 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
586 /*@modifies spec->sourceHeader, spec->cookie, spec->sourceCpioList,
587 spec->sourceRpmName, spec->sourcePkgId, spec->packages->header,
588 rpmGlobalMacroContext, fileSystem, internalState @*/;
589
590 /*@=redecl@*/
591 #ifdef __cplusplus
592 }
593 #endif
594
595 #endif /* _H_RPMBUILD_ */