12 #define _RPMTAG_INTERNAL
60 for (; p->
token != NULL; p++)
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);
106 spec->
foo[spec->
nfoo].iob = NULL;
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') {
296 if (ofi->
fd == NULL) {
312 if (f == NULL || !fgets(ofi->
readBuf, (
int)
sizeof(ofi->
readBuf), f)) {
384 }
else if (! strncmp(
"%ifarch", s,
sizeof(
"%ifarch")-1)) {
385 const char *arch =
rpmExpand(
"%{_target_cpu}", NULL);
389 }
else if (! strncmp(
"%ifnarch", s,
sizeof(
"%ifnarch")-1)) {
390 const char *arch =
rpmExpand(
"%{_target_cpu}", NULL);
394 }
else if (! strncmp(
"%ifos", s,
sizeof(
"%ifos")-1)) {
395 const char *os =
rpmExpand(
"%{_target_os}", NULL);
399 }
else if (! strncmp(
"%ifnos", s,
sizeof(
"%ifnos")-1)) {
400 const char *os =
rpmExpand(
"%{_target_os}", NULL);
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",
513 N, V, R, spec->
noSource ?
"no" :
"");
514 fileName[
sizeof(fileName)-1] =
'\0';
531 int recursing,
const char *passPhrase,
532 const char *cookie,
int anyarch,
int force,
int verify)
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;
713 const char *arch =
rpmExpand(
"%{_target_cpu}", NULL);
714 const char *os =
rpmExpand(
"%{_target_os}", NULL);
716 for (pkg = spec->
packages; pkg != NULL; pkg = pkg->
next) {
734 if(pkg->
noarch && !platformNoarch && strcmp(arch,
"noarch")) {
736 platformNoarch =
rpmExpand(
"%{_target_platform}", NULL);
757 platform =
_free(platform);
758 platformNoarch =
_free(platformNoarch);
769 platform =
_free(platform);
770 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 const char size_t len
const char bson_timestamp_t * ts
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,...)
rpmiob rpmiobAppend(rpmiob iob, const char *s, size_t nl)
Append string to I/O buffer.
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.
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
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