12 #define _RPMTAG_INTERNAL
66 const char * line = spec->
line;
92 if (aTags !=
NULL && aTags[0] !=
NULL) {
97 #if defined(RPM_VENDOR_OPENPKG)
98 av = argvSearchLinear(aTags, s, argvFnmatchCasefold);
123 const char *
b, *
be = line;
124 size_t toklen = strlen(token);
127 while ( *(b = be) !=
'\0' ) {
133 if (toklen != (
size_t)(be-b) ||
xstrncasecmp(token, b, (be-b)))
189 int pc = 0,
bc = 0, nc = 0;
194 while (from && *from && ch !=
'\n')
195 ch = *to++ = *from++;
203 for (p = spec->
lbuf; *p; p++) {
207 case '\n': p++, nc = 1;
break;
212 case '\n': nc = 0;
break;
215 case '{': p++,
bc++;
break;
216 case '(': p++, pc++;
break;
217 case '%': p++;
break;
220 case '{':
if (
bc > 0)
bc++;
break;
221 case '}':
if (
bc > 0)
bc--;
break;
222 case '(':
if (pc > 0) pc++;
break;
223 case ')':
if (pc > 0) pc--;
break;
229 if (pc ||
bc || nc ) {
266 while (*spec->
nextline && ch !=
'\n') {
384 }
else if (! strncmp(
"%ifarch", s,
sizeof(
"%ifarch")-1)) {
389 }
else if (! strncmp(
"%ifnarch", s,
sizeof(
"%ifnarch")-1)) {
394 }
else if (! strncmp(
"%ifos", s,
sizeof(
"%ifos")-1)) {
399 }
else if (! strncmp(
"%ifnos", s,
sizeof(
"%ifnos")-1)) {
404 }
else if (! strncmp(
"%if", s,
sizeof(
"%if")-1)) {
409 _(
"%s:%d: parseExpressionBoolean returns %d\n"),
413 }
else if (! strncmp(
"%else", s,
sizeof(
"%else")-1)) {
418 _(
"%s:%d: Got a %%else with no %%if\n"),
424 spec->
line[0] =
'\0';
425 }
else if (! strncmp(
"%endif", s,
sizeof(
"%endif")-1)) {
430 _(
"%s:%d: Got a %%endif with no %%if\n"),
437 spec->
line[0] =
'\0';
438 }
else if (spec->
readStack->
reading && ! strncmp(
"%include", s,
sizeof(
"%include")-1)) {
439 char *fileName, *endFileName, *
p;
448 endFileName = fileName;
470 spec->
line[0] =
'\0';
474 spec->
line[0] =
'\0';
508 const char *
N, *V, *R;
509 char fileName[BUFSIZ];
512 (
void)
snprintf(fileName,
sizeof(fileName),
"%s-%s-%s.%ssrc.rpm",
514 fileName[
sizeof(fileName)-1] =
'\0';
536 int initialPackage = 1;
557 spec->
toplevel = (!recursing ? 1 : 0);
631 if (goterror || parsePart >=
PART_LAST) {
651 for (x = 0; x < spec->
BACount; x++) {
659 passPhrase, cookie, anyarch, force, verify)
677 _(
"No compatible architectures found for build\n"));
712 const char *platformNoarch =
NULL;
734 if(pkg->
noarch && !platformNoarch &&
strcmp(arch,
"noarch")) {
757 platform =
_free(platform);
758 platformNoarch =
_free(platformNoarch);
769 platform =
_free(platform);
770 platformNoarch =
_free(platformNoarch);
static void initParts(struct PartRec *p)
void handleComments(char *s)
Truncate comment lines.
enum rpmStripFlags_e rpmStripFlags
Spec file parser stripping flags.
rpmlog(RPMLOG_ERR,"%s\n", buf)
const char * sourceRpmName
Spec rpmtsSetSpec(rpmts ts, Spec spec)
Set a spec control structure in transaction set.
struct OpenFileInfo * next
char * xstrdup(const char *str)
int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
Parse %build/%install/%clean section(s) of a spec file.
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
Spec freeSpec(Spec spec)
Destroy a spec file control structure.
struct rpmts_s * rpmts
The RPM Transaction Set.
int parseExpressionBoolean(Spec spec, const char *expr)
Evaluate boolean expression.
int argvStrcasecmp(ARGstr_t *a, ARGstr_t *b)
Compare argv elements using strcasecmp (qsort/bsearch).
void addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
int parsePrep(Spec spec, int verify)
Parse %prep section of a spec file.
rpmiob rpmiobAppend(rpmiob iob, const char *s, size_t nl)
Append string to I/O buffer.
static int genSourceRpmName(Spec spec)
int xstrncasecmp(const char *s1, const char *s2, size_t n)
Locale insensitive strncasecmp(3).
rpmTag tagGenerate(const char *s)
Generate a tag from arbitrary string.
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.
memset(_r, 0, sizeof(*_r))
int parsePreamble(Spec spec, int initialPackage)
Parse tags from preamble of a spec file.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
void * xcalloc(size_t nmemb, size_t size)
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
static int readLineFromOFI(Spec spec, OFI_t *ofi)
static int xisspace(int c)
const char * tagName(rpmTag tag)
Return tag name from value.
int parseChangelog(Spec spec)
Parse %changelog section of a spec file.
static struct PartRec partList[]
Structure(s) used for dependency tag sets.
Spec newSpec(void)
Create and initialize Spec structure.
The structure used to store values parsed from a spec file.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
int parseScript(Spec spec, int parsePart)
Parse %pre et al scriptlets from a spec file.
static int copyNextLineFromOFI(Spec spec, OFI_t *ofi, rpmStripFlags strip)
void closeSpec(Spec spec)
Stop reading from spec file, freeing resources.
int Fclose(FD_t fd)
fclose(3) clone.
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
struct ReadLevelEntry * readStack
static int restoreFirstChar(Spec spec)
static const char *char c
Return text between pl and matching pr characters.
static int copyNextLineFinish(Spec spec, int strip)
struct OpenFileInfo * newOpenFileInfo(void)
int Ferror(FD_t fd)
ferror(3) clone.
static int matchTok(const char *token, const char *line)
return strcmp(ame->name, bme->name)
static int snprintf(char *buf, int nb, const char *fmt,...)
This is the only module users of librpmbuild should need to include.
int parseDescription(Spec spec)
Parse %description section of a spec file.
Structures and prototypes used for an "rpmts" transaction set.
char * tagCanonicalize(const char *s)
Canonicalize a rpmTag string.
static void * fdGetFp(FD_t fd)
enum rpmParseState_e rpmParseState
ARGV_t argvSearch(ARGV_t argv, ARGstr_t val, int(*compar)(ARGstr_t *, ARGstr_t *))
Find an element in an argv array.
int expandMacros(void *spec, MacroContext mc, char *sbuf, size_t slen)
Expand macro into buffer.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
The structure used to store values for a package.
int parseFiles(Spec spec)
Parse %files section of a spec file.
int readLine(Spec spec, rpmStripFlags strip)
Read next line from spec file.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
static const char * platform
struct OpenFileInfo * fileStack
rpmds rpmdsThis(Header h, rpmTag tagN, evrFlags Flags)
Create, load and initialize a dependency for this header.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
static void forceIncludeFile(Spec spec, const char *fileName)
struct ReadLevelEntry * next