15 #define _RPMEVR_INTERNAL 16 #define _RPMTAG_INTERNAL 81 xx = poptParseArgvString(line, &argc, &argv);
110 se = strchr(spec->
line,
'#');
113 while (--se >= spec->
line && strchr(
" \t\n\r", *se) != NULL)
119 (void)strtok(s,
" \t\n");
121 if (!(se = strtok(NULL,
" \t\n")))
124 if (!strcmp(se,
"-n")) {
125 if (!(se = strtok(NULL,
" \t\n"))) {
136 rc = (strtok(NULL,
" \t\n") ? 1 : 0);
148 return ((!s || (s[0] ==
'n' || s[0] ==
'N' || s[0] ==
'0') ||
163 {
"interp", RPMSENSE_INTERP },
164 {
"preun", RPMSENSE_SCRIPT_PREUN },
165 {
"pre", RPMSENSE_SCRIPT_PRE },
166 {
"postun", RPMSENSE_SCRIPT_POSTUN },
167 {
"post", RPMSENSE_SCRIPT_POST },
168 {
"rpmlib", RPMSENSE_RPMLIB },
169 {
"verify", RPMSENSE_SCRIPT_VERIFY },
170 {
"hint", RPMSENSE_MISSINGOK },
178 {
"prep", RPMSENSE_SCRIPT_PREP },
179 {
"build", RPMSENSE_SCRIPT_BUILD },
180 {
"install", RPMSENSE_SCRIPT_INSTALL },
181 {
"clean", RPMSENSE_SCRIPT_CLEAN },
182 {
"hint", RPMSENSE_MISSINGOK },
199 while ((c = *s) &&
xisspace(c)) s++;
201 while ((c = *se) &&
xisalpha(c)) se++;
204 for (tb = tokbits; tb->
name; tb++) {
205 if (tb->
name != NULL &&
206 strlen(tb->
name) == (
size_t)(se-s) && !strncmp(tb->
name, s, (se-s)))
209 if (tb->
name == NULL)
212 while ((c = *se) &&
xisspace(c)) se++;
218 if (c == 0 && bp) *bp =
bits;
228 char *se = s + strlen(s);
231 while (--se > s && strchr(
" \t\n\r", *se) != NULL)
234 if ((se = strchr(s,
'#')) != NULL) {
236 while (--se > s && strchr(
" \t\n\r", *se) != NULL)
276 const char *arch =
rpmExpand(
"%{_target_cpu}", NULL);
277 const char *os =
rpmExpand(
"%{_target_os}", NULL);
318 _(
"%s field must be present in package: %s\n"),
346 if (he->
tag != lastTag) {
374 { 0xffffffff,
"%{class}" },
395 if (tag == 0xffffffff) {
404 if (val && *val !=
'%') {
421 static size_t iconsize = 0;
423 const char *fn, *Lurlfn = NULL;
437 icon =
alloca(iconsize+1);
439 for (sp = spec->
sources; sp != NULL; sp = sp->
next) {
448 #if defined(RPM_VENDOR_OPENPKG) 453 if (access(Lurlfn,
F_OK) == -1) {
454 Lurlfn =
_free(Lurlfn);
462 urltype =
urlPath(Lurlfn, &fn);
478 fd =
Fopen(fn,
"r%{?_rpmgio}");
479 if (fd == NULL ||
Ferror(fd)) {
487 nb =
Fread(icon,
sizeof(icon[0]), iconsize, fd);
488 if (
Ferror(fd) || nb == 0) {
493 if (nb >= iconsize) {
499 if (icon[0] ==
'G' && icon[1] ==
'I' && icon[2] ==
'F')
502 if (icon[0] ==
'/' && icon[1] ==
'*' && icon[2] ==
' ' 503 && icon[3] ==
'X' && icon[4] ==
'P' && icon[5] ==
'M')
518 Lurlfn =
_free(Lurlfn);
556 #define SINGLE_TOKEN_ONLY \ 558 rpmlog(RPMLOG_ERR, _("line %d: Tag takes single token only: %s\n"), \ 559 spec->lineNum, spec->line); \ 570 const char * tagN =
tagName(tag);
571 const char * pattern =
rpmExpand(
"%{?pattern_", tagN,
"}", NULL);
574 if (pattern && *pattern) {
595 pattern =
_free(pattern);
603 const char *macro,
const char *
lang)
613 char * field = spec->
line;
624 while ((*field) && (*field !=
':'))
664 if (strchr(field,
'-') != NULL) {
671 if (strchr(field,
'-') != NULL) {
686 #if defined(RPM_VENDOR_OPENPKG) 702 #if defined(SUPPORT_I18NSTRING_TYPE) 703 (void) headerAddI18NString(pkg->
header, tag, field, lang);
721 (void)
urlPath(buildRootURL, &buildRoot);
722 if (*buildRoot ==
'\0') buildRoot =
"/";
723 if (!strcmp(buildRoot,
"/")) {
725 _(
"BuildRoot can not be \"/\": %s\n"), spec->buildRootURL);
726 buildRootURL =
_free(buildRootURL);
729 buildRootURL =
_free(buildRootURL);
740 if (he->
p.
argv[he->
c][0] !=
'/') {
742 _(
"line %d: Prefixes must begin with \"/\": %s\n"),
747 len = (int)strlen(he->
p.
argv[he->
c]);
748 if (he->
p.
argv[he->
c][len - 1] ==
'/' && len > 1) {
750 _(
"line %d: Prefixes must not end with \"/\": %s\n"),
760 if (field[0] !=
'/') {
762 _(
"line %d: Docdir must begin with '/': %s\n"),
776 _(
"line %d: %s takes an integer value: %s\n"),
800 if ((rc =
addSource(spec, pkg, field, tag)))
806 if ((rc =
addSource(spec, pkg, field, tag)))
820 if ((rc =
parseBits(lang, buildScriptBits, &tagflags))) {
822 _(
"line %d: Bad %s: qualifiers: %s\n"),
826 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
831 if ((rc =
parseBits(lang, installScriptBits, &tagflags))) {
833 _(
"line %d: Bad %s: qualifiers: %s\n"),
837 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
843 tagflags = RPMSENSE_MISSINGOK;
844 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
851 tagflags = RPMSENSE_MISSINGOK;
852 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
861 tagflags = RPMSENSE_ANY;
862 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
874 {
const char ** BANames = NULL;
876 if ((rc = poptParseArgvString(field, &BACount, &BANames))) {
878 _(
"line %d: Bad BuildArchitecture format: %s\n"),
883 if (BACount > 0 && BANames != NULL) {
889 if (BACount != 1 || strcmp(BANames[0],
"noarch")) {
891 _(
"line %d: Only \"noarch\" sub-packages are supported: %s\n"),
893 BANames =
_free(BANames);
898 BANames =
_free(BANames);
905 he->
p.
argv= (
const char **) &field;
995 #if defined(RPM_VENDOR_OPENPKG) 1006 const char ** macro,
char *
lang)
1014 for (p = preambleList; p->
token != NULL; p++) {
1015 len = strlen(p->
token);
1029 if (tagp && p->
token == NULL) {
1037 if (aTags != NULL && aTags[0] != NULL) {
1040 #if defined(RPM_VENDOR_OPENPKG) 1041 av = argvSearchLinear(aTags, s, argvFnmatchCasefold);
1054 s = spec->
line + len;
1062 if (*s !=
':')
return 1;
1071 if (*s !=
'(')
return 1;
1078 if (*s !=
')')
return 1;
1081 if (*s !=
':')
return 1;
1106 strcpy(NVR,
"(main package)");
1111 assert(initialPackage);
1112 }
else if (! initialPackage) {
1131 for (lastpkg = spec->
packages; lastpkg->
next != NULL; lastpkg = lastpkg->
next)
1134 assert(lastpkg != NULL);
1135 lastpkg->
next = pkg;
1141 sprintf(NVR,
"%s-%s", he->
p.
str, name);
1159 const char * macro = NULL;
1165 if (*linep !=
'\0') {
1192 if (initialPackage) {
1193 const char *s =
rpmExpand(
"%{?buildroot}", NULL);
1195 (void)
addMacro(NULL,
"buildroot", NULL, s, -1);
1213 #ifdef RPM_VENDOR_PLD
miRE mireNew(rpmMireMode mode, int tag)
Create pattern container.
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
static rpmTag copyTagsDuringParse[]
static rpmRC checkForRequired(Header h, const char *NVR)
Check that required tags are present in header.
enum urltype_e urltype
Supported URL types.
Package newPackage(Spec spec)
Create and initialize package control structure.
char * xstrdup(const char *str)
Package freePackages(Package packages)
Destroy all packages associated with spec file.
struct tokenBits_s * tokenBits
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
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).
int mireRegcomp(miRE mire, const char *pattern)
Compile pattern match.
int mireSetCOptions(miRE mire, rpmMireMode mode, int tag, int options, const unsigned char *table)
Initialize pattern compile options.
rpmRC lookupPackage(Spec spec, const char *name, int flag, Package *pkg)
Find sub-package control structure by name.
static int checkForValidArchitectures(Spec spec)
static char * findLastChar(char *s)
int addSource(Spec spec, Package pkg, const char *field, rpmTag tag)
addSource.
void addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
static rpmRC checkForDuplicates(Header h, const char *NVR)
Check that no duplicate tags are present in header.
static int xisalpha(int c)
static void rpmlog(int code, const char *fmt,...)
static struct tokenBits_s installScriptBits[]
int readLine(Spec spec, rpmStripFlags strip)
Read next line from spec file.
rpmTag tagValue(const char *tagstr)
Return tag value from name.
rpmTag tagGenerate(const char *s)
Generate a tag from arbitrary string.
static rpmRC handlePreambleTag(Spec spec, Package pkg, rpmTag tag, const char *macro, const char *lang)
Yet Another syslog(3) API clone.
void delMacro(MacroContext mc, const char *n)
Delete macro from context.
miRE mireFree(miRE mire)
Free pattern container.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
static rpmRC tagValidate(Spec spec, rpmTag tag, const char *value)
int parseNoSource(Spec spec, const char *field, rpmTag tag)
parseNoSource.
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
enum evrFlags_e rpmsenseFlags
static int xisspace(int c)
static void addOrAppendListEntry(Header h, rpmTag tag, char *line)
const char * tagName(rpmTag tag)
Return tag name from value.
The FD_t File Handle data structure.
const char * rpmGenPath(const char *urlroot, const char *urlmdir, const char *urlfile)
Merge 3 args into path, any or all of which may be a url.
int mireRegexec(miRE mire, const char *val, size_t vallen)
Execute pattern match.
int xstrcasecmp(const char *s1, const char *s2)
Locale insensitive strcasecmp(3).
The structure used to store values parsed from a spec file.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
size_t Fread(void *buf, size_t size, size_t nmemb, FD_t fd)
fread(3) clone.
int parsePreamble(Spec spec, int initialPackage)
Parse tags from preamble of a spec file.
int Fclose(FD_t fd)
fclose(3) clone.
spectag stashSt(Spec spec, Header h, rpmTag tag, const char *lang)
stashSt.
static int parseSimplePart(Spec spec, char **Np, rpmParseState *flag)
static rpmTag requiredTags[]
static int isMemberInEntry(Header h, const char *name, rpmTag tag)
static struct optionalTag optionalTags[]
static int parseBits(const char *s, const tokenBits tokbits, rpmsenseFlags *bp)
#define SINGLE_TOKEN_ONLY
enum rpmRC_e rpmRC
RPM return codes.
int Ferror(FD_t fd)
ferror(3) clone.
int parseNum(const char *line, rpmuint32_t *res)
Parse a number.
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
This is the only module users of librpmbuild should need to include.
static int doIcon(Spec spec, Header h)
static struct PreambleRec_s preambleList[]
static struct tokenBits_s buildScriptBits[]
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
static void fillOutMainPackage(Header h)
char * tagCanonicalize(const char *s)
Canonicalize a rpmTag string.
rpmRC parseRCPOT(Spec spec, Package pkg, const char *field, rpmTag tagN, rpmuint32_t index, rpmsenseFlags tagflags)
Parse dependency relations from spec file and/or autogenerated output buffer.
enum rpmParseState_e rpmParseState
static int parseYesNo(const char *s)
ARGV_t argvSearch(ARGV_t argv, ARGstr_t val, int(*compar)(ARGstr_t *, ARGstr_t *))
Find an element in an argv array.
static int findPreambleTag(Spec spec, rpmTag *tagp, const char **macro, char *lang)
The structure used to store values for a package.
#define RPMBUILD_DEFAULT_LANG
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
struct PreambleRec_s * PreambleRec