15 #define _RPMEVR_INTERNAL
16 #define _RPMTAG_INTERNAL
33 #if !defined(RPM_VENDOR_PLD)
83 xx = poptParseArgvString(line, &argc, &argv);
112 se = strchr(spec->
line,
'#');
115 while (--se >= spec->
line && strchr(
" \t\n\r", *se) !=
NULL)
121 (
void)strtok(s,
" \t\n");
123 if (!(se = strtok(
NULL,
" \t\n")))
127 if (!(se = strtok(
NULL,
" \t\n"))) {
138 rc = (strtok(
NULL,
" \t\n") ? 1 : 0);
150 return ((!s || (s[0] ==
'n' || s[0] ==
'N' || s[0] ==
'0') ||
165 {
"interp", RPMSENSE_INTERP },
166 {
"preun", RPMSENSE_SCRIPT_PREUN },
167 {
"pre", RPMSENSE_SCRIPT_PRE },
168 {
"postun", RPMSENSE_SCRIPT_POSTUN },
169 {
"post", RPMSENSE_SCRIPT_POST },
170 {
"rpmlib", RPMSENSE_RPMLIB },
171 {
"verify", RPMSENSE_SCRIPT_VERIFY },
172 {
"hint", RPMSENSE_MISSINGOK },
180 {
"prep", RPMSENSE_SCRIPT_PREP },
181 {
"build", RPMSENSE_SCRIPT_BUILD },
182 {
"install", RPMSENSE_SCRIPT_INSTALL },
183 {
"clean", RPMSENSE_SCRIPT_CLEAN },
184 {
"hint", RPMSENSE_MISSINGOK },
201 while ((c = *s) &&
xisspace(c)) s++;
203 while ((c = *se) &&
xisalpha(c)) se++;
206 for (tb = tokbits; tb->
name; tb++) {
208 strlen(tb->
name) == (
size_t)(se-s) && !strncmp(tb->
name, s, (se-s)))
214 while ((c = *se) &&
xisspace(c)) se++;
220 if (c == 0 && bp) *bp =
bits;
230 char *
se = s + strlen(s);
233 while (--se > s && strchr(
" \t\n\r", *se) !=
NULL)
236 if ((se = strchr(s,
'#')) !=
NULL) {
238 while (--se > s && strchr(
" \t\n\r", *se) !=
NULL)
320 _(
"%s field must be present in package: %s\n"),
348 if (he->
tag != lastTag) {
376 { 0xffffffff,
"%{class}" },
397 if (tag == 0xffffffff) {
406 if (val && *val !=
'%') {
423 static size_t iconsize = 0;
425 const char *
fn, *Lurlfn =
NULL;
439 icon =
alloca(iconsize+1);
450 #if defined(RPM_VENDOR_OPENPKG)
455 if (access(Lurlfn,
F_OK) == -1) {
456 Lurlfn =
_free(Lurlfn);
464 urltype =
urlPath(Lurlfn, &fn);
480 fd =
Fopen(fn,
"r%{?_rpmgio}");
489 nb =
Fread(icon,
sizeof(icon[0]), iconsize, fd);
490 if (
Ferror(fd) || nb == 0) {
495 if (nb >= iconsize) {
501 if (icon[0] ==
'G' && icon[1] ==
'I' && icon[2] ==
'F')
504 if (icon[0] ==
'/' && icon[1] ==
'*' && icon[2] ==
' '
505 && icon[3] ==
'X' && icon[4] ==
'P' && icon[5] ==
'M')
520 Lurlfn =
_free(Lurlfn);
558 #define SINGLE_TOKEN_ONLY \
560 rpmlog(RPMLOG_ERR, _("line %d: Tag takes single token only: %s\n"), \
561 spec->lineNum, spec->line); \
572 const char * tagN =
tagName(tag);
576 if (pattern && *pattern) {
597 pattern =
_free(pattern);
605 const char *macro,
const char *
lang)
615 char * field = spec->
line;
626 while ((*field) && (*field !=
':'))
666 if (strchr(field,
'-') !=
NULL) {
673 if (strchr(field,
'-') !=
NULL) {
688 #if defined(RPM_VENDOR_OPENPKG)
704 #if defined(SUPPORT_I18NSTRING_TYPE)
705 (
void) headerAddI18NString(pkg->
header, tag, field, lang);
724 if (*buildRoot ==
'\0') buildRoot =
"/";
725 if (!
strcmp(buildRoot,
"/")) {
727 _(
"BuildRoot can not be \"/\": %s\n"), spec->buildRootURL);
742 if (he->
p.
argv[he->
c][0] !=
'/') {
744 _(
"line %d: Prefixes must begin with \"/\": %s\n"),
750 if (he->
p.
argv[he->
c][len - 1] ==
'/' && len > 1) {
752 _(
"line %d: Prefixes must not end with \"/\": %s\n"),
762 if (field[0] !=
'/') {
764 _(
"line %d: Docdir must begin with '/': %s\n"),
778 _(
"line %d: %s takes an integer value: %s\n"),
802 if ((rc =
addSource(spec, pkg, field, tag)))
808 if ((rc =
addSource(spec, pkg, field, tag)))
822 if ((rc =
parseBits(lang, buildScriptBits, &tagflags))) {
824 _(
"line %d: Bad %s: qualifiers: %s\n"),
828 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
833 if ((rc =
parseBits(lang, installScriptBits, &tagflags))) {
835 _(
"line %d: Bad %s: qualifiers: %s\n"),
839 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
845 tagflags = RPMSENSE_MISSINGOK;
846 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
853 tagflags = RPMSENSE_MISSINGOK;
854 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
863 tagflags = RPMSENSE_ANY;
864 if ((rc =
parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
876 {
const char ** BANames =
NULL;
878 if ((rc = poptParseArgvString(field, &BACount, &BANames))) {
880 _(
"line %d: Bad BuildArchitecture format: %s\n"),
885 if (BACount > 0 && BANames !=
NULL) {
891 if (BACount != 1 ||
strcmp(BANames[0],
"noarch")) {
893 _(
"line %d: Only \"noarch\" sub-packages are supported: %s\n"),
895 BANames =
_free(BANames);
900 BANames =
_free(BANames);
907 he->
p.
argv= (
const char **) &field;
997 #if defined(RPM_VENDOR_OPENPKG)
1008 const char ** macro,
char *
lang)
1016 for (p = preambleList; p->
token !=
NULL; p++) {
1017 len = strlen(p->
token);
1039 if (aTags !=
NULL && aTags[0] !=
NULL) {
1042 #if defined(RPM_VENDOR_OPENPKG)
1043 av = argvSearchLinear(aTags, s, argvFnmatchCasefold);
1064 if (*s !=
':')
return 1;
1073 if (*s !=
'(')
return 1;
1080 if (*s !=
')')
return 1;
1083 if (*s !=
':')
return 1;
1108 strcpy(NVR,
"(main package)");
1114 }
else if (! initialPackage) {
1138 lastpkg->
next = pkg;
1147 strncpy(NVR, name,
sizeof(NVR)-1);
1148 NVR[
sizeof(NVR)-1] =
'\0';
1164 const char * macro =
NULL;
1170 if (*linep !=
'\0') {
1197 if (initialPackage) {
1218 #ifdef RPM_VENDOR_PLD
miRE mireNew(rpmMireMode mode, int tag)
Create pattern container.
rpmlog(RPMLOG_ERR,"%s\n", buf)
static rpmTag copyTagsDuringParse[]
static rpmRC checkForRequired(Header h, const char *NVR)
Check that required tags are present in header.
int parseNum(const char *line, rpmuint32_t *res)
Parse a number.
enum urltype_e urltype
Supported URL types.
char * xstrdup(const char *str)
struct tokenBits_s * tokenBits
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
static char *size_t nb
fgets(3) analogue that reads \ continuations.
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)
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 struct tokenBits_s installScriptBits[]
spectag stashSt(Spec spec, Header h, rpmTag tag, const char *lang)
stashSt.
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
int xstrncasecmp(const char *s1, const char *s2, size_t n)
Locale insensitive strncasecmp(3).
rpmTag tagValue(const char *tagstr)
Return tag value from name.
rpmTag tagGenerate(const char *s)
Generate a tag from arbitrary string.
sprintf(t," (%u)",(unsigned) dig->nbytes)
static rpmRC handlePreambleTag(Spec spec, Package pkg, rpmTag tag, const char *macro, const char *lang)
enum rpmRC_e rpmRC
RPM return codes.
Yet Another syslog(3) API clone.
memset(_r, 0, sizeof(*_r))
int parsePreamble(Spec spec, int initialPackage)
Parse tags from preamble of a spec file.
miRE mireFree(miRE mire)
Free pattern container.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
assert(key->size==sizeof(hdrNum))
Package newPackage(Spec spec)
Create and initialize package control structure.
static rpmRC tagValidate(Spec spec, rpmTag tag, const char *value)
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
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.
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 Fclose(FD_t fd)
fclose(3) clone.
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
static const char *char c
Return text between pl and matching pr characters.
int Ferror(FD_t fd)
ferror(3) clone.
const char * buildRootURL
return strcmp(ame->name, bme->name)
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.
int xstrcasecmp(const char *s1, const char *s2)
Locale insensitive strcasecmp(3).
static int doIcon(Spec spec, Header h)
static struct PreambleRec_s preambleList[]
static struct tokenBits_s buildScriptBits[]
static void fillOutMainPackage(Header h)
char * tagCanonicalize(const char *s)
Canonicalize a rpmTag string.
Package freePackages(Package packages)
Destroy all packages associated with spec file.
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)
int parseNoSource(Spec spec, const char *field, rpmTag tag)
parseNoSource.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
int addSource(Spec spec, Package pkg, const char *field, rpmTag tag)
addSource.
char * buf
Parse (and execute) macro undefinition.
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.
The structure used to store values for a package.
int
Save source and expand field into target.
#define RPMBUILD_DEFAULT_LANG
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.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
struct PreambleRec_s * PreambleRec