1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1995-12-13 01:53:17 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#include "rpmbuild.h"
|
1998-08-09 06:27:08 +08:00
|
|
|
#include "buildio.h"
|
1998-07-31 06:09:42 +08:00
|
|
|
|
1999-05-07 07:21:08 +08:00
|
|
|
extern char *specedit;
|
1999-04-02 06:26:44 +08:00
|
|
|
extern MacroContext globalMacroContext;
|
1999-02-23 01:44:57 +08:00
|
|
|
|
1999-07-20 00:20:02 +08:00
|
|
|
#define SKIPWHITE(_x) {while(*(_x) && (isspace(*_x) || *(_x) == ',')) (_x)++;}
|
|
|
|
#define SKIPNONWHITE(_x){while(*(_x) &&!(isspace(*_x) || *(_x) == ',')) (_x)++;}
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
static inline void freeTriggerFiles(/*@only@*/ 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;
|
|
|
|
FREE(o->fileName);
|
|
|
|
FREE(o->script);
|
|
|
|
FREE(o->prog);
|
1998-07-31 06:09:42 +08:00
|
|
|
free(o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
static inline void freeCpioList(/*@only@*/ struct cpioFileMapping *cpioList, int cpioCount)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
|
|
|
struct cpioFileMapping *p = cpioList;
|
|
|
|
|
|
|
|
while (cpioCount--) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("archive = %s, fs = %s\n"),
|
1998-07-31 06:09:42 +08:00
|
|
|
p->archivePath, p->fsPath);
|
|
|
|
FREE(p->archivePath);
|
|
|
|
FREE(p->fsPath);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
FREE(cpioList);
|
|
|
|
}
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
static inline void freeSources(/*@only@*/ struct Source *s)
|
|
|
|
{
|
|
|
|
struct Source *r, *t = s;
|
|
|
|
|
|
|
|
while (t != NULL) {
|
|
|
|
r = t;
|
|
|
|
t = t->next;
|
|
|
|
FREE(r->fullSource);
|
|
|
|
free(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int lookupPackage(Spec spec, const char *name, int flag, /*@out@*/Package *pkg)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
1999-07-20 00:20:02 +08:00
|
|
|
const char *pname;
|
1998-11-21 04:18:22 +08:00
|
|
|
const char *fullName;
|
1998-07-31 06:09:42 +08:00
|
|
|
Package p;
|
|
|
|
|
|
|
|
/* "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;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Construct package name */
|
1999-07-20 00:20:02 +08:00
|
|
|
{ char *n;
|
1998-07-31 06:09:42 +08:00
|
|
|
if (flag == PART_SUBNAME) {
|
|
|
|
headerGetEntry(spec->packages->header, RPMTAG_NAME,
|
1999-07-20 00:20:02 +08:00
|
|
|
NULL, (void **) &pname, NULL);
|
|
|
|
fullName = n = alloca(strlen(pname) + 1 + strlen(name) + 1);
|
|
|
|
while (*pname) *n++ = *pname++;
|
|
|
|
*n++ = '-';
|
1998-07-31 06:09:42 +08:00
|
|
|
} else {
|
1999-07-20 00:20:02 +08:00
|
|
|
fullName = n = alloca(strlen(name)+1);
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
1999-07-20 00:20:02 +08:00
|
|
|
strcpy(n, 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) {
|
1999-07-20 00:20:02 +08:00
|
|
|
headerGetEntry(p->header, RPMTAG_NAME, NULL, (void **) &pname, NULL);
|
|
|
|
if (pname && (! strcmp(fullName, pname))) {
|
1998-08-09 06:27:08 +08:00
|
|
|
break;
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-20 00:20:02 +08:00
|
|
|
if (pkg)
|
1998-08-09 06:27:08 +08:00
|
|
|
*pkg = p;
|
|
|
|
return ((p == NULL) ? 1 : 0);
|
1998-07-31 06:09:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Package newPackage(Spec spec)
|
|
|
|
{
|
|
|
|
Package p;
|
|
|
|
Package pp;
|
|
|
|
|
|
|
|
p = malloc(sizeof(*p));
|
|
|
|
|
|
|
|
p->header = headerNew();
|
|
|
|
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->cpioCount = 0;
|
|
|
|
|
|
|
|
p->preInFile = NULL;
|
|
|
|
p->postInFile = NULL;
|
|
|
|
p->preUnFile = NULL;
|
|
|
|
p->postUnFile = NULL;
|
|
|
|
p->verifyFile = NULL;
|
|
|
|
|
|
|
|
p->specialDoc = NULL;
|
|
|
|
|
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)
|
|
|
|
;
|
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;
|
|
|
|
}
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
void freePackage(/*@only@*/ Package p)
|
1998-07-31 06:09:42 +08:00
|
|
|
{
|
1998-11-21 04:18:22 +08:00
|
|
|
if (p == NULL)
|
1998-07-31 06:09:42 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
FREE(p->preInFile);
|
|
|
|
FREE(p->postInFile);
|
|
|
|
FREE(p->preUnFile);
|
|
|
|
FREE(p->postUnFile);
|
|
|
|
FREE(p->verifyFile);
|
|
|
|
|
|
|
|
headerFree(p->header);
|
|
|
|
freeStringBuf(p->fileList);
|
|
|
|
FREE(p->fileFile);
|
|
|
|
freeCpioList(p->cpioList, p->cpioCount);
|
|
|
|
|
|
|
|
freeStringBuf(p->specialDoc);
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
freeSources(p->icon);
|
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
freeTriggerFiles(p->triggerFiles);
|
|
|
|
|
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void freePackages(Spec spec)
|
|
|
|
{
|
|
|
|
Package p;
|
|
|
|
|
|
|
|
while (spec->packages) {
|
|
|
|
p = spec->packages;
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->packages = spec->packages->next;
|
|
|
|
p->next = NULL;
|
1998-07-31 06:09:42 +08:00
|
|
|
freePackage(p);
|
|
|
|
}
|
|
|
|
}
|
1995-11-28 06:31:21 +08:00
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
static inline /*@owned@*/ struct Source *findSource(Spec spec, int 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
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
for (p = spec->sources; p != NULL; p = p->next) {
|
1998-07-26 05:00:26 +08:00
|
|
|
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
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#ifdef UNUSED
|
|
|
|
static char *getSourceAux(Spec spec, int num, int flag, int full)
|
|
|
|
{
|
|
|
|
struct Source *p = spec->sources;
|
1995-12-28 00:50:50 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
p = findSource(spec, num, flag);
|
1995-12-28 00:50:50 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
return (p) ? (full ? p->fullSource : p->source) : NULL;
|
|
|
|
}
|
1995-12-28 00:50:50 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static char *getSource(Spec spec, int num, int flag)
|
|
|
|
{
|
|
|
|
return getSourceAux(spec, num, flag, 0);
|
1995-12-28 00:50:50 +08:00
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
static char *getFullSource(Spec spec, int num, int flag)
|
1996-06-28 01:22:18 +08:00
|
|
|
{
|
1998-07-26 05:00:26 +08:00
|
|
|
return getSourceAux(spec, num, flag, 1);
|
|
|
|
}
|
|
|
|
#endif /* UNUSED */
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-07-20 00:20:02 +08:00
|
|
|
int parseNoSource(Spec spec, const char *field, int tag)
|
1998-07-26 05:00:26 +08:00
|
|
|
{
|
1999-07-20 00:20:02 +08:00
|
|
|
const char *f, *fe;
|
|
|
|
const char *name;
|
1998-07-26 05:00:26 +08:00
|
|
|
int num, flag;
|
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;
|
|
|
|
for (f = fe; *f; 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);
|
|
|
|
if (*fe) fe++;
|
|
|
|
|
|
|
|
if (parseNum(f, &num)) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad number: %s"),
|
1999-07-20 00:20:02 +08:00
|
|
|
spec->lineNum, f);
|
1998-07-26 05:00:26 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1996-05-08 02:49:33 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (! (p = findSource(spec, num, flag))) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad no%s number: %d"),
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->lineNum, name, num);
|
|
|
|
return RPMERR_BADSPEC;
|
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
|
|
|
}
|
|
|
|
|
1999-07-20 00:20:02 +08:00
|
|
|
int addSource(Spec spec, Package pkg, const char *field, int tag)
|
1995-11-28 06:31:21 +08:00
|
|
|
{
|
1998-01-13 05:31:29 +08:00
|
|
|
struct Source *p;
|
|
|
|
int flag = 0;
|
|
|
|
char *name = NULL;
|
1999-07-20 00:20:02 +08:00
|
|
|
char *nump;
|
|
|
|
const char *fieldp = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
char buf[BUFSIZ];
|
|
|
|
int num = 0;
|
|
|
|
|
|
|
|
switch (tag) {
|
|
|
|
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;
|
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 ':' */
|
1995-12-14 23:52:51 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
nump = buf;
|
1998-06-29 12:42:36 +08:00
|
|
|
while ((*fieldp != ':') && (*fieldp != ' ') && (*fieldp != '\t')) {
|
1998-01-13 05:31:29 +08:00
|
|
|
*nump++ = *fieldp++;
|
1996-02-22 01:19:52 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
*nump = '\0';
|
1995-12-14 23:52:51 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
nump = buf;
|
|
|
|
SKIPSPACE(nump);
|
|
|
|
if (! *nump) {
|
|
|
|
num = 0;
|
1996-02-22 01:19:52 +08:00
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
if (parseNum(buf, &num)) {
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad %s number: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, name, spec->line);
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
1996-02-23 10:22:18 +08:00
|
|
|
}
|
1996-02-22 01:19:52 +08:00
|
|
|
}
|
1997-01-25 12:48:06 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
/* Create the entry and link it in */
|
|
|
|
p = malloc(sizeof(struct Source));
|
|
|
|
p->num = num;
|
|
|
|
p->fullSource = strdup(field);
|
|
|
|
p->source = strrchr(p->fullSource, '/');
|
|
|
|
p->flags = flag;
|
|
|
|
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) {
|
1999-01-06 07:13:56 +08:00
|
|
|
const char *body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
|
1998-09-06 04:02:08 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
sprintf(buf, "%s%d",
|
|
|
|
(flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);
|
1998-08-02 23:14:38 +08:00
|
|
|
addMacro(spec->macros, buf, NULL, body, RMIL_SPEC);
|
1998-01-13 05:31:29 +08:00
|
|
|
sprintf(buf, "%sURL%d",
|
|
|
|
(flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);
|
1998-08-02 23:14:38 +08:00
|
|
|
addMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC);
|
1999-01-06 07:13:56 +08:00
|
|
|
xfree(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
|
|
|
|
1999-02-23 01:44:57 +08:00
|
|
|
static inline struct speclines * newSl(void)
|
|
|
|
{
|
|
|
|
struct speclines *sl;
|
1999-05-07 07:21:08 +08:00
|
|
|
if (specedit == NULL)
|
1999-02-23 01:44:57 +08:00
|
|
|
return NULL;
|
|
|
|
sl = malloc(sizeof(struct speclines));
|
|
|
|
sl->sl_lines = NULL;
|
|
|
|
sl->sl_nalloc = 0;
|
|
|
|
sl->sl_nlines = 0;
|
|
|
|
return sl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void freeSl(struct speclines *sl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (sl == NULL)
|
|
|
|
return;
|
|
|
|
for (i = 0; i < sl->sl_nlines; i++)
|
|
|
|
FREE(sl->sl_lines[i]);
|
|
|
|
FREE(sl->sl_lines);
|
|
|
|
free(sl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct spectags * newSt(void)
|
|
|
|
{
|
|
|
|
struct spectags *st;
|
1999-05-07 07:21:08 +08:00
|
|
|
if (specedit == NULL)
|
1999-02-23 01:44:57 +08:00
|
|
|
return NULL;
|
|
|
|
st = malloc(sizeof(struct spectags));
|
|
|
|
st->st_t = NULL;
|
|
|
|
st->st_nalloc = 0;
|
|
|
|
st->st_ntags = 0;
|
|
|
|
return st;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void freeSt(struct spectags *st)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (st == NULL)
|
|
|
|
return;
|
|
|
|
for (i = 0; i < st->st_ntags; i++) {
|
|
|
|
struct spectag *t = st->st_t + i;
|
|
|
|
FREE(t->t_lang);
|
|
|
|
FREE(t->t_msgid);
|
|
|
|
}
|
|
|
|
FREE(st->st_t);
|
|
|
|
free(st);
|
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
Spec newSpec(void)
|
1995-12-13 01:53:17 +08:00
|
|
|
{
|
1998-07-26 05:00:26 +08:00
|
|
|
Spec spec;
|
1995-11-28 06:31:21 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec = (Spec)malloc(sizeof *spec);
|
|
|
|
|
|
|
|
spec->specFile = NULL;
|
|
|
|
spec->sourceRpmName = NULL;
|
1995-12-12 06:52:59 +08:00
|
|
|
|
1999-02-23 01:44:57 +08:00
|
|
|
spec->sl = newSl();
|
|
|
|
spec->st = newSt();
|
|
|
|
|
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;
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->lineNum = 0;
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->readStack = malloc(sizeof(struct ReadLevelEntry));
|
|
|
|
spec->readStack->next = NULL;
|
|
|
|
spec->readStack->reading = 1;
|
1995-12-14 23:52:51 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->prep = NULL;
|
|
|
|
spec->build = NULL;
|
|
|
|
spec->install = NULL;
|
|
|
|
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
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->sourceHeader = NULL;
|
1997-03-31 22:16:11 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
spec->sourceCpioCount = 0;
|
|
|
|
spec->sourceCpioList = NULL;
|
|
|
|
|
|
|
|
spec->gotBuildRoot = 0;
|
|
|
|
spec->buildRoot = NULL;
|
|
|
|
|
|
|
|
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();
|
|
|
|
spec->buildArchitectures = NULL;
|
|
|
|
spec->buildArchitectureCount = 0;
|
|
|
|
spec->inBuildArchitectures = 0;
|
|
|
|
spec->buildArchitectureSpecs = NULL;
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->force = 0;
|
|
|
|
spec->anyarch = 0;
|
|
|
|
|
1998-08-01 04:11:49 +08:00
|
|
|
spec->macros = &globalMacroContext;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
return spec;
|
1997-07-25 21:09:05 +08:00
|
|
|
}
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
void freeSpec(/*@only@*/ Spec spec)
|
1995-12-13 01:53:17 +08:00
|
|
|
{
|
1998-10-07 01:34:58 +08:00
|
|
|
struct OpenFileInfo *ofi;
|
1998-07-26 05:00:26 +08:00
|
|
|
struct ReadLevelEntry *rl;
|
1998-10-07 01:34:58 +08:00
|
|
|
|
1999-02-23 01:44:57 +08:00
|
|
|
freeSl(spec->sl); spec->sl = NULL;
|
|
|
|
freeSt(spec->st); spec->st = NULL;
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
freeStringBuf(spec->prep); spec->prep = NULL;
|
|
|
|
freeStringBuf(spec->build); spec->build = NULL;
|
|
|
|
freeStringBuf(spec->install); spec->install = NULL;
|
|
|
|
freeStringBuf(spec->clean); spec->clean = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
FREE(spec->buildRoot);
|
|
|
|
FREE(spec->buildSubdir);
|
|
|
|
FREE(spec->specFile);
|
|
|
|
FREE(spec->sourceRpmName);
|
|
|
|
|
1998-10-07 01:34:58 +08:00
|
|
|
while (spec->fileStack) {
|
|
|
|
ofi = spec->fileStack;
|
|
|
|
spec->fileStack = spec->fileStack->next;
|
1998-11-21 04:18:22 +08:00
|
|
|
ofi->next = NULL;
|
1998-10-07 01:34:58 +08:00
|
|
|
FREE(ofi->fileName);
|
|
|
|
free(ofi);
|
|
|
|
}
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
while (spec->readStack) {
|
|
|
|
rl = spec->readStack;
|
|
|
|
spec->readStack = spec->readStack->next;
|
1998-11-21 04:18:22 +08:00
|
|
|
rl->next = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
free(rl);
|
1995-12-13 01:53:17 +08:00
|
|
|
}
|
|
|
|
|
1998-11-17 05:40:28 +08:00
|
|
|
if (spec->sourceHeader != NULL) {
|
1998-07-26 05:00:26 +08:00
|
|
|
headerFree(spec->sourceHeader);
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->sourceHeader = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
}
|
1995-12-18 22:56:49 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
freeCpioList(spec->sourceCpioList, spec->sourceCpioCount);
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->sourceCpioList = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
|
|
|
|
headerFree(spec->buildRestrictions);
|
1998-11-21 04:18:22 +08:00
|
|
|
spec->buildRestrictions = NULL;
|
1995-12-18 22:56:49 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
if (!spec->inBuildArchitectures) {
|
|
|
|
while (spec->buildArchitectureCount--) {
|
|
|
|
freeSpec(
|
|
|
|
spec->buildArchitectureSpecs[spec->buildArchitectureCount]);
|
|
|
|
}
|
1998-11-21 04:18:22 +08:00
|
|
|
FREE(spec->buildArchitectureSpecs);
|
1995-12-18 22:56:49 +08:00
|
|
|
}
|
1998-07-26 05:00:26 +08:00
|
|
|
FREE(spec->buildArchitectures);
|
1995-12-18 22:56:49 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
FREE(spec->passPhrase);
|
|
|
|
FREE(spec->cookie);
|
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
freeSources(spec->sources); spec->sources = NULL;
|
1998-07-26 05:00:26 +08:00
|
|
|
freePackages(spec);
|
|
|
|
closeSpec(spec);
|
|
|
|
|
|
|
|
free(spec);
|
1995-12-18 22:56:49 +08:00
|
|
|
}
|
1998-10-07 01:34:58 +08:00
|
|
|
|
1998-11-21 04:18:22 +08:00
|
|
|
/*@only@*/ struct OpenFileInfo * newOpenFileInfo(void)
|
1998-10-07 01:34:58 +08:00
|
|
|
{
|
|
|
|
struct OpenFileInfo *ofi;
|
|
|
|
|
|
|
|
ofi = malloc(sizeof(struct OpenFileInfo));
|
|
|
|
ofi->file = NULL;
|
|
|
|
ofi->fileName = NULL;
|
|
|
|
ofi->lineNum = 0;
|
|
|
|
ofi->readBuf[0] = '\0';
|
|
|
|
ofi->readPtr = NULL;
|
|
|
|
ofi->next = NULL;
|
|
|
|
|
|
|
|
return ofi;
|
|
|
|
}
|