Skip to content

Commit

Permalink
- fix: specfile queries with BuildArch: (#27589).
Browse files Browse the repository at this point in the history
CVS patchset: 4746
CVS date: 2001/05/06 19:17:14
  • Loading branch information
jbj committed May 6, 2001
1 parent 6f5615e commit c3835f5
Show file tree
Hide file tree
Showing 15 changed files with 192 additions and 164 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
- more boring lclint annotations and fiddles.
- yet more boring lclint annotations and fiddles.
- still more boring lclint annotations and fiddles.
- enough lclint annotations and fiddles already.
- fix: specfile queries with BuildArch: (#27589).

4.0 -> 4.0.[12]
- add doxygen and lclint annotations most everywhere.
Expand Down
3 changes: 1 addition & 2 deletions build.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ static int buildForTarget(const char * arg, BTA_t ba,
rc = 0;

exit:
if (spec)
freeSpec(spec);
spec = freeSpec(spec);
buildRootURL = _free(buildRootURL);
return rc;
}
Expand Down
10 changes: 5 additions & 5 deletions build/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ int buildSpec(Spec spec, int what, int test)
{
int rc = 0;

if (!spec->inBuildArchitectures && spec->buildArchitectureCount) {
if (!spec->recursing && spec->BACount) {
int x;
/* When iterating over buildArchitectures, do the source */
/* When iterating over BANames, do the source */
/* packaging on the first run, and skip RMSOURCE altogether */
if (spec->buildArchitectureSpecs != NULL)
for (x = 0; x < spec->buildArchitectureCount; x++) {
if ((rc = buildSpec(spec->buildArchitectureSpecs[x],
if (spec->BASpecs != NULL)
for (x = 0; x < spec->BACount; x++) {
if ((rc = buildSpec(spec->BASpecs[x],
(what & ~RPMBUILD_RMSOURCE) |
(x ? 0 : (what & RPMBUILD_PACKAGESOURCE)),
test))) {
Expand Down
7 changes: 4 additions & 3 deletions build/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ static void dupAttrRec(const AttrRec oar, /*@in@*/ /*@out@*/ AttrRec nar)
#if 0
/**
*/
static void dumpAttrRec(const char *msg, AttrRec ar) /*@*/
static void dumpAttrRec(const char * msg, AttrRec ar)
/*@modifies fileSystem @*/
{
if (msg)
fprintf(stderr, "%s:\t", msg);
Expand Down Expand Up @@ -1835,10 +1836,10 @@ void initSourceHeader(Spec spec)
}
headerFreeIterator(hi);

if (spec->buildArchitectures && spec->buildArchitectureCount > 0) {
if (spec->BANames && spec->BACount > 0) {
(void) headerAddEntry(spec->sourceHeader, RPMTAG_BUILDARCHS,
RPM_STRING_ARRAY_TYPE,
spec->buildArchitectures, spec->buildArchitectureCount);
spec->BANames, spec->BACount);
}
}

Expand Down
2 changes: 1 addition & 1 deletion build/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig
if (specp)
*specp = spec;
else
freeSpec(spec);
spec = freeSpec(spec);

if (csa != NULL)
csa->cpioFdIn = fdi;
Expand Down
2 changes: 1 addition & 1 deletion build/parseDescription.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int parseDescription(Spec spec)
int arg;
const char **argv = NULL;
poptContext optCon = NULL;
struct spectag *t = NULL;
spectag t = NULL;

name = NULL;
lang = RPMBUILD_DEFAULT_LANG;
Expand Down
17 changes: 8 additions & 9 deletions build/parsePreamble.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,13 @@ static int readIcon(Header h, const char *file)
return rc;
}

struct spectag *
stashSt(Spec spec, Header h, int tag, const char *lang)
spectag stashSt(Spec spec, Header h, int tag, const char * lang)
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
struct spectag *t = NULL;
spectag t = NULL;

if (spec->st) {
struct spectags *st = spec->st;
spectags st = spec->st;
if (st->st_ntags == st->st_nalloc) {
st->st_nalloc += 10;
st->st_t = xrealloc(st->st_t, st->st_nalloc * sizeof(*(st->st_t)));
Expand Down Expand Up @@ -638,15 +637,15 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro,
break;
case RPMTAG_BUILDARCHS:
if ((rc = poptParseArgvString(field,
&(spec->buildArchitectureCount),
&(spec->buildArchitectures)))) {
&(spec->BACount),
&(spec->BANames)))) {
rpmError(RPMERR_BADSPEC,
_("line %d: Bad BuildArchitecture format: %s\n"),
spec->lineNum, spec->line);
return RPMERR_BADSPEC;
}
if (!spec->buildArchitectureCount)
spec->buildArchitectures = _free(spec->buildArchitectures);
if (!spec->BACount)
spec->BANames = _free(spec->BANames);
break;

default:
Expand Down Expand Up @@ -839,7 +838,7 @@ int parsePreamble(Spec spec, int initialPackage)
}
if (handlePreambleTag(spec, pkg, tag, macro, lang))
return RPMERR_BADSPEC;
if (spec->buildArchitectures && !spec->inBuildArchitectures)
if (spec->BANames && !spec->recursing)
return PART_BUILDARCHITECTURES;
}
if ((rc =
Expand Down
91 changes: 49 additions & 42 deletions build/parseSpec.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ int readLine(Spec spec, int strip)
ofi->lineNum++;
spec->lineNum = ofi->lineNum;
if (spec->sl) {
struct speclines * sl = spec->sl;
speclines sl = spec->sl;
if (sl->sl_nlines == sl->sl_nalloc) {
sl->sl_nalloc += 100;
sl->sl_lines = (char **) xrealloc(sl->sl_lines,
Expand Down Expand Up @@ -354,8 +354,9 @@ void closeSpec(Spec spec)

extern int noLang; /* XXX FIXME: pass as arg */

/*@todo Skip parse recursion if os is not compatible. @*/
int parseSpec(Spec *specp, const char *specFile, const char *rootURL,
const char *buildRootURL, int inBuildArch, const char *passPhrase,
const char *buildRootURL, int recursing, const char *passPhrase,
char *cookie, int anyarch, int force)
{
rpmParseState parsePart = PART_PREAMBLE;
Expand All @@ -364,7 +365,6 @@ int parseSpec(Spec *specp, const char *specFile, const char *rootURL,
const char *saveArch;
#endif
Package pkg;
int x, index;
Spec spec;

/* Set up a new Spec structure with no packages. */
Expand Down Expand Up @@ -396,7 +396,7 @@ if (_debug)
fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootURL, spec->buildRootURL, buildRoot);
}
addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
spec->inBuildArchitectures = inBuildArch;
spec->recursing = recursing;
spec->anyarch = anyarch;
spec->force = force;

Expand Down Expand Up @@ -456,65 +456,72 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU
}

if (parsePart >= PART_LAST) {
freeSpec(spec);
spec = freeSpec(spec);
return parsePart;
}

if (parsePart == PART_BUILDARCHITECTURES) {
spec->buildArchitectureSpecs =
xmalloc(sizeof(Spec) * spec->buildArchitectureCount);
int index;
int x;

closeSpec(spec);

spec->BASpecs = xmalloc(spec->BACount * sizeof(Spec));
index = 0;
if (spec->buildArchitectures != NULL)
for (x = 0; x < spec->buildArchitectureCount; x++) {
if (rpmMachineScore(RPM_MACHTABLE_BUILDARCH,
spec->buildArchitectures[x])) {
if (spec->BANames != NULL)
for (x = 0; x < spec->BACount; x++) {

/* Skip if not arch is not compatible. */
if (!rpmMachineScore(RPM_MACHTABLE_BUILDARCH, spec->BANames[x]))
continue;
#ifdef DYING
rpmGetMachine(&saveArch, NULL);
saveArch = xstrdup(saveArch);
rpmSetMachine(spec->buildArchitectures[x], NULL);
rpmGetMachine(&saveArch, NULL);
saveArch = xstrdup(saveArch);
rpmSetMachine(spec->BANames[x], NULL);
#else
addMacro(NULL, "_target_cpu", NULL, spec->buildArchitectures[x], RMIL_RPMRC);
addMacro(NULL, "_target_cpu", NULL, spec->BANames[x], RMIL_RPMRC);
#endif
if (parseSpec(&(spec->buildArchitectureSpecs[index]),
if (parseSpec(&(spec->BASpecs[index]),
specFile, spec->rootURL, buildRootURL, 1,
passPhrase, cookie, anyarch, force)) {
spec->buildArchitectureCount = index;
freeSpec(spec);
passPhrase, cookie, anyarch, force))
{
spec->BACount = index;
spec = freeSpec(spec);
return RPMERR_BADSPEC;
}
}
#ifdef DYING
rpmSetMachine(saveArch, NULL);
saveArch = _free(saveArch);
rpmSetMachine(saveArch, NULL);
saveArch = _free(saveArch);
#else
delMacro(NULL, "_target_cpu");
delMacro(NULL, "_target_cpu");
#endif
index++;
}
index++;
}
spec->buildArchitectureCount = index;

spec->BACount = index;
if (! index) {
freeSpec(spec);
rpmError(RPMERR_BADSPEC, _("No buildable architectures\n"));
spec = freeSpec(spec);
rpmError(RPMERR_BADSPEC,
_("No compatible architectures found for build\n"));
return RPMERR_BADSPEC;
}

/* XXX HACK: Swap sl/st with child.
/*
* Return the 1st child's fully parsed Spec structure.
* The restart of the parse when encountering BuildArch
* causes problems for "rpm -q --specfile --specedit"
* which needs to keep track of the entire spec file.
* causes problems for "rpm -q --specfile". This is
* still a hack because there may be more than 1 arch
* specified (unlikely but possible.) There's also the
* further problem that the macro context, particularly
* %{_target_cpu}, disagrees with the info in the header.
*/

if (spec->sl && spec->st) {
Spec nspec = *spec->buildArchitectureSpecs;
struct speclines *sl = spec->sl;
struct spectags *st = spec->st;
spec->sl = nspec->sl;
spec->st = nspec->st;
nspec->sl = sl;
nspec->st = st;
if (spec->BACount >= 1) {
Spec nspec = spec->BASpecs[0];
spec->BASpecs = _free(spec->BASpecs);
spec = freeSpec(spec);
spec = nspec;
}

closeSpec(spec);
*specp = spec;
return 0;
}
Expand Down Expand Up @@ -551,7 +558,7 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU
(void) headerNVR(pkg->header, &name, NULL, NULL);
rpmError(RPMERR_BADSPEC, _("Package has no %%description: %s\n"),
name);
freeSpec(spec);
spec = freeSpec(spec);
return RPMERR_BADSPEC;
}

Expand Down
26 changes: 14 additions & 12 deletions build/rpmbuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,18 @@ int lookupPackage(Spec spec, /*@null@*/ const char * name, int flag,

/** \ingroup rpmbuild
* Destroy all packages associated with spec file.
* @param spec spec file control structure
* @param packages package control structure chain
* @return NULL
*/
void freePackages(Spec spec)
/*@modifies spec->packages @*/;
/*@null@*/ Package freePackages(/*@only@*/ /*@null@*/ Package packages)
/*@modifies packages @*/;

/** \ingroup rpmbuild
* Destroy package control structure.
* @param pkg package control structure
* @return NULL
*/
void freePackage(/*@only@*/ Package pkg)
/*@null@*/ Package freePackage(/*@only@*/ /*@null@*/ Package pkg)
/*@modifies pkg @*/;

/** \ingroup rpmbuild
Expand Down Expand Up @@ -380,7 +382,7 @@ int processBinaryFiles(Spec spec, int installSpecialDoc, int test)
*/
void initSourceHeader(Spec spec)
/*@modifies spec->sourceHeader,
spec->buildRestrictions, spec->buildArchitectures,
spec->buildRestrictions, spec->BANames,
spec->packages->header @*/;

/** \ingroup rpmbuild
Expand All @@ -390,7 +392,7 @@ void initSourceHeader(Spec spec)
*/
int processSourceFiles(Spec spec)
/*@modifies spec->sourceHeader, spec->sourceCpioList,
spec->buildRestrictions, spec->buildArchitectures,
spec->buildRestrictions, spec->BANames,
spec->packages->header @*/;

/* global entry points */
Expand All @@ -401,7 +403,7 @@ int processSourceFiles(Spec spec)
* @param specFile
* @param rootdir
* @param buildRoot
* @param inBuildArch
* @param recursing parse is recursive?
* @param passPhrase
* @param cookie
* @param anyarch
Expand All @@ -411,7 +413,7 @@ int processSourceFiles(Spec spec)
int parseSpec(/*@out@*/ Spec * specp, const char * specFile,
/*@null@*/ const char * rootdir,
/*@null@*/ const char * buildRoot,
int inBuildArch,
int recursing,
/*@null@*/ const char * passPhrase,
/*@null@*/ char * cookie,
int anyarch, int force)
Expand All @@ -422,7 +424,7 @@ int parseSpec(/*@out@*/ Spec * specp, const char * specFile,
* @param specFile
* @param rootdir
* @param buildRoot
* @param inBuildArch
* @param recursing parse is recursive?
* @param passPhrase
* @param cookie
* @param anyarch
Expand All @@ -432,7 +434,7 @@ int parseSpec(/*@out@*/ Spec * specp, const char * specFile,
extern int (*parseSpecVec) (Spec * specp, const char * specFile,
const char * rootdir,
/*@null@*/ const char * buildRoot,
int inBuildArch,
int recursing,
/*@null@*/ const char * passPhrase,
/*@null@*/ char * cookie,
int anyarch, int force)
Expand All @@ -448,8 +450,8 @@ extern int (*parseSpecVec) (Spec * specp, const char * specFile,
int buildSpec(Spec spec, int what, int test)
/*@modifies spec->sourceHeader, spec->sourceCpioList, spec->cookie,
spec->sourceRpmName, spec->macros,
spec->buildArchitectureSpecs,
spec->buildRestrictions, spec->buildArchitectures,
spec->BASpecs,
spec->buildRestrictions, spec->BANames,
spec->packages->cpioList, spec->packages->specialDoc,
spec->packages->header @*/;

Expand Down
Loading

0 comments on commit c3835f5

Please sign in to comment.