1 #ifndef _RPMBUILD_INTERNAL_H
2 #define _RPMBUILD_INTERNAL_H
4 #include <rpm/rpmbuild.h>
5 #include <rpm/rpmutil.h>
6 #include "build/rpmbuild_misc.h"
8 struct TriggerFileEntry {
14 struct TriggerFileEntry * next;
17 typedef struct ReadLevelEntry {
20 struct ReadLevelEntry * next;
27 const char * source; /* Pointer into fullSource */
33 typedef struct Package_s * Package;
36 * The structure used to store values parsed from a spec file.
39 char * specFile; /*!< Name of the spec file. */
44 struct OpenFileInfo * fileStack;
53 struct ReadLevelEntry * readStack;
55 Header buildRestrictions;
57 const char ** BANames;
59 int recursing; /*!< parse is recursive? */
63 struct Source * sources;
68 unsigned char * sourcePkgId;
72 rpmMacroContext macros;
74 StringBuf prep; /*!< %prep scriptlet. */
75 StringBuf build; /*!< %build scriptlet. */
76 StringBuf install; /*!< %install scriptlet. */
77 StringBuf check; /*!< %check scriptlet. */
78 StringBuf clean; /*!< %clean scriptlet. */
80 StringBuf parsed; /*!< parsed spec contents */
82 Package packages; /*!< Package list. */
86 * The structure used to store values for a package.
90 rpmds ds; /*!< Requires: N = EVR */
98 char * preInFile; /*!< %pre scriptlet. */
99 char * postInFile; /*!< %post scriptlet. */
100 char * preUnFile; /*!< %preun scriptlet. */
101 char * postUnFile; /*!< %postun scriptlet. */
102 char * preTransFile; /*!< %pretrans scriptlet. */
103 char * postTransFile; /*!< %posttrans scriptlet. */
104 char * verifyFile; /*!< %verifyscript scriptlet. */
106 struct TriggerFileEntry * triggerFiles;
109 ARGV_t fileList; /* If NULL, package will not be written */
115 #define PART_SUBNAME 0
118 /** \ingroup rpmbuild
119 * rpmSpec file parser states.
122 typedef enum rpmParseState_e {
123 PART_ERROR = -1, /*!< */
124 PART_NONE = 0+PART_BASE, /*!< */
125 /* leave room for RPMRC_NOTFOUND returns. */
126 PART_PREAMBLE = 11+PART_BASE, /*!< */
127 PART_PREP = 12+PART_BASE, /*!< */
128 PART_BUILD = 13+PART_BASE, /*!< */
129 PART_INSTALL = 14+PART_BASE, /*!< */
130 PART_CHECK = 15+PART_BASE, /*!< */
131 PART_CLEAN = 16+PART_BASE, /*!< */
132 PART_FILES = 17+PART_BASE, /*!< */
133 PART_PRE = 18+PART_BASE, /*!< */
134 PART_POST = 19+PART_BASE, /*!< */
135 PART_PREUN = 20+PART_BASE, /*!< */
136 PART_POSTUN = 21+PART_BASE, /*!< */
137 PART_PRETRANS = 22+PART_BASE, /*!< */
138 PART_POSTTRANS = 23+PART_BASE, /*!< */
139 PART_DESCRIPTION = 24+PART_BASE, /*!< */
140 PART_CHANGELOG = 25+PART_BASE, /*!< */
141 PART_TRIGGERIN = 26+PART_BASE, /*!< */
142 PART_TRIGGERUN = 27+PART_BASE, /*!< */
143 PART_VERIFYSCRIPT = 28+PART_BASE, /*!< */
144 PART_BUILDARCHITECTURES= 29+PART_BASE,/*!< */
145 PART_TRIGGERPOSTUN = 30+PART_BASE, /*!< */
146 PART_TRIGGERPREIN = 31+PART_BASE, /*!< */
147 PART_POLICIES = 32+PART_BASE, /*!< */
148 PART_LAST = 33+PART_BASE /*!< */
152 #define STRIP_NOTHING 0
153 #define STRIP_TRAILINGSPACE (1 << 0)
154 #define STRIP_COMMENTS (1 << 1)
160 /** \ingroup rpmbuild
161 * Create and initialize rpmSpec structure.
162 * @return spec spec file control structure
165 rpmSpec newSpec(void);
167 /** \ingroup rpmbuild
168 * Stop reading from spec file, freeing resources.
169 * @param spec spec file control structure
172 void closeSpec(rpmSpec spec);
174 /** \ingroup rpmbuild
175 * Read next line from spec file.
176 * @param spec spec file control structure
177 * @param strip truncate comments?
178 * @return 0 on success, 1 on EOF, <0 on error
181 int readLine(rpmSpec spec, int strip);
183 /** \ingroup rpmbuild
184 * Check line for section separator, return next parser state.
185 * @param line from spec file
186 * @return next parser state
189 int isPart(const char * line) ;
191 /** \ingroup rpmbuild
192 * Parse %%build/%%install/%%clean section(s) of a spec file.
193 * @param spec spec file control structure
194 * @param parsePart current rpmParseState
195 * @return >= 0 next rpmParseState, < 0 on error
198 int parseBuildInstallClean(rpmSpec spec, int parsePart);
200 /** \ingroup rpmbuild
201 * Parse %%changelog section of a spec file.
202 * @param spec spec file control structure
203 * @return >= 0 next rpmParseState, < 0 on error
206 int parseChangelog(rpmSpec spec);
208 /** \ingroup rpmbuild
209 * Parse %%description section of a spec file.
210 * @param spec spec file control structure
211 * @return >= 0 next rpmParseState, < 0 on error
214 int parseDescription(rpmSpec spec);
216 /** \ingroup rpmbuild
217 * Parse %%files section of a spec file.
218 * @param spec spec file control structure
219 * @return >= 0 next rpmParseState, < 0 on error
222 int parseFiles(rpmSpec spec);
224 /** \ingroup rpmbuild
225 * Parse %%sepolicy section of a spec file.
226 * @param spec spec file control structure
227 * @return >= 0 next rpmParseState, < 0 on error
230 int parsePolicies(rpmSpec spec);
232 /** \ingroup rpmbuild
233 * Parse tags from preamble of a spec file.
234 * @param spec spec file control structure
235 * @param initialPackage
236 * @return >= 0 next rpmParseState, < 0 on error
239 int parsePreamble(rpmSpec spec, int initialPackage);
241 /** \ingroup rpmbuild
242 * Parse %%prep section of a spec file.
243 * @param spec spec file control structure
244 * @return >= 0 next rpmParseState, < 0 on error
247 int parsePrep(rpmSpec spec);
249 /** \ingroup rpmbuild
250 * Parse %%pre et al scriptlets from a spec file.
251 * @param spec spec file control structure
252 * @param parsePart current rpmParseState
253 * @return >= 0 next rpmParseState, < 0 on error
256 int parseScript(rpmSpec spec, int parsePart);
258 /** \ingroup rpmbuild
259 * Check for inappropriate characters. All alphanums are considered sane.
261 * @param field string to check
262 * @param fsize size of string to check
263 * @param whitelist string of permitted characters
264 * @return RPMRC_OK if OK
267 rpmRC rpmCharCheck(rpmSpec spec, const char *field, size_t fsize, const char *whitelist);
269 /** \ingroup rpmbuild
270 * Parse dependency relations from spec file and/or autogenerated output buffer.
271 * @param spec spec file control structure
272 * @param pkg package control structure
273 * @param field text to parse (e.g. "foo < 0:1.2-3, bar = 5:6.7")
274 * @param tagN tag, identifies type of dependency
275 * @param index (0 always)
276 * @param tagflags dependency flags already known from context
277 * @return RPMRC_OK on success, RPMRC_FAIL on failure
280 rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char * field, rpmTagVal tagN,
281 int index, rpmsenseFlags tagflags);
283 /** \ingroup rpmbuild
284 * Evaluate boolean expression.
285 * @param spec spec file control structure
286 * @param expr expression to parse
290 int parseExpressionBoolean(rpmSpec spec, const char * expr);
292 /** \ingroup rpmbuild
293 * Run a build script, assembled from spec file scriptlet section.
295 * @param spec spec file control structure
296 * @param what type of script
297 * @param name name of scriptlet section
298 * @param sb lines that compose script body
299 * @param test don't execute scripts or package if testing
300 * @return RPMRC_OK on success
303 rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char * name,
304 const char * sb, int test);
306 /** \ingroup rpmbuild
307 * Find sub-package control structure by name.
308 * @param spec spec file control structure
309 * @param name (sub-)package name
310 * @param flag if PART_SUBNAME, then 1st package name is prepended
311 * @retval pkg package control structure
312 * @return 0 on success, 1 on failure
315 rpmRC lookupPackage(rpmSpec spec, const char * name, int flag,
318 /** \ingroup rpmbuild
319 * Create and initialize package control structure.
320 * @param spec spec file control structure
321 * @return package control structure
324 Package newPackage(rpmSpec spec);
326 /** \ingroup rpmbuild
327 * Post-build processing for binary package(s).
328 * @param spec spec file control structure
329 * @param pkgFlags bit(s) to control package generation
330 * @param installSpecialDoc
331 * @param test don't execute scripts or package if testing
332 * @return 0 on success
335 rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
336 int installSpecialDoc, int test);
339 * Generate package dependencies.
340 * @param spec spec file control
341 * @param pkg package control
342 * @return RPMRC_OK on success
345 rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg);
348 * Return helper output.
349 * @param av helper argv (with possible macros)
350 * @param sb_stdin helper input
351 * @retval *sb_stdoutp helper output
352 * @param failnonzero IS non-zero helper exit status a failure?
353 * @param buildRoot buildRoot directory (or NULL)
356 int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
357 int failnonzero, const char *buildRoot);
359 /** \ingroup rpmbuild
360 * Post-build processing for policies in binary package(s).
361 * @param spec spec file control structure
362 * @param test don't execute scripts or package if testing
363 * @return 0 on success
366 rpmRC processBinaryPolicies(rpmSpec spec, int test);
368 /** \ingroup rpmbuild
369 * Post-build processing for source package.
370 * @param spec spec file control structure
371 * @param pkgFlags bit(s) to control package generation
372 * @return 0 on success
375 rpmRC processSourceFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags);
377 /** \ingroup rpmbuild
378 * Generate binary package(s).
379 * @param spec spec file control structure
380 * @param cookie build identifier "cookie" or NULL
381 * @param cheating was build shortcircuited?
382 * @return RPMRC_OK on success
385 rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating);
387 /** \ingroup rpmbuild
388 * Generate source package.
389 * @param spec spec file control structure
390 * @retval cookie build identifier "cookie" or NULL
391 * @return RPMRC_OK on success
394 rpmRC packageSources(rpmSpec spec, char **cookie);
400 #endif /* _RPMBUILD_INTERNAL_H */