12 #define _RPMTAG_INTERNAL 64 for (; p->
token != NULL; p++)
70 const char * line = spec->
line;
96 if (aTags != NULL && aTags[0] != NULL) {
99 #if defined(RPM_VENDOR_OPENPKG) 100 av = argvSearchLinear(aTags, s, argvFnmatchCasefold);
108 spec->
foo[spec->
nfoo].iob = NULL;
125 const char *b, *be = line;
126 size_t toklen = strlen(token);
129 while ( *(b = be) !=
'\0' ) {
135 if (toklen != (
size_t)(be-b) ||
xstrncasecmp(token, b, (be-b)))
191 int pc = 0, bc = 0, nc = 0;
196 while (from && *from && ch !=
'\n')
197 ch = *to++ = *from++;
205 for (p = spec->
lbuf; *p; p++) {
209 case '\n': p++, nc = 1;
break;
214 case '\n': nc = 0;
break;
217 case '{': p++, bc++;
break;
218 case '(': p++, pc++;
break;
219 case '%': p++;
break;
222 case '{':
if (bc > 0) bc++;
break;
223 case '}':
if (bc > 0) bc--;
break;
224 case '(':
if (pc > 0) pc++;
break;
225 case ')':
if (pc > 0) pc--;
break;
231 if (pc || bc || nc ) {
268 while (*spec->
nextline && ch !=
'\n') {
298 if (ofi->
fd == NULL) {
314 if (f == NULL || !fgets(ofi->
readBuf, (
int)
sizeof(ofi->
readBuf), f)) {
386 }
else if (! strncmp(
"%ifarch", s,
sizeof(
"%ifarch")-1)) {
387 const char *arch =
rpmExpand(
"%{_target_cpu}", NULL);
391 }
else if (! strncmp(
"%ifnarch", s,
sizeof(
"%ifnarch")-1)) {
392 const char *arch =
rpmExpand(
"%{_target_cpu}", NULL);
396 }
else if (! strncmp(
"%ifos", s,
sizeof(
"%ifos")-1)) {
397 const char *os =
rpmExpand(
"%{_target_os}", NULL);
401 }
else if (! strncmp(
"%ifnos", s,
sizeof(
"%ifnos")-1)) {
402 const char *os =
rpmExpand(
"%{_target_os}", NULL);
406 }
else if (! strncmp(
"%if", s,
sizeof(
"%if")-1)) {
411 _(
"%s:%d: parseExpressionBoolean returns %d\n"),
415 }
else if (! strncmp(
"%else", s,
sizeof(
"%else")-1)) {
420 _(
"%s:%d: Got a %%else with no %%if\n"),
426 spec->
line[0] =
'\0';
427 }
else if (! strncmp(
"%endif", s,
sizeof(
"%endif")-1)) {
432 _(
"%s:%d: Got a %%endif with no %%if\n"),
439 spec->
line[0] =
'\0';
440 }
else if (spec->
readStack->
reading && ! strncmp(
"%include", s,
sizeof(
"%include")-1)) {
441 char *fileName, *endFileName, *p;
450 endFileName = fileName;
472 spec->
line[0] =
'\0';
476 spec->
line[0] =
'\0';
505 const char *N, *V, *R;
506 char fileName[BUFSIZ];
509 (void)
snprintf(fileName,
sizeof(fileName),
"%s-%s-%s.%ssrc.rpm",
510 N, V, R, spec->
noSource ?
"no" :
"");
511 fileName[
sizeof(fileName)-1] =
'\0';
528 int recursing,
const char *passPhrase,
529 const char *cookie,
int anyarch,
int force,
int verify)
533 int initialPackage = 1;
554 spec->
toplevel = (!recursing ? 1 : 0);
632 if (goterror || parsePart >=
PART_LAST) {
652 for (x = 0; x < spec->
BACount; x++) {
660 passPhrase, cookie, anyarch, force, verify)
678 _(
"No compatible architectures found for build\n"));
713 const char *platformNoarch = NULL;
714 const char *arch =
rpmExpand(
"%{_target_cpu}", NULL);
715 const char *os =
rpmExpand(
"%{_target_os}", NULL);
717 for (pkg = spec->
packages; pkg != NULL; pkg = pkg->
next) {
735 if(pkg->
noarch && !platformNoarch && strcmp(arch,
"noarch")) {
737 platformNoarch =
rpmExpand(
"%{_target_platform}", NULL);
758 platform =
_free(platform);
759 platformNoarch =
_free(platformNoarch);
770 platform =
_free(platform);
771 platformNoarch =
_free(platformNoarch);
static void initParts(struct PartRec *p)
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
enum rpmStripFlags_e rpmStripFlags
Spec file parser stripping flags.
int parseScript(Spec spec, int parsePart)
Parse %pre et al scriptlets from a spec file.
const char * sourceRpmName
static void * fdGetFp(FD_t fd)
int parseDescription(Spec spec)
Parse %description section of a spec file.
struct OpenFileInfo * next
char * xstrdup(const char *str)
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
int parseBuildInstallClean(Spec spec, rpmParseState parsePart)
Parse %build/%install/%clean section(s) of a spec file.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
int xstrncasecmp(const char *s1, const char *s2, size_t n)
Locale insensitive strncasecmp(3).
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.
static void rpmlog(int code, const char *fmt,...)
int parsePrep(Spec spec, int verify)
Parse %prep section of a spec file.
int readLine(Spec spec, rpmStripFlags strip)
Read next line from spec file.
static int genSourceRpmName(Spec spec)
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.
rpmTag tagGenerate(const char *s)
Generate a tag from arbitrary string.
void delMacro(MacroContext mc, const char *n)
Delete macro from context.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
void * xcalloc(size_t nmemb, size_t size)
static int readLineFromOFI(Spec spec, OFI_t *ofi)
static int xisspace(int c)
const char * tagName(rpmTag tag)
Return tag name from value.
static struct PartRec partList[]
Structure(s) used for dependency tag sets.
The structure used to store values parsed from a spec file.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
Spec freeSpec(Spec spec)
Destroy a spec file control structure.
static int copyNextLineFromOFI(Spec spec, OFI_t *ofi, rpmStripFlags strip)
int parseExpressionBoolean(Spec spec, const char *expr)
Evaluate boolean expression.
int parseFiles(Spec spec)
Parse %files section of a spec file.
int parsePreamble(Spec spec, int initialPackage)
Parse tags from preamble of a spec file.
int Fclose(FD_t fd)
fclose(3) clone.
struct ReadLevelEntry * readStack
Spec rpmtsSetSpec(rpmts ts, Spec spec)
Set a spec control structure in transaction set.
static int restoreFirstChar(Spec spec)
Spec newSpec(void)
Create and initialize Spec structure.
static int copyNextLineFinish(Spec spec, int strip)
int Ferror(FD_t fd)
ferror(3) clone.
static int matchTok(const char *token, const char *line)
static int snprintf(char *buf, int nb, const char *fmt,...)
This is the only module users of librpmbuild should need to include.
struct rpmts_s * rpmts
The RPM Transaction Set.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int headerNEVRA(Header h, const char **np, const char **ep, const char **vp, const char **rp, const char **ap)
Return name, epoch, version, release, arch strings from header.
Structures and prototypes used for an "rpmts" transaction set.
char * tagCanonicalize(const char *s)
Canonicalize a rpmTag string.
int parseChangelog(Spec spec)
Parse %changelog section of a spec file.
void closeSpec(Spec spec)
Stop reading from spec file, freeing resources.
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.
The structure used to store values for a package.
struct OpenFileInfo * newOpenFileInfo(void)
void handleComments(char *s)
Truncate comment lines.
static const char * platform
struct OpenFileInfo * fileStack
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
rpmds rpmdsThis(Header h, rpmTag tagN, evrFlags Flags)
Create, load and initialize a dependency for this header.
static void forceIncludeFile(Spec spec, const char *fileName)
struct ReadLevelEntry * next