36 #define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;} 37 #define SKIPNONWHITE(_x){while(*(_x) &&!(xisspace(*_x) || *(_x) == ',')) (_x)++;} 103 assert(xx != 0 && he->
p.
str != NULL);
109 if ((V = strrchr(N,
'-')) != NULL &&
xisdigit(V[1])) {
123 if (xx && he->
p.
str != NULL) {
124 n = (
char *) he->
p.
str;
130 if (xx && he->
p.
str != NULL) {
131 v = (
char *) he->
p.
str;
141 if (!strcmp(NV, nv) || !strcmp(NV, n)
142 || (!strcmp(N, n) && (V == NULL || !strcmp(V, v))))
166 if (pkg == NULL)
return;
181 if (pkg->
fi != NULL) {
198 if (_pkgPool == NULL) {
204 memset(((
char *)pkg)+
sizeof(pkg->
_item), 0,
sizeof(*pkg)-
sizeof(pkg->
_item));
220 pkg->triggers = NULL;
221 pkg->triggerScripts = NULL;
249 while ((p = packages) != NULL) {
265 if ((num == p->
num) && (p->
flags & flag))
return p;
285 for (i = 0; i <
num; i++)
286 if ((p = p->
next) == NULL)
return NULL;
318 return source->
flags;
336 for (f = fe; *f !=
'\0'; f = fe) {
344 if (*fe !=
'\0') fe++;
366 const char *field,
rpmTag tag)
369 #if defined(RPM_VENDOR_OPENPKG) 373 const char *
name = NULL;
374 const char *mdir = NULL;
375 const char *fieldp = NULL;
384 fieldp = spec->
line + strlen(name);
389 fieldp = spec->
line + strlen(name);
400 #if !defined(RPM_VENDOR_OPENPKG) 402 assert(mdir != NULL);
406 if (fieldp != NULL) {
409 num = strtoul(fieldp, &end, 10);
420 if ( p->
num != num )
continue;
439 #if defined(RPM_VENDOR_OPENPKG) 442 while (p_last != NULL && p_last->
next != NULL)
443 p_last = p_last->
next;
456 #if defined(RPM_VENDOR_OPENPKG) 465 sprintf(buf,
"%sURL%d",
466 (flag & RPMFILE_PATCH) ?
"PATCH" :
"SOURCE", num);
471 const char * what = (flag &
RPMFILE_PATCH) ?
"patches" :
"sources";
511 if (sl == NULL)
return NULL;
541 if (st == NULL)
return NULL;
542 for (i = 0; i < st->
st_ntags; i++) {
557 if (spec == NULL)
return;
591 if (spec->
fi != NULL) {
635 if (_specPool == NULL) {
641 memset(((
char *)spec)+
sizeof(spec->
_item), 0,
sizeof(*spec)-
sizeof(spec->
_item));
647 static const char _spec_line_buffer_size[] =
648 "%{?_spec_line_buffer_size}%{!?_spec_line_buffer_size:100000}";
659 spec->
lbuf[0] =
'\0';
745 const char * msgstr = NULL;
749 if (sl == NULL || st == NULL)
752 for (i = 0; i < st->
st_ntags; i++) {
766 for (fe = fmt; *fe && *fe !=
'('; fe++)
768 if (*fe ==
'(') *fe =
'\0';
770 for (pkg = spec->
packages; pkg != NULL; pkg = pkg->
next) {
774 if (!strcmp(he->
p.
str, fmt)) {
780 if (pkg == NULL || h == NULL)
789 msgstr =
_free(msgstr);
793 if (msgstr == NULL) {
806 {
char *buf =
xmalloc(strlen(tn) +
sizeof(
": ") + strlen(msgstr));
830 msgstr =
_free(msgstr);
837 if (strchr(s,
'\n') == NULL && s[strlen(s)-1] !=
'\n')
860 const char * expandedLine;
864 printf(
"%s", expandedLine);
866 if (strchr(s,
'\n') == NULL && s[strlen(s)-1] !=
'\n')
885 if (progTag !=(
rpmTag) 0) {
886 static const char prog[] =
"/bin/sh";
894 if (scriptTag != (
rpmTag)0 && iob != NULL) {
914 if (spec->
prep != NULL)
917 if (spec->
build != NULL)
923 if (spec->
check != NULL)
926 if (spec->
clean != NULL)
949 int anyarch = (target == NULL) ? 1 : 0;
950 char * passPhrase =
"";
957 if (
parseSpec(ts, specName,
"/", recursing, passPhrase,
958 cookie, anyarch, 1, verify)
962 _(
"query of specfile %s failed, can't parse\n"),
987 for (pkg = spec->
packages; pkg != NULL; pkg = pkg->
next) {
992 if (target == NULL || pkg->
fileList != NULL)
1015 if (targets == NULL) {
1022 _(
"Query specfile for platform(s): %s\n"), targets);
1023 for (t = targets; *t !=
'\0'; t = te) {
1025 if ((te = strchr(t,
',')) == NULL)
1028 strncpy(target, t, (te-t));
1029 target[te-t] =
'\0';
1050 if ((te = strchr(t,
',')) == NULL)
1053 strncpy(target, t, (te-t));
1054 target[te-t] =
'\0';
Package newPackage(Spec spec)
Create and initialize package control structure.
void rpmFreeMacros(MacroContext mc)
Destroy macro context.
static void specFini(void *_spec)
static spectags newSt(void)
pgpDig pgpDigFree(pgpDig dig)
Destroy a container for parsed OpenPGP packates.
Package freePackages(Package packages)
Destroy all packages associated with spec file.
const char * sourceRpmName
OpenPGP constants and structures from RFC-2440.
struct OpenFileInfo * next
static spectags freeSt(spectags st)
char * xstrdup(const char *str)
void * rpmluavFree(rpmluav var)
const char * specFullSourceName(SpecSource source)
Return a ptr to the full url of the source.
int rpmReadConfigFiles(const char *file, const char *target)
static void printNewSpecfile(Spec spec)
Print copy of spec file, filling in Group/Description/Summary from specspo.
Structure(s) used for file info tag sets.
void rpmluavSetListMode(rpmluav var, int flag)
rpmioItem rpmioLinkPoolItem(rpmioItem item, const char *msg, const char *fn, unsigned ln)
Increment a pool item refcount.
void addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
rpmfi rpmfiFree(rpmfi fi)
Destroy a file info set.
rpmiob rpmiobFree(rpmiob iob)
Destroy a I/O buffer instance.
int specSourceNum(SpecSource source)
Return the spec or source patch number.
static void rpmlog(int code, const char *fmt,...)
Spec newSpec(void)
Create and initialize Spec structure.
rpmds rpmdsFree(rpmds ds)
Destroy a dependency set.
static Package pkgGetPool(rpmioPool pool)
Command line option information.
char * headerSprintf(Header h, const char *fmt, headerTagTableEntry tags, headerSprintfExtension exts, errmsg_t *errmsg)
Return formatted output string from header tags.
void rpmluaPushTable(rpmlua _lua, const char *key,...)
void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
const char * getSourceDir(rpmfileAttrs attr)
Return the macro directory location from source file flags.
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 tagValue(const char *tagstr)
Return tag value from name.
static Spec specGetPool(rpmioPool pool)
Yet Another syslog(3) API clone.
MacroContext rpmGlobalMacroContext
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
static speclines freeSl(speclines sl)
static speclines newSl(void)
struct rpmfi_s * rpmfi
File info tag sets from a header, so that a header can be discarded early.
static struct TriggerFileEntry * freeTriggerFiles(struct TriggerFileEntry *p)
struct rpmluav_s * rpmluav
const char * rpmcliTargets
const char * tagName(rpmTag tag)
Return tag name from value.
rpmuint32_t sstates[RPMSCRIPT_MAX]
int specSourceFlags(SpecSource source)
Return flags set for the source.
struct OpenFileInfo * newOpenFileInfo(void)
struct TriggerFileEntry * triggerFiles
Structure(s) used for dependency tag sets.
rpmuint32_t smetrics[RPMSCRIPT_MAX]
static int initSourceHeaderScriptlets(Spec spec)
Add expanded build scriptlets to srpm header.
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.
rpmRC lookupPackage(Spec spec, const char *name, int flag, Package *pkgp)
Find sub-package control structure by name.
The structure used to store values parsed from a spec file.
Header headerFree(Header h)
Dereference a header instance.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
Spec freeSpec(Spec spec)
Destroy a spec file control structure.
struct Package_s * Package
SpecSource getSource(Spec spec, int num)
Return a source control structure.
void rpmluaDelVar(rpmlua _lua, const char *key,...)
struct TriggerFileEntry * next
static int initSourceHeaderScriptlet(Header h, rpmTag progTag, rpmTag scriptTag, rpmiob iob)
Add expanded build scriptlet to srpm header.
Package freePackage(Package pkg)
Destroy a package control structure.
struct ReadLevelEntry * readStack
Spec rpmtsSetSpec(rpmts ts, Spec spec)
Set a spec control structure in transaction set.
Routines to read and write packages.
const char * specSourceName(SpecSource source)
Return a ptr to the source file name.
static int _specQuery(rpmts ts, QVA_t qva, const char *specName, const char *target)
Parse a spec file, and query the resultant header.
static void printParsedSpecfile(Spec spec)
Print parsed copy of spec file with expanded macros.
enum rpmRC_e rpmRC
RPM return codes.
char * rpmiobStr(rpmiob iob)
Return I/O buffer (as string).
static void pkgFini(void *_pkg)
int parseNum(const char *line, rpmuint32_t *res)
Parse a number.
static struct Source * findSource(Spec spec, rpmuint32_t num, int flag)
static int xisdigit(int c)
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
rpmRC(* _parseRCPOT)(Spec spec, Package pkg, const char *field, rpmTag tagN, rpmuint32_t index, rpmsenseFlags tagflags)
int rpmspecQuery(rpmts ts, QVA_t qva, const char *arg)
Function to query spec file(s).
char * stpcpy(char *dest, const char *src)
struct rpmts_s * rpmts
The RPM Transaction Set.
void rpmluaSetVar(rpmlua _lua, rpmluav var)
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Structures and prototypes used for an "rpmts" transaction set.
tagStore_t tagStoreFree(tagStore_t dbiTags, size_t dbiNTags)
Destroy tagStore array.
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.
static struct Source * freeSources(struct Source *s)
Destroy source component chain.
void closeSpec(Spec spec)
Stop reading from spec file, freeing resources.
The structure used to store values for a package.
int parseNoSource(Spec spec, const char *field, rpmTag tag)
parseNoSource.
#define RPMBUILD_DEFAULT_LANG
struct OpenFileInfo * fileStack
int initSourceHeader(Spec spec, rpmiob *sfp)
Create and initialize header for source package.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
struct ReadLevelEntry * next
int SpecSourceCount(Spec spec)
Return the count of source set in specfile.
unsigned char * sourcePkgId
const char * sanityCheckFile
char * rpmMCExpand(MacroContext mc, const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s) in a context.
int addSource(Spec spec, Package pkg, const char *field, rpmTag tag)
addSource.