summaryrefslogtreecommitdiff
path: root/build/rpmfc.c
diff options
context:
space:
mode:
authorJindrich Novy <jnovy@redhat.com>2011-03-10 16:45:49 +0100
committerJindrich Novy <jnovy@redhat.com>2011-03-10 16:46:22 +0100
commiteb7be49dfa9d03e16431dda8c643a5fa3e300cc2 (patch)
treec42394f50159530ca540f0ae4457bdb147d90a3d /build/rpmfc.c
parente6d66aab71b0f9345a6ad49e6b522ac788fd6f28 (diff)
downloadlibrpm-tizen-eb7be49dfa9d03e16431dda8c643a5fa3e300cc2.tar.gz
librpm-tizen-eb7be49dfa9d03e16431dda8c643a5fa3e300cc2.tar.bz2
librpm-tizen-eb7be49dfa9d03e16431dda8c643a5fa3e300cc2.zip
Clean up rpmfcApply() and rpmfcHelper()
Diffstat (limited to 'build/rpmfc.c')
-rw-r--r--build/rpmfc.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/build/rpmfc.c b/build/rpmfc.c
index f1a68d5b4..b2315ad1a 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -443,44 +443,22 @@ static ARGV_t runCmd(const char *nsdep, const char *depname,
/**
* Run per-interpreter dependency helper.
* @param fc file classifier
- * @param deptype 'P' == Provides:, 'R' == Requires:, helper
* @param nsdep class name for interpreter (e.g. "perl")
- * @return 0 on success
+ * @param depname "provides" or "requires"
+ * @param depsp fc->provides or fc->requires
+ * @param dsContext RPMSENSE_FIND_PROVIDES or RPMSENSE_FIND_REQUIRES
+ * @param tagN RPMTAG_PROVIDENAME or RPMTAG_REQUIRENAME
+ * @return 0
*/
-static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep)
+static int rpmfcHelper(rpmfc fc, const char *nsdep, const char *depname,
+ rpmds *depsp, rpmsenseFlags dsContext, rpmTagVal tagN)
{
ARGV_t pav = NULL;
const char * fn = fc->fn[fc->ix];
- const char * depname = NULL;
- rpmds * depsp;
- rpmsenseFlags dsContext;
- rpmTagVal tagN;
int pac;
regex_t *exclude = NULL;
regex_t *exclude_from = NULL;
- switch (deptype) {
- default:
- return -1;
- break;
- case 'P':
- if (fc->skipProv)
- return 0;
- depname = "provides";
- depsp = &fc->provides;
- dsContext = RPMSENSE_FIND_PROVIDES;
- tagN = RPMTAG_PROVIDENAME;
- break;
- case 'R':
- if (fc->skipReq)
- return 0;
- depname = "requires";
- depsp = &fc->requires;
- dsContext = RPMSENSE_FIND_REQUIRES;
- tagN = RPMTAG_REQUIRENAME;
- break;
- }
-
/* If the entire path is filtered out, there's nothing more to do */
exclude_from = rpmfcAttrReg(depname, "exclude_from");
if (regMatch(exclude_from, fn+fc->brlen))
@@ -523,7 +501,7 @@ static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep)
/* Add to package and file dependencies unless filtered */
if (regMatch(exclude, rpmdsDNEVR(ds)+2) == 0) {
(void) rpmdsMerge(depsp, ds);
- rpmfcAddFileDep(&fc->ddict, fc->ix, ds, deptype);
+ rpmfcAddFileDep(&fc->ddict, fc->ix, ds, tagN == RPMTAG_PROVIDENAME ? 'P' : 'R');
}
ds = rpmdsFree(ds);
@@ -537,6 +515,38 @@ exit:
return 0;
}
+/**
+ * Run per-interpreter Provides: dependency helper.
+ * @param fc file classifier
+ * @param nsdep class name for interpreter (e.g. "perl")
+ * @return 0
+ */
+static int rpmfcHelperProvides(rpmfc fc, const char * nsdep)
+{
+ if (fc->skipProv)
+ return 0;
+
+ rpmfcHelper(fc, nsdep, "provides", &fc->provides, RPMSENSE_FIND_PROVIDES, RPMTAG_PROVIDENAME);
+
+ return 0;
+}
+
+/**
+ * Run per-interpreter Requires: dependency helper.
+ * @param fc file classifier
+ * @param nsdep class name for interpreter (e.g. "perl")
+ * @return 0
+ */
+static int rpmfcHelperRequires(rpmfc fc, const char * nsdep)
+{
+ if (fc->skipReq)
+ return 0;
+
+ rpmfcHelper(fc, nsdep, "requires", &fc->requires, RPMSENSE_FIND_REQUIRES, RPMTAG_REQUIRENAME);
+
+ return 0;
+}
+
/* Only used for elf coloring and controlling RPMTAG_FILECLASS inclusion now */
static const struct rpmfcTokens_s rpmfcTokens[] = {
{ "directory", RPMFC_INCLUDE },
@@ -795,13 +805,12 @@ rpmRC rpmfcApply(rpmfc fc)
int dix;
int ix;
int i;
- int xx = 0;
/* Generate package and per-file dependencies. */
for (fc->ix = 0; fc->fn != NULL && fc->fn[fc->ix] != NULL; fc->ix++) {
for (ARGV_t fattr = fc->fattrs[fc->ix]; fattr && *fattr; fattr++) {
- xx += rpmfcHelper(fc, 'P', *fattr);
- xx += rpmfcHelper(fc, 'R', *fattr);
+ rpmfcHelperProvides(fc, *fattr);
+ rpmfcHelperRequires(fc, *fattr);
}
}
@@ -846,20 +855,15 @@ rpmRC rpmfcApply(rpmfc fc)
break;
}
-/* XXX assertion incorrect while generating -debuginfo deps. */
-#if 0
-assert(dix >= 0);
-#else
if (dix < 0)
continue;
-#endif
val = (deptype << 24) | (dix & 0x00ffffff);
- xx = argiAdd(&fc->ddictx, -1, val);
+ argiAdd(&fc->ddictx, -1, val);
if (previx != ix) {
previx = ix;
- xx = argiAdd(&fc->fddictx, ix, argiCount(fc->ddictx)-1);
+ argiAdd(&fc->fddictx, ix, argiCount(fc->ddictx)-1);
}
if (fc->fddictn && fc->fddictn->vals)
fc->fddictn->vals[ix]++;