2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup rpmbuild
|
|
|
|
* \file build/spec.c
|
2000-01-25 04:02:32 +08:00
|
|
|
* Handle spec data structure.
|
|
|
|
*/
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1995-12-13 01:53:17 +08:00
|
|
|
|
2008-02-03 22:24:07 +08:00
|
|
|
#include <rpm/header.h>
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmds.h>
|
|
|
|
#include <rpm/rpmfi.h>
|
|
|
|
#include <rpm/rpmts.h>
|
|
|
|
#include <rpm/rpmlog.h>
|
|
|
|
#include <rpm/rpmfileutil.h>
|
2002-04-12 00:55:19 +08:00
|
|
|
|
2008-01-30 23:05:29 +08:00
|
|
|
#include "build/buildio.h"
|
2008-02-25 18:24:22 +08:00
|
|
|
#include "rpmio/rpmlua.h"
|
2008-01-30 23:05:29 +08:00
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1998-07-31 06:09:42 +08:00
|
|
|
|
2008-03-18 15:10:13 +08:00
|
|
|
#define SKIPSPACE(s) { while (*(s) && risspace(*(s))) (s)++; }
|
|
|
|
#define SKIPWHITE(_x) {while(*(_x) && (risspace(*_x) || *(_x) == ',')) (_x)++;}
|
|
|
|
#define SKIPNONWHITE(_x){while(*(_x) &&!(risspace(*_x) || *(_x) == ',')) (_x)++;}
|
1999-07-20 00:20:02 +08:00
|
|
|
|
2001-01-11 22:13:04 +08:00
|
|
|
/**
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param p trigger entry chain
|
2001-05-07 03:17:14 +08:00
|
|
|
* @return NULL always
|
2001-01-11 22:13:04 +08:00
|
|
|
*/
|
2001-05-07 03:17:14 +08:00
|
|
|
static inline
|
2007-09-12 05:03:27 +08:00
|
|
|
struct TriggerFileEntry * freeTriggerFiles(struct TriggerFileEntry * p)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
1998-11-21 04:18:22 +08:00
|
|
|
struct TriggerFileEntry *o, *q = p;
|
1998-07-31 06:09:42 +08:00
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
while (q != NULL) {
|
|
|
|
o = q;
|
|
|
|
q = q->next;
|
2001-04-29 09:05:43 +08:00
|
|
|
o->fileName = _free(o->fileName);
|
|
|
|
o->script = _free(o->script);
|
|
|
|
o->prog = _free(o->prog);
|
|
|
|
o = _free(o);
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
2001-05-07 03:17:14 +08:00
|
|
|
return NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
|
2001-01-11 22:13:04 +08:00
|
|
|
/**
|
2001-05-07 03:17:14 +08:00
|
|
|
* Destroy source component chain.
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param s source component chain
|
2001-05-07 03:17:14 +08:00
|
|
|
* @return NULL always
|
2001-01-11 22:13:04 +08:00
|
|
|
*/
|
2001-05-07 03:17:14 +08:00
|
|
|
static inline
|
2007-09-12 05:03:27 +08:00
|
|
|
struct Source * freeSources(struct Source * s)
|
1998-11-21 04:18:22 +08:00
|
|
|
{
|
|
|
|
struct Source *r, *t = s;
|
|
|
|
|
|
|
|
while (t != NULL) {
|
|
|
|
r = t;
|
|
|
|
t = t->next;
|
2001-04-29 09:05:43 +08:00
|
|
|
r->fullSource = _free(r->fullSource);
|
|
|
|
r = _free(r);
|
1998-11-21 04:18:22 +08:00
|
|
|
}
|
2001-05-07 03:17:14 +08:00
|
|
|
return NULL;
|
1998-11-21 04:18:22 +08:00
|
|
|
}
|
|
|
|
|
2007-12-07 16:43:53 +08:00
|
|
|
rpmRC lookupPackage(rpmSpec spec, const char *name, int flag,Package *pkg)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
1999-07-20 00:20:02 +08:00
|
|
|
const char *pname;
|
2008-04-25 16:45:35 +08:00
|
|
|
char *fullName = NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
Package p;
|
2008-04-25 16:45:35 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
/* "main" package */
|
1999-07-20 00:20:02 +08:00
|
|
|
if (name == NULL) {
|
|
|
|
if (pkg)
|
1998-07-31 06:09:42 +08:00
|
|
|
*pkg = spec->packages;
|
2007-12-07 16:43:53 +08:00
|
|
|
return RPMRC_OK;
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Construct package name */
|
|
|
|
if (flag == PART_SUBNAME) {
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) headerNVR(spec->packages->header, &pname, NULL, NULL);
|
2008-04-25 16:45:35 +08:00
|
|
|
rasprintf(&fullName, "%s-%s", pname, name);
|
1998-07-31 06:09:42 +08:00
|
|
|
} else {
|
2008-04-25 16:45:35 +08:00
|
|
|
fullName = xstrdup(name);
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
|
1999-07-20 00:20:02 +08:00
|
|
|
/* Locate package with fullName */
|
1998-08-09 06:27:08 +08:00
|
|
|
for (p = spec->packages; p != NULL; p = p->next) {
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) headerNVR(p->header, &pname, NULL, NULL);
|
1999-07-20 00:20:02 +08:00
|
|
|
if (pname && (! strcmp(fullName, pname))) {
|
1998-08-09 06:27:08 +08:00
|
|
|
break;
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
}
|
2008-04-25 16:45:35 +08:00
|
|
|
free(fullName);
|
1998-07-31 06:09:42 +08:00
|
|
|
|
1999-07-20 00:20:02 +08:00
|
|
|
if (pkg)
|
2007-09-12 05:03:27 +08:00
|
|
|
*pkg = p;
|
2007-12-07 16:43:53 +08:00
|
|
|
return ((p == NULL) ? RPMRC_FAIL : RPMRC_OK);
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
|
2007-09-21 20:23:02 +08:00
|
|
|
Package newPackage(rpmSpec spec)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
|
|
|
Package p;
|
|
|
|
Package pp;
|
|
|
|
|
2001-09-25 05:53:14 +08:00
|
|
|
p = xcalloc(1, sizeof(*p));
|
1998-07-31 06:09:42 +08:00
|
|
|
|
|
|
|
p->header = headerNew();
|
2002-12-24 15:21:04 +08:00
|
|
|
p->ds = NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
p->icon = NULL;
|
1999-03-27 04:07:34 +08:00
|
|
|
|
|
|
|
p->autoProv = 1;
|
|
|
|
p->autoReq = 1;
|
1998-07-31 06:09:42 +08:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
p->reqProv = NULL;
|
|
|
|
p->triggers = NULL;
|
|
|
|
p->triggerScripts = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
p->triggerFiles = NULL;
|
|
|
|
|
|
|
|
p->fileFile = NULL;
|
|
|
|
p->fileList = NULL;
|
|
|
|
|
|
|
|
p->cpioList = NULL;
|
|
|
|
|
|
|
|
p->preInFile = NULL;
|
|
|
|
p->postInFile = NULL;
|
|
|
|
p->preUnFile = NULL;
|
|
|
|
p->postUnFile = NULL;
|
|
|
|
p->verifyFile = NULL;
|
|
|
|
|
|
|
|
p->specialDoc = NULL;
|
2008-05-06 17:48:09 +08:00
|
|
|
p->specialDocDir = NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
if (spec->packages == NULL) {
|
1998-07-31 06:09:42 +08:00
|
|
|
spec->packages = p;
|
|
|
|
} else {
|
|
|
|
/* Always add package to end of list */
|
1998-11-21 04:18:22 +08:00
|
|
|
for (pp = spec->packages; pp->next != NULL; pp = pp->next)
|
2001-06-06 03:26:22 +08:00
|
|
|
{};
|
1998-07-31 06:09:42 +08:00
|
|
|
pp->next = p;
|
|
|
|
}
|
1998-11-21 04:18:22 +08:00
|
|
|
p->next = NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
Package freePackage(Package pkg)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
2001-10-16 01:53:34 +08:00
|
|
|
if (pkg == NULL) return NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
|
2008-03-25 01:03:20 +08:00
|
|
|
pkg->preInFile = _free(pkg->preInFile);
|
|
|
|
pkg->postInFile = _free(pkg->postInFile);
|
|
|
|
pkg->preUnFile = _free(pkg->preUnFile);
|
|
|
|
pkg->postUnFile = _free(pkg->postUnFile);
|
|
|
|
pkg->verifyFile = _free(pkg->verifyFile);
|
2001-10-16 01:53:34 +08:00
|
|
|
|
2002-07-14 03:08:51 +08:00
|
|
|
pkg->header = headerFree(pkg->header);
|
2002-12-24 15:21:04 +08:00
|
|
|
pkg->ds = rpmdsFree(pkg->ds);
|
2001-10-16 01:53:34 +08:00
|
|
|
pkg->fileList = freeStringBuf(pkg->fileList);
|
2008-03-25 01:03:20 +08:00
|
|
|
pkg->fileFile = _free(pkg->fileFile);
|
2001-10-16 01:53:34 +08:00
|
|
|
if (pkg->cpioList) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi fi = pkg->cpioList;
|
2001-10-16 01:53:34 +08:00
|
|
|
pkg->cpioList = NULL;
|
2002-08-20 06:27:44 +08:00
|
|
|
fi = rpmfiFree(fi);
|
2001-01-24 07:03:28 +08:00
|
|
|
}
|
1998-07-31 06:09:42 +08:00
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
pkg->specialDoc = freeStringBuf(pkg->specialDoc);
|
2008-05-06 17:48:09 +08:00
|
|
|
pkg->specialDocDir = _free(pkg->specialDocDir);
|
2001-10-16 01:53:34 +08:00
|
|
|
pkg->icon = freeSources(pkg->icon);
|
|
|
|
pkg->triggerFiles = freeTriggerFiles(pkg->triggerFiles);
|
1998-07-31 06:09:42 +08:00
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
pkg = _free(pkg);
|
2001-05-07 03:17:14 +08:00
|
|
|
return NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
|
2001-05-07 03:17:14 +08:00
|
|
|
Package freePackages(Package packages)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
|
|
|
Package p;
|
|
|
|
|
2001-05-07 03:17:14 +08:00
|
|
|
while ((p = packages) != NULL) {
|
|
|
|
packages = p->next;
|
1998-11-21 04:18:22 +08:00
|
|
|
p->next = NULL;
|
2001-05-07 03:17:14 +08:00
|
|
|
p = freePackage(p);
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
2001-05-07 03:17:14 +08:00
|
|
|
return NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
1995-11-28 06:31:21 +08:00
|
|
|
|
2001-01-11 22:13:04 +08:00
|
|
|
/**
|
|
|
|
*/
|
2008-07-01 18:51:08 +08:00
|
|
|
static inline struct Source *findSource(rpmSpec spec, uint32_t num, int flag)
|
1995-12-28 00:50:50 +08:00
|
|
|
{
|
1998-11-21 04:18:22 +08:00
|
|
|
struct Source *p;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2001-05-07 03:17:14 +08:00
|
|
|
for (p = spec->sources; p != NULL; p = p->next)
|
|
|
|
if ((num == p->num) && (p->flags & flag)) return p;
|
1995-12-28 00:50:50 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
1995-12-28 00:50:50 +08:00
|
|
|
|
2008-02-05 23:42:19 +08:00
|
|
|
int parseNoSource(rpmSpec spec, const char * field, rpmTag tag)
|
1998-07-26 05:00:26 +08:00
|
|
|
{
|
1999-07-20 00:20:02 +08:00
|
|
|
const char *f, *fe;
|
|
|
|
const char *name;
|
2008-07-01 18:52:16 +08:00
|
|
|
int flag;
|
|
|
|
uint32_t num;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (tag == RPMTAG_NOSOURCE) {
|
|
|
|
flag = RPMBUILD_ISSOURCE;
|
|
|
|
name = "source";
|
|
|
|
} else {
|
|
|
|
flag = RPMBUILD_ISPATCH;
|
|
|
|
name = "patch";
|
1996-05-08 02:49:33 +08:00
|
|
|
}
|
|
|
|
|
1999-07-20 00:20:02 +08:00
|
|
|
fe = field;
|
2001-05-01 06:32:22 +08:00
|
|
|
for (f = fe; *f != '\0'; f = fe) {
|
1998-11-21 04:18:22 +08:00
|
|
|
struct Source *p;
|
1999-07-20 00:20:02 +08:00
|
|
|
|
|
|
|
SKIPWHITE(f);
|
|
|
|
if (*f == '\0')
|
|
|
|
break;
|
|
|
|
fe = f;
|
|
|
|
SKIPNONWHITE(fe);
|
2001-05-01 06:32:22 +08:00
|
|
|
if (*fe != '\0') fe++;
|
1999-07-20 00:20:02 +08:00
|
|
|
|
2008-07-01 18:52:16 +08:00
|
|
|
if (parseUnsignedNum(f, &num)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Bad number: %s\n"),
|
1999-07-20 00:20:02 +08:00
|
|
|
spec->lineNum, f);
|
2007-12-07 16:43:53 +08:00
|
|
|
return RPMRC_FAIL;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1996-05-08 02:49:33 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (! (p = findSource(spec, num, flag))) {
|
2008-07-01 18:52:16 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Bad no%s number: %u\n"),
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->lineNum, name, num);
|
2007-12-07 16:43:53 +08:00
|
|
|
return RPMRC_FAIL;
|
1996-05-08 02:49:33 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
p->flags |= RPMBUILD_ISNO;
|
1997-09-17 04:09:31 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
1995-12-12 06:52:59 +08:00
|
|
|
}
|
|
|
|
|
2008-02-05 23:42:19 +08:00
|
|
|
int addSource(rpmSpec spec, Package pkg, const char *field, rpmTag tag)
|
1995-11-28 06:31:21 +08:00
|
|
|
{
|
1998-01-13 05:31:29 +08:00
|
|
|
struct Source *p;
|
|
|
|
int flag = 0;
|
2007-12-14 21:17:59 +08:00
|
|
|
const char *name = NULL;
|
1999-07-20 00:20:02 +08:00
|
|
|
char *nump;
|
2008-03-23 20:50:07 +08:00
|
|
|
char *fieldp = NULL;
|
|
|
|
char *buf = NULL;
|
2008-07-01 18:52:16 +08:00
|
|
|
uint32_t num = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2008-08-20 17:01:38 +08:00
|
|
|
switch (tag) {
|
1998-01-13 05:31:29 +08:00
|
|
|
case RPMTAG_SOURCE:
|
|
|
|
flag = RPMBUILD_ISSOURCE;
|
|
|
|
name = "source";
|
|
|
|
fieldp = spec->line + 6;
|
|
|
|
break;
|
|
|
|
case RPMTAG_PATCH:
|
|
|
|
flag = RPMBUILD_ISPATCH;
|
|
|
|
name = "patch";
|
|
|
|
fieldp = spec->line + 5;
|
|
|
|
break;
|
|
|
|
case RPMTAG_ICON:
|
|
|
|
flag = RPMBUILD_ISICON;
|
1999-07-20 00:20:02 +08:00
|
|
|
fieldp = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
break;
|
2008-08-20 17:01:38 +08:00
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
break;
|
1995-12-14 23:52:51 +08:00
|
|
|
}
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
/* Get the number */
|
|
|
|
if (tag != RPMTAG_ICON) {
|
|
|
|
/* We already know that a ':' exists, and that there */
|
|
|
|
/* are no spaces before it. */
|
1998-06-29 12:42:36 +08:00
|
|
|
/* This also now allows for spaces and tabs between */
|
|
|
|
/* the number and the ':' */
|
2008-03-23 20:50:07 +08:00
|
|
|
char ch;
|
|
|
|
char *fieldp_backup = fieldp;
|
1995-12-14 23:52:51 +08:00
|
|
|
|
1998-06-29 12:42:36 +08:00
|
|
|
while ((*fieldp != ':') && (*fieldp != ' ') && (*fieldp != '\t')) {
|
2008-03-23 20:50:07 +08:00
|
|
|
fieldp++;
|
1996-02-22 01:19:52 +08:00
|
|
|
}
|
2008-03-23 20:50:07 +08:00
|
|
|
ch = *fieldp;
|
|
|
|
*fieldp = '\0';
|
1995-12-14 23:52:51 +08:00
|
|
|
|
2008-03-23 20:50:07 +08:00
|
|
|
nump = fieldp_backup;
|
1998-01-13 05:31:29 +08:00
|
|
|
SKIPSPACE(nump);
|
2001-05-04 05:00:18 +08:00
|
|
|
if (nump == NULL || *nump == '\0') {
|
2008-07-07 20:49:33 +08:00
|
|
|
num = flag == RPMBUILD_ISSOURCE ? 0 : INT_MAX;
|
1996-02-22 01:19:52 +08:00
|
|
|
} else {
|
2008-07-01 18:52:16 +08:00
|
|
|
if (parseUnsignedNum(fieldp_backup, &num)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Bad %s number: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, name, spec->line);
|
2008-03-23 20:50:07 +08:00
|
|
|
*fieldp = ch;
|
2007-12-07 16:43:53 +08:00
|
|
|
return RPMRC_FAIL;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1996-02-23 10:22:18 +08:00
|
|
|
}
|
2008-03-23 20:50:07 +08:00
|
|
|
*fieldp = ch;
|
1996-02-22 01:19:52 +08:00
|
|
|
}
|
1997-01-25 12:48:06 +08:00
|
|
|
|
2008-08-07 20:50:49 +08:00
|
|
|
/* Check whether tags of the same number haven't already been defined */
|
|
|
|
for (p = spec->sources; p != NULL; p = p->next) {
|
|
|
|
if ( p->num != num ) continue;
|
2008-08-08 18:53:57 +08:00
|
|
|
if ((tag == RPMTAG_SOURCE && p->flags == RPMBUILD_ISSOURCE) ||
|
|
|
|
(tag == RPMTAG_PATCH && p->flags == RPMBUILD_ISPATCH)) {
|
2008-08-07 20:50:49 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("%s %d defined multiple times\n"), name, num);
|
|
|
|
return RPMRC_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
/* Create the entry and link it in */
|
2001-10-16 22:58:57 +08:00
|
|
|
p = xmalloc(sizeof(*p));
|
1998-01-13 05:31:29 +08:00
|
|
|
p->num = num;
|
1999-09-21 11:22:53 +08:00
|
|
|
p->fullSource = xstrdup(field);
|
1998-01-13 05:31:29 +08:00
|
|
|
p->flags = flag;
|
2001-05-07 03:17:14 +08:00
|
|
|
p->source = strrchr(p->fullSource, '/');
|
1998-01-13 05:31:29 +08:00
|
|
|
if (p->source) {
|
|
|
|
p->source++;
|
1997-01-25 12:48:06 +08:00
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
p->source = p->fullSource;
|
1997-01-25 12:48:06 +08:00
|
|
|
}
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if (tag != RPMTAG_ICON) {
|
|
|
|
p->next = spec->sources;
|
|
|
|
spec->sources = p;
|
|
|
|
} else {
|
|
|
|
p->next = pkg->icon;
|
|
|
|
pkg->icon = p;
|
1995-11-28 06:31:21 +08:00
|
|
|
}
|
1995-12-28 00:50:50 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->numSources++;
|
1995-12-28 00:50:50 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if (tag != RPMTAG_ICON) {
|
2007-12-15 16:39:15 +08:00
|
|
|
char *body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
|
1998-09-06 04:02:08 +08:00
|
|
|
|
2008-03-23 20:50:07 +08:00
|
|
|
rasprintf(&buf, "%s%d",
|
1998-01-13 05:31:29 +08:00
|
|
|
(flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);
|
1998-08-02 23:14:38 +08:00
|
|
|
addMacro(spec->macros, buf, NULL, body, RMIL_SPEC);
|
2008-03-23 20:50:07 +08:00
|
|
|
free(buf);
|
|
|
|
rasprintf(&buf, "%sURL%d",
|
1998-01-13 05:31:29 +08:00
|
|
|
(flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);
|
1998-08-02 23:14:38 +08:00
|
|
|
addMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC);
|
2008-03-23 20:50:07 +08:00
|
|
|
free(buf);
|
2008-02-25 18:24:22 +08:00
|
|
|
#ifdef WITH_LUA
|
|
|
|
{
|
|
|
|
rpmlua lua = NULL; /* global state */
|
|
|
|
const char * what = (flag & RPMBUILD_ISPATCH) ? "patches" : "sources";
|
|
|
|
rpmluaPushTable(lua, what);
|
|
|
|
rpmluav var = rpmluavNew();
|
|
|
|
rpmluavSetListMode(var, 1);
|
|
|
|
rpmluavSetValue(var, RPMLUAV_STRING, body);
|
|
|
|
rpmluaSetVar(lua, var);
|
|
|
|
var = rpmluavFree(var);
|
|
|
|
rpmluaPop(lua);
|
|
|
|
}
|
|
|
|
#endif
|
2001-04-29 09:05:43 +08:00
|
|
|
body = _free(body);
|
1995-11-28 06:31:21 +08:00
|
|
|
}
|
1995-12-13 01:53:17 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
return 0;
|
1995-12-13 01:53:17 +08:00
|
|
|
}
|
1995-11-28 06:31:21 +08:00
|
|
|
|
2001-01-11 22:13:04 +08:00
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 05:03:27 +08:00
|
|
|
static inline speclines freeSl(speclines sl)
|
1999-02-23 01:44:57 +08:00
|
|
|
{
|
|
|
|
int i;
|
2001-05-07 03:17:14 +08:00
|
|
|
if (sl == NULL) return NULL;
|
1999-02-23 01:44:57 +08:00
|
|
|
for (i = 0; i < sl->sl_nlines; i++)
|
2001-04-29 09:05:43 +08:00
|
|
|
sl->sl_lines[i] = _free(sl->sl_lines[i]);
|
|
|
|
sl->sl_lines = _free(sl->sl_lines);
|
2001-05-07 03:17:14 +08:00
|
|
|
return _free(sl);
|
1999-02-23 01:44:57 +08:00
|
|
|
}
|
|
|
|
|
2001-01-11 22:13:04 +08:00
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 05:03:27 +08:00
|
|
|
static inline spectags freeSt(spectags st)
|
1999-02-23 01:44:57 +08:00
|
|
|
{
|
|
|
|
int i;
|
2001-05-07 03:17:14 +08:00
|
|
|
if (st == NULL) return NULL;
|
1999-02-23 01:44:57 +08:00
|
|
|
for (i = 0; i < st->st_ntags; i++) {
|
2001-05-07 03:17:14 +08:00
|
|
|
spectag t = st->st_t + i;
|
2008-03-25 01:03:00 +08:00
|
|
|
t->t_lang = _free(t->t_lang);
|
|
|
|
t->t_msgid = _free(t->t_msgid);
|
1999-02-23 01:44:57 +08:00
|
|
|
}
|
2001-04-29 09:05:43 +08:00
|
|
|
st->st_t = _free(st->st_t);
|
2001-05-07 03:17:14 +08:00
|
|
|
return _free(st);
|
1999-02-23 01:44:57 +08:00
|
|
|
}
|
|
|
|
|
2007-09-21 20:23:02 +08:00
|
|
|
rpmSpec newSpec(void)
|
1995-12-13 01:53:17 +08:00
|
|
|
{
|
2007-09-21 20:23:02 +08:00
|
|
|
rpmSpec spec = xcalloc(1, sizeof(*spec));
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
spec->specFile = NULL;
|
1995-12-12 06:52:59 +08:00
|
|
|
|
2008-07-07 15:17:21 +08:00
|
|
|
spec->sl = NULL;
|
|
|
|
spec->st = NULL;
|
1999-02-23 01:44:57 +08:00
|
|
|
|
1998-10-07 01:34:58 +08:00
|
|
|
spec->fileStack = NULL;
|
1999-07-20 02:39:48 +08:00
|
|
|
spec->lbuf[0] = '\0';
|
|
|
|
spec->line = spec->lbuf;
|
|
|
|
spec->nextline = NULL;
|
1999-07-27 05:51:03 +08:00
|
|
|
spec->nextpeekc = '\0';
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->lineNum = 0;
|
2001-04-29 09:05:43 +08:00
|
|
|
spec->readStack = xcalloc(1, sizeof(*spec->readStack));
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->readStack->next = NULL;
|
|
|
|
spec->readStack->reading = 1;
|
1995-12-14 23:52:51 +08:00
|
|
|
|
2008-04-05 01:37:48 +08:00
|
|
|
spec->rootDir = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->prep = NULL;
|
|
|
|
spec->build = NULL;
|
|
|
|
spec->install = NULL;
|
2002-12-22 04:37:37 +08:00
|
|
|
spec->check = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->clean = NULL;
|
1996-07-17 09:35:08 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->sources = NULL;
|
|
|
|
spec->packages = NULL;
|
|
|
|
spec->noSource = 0;
|
|
|
|
spec->numSources = 0;
|
1996-07-17 09:35:08 +08:00
|
|
|
|
2002-12-22 04:37:37 +08:00
|
|
|
spec->sourceRpmName = NULL;
|
|
|
|
spec->sourcePkgId = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->sourceHeader = NULL;
|
|
|
|
spec->sourceCpioList = NULL;
|
|
|
|
|
2008-04-05 01:37:48 +08:00
|
|
|
spec->buildRoot = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->buildSubdir = NULL;
|
1997-07-25 21:09:05 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->passPhrase = NULL;
|
|
|
|
spec->timeCheck = 0;
|
|
|
|
spec->cookie = NULL;
|
|
|
|
|
|
|
|
spec->buildRestrictions = headerNew();
|
2001-05-07 03:17:14 +08:00
|
|
|
spec->BANames = NULL;
|
|
|
|
spec->BACount = 0;
|
|
|
|
spec->recursing = 0;
|
|
|
|
spec->BASpecs = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->force = 0;
|
|
|
|
spec->anyarch = 0;
|
|
|
|
|
2007-09-12 05:03:27 +08:00
|
|
|
spec->macros = rpmGlobalMacroContext;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
2008-02-25 18:24:22 +08:00
|
|
|
#ifdef WITH_LUA
|
|
|
|
{
|
|
|
|
/* make sure patches and sources tables always exist */
|
|
|
|
rpmlua lua = NULL; /* global state */
|
|
|
|
rpmluaPushTable(lua, "patches");
|
|
|
|
rpmluaPushTable(lua, "sources");
|
|
|
|
rpmluaPop(lua);
|
|
|
|
rpmluaPop(lua);
|
|
|
|
}
|
|
|
|
#endif
|
1998-07-26 05:00:26 +08:00
|
|
|
return spec;
|
1997-07-25 21:09:05 +08:00
|
|
|
}
|
|
|
|
|
2007-09-21 20:23:02 +08:00
|
|
|
rpmSpec freeSpec(rpmSpec spec)
|
1995-12-13 01:53:17 +08:00
|
|
|
{
|
1998-07-26 05:00:26 +08:00
|
|
|
struct ReadLevelEntry *rl;
|
1998-10-07 01:34:58 +08:00
|
|
|
|
2001-05-07 03:17:14 +08:00
|
|
|
if (spec == NULL) return NULL;
|
|
|
|
|
|
|
|
spec->sl = freeSl(spec->sl);
|
|
|
|
spec->st = freeSt(spec->st);
|
1999-02-23 01:44:57 +08:00
|
|
|
|
2001-05-06 03:28:32 +08:00
|
|
|
spec->prep = freeStringBuf(spec->prep);
|
|
|
|
spec->build = freeStringBuf(spec->build);
|
|
|
|
spec->install = freeStringBuf(spec->install);
|
2002-12-22 04:37:37 +08:00
|
|
|
spec->check = freeStringBuf(spec->check);
|
2001-05-06 03:28:32 +08:00
|
|
|
spec->clean = freeStringBuf(spec->clean);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2008-04-05 01:37:48 +08:00
|
|
|
spec->buildRoot = _free(spec->buildRoot);
|
2008-03-25 01:03:20 +08:00
|
|
|
spec->buildSubdir = _free(spec->buildSubdir);
|
2008-04-05 01:37:48 +08:00
|
|
|
spec->rootDir = _free(spec->rootDir);
|
2008-03-25 01:03:20 +08:00
|
|
|
spec->specFile = _free(spec->specFile);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
2001-05-07 03:17:14 +08:00
|
|
|
closeSpec(spec);
|
1998-10-07 01:34:58 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
while (spec->readStack) {
|
|
|
|
rl = spec->readStack;
|
2001-04-29 09:05:43 +08:00
|
|
|
spec->readStack = rl->next;
|
1998-11-21 04:18:22 +08:00
|
|
|
rl->next = NULL;
|
2001-04-29 09:05:43 +08:00
|
|
|
rl = _free(rl);
|
1995-12-13 01:53:17 +08:00
|
|
|
}
|
|
|
|
|
2008-03-25 01:03:20 +08:00
|
|
|
spec->sourceRpmName = _free(spec->sourceRpmName);
|
2002-12-22 04:37:37 +08:00
|
|
|
spec->sourcePkgId = _free(spec->sourcePkgId);
|
2002-07-14 03:08:51 +08:00
|
|
|
spec->sourceHeader = headerFree(spec->sourceHeader);
|
1995-12-18 22:56:49 +08:00
|
|
|
|
2001-01-24 23:58:35 +08:00
|
|
|
if (spec->sourceCpioList) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi fi = spec->sourceCpioList;
|
2001-04-29 09:05:43 +08:00
|
|
|
spec->sourceCpioList = NULL;
|
2002-08-20 06:27:44 +08:00
|
|
|
fi = rpmfiFree(fi);
|
2001-01-24 07:03:28 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
|
2002-07-14 03:08:51 +08:00
|
|
|
spec->buildRestrictions = headerFree(spec->buildRestrictions);
|
1995-12-18 22:56:49 +08:00
|
|
|
|
2001-05-07 03:17:14 +08:00
|
|
|
if (!spec->recursing) {
|
|
|
|
if (spec->BASpecs != NULL)
|
|
|
|
while (spec->BACount--) {
|
|
|
|
spec->BASpecs[spec->BACount] =
|
|
|
|
freeSpec(spec->BASpecs[spec->BACount]);
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
2001-05-07 03:17:14 +08:00
|
|
|
spec->BASpecs = _free(spec->BASpecs);
|
1995-12-18 22:56:49 +08:00
|
|
|
}
|
2001-05-07 03:17:14 +08:00
|
|
|
spec->BANames = _free(spec->BANames);
|
1995-12-18 22:56:49 +08:00
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
spec->passPhrase = _free(spec->passPhrase);
|
2008-03-25 01:03:20 +08:00
|
|
|
spec->cookie = _free(spec->cookie);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
2008-02-25 18:24:22 +08:00
|
|
|
#ifdef WITH_LUA
|
|
|
|
rpmlua lua = NULL; /* global state */
|
|
|
|
rpmluaDelVar(lua, "patches");
|
|
|
|
rpmluaDelVar(lua, "sources");
|
|
|
|
#endif
|
|
|
|
|
2001-05-07 03:17:14 +08:00
|
|
|
spec->sources = freeSources(spec->sources);
|
|
|
|
spec->packages = freePackages(spec->packages);
|
1998-07-26 05:00:26 +08:00
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
spec = _free(spec);
|
2001-05-07 03:17:14 +08:00
|
|
|
|
|
|
|
return spec;
|
1995-12-18 22:56:49 +08:00
|
|
|
}
|
1998-10-07 01:34:58 +08:00
|
|
|
|
2002-12-22 10:11:05 +08:00
|
|
|
struct OpenFileInfo * newOpenFileInfo(void)
|
1998-10-07 01:34:58 +08:00
|
|
|
{
|
|
|
|
struct OpenFileInfo *ofi;
|
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
ofi = xmalloc(sizeof(*ofi));
|
1999-11-05 05:26:08 +08:00
|
|
|
ofi->fd = NULL;
|
1998-10-07 01:34:58 +08:00
|
|
|
ofi->fileName = NULL;
|
|
|
|
ofi->lineNum = 0;
|
|
|
|
ofi->readBuf[0] = '\0';
|
|
|
|
ofi->readPtr = NULL;
|
|
|
|
ofi->next = NULL;
|
|
|
|
|
|
|
|
return ofi;
|
|
|
|
}
|
2002-12-22 10:11:05 +08:00
|
|
|
|
|
|
|
int rpmspecQuery(rpmts ts, QVA_t qva, const char * arg)
|
|
|
|
{
|
2007-09-21 20:23:02 +08:00
|
|
|
rpmSpec spec = NULL;
|
2002-12-22 10:11:05 +08:00
|
|
|
Package pkg;
|
|
|
|
char * buildRoot = NULL;
|
|
|
|
int recursing = 0;
|
|
|
|
char * passPhrase = "";
|
|
|
|
char *cookie = NULL;
|
|
|
|
int anyarch = 1;
|
|
|
|
int force = 1;
|
|
|
|
int res = 1;
|
|
|
|
int xx;
|
|
|
|
|
|
|
|
if (qva->qva_showPackage == NULL)
|
|
|
|
goto exit;
|
|
|
|
|
2007-09-12 05:03:27 +08:00
|
|
|
/* FIX: make spec abstract */
|
2002-12-22 10:11:05 +08:00
|
|
|
if (parseSpec(ts, arg, "/", buildRoot, recursing, passPhrase,
|
|
|
|
cookie, anyarch, force)
|
|
|
|
|| (spec = rpmtsSetSpec(ts, NULL)) == NULL)
|
|
|
|
{
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
2002-12-22 10:11:05 +08:00
|
|
|
_("query of specfile %s failed, can't parse\n"), arg);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = 0;
|
|
|
|
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next)
|
|
|
|
xx = qva->qva_showPackage(qva, ts, pkg->header);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
spec = freeSpec(spec);
|
|
|
|
return res;
|
|
|
|
}
|