From: Panu Matilainen Date: Wed, 25 Aug 2010 11:04:52 +0000 (+0300) Subject: Eliminate initSourceHeader() from librpmbuild API X-Git-Tag: tznext/4.11.0.1.tizen20130304~1811 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e677ea1ea86cb3202256e7657066538d3b1b2705;p=tools%2Flibrpm-tizen.git Eliminate initSourceHeader() from librpmbuild API - This is a funky little implementation detail which no caller should have to bother with. Move it to parseSpec.c which is the only place needing it now and make static. --- diff --git a/build/files.c b/build/files.c index 16d2cee..5e317fb 100644 --- a/build/files.c +++ b/build/files.c @@ -1967,30 +1967,6 @@ exit: return fl.processingFailed ? RPMRC_FAIL : RPMRC_OK; } -static const rpmTag sourceTags[] = { - RPMTAG_NAME, - RPMTAG_VERSION, - RPMTAG_RELEASE, - RPMTAG_EPOCH, - RPMTAG_SUMMARY, - RPMTAG_DESCRIPTION, - RPMTAG_PACKAGER, - RPMTAG_DISTRIBUTION, - RPMTAG_DISTURL, - RPMTAG_VENDOR, - RPMTAG_LICENSE, - RPMTAG_GROUP, - RPMTAG_OS, - RPMTAG_ARCH, - RPMTAG_CHANGELOGTIME, - RPMTAG_CHANGELOGNAME, - RPMTAG_CHANGELOGTEXT, - RPMTAG_URL, - RPMTAG_BUGURL, - HEADER_I18NTABLE, - 0 -}; - static void genSourceRpmName(rpmSpec spec) { if (spec->sourceRpmName == NULL) { @@ -2001,50 +1977,6 @@ static void genSourceRpmName(rpmSpec spec) } } -void initSourceHeader(rpmSpec spec) -{ - HeaderIterator hi; - struct rpmtd_s td; - struct Source *srcPtr; - - spec->sourceHeader = headerNew(); - /* Only specific tags are added to the source package header */ - headerCopyTags(spec->packages->header, spec->sourceHeader, sourceTags); - - /* Add the build restrictions */ - hi = headerInitIterator(spec->buildRestrictions); - while (headerNext(hi, &td)) { - if (rpmtdCount(&td) > 0) { - (void) headerPut(spec->sourceHeader, &td, HEADERPUT_DEFAULT); - } - rpmtdFreeData(&td); - } - hi = headerFreeIterator(hi); - - if (spec->BANames && spec->BACount > 0) { - headerPutStringArray(spec->sourceHeader, RPMTAG_BUILDARCHS, - spec->BANames, spec->BACount); - } - - /* Add tags for sources and patches */ - for (srcPtr = spec->sources; srcPtr != NULL; srcPtr = srcPtr->next) { - if (srcPtr->flags & RPMBUILD_ISSOURCE) { - headerPutString(spec->sourceHeader, RPMTAG_SOURCE, srcPtr->source); - if (srcPtr->flags & RPMBUILD_ISNO) { - headerPutUint32(spec->sourceHeader, RPMTAG_NOSOURCE, - &srcPtr->num, 1); - } - } - if (srcPtr->flags & RPMBUILD_ISPATCH) { - headerPutString(spec->sourceHeader, RPMTAG_PATCH, srcPtr->source); - if (srcPtr->flags & RPMBUILD_ISNO) { - headerPutUint32(spec->sourceHeader, RPMTAG_NOPATCH, - &srcPtr->num, 1); - } - } - } -} - int processSourceFiles(rpmSpec spec) { struct Source *srcPtr; diff --git a/build/parseSpec.c b/build/parseSpec.c index 95549e6c..eccd6e8 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -417,6 +417,74 @@ void closeSpec(rpmSpec spec) } } +static const rpmTag sourceTags[] = { + RPMTAG_NAME, + RPMTAG_VERSION, + RPMTAG_RELEASE, + RPMTAG_EPOCH, + RPMTAG_SUMMARY, + RPMTAG_DESCRIPTION, + RPMTAG_PACKAGER, + RPMTAG_DISTRIBUTION, + RPMTAG_DISTURL, + RPMTAG_VENDOR, + RPMTAG_LICENSE, + RPMTAG_GROUP, + RPMTAG_OS, + RPMTAG_ARCH, + RPMTAG_CHANGELOGTIME, + RPMTAG_CHANGELOGNAME, + RPMTAG_CHANGELOGTEXT, + RPMTAG_URL, + RPMTAG_BUGURL, + HEADER_I18NTABLE, + 0 +}; + +static void initSourceHeader(rpmSpec spec) +{ + HeaderIterator hi; + struct rpmtd_s td; + struct Source *srcPtr; + + spec->sourceHeader = headerNew(); + /* Only specific tags are added to the source package header */ + headerCopyTags(spec->packages->header, spec->sourceHeader, sourceTags); + + /* Add the build restrictions */ + hi = headerInitIterator(spec->buildRestrictions); + while (headerNext(hi, &td)) { + if (rpmtdCount(&td) > 0) { + (void) headerPut(spec->sourceHeader, &td, HEADERPUT_DEFAULT); + } + rpmtdFreeData(&td); + } + hi = headerFreeIterator(hi); + + if (spec->BANames && spec->BACount > 0) { + headerPutStringArray(spec->sourceHeader, RPMTAG_BUILDARCHS, + spec->BANames, spec->BACount); + } + + /* Add tags for sources and patches */ + for (srcPtr = spec->sources; srcPtr != NULL; srcPtr = srcPtr->next) { + if (srcPtr->flags & RPMBUILD_ISSOURCE) { + headerPutString(spec->sourceHeader, RPMTAG_SOURCE, srcPtr->source); + if (srcPtr->flags & RPMBUILD_ISNO) { + headerPutUint32(spec->sourceHeader, RPMTAG_NOSOURCE, + &srcPtr->num, 1); + } + } + if (srcPtr->flags & RPMBUILD_ISPATCH) { + headerPutString(spec->sourceHeader, RPMTAG_PATCH, srcPtr->source); + if (srcPtr->flags & RPMBUILD_ISNO) { + headerPutUint32(spec->sourceHeader, RPMTAG_NOPATCH, + &srcPtr->num, 1); + } + } + } +} + extern int noLang; /* XXX FIXME: pass as arg */ int parseSpec(rpmts ts, const char *specFile, const char *rootDir, diff --git a/build/rpmbuild.h b/build/rpmbuild.h index b166060..7d37d8f 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -324,12 +324,6 @@ int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR); int processBinaryFiles(rpmSpec spec, int installSpecialDoc, int test); /** \ingroup rpmbuild - * Create and initialize header for source package. - * @param spec spec file control structure - */ -void initSourceHeader(rpmSpec spec); - -/** \ingroup rpmbuild * Post-build processing for source package. * @param spec spec file control structure * @return 0 on success