- use rpmfiFDepends() underneath --fileprovide/--filerequire.
authorjbj <devnull@localhost>
Mon, 30 Dec 2002 00:03:53 +0000 (00:03 +0000)
committerjbj <devnull@localhost>
Mon, 30 Dec 2002 00:03:53 +0000 (00:03 +0000)
CVS patchset: 5986
CVS date: 2002/12/30 00:03:53

CHANGES
lib/rpmfi.c
python/rpmfi-py.c
rpm.spec.in

diff --git a/CHANGES b/CHANGES
index 37e90cc..3ab58af 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -87,7 +87,8 @@
        - don't segfault with packages produced by rpm-2.93 (#80618).
        - python: eliminate hash.[ch] and upgrade.[ch], methods too.
        - fix :armor query extension, tgpg mktmp handling (#80684).
-       - use rpmfiClass() underneath --fileclass.
+       - use rpmfiFClass() underneath --fileclass.
+       - use rpmfiFDepends() underneath --fileprovide/--filerequire.
 
 4.0.4 -> 4.1:
        - loosely wire beecrypt library into rpm.
index ebe5eb7..79176fa 100644 (file)
@@ -1103,7 +1103,7 @@ rpmfi rpmfiNew(rpmts ts, Header h, rpmTag tagN, int scareMem)
 
     xx = hge(h, RPMTAG_DEPENDSDICT, NULL, (void **) &fi->ddict, &fi->nddict);
     xx = hge(h, RPMTAG_FILEDEPENDSX, NULL, (void **) &fi->fddictx, NULL);
-    xx = hge(h, RPMTAG_FILEDEPENDSN, NULL, (void **) &fi->fddictx, NULL);
+    xx = hge(h, RPMTAG_FILEDEPENDSN, NULL, (void **) &fi->fddictn, NULL);
 
     xx = hge(h, RPMTAG_FILESTATES, NULL, (void **) &fi->fstates, NULL);
     if (xx == 0 || fi->fstates == NULL)
@@ -1227,9 +1227,9 @@ void rpmfiBuildFClasses(Header h,
 {
     int scareMem = 1;
     rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem);
-    int ac;
-    const char ** av;
     const char * FClass;
+    const char ** av;
+    int ac;
     size_t nb;
     char * t;
 
@@ -1281,105 +1281,92 @@ void rpmfiBuildFDeps(Header h, rpmTag tagN,
        /*@out@*/ const char *** fdepsp, /*@out@*/ int * fcp)
 {
     int scareMem = 1;
-    HGE_t hge = (HGE_t)headerGetEntryMinMemory;
-    HFD_t hfd = headerFreeData;
+    rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem);
+    rpmds ds = NULL;
+    const char ** av;
+    int ac;
+    size_t nb;
+    char * t;
     char deptype = 'R';
     char mydt;
-    rpmds ds;
     const char * DNEVR;
     const int_32 * ddict;
-    const int_32 * fddictx;
-    const int_32 * fddictn;
-    int_32 nddict, nfddictx, nfddictn;
-    const char ** av;
-    int_32 ac = 0;
-    size_t nb;
-    rpmTagType ddt, fxt, fnt;
-    char * t;
     unsigned ix;
-    int dx, ndx, i, xx;
+    int ndx;
 
-    if (!hge(h, RPMTAG_FILESIZES, NULL, (void **) NULL, &ac) || ac == 0) {
-       if (fdepsp) *fdepsp = NULL;
-       if (fcp) *fcp = 0;
-       return;         /* no file list */
+    if ((ac = rpmfiFC(fi)) <= 0) {
+       av = NULL;
+       ac = 0;
+       goto exit;
     }
 
     if (tagN == RPMTAG_PROVIDENAME)
        deptype = 'P';
     else if (tagN == RPMTAG_REQUIRENAME)
        deptype = 'R';
-    ds = rpmdsNew(h, tagN, scareMem);
 
-    fddictn = NULL;
-    nfddictn = 0;
-    xx = hge(h, RPMTAG_FILEDEPENDSN, &fnt, (void **) &fddictn, &nfddictn);
-    fddictx = NULL;
-    nfddictx = 0;
-    xx = hge(h, RPMTAG_FILEDEPENDSX, &fxt, (void **) &fddictx, &nfddictx);
-    ddict = NULL;
-    nddict = 0;
-    xx = hge(h, RPMTAG_DEPENDSDICT, &ddt, (void **) &ddict, &nddict);
+    ds = rpmdsNew(h, tagN, scareMem);
 
+    /* Compute size of file depends argv array blob. */
     nb = (ac + 1) * sizeof(*av);
-    for (i = 0; i < ac; i++) {
-       if (fddictx != NULL && fddictn != NULL) {
-           dx = fddictx[i];
-           ndx = fddictn[i];
-           if (ddict != NULL)
-           while (ndx-- > 0) {
-               ix = ddict[dx++];
-               mydt = ((ix >> 24) & 0xff);
-               if (mydt != deptype)
-                   /*@innercontinue@*/ continue;
-               ix &= 0x00ffffff;
-               (void) rpmdsSetIx(ds, ix-1);
-               if (rpmdsNext(ds) < 0)
-                   /*@innercontinue@*/ continue;
-               DNEVR = rpmdsDNEVR(ds);
-               if (DNEVR != NULL)
-                   nb += strlen(DNEVR+2) + 1;
-           }
+    fi = rpmfiInit(fi, 0);
+    if (fi != NULL)
+    while (rpmfiNext(fi) >= 0) {
+       ddict = NULL;
+       ndx = rpmfiFDepends(fi, &ddict);
+       if (ddict != NULL)
+       while (ndx-- > 0) {
+           ix = *ddict++;
+           mydt = ((ix >> 24) & 0xff);
+           if (mydt != deptype)
+               /*@innercontinue@*/ continue;
+           ix &= 0x00ffffff;
+           (void) rpmdsSetIx(ds, ix-1);
+           if (rpmdsNext(ds) < 0)
+               /*@innercontinue@*/ continue;
+           DNEVR = rpmdsDNEVR(ds);
+           if (DNEVR != NULL)
+               nb += strlen(DNEVR+2) + 1;
        }
        nb += 1;
     }
 
+    /* Create and load file depends argv array. */
     av = xmalloc(nb);
     t = ((char *) av) + ((ac + 1) * sizeof(*av));
+    ac = 0;
     /*@-branchstate@*/
-    for (i = 0; i < ac; i++) {
-       av[i] = t;
-       if (fddictx != NULL && fddictn != NULL) {
-           dx = fddictx[i];
-           ndx = fddictn[i];
-           if (ddict != NULL)
-           while (ndx-- > 0) {
-               ix = ddict[dx++];
-               mydt = ((ix >> 24) & 0xff);
-               if (mydt != deptype)
-                   /*@innercontinue@*/ continue;
-               ix &= 0x00ffffff;
-               (void) rpmdsSetIx(ds, ix-1);
-               if (rpmdsNext(ds) < 0)
-                   /*@innercontinue@*/ continue;
-               DNEVR = rpmdsDNEVR(ds);
-               if (DNEVR != NULL) {
-                   t = stpcpy(t, DNEVR+2);
-                   *t++ = ' ';
-                   *t = '\0';
-               }
+    fi = rpmfiInit(fi, 0);
+    if (fi != NULL)
+    while (rpmfiNext(fi) >= 0) {
+       av[ac++] = t;
+       ddict = NULL;
+       ndx = rpmfiFDepends(fi, &ddict);
+       if (ddict != NULL)
+       while (ndx-- > 0) {
+           ix = *ddict++;
+           mydt = ((ix >> 24) & 0xff);
+           if (mydt != deptype)
+               /*@innercontinue@*/ continue;
+           ix &= 0x00ffffff;
+           (void) rpmdsSetIx(ds, ix-1);
+           if (rpmdsNext(ds) < 0)
+               /*@innercontinue@*/ continue;
+           DNEVR = rpmdsDNEVR(ds);
+           if (DNEVR != NULL) {
+               t = stpcpy(t, DNEVR+2);
+               *t++ = ' ';
+               *t = '\0';
            }
        }
        *t++ = '\0';
     }
-    av[ac] = NULL;
     /*@=branchstate@*/
+    av[ac] = NULL;
 
-    ddict = hfd(ddict, ddt);
-    fddictx = hfd(fddictx, fxt);
-    fddictn = hfd(fddictn, fnt);
+exit:
+    fi = rpmfiFree(fi);
     ds = rpmdsFree(ds);
-
     /*@-branchstate@*/
     if (fdepsp)
        *fdepsp = av;
index f1e4c42..5da2798 100644 (file)
@@ -183,6 +183,26 @@ rpmfi_FGroup(rpmfiObject * s, PyObject * args)
     return Py_BuildValue("s", xstrdup(rpmfiFGroup(s->fi)));
 }
 
+static PyObject *
+rpmfi_FColor(rpmfiObject * s, PyObject * args)
+       /*@*/
+{
+    if (!PyArg_ParseTuple(args, ":FColor")) return NULL;
+    return Py_BuildValue("i", rpmfiFColor(s->fi));
+}
+
+static PyObject *
+rpmfi_FClass(rpmfiObject * s, PyObject * args)
+       /*@*/
+{
+    const char * FClass;
+
+    if (!PyArg_ParseTuple(args, ":FClass")) return NULL;
+    if ((FClass = rpmfiFClass(s->fi)) == NULL)
+       FClass = "";
+    return Py_BuildValue("s", xstrdup(FClass));
+}
+
 #if Py_TPFLAGS_HAVE_ITER
 static PyObject *
 rpmfi_iter(rpmfiObject * s, /*@unused@*/ PyObject * args)
@@ -353,6 +373,10 @@ static struct PyMethodDef rpmfi_methods[] = {
        NULL},
  {"FGroup",    (PyCFunction)rpmfi_FGroup,      METH_VARARGS,
        NULL},
+ {"FColor",    (PyCFunction)rpmfi_FColor,      METH_VARARGS,
+       NULL},
+ {"FClass",    (PyCFunction)rpmfi_FClass,      METH_VARARGS,
+       NULL},
  {"next",      (PyCFunction)rpmfi_Next,        METH_VARARGS,
 "fi.next() -> (FN, FSize, FMode, FMtime, FFlags, FRdev, FInode, FNlink, FState, VFlags, FUser, FGroup, FMD5))\n\
 - Retrieve next file info tuple.\n" },
index cb69b2e..ee8e541 100644 (file)
@@ -463,7 +463,8 @@ exit 0
 - don't segfault with packages produced by rpm-2.93 (#80618).
 - python: eliminate hash.[ch] and upgrade.[ch], methods too.
 - fix :armor query extension, tgpg mktmp handling (#80684).
-- use rpmfiClass() underneath --fileclass.
+- use rpmfiFClass() underneath --fileclass.
+- use rpmfiFDepends() underneath --fileprovide/--filerequire.
 
 * Sat Dec 28 2002 Jeff Johnson <jbj@redhat.com> 4.2-0.45
 - error if querying with iterator on different sized arrays.