summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-12-30 02:37:01 +0000
committerjbj <devnull@localhost>2002-12-30 02:37:01 +0000
commit24e9464d2e30b02b4178198947b45fb45c165cbb (patch)
tree7ccb154af0641f7c55d4b56ca2d133a533ef552d /lib
parent1b8508adc27371a944e730c218364eea110f8d9f (diff)
downloadlibrpm-tizen-24e9464d2e30b02b4178198947b45fb45c165cbb.tar.gz
librpm-tizen-24e9464d2e30b02b4178198947b45fb45c165cbb.tar.bz2
librpm-tizen-24e9464d2e30b02b4178198947b45fb45c165cbb.zip
- use rpmfiFDepends() underneath --fileprovide and --filerequire.
- python: add fi.FColor() and fi.FClass() methods. - calculate dependency color and refernces. - python: add ds.Color() and ds.Refs() methods. CVS patchset: 5987 CVS date: 2002/12/30 02:37:01
Diffstat (limited to 'lib')
-rw-r--r--lib/rpmds.c63
-rw-r--r--lib/rpmds.h40
-rw-r--r--lib/rpmte.c73
-rw-r--r--lib/rpmte.h10
4 files changed, 181 insertions, 5 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index 75fd6777b..7d05e5358 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -101,6 +101,8 @@ fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);
/*@=branchstate@*/
ds->DNEVR = _free(ds->DNEVR);
+ ds->Color = _free(ds->Color);
+ ds->Refs = _free(ds->Refs);
(void) rpmdsUnlink(ds, ds->Type);
/*@-refcounttrans -usereleased@*/
@@ -174,6 +176,8 @@ rpmds rpmdsNew(Header h, rpmTag tagN, int scareMem)
ds->Flags = memcpy(xmalloc(ds->Count * sizeof(*ds->Flags)),
ds->Flags, ds->Count * sizeof(*ds->Flags));
/*@=boundsread@*/
+ ds->Color = xcalloc(Count, sizeof(*ds->Color));
+ ds->Refs = xcalloc(Count, sizeof(*ds->Refs));
/*@-modfilesys@*/
if (_rpmds_debug < 0)
@@ -443,9 +447,8 @@ rpmTag rpmdsTagN(const rpmds ds)
{
rpmTag tagN = 0;
- if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
+ if (ds != NULL)
tagN = ds->tagN;
- }
return tagN;
}
@@ -469,6 +472,62 @@ int rpmdsSetNoPromote(rpmds ds, int nopromote)
return onopromote;
}
+int_32 rpmdsColor(const rpmds ds)
+{
+ int_32 Color = 0;
+
+ if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
+/*@-boundsread@*/
+ if (ds->Color != NULL)
+ Color = ds->Color[ds->i];
+/*@=boundsread@*/
+ }
+ return Color;
+}
+
+int_32 rpmdsSetColor(const rpmds ds, int_32 color)
+{
+ int_32 ocolor = 0;
+
+ if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
+/*@-boundsread@*/
+ if (ds->Color != NULL) {
+ ocolor = ds->Color[ds->i];
+ ds->Color[ds->i] = color;
+ }
+/*@=boundsread@*/
+ }
+ return ocolor;
+}
+
+int_32 rpmdsRefs(const rpmds ds)
+{
+ int_32 Refs = 0;
+
+ if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
+/*@-boundsread@*/
+ if (ds->Refs != NULL)
+ Refs = ds->Refs[ds->i];
+/*@=boundsread@*/
+ }
+ return Refs;
+}
+
+int_32 rpmdsSetRefs(const rpmds ds, int_32 refs)
+{
+ int_32 orefs = 0;
+
+ if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
+/*@-boundsread@*/
+ if (ds->Refs != NULL) {
+ orefs = ds->Refs[ds->i];
+ ds->Refs[ds->i] = refs;
+ }
+/*@=boundsread@*/
+ }
+ return orefs;
+}
+
void rpmdsNotify(rpmds ds, const char * where, int rc)
{
if (!(ds != NULL && ds->i >= 0 && ds->i < ds->Count))
diff --git a/lib/rpmds.h b/lib/rpmds.h
index a09e7b26f..f657cd553 100644
--- a/lib/rpmds.h
+++ b/lib/rpmds.h
@@ -38,7 +38,11 @@ struct rpmds_s {
/*@only@*/ /*@null@*/
const char ** EVR; /*!< Epoch-Version-Release. */
/*@only@*/ /*@null@*/
- int_32 * Flags; /*!< Flags identifying context/comparison. */
+ int_32 * Flags; /*!< Bit(s) identifying context/comparison. */
+/*@only@*/ /*@null@*/
+ int_32 * Color; /*!< Bit(s) calculated from file color(s). */
+/*@only@*/ /*@null@*/
+ int_32 * Refs; /*!< No. of file refs. */
rpmTag tagN; /*!< Header tag. */
rpmTagType Nt, EVRt, Ft; /*!< Tag data types. */
int_32 Count; /*!< No. of elements */
@@ -238,6 +242,40 @@ int rpmdsSetNoPromote(/*@null@*/ rpmds ds, int nopromote)
/*@modifies ds @*/;
/**
+ * Return current dependency color.
+ * @param ds dependency set
+ * @return current dependency color
+ */
+int_32 rpmdsColor(/*@null@*/ const rpmds ds)
+ /*@*/;
+
+/**
+ * Return current dependency color.
+ * @param ds dependency set
+ * @param color new dependency color
+ * @return previous dependency color
+ */
+int_32 rpmdsSetColor(/*@null@*/ const rpmds ds, int_32 color)
+ /*@*/;
+
+/**
+ * Return current dependency file refs.
+ * @param ds dependency set
+ * @return current dependency file refs, -1 on global
+ */
+int_32 rpmdsRefs(/*@null@*/ const rpmds ds)
+ /*@*/;
+
+/**
+ * Return current dependency color.
+ * @param ds dependency set
+ * @param refs new dependency refs
+ * @return previous dependency refs
+ */
+int_32 rpmdsSetRefs(/*@null@*/ const rpmds ds, int_32 refs)
+ /*@*/;
+
+/**
* Notify of results of dependency match.
* @param ds dependency set
* @param where where dependency was resolved (or NULL)
diff --git a/lib/rpmte.c b/lib/rpmte.c
index 70fcc2a15..b2211a08f 100644
--- a/lib/rpmte.c
+++ b/lib/rpmte.c
@@ -141,7 +141,6 @@ static void addTE(rpmts ts, rpmte p, Header h,
p->key = key;
p->fd = NULL;
- p->multiLib = 0;
p->this = rpmdsThis(h, RPMTAG_PROVIDENAME, RPMSENSE_EQUAL);
p->provides = rpmdsNew(h, RPMTAG_PROVIDENAME, scareMem);
@@ -152,6 +151,11 @@ static void addTE(rpmts ts, rpmte p, Header h,
savep = rpmtsSetRelocateElement(ts, p);
p->fi = rpmfiNew(ts, h, RPMTAG_BASENAMES, scareMem);
(void) rpmtsSetRelocateElement(ts, savep);
+
+ rpmteColorDS(p, RPMTAG_PROVIDENAME);
+ rpmteColorDS(p, RPMTAG_REQUIRENAME);
+
+ p->multiLib = 0;
}
/*@=bounds@*/
@@ -432,6 +436,73 @@ rpmfi rpmteFI(rpmte te, rpmTag tag)
/*@=compdef =refcounttrans =retalias =retexpose =usereleased @*/
}
+void rpmteColorDS(rpmte te, rpmTag tag)
+{
+ rpmfi fi = rpmteFI(te, RPMTAG_BASENAMES);
+ rpmds ds = rpmteDS(te, tag);
+ char deptype = 'R';
+ char mydt;
+ const int_32 * ddict;
+ int_32 * colors;
+ int_32 * refs;
+ int_32 val;
+ int Count;
+ size_t nb;
+ unsigned ix;
+ int ndx, i;
+
+ if (!(te && (Count = rpmdsCount(ds)) > 0 && rpmfiFC(fi) > 0))
+ return;
+
+ switch (tag) {
+ default:
+ return;
+ /*@notreached@*/ break;
+ case RPMTAG_PROVIDENAME:
+ deptype = 'P';
+ break;
+ case RPMTAG_REQUIRENAME:
+ deptype = 'R';
+ break;
+ }
+
+ nb = Count * sizeof(*colors);
+ colors = memset(alloca(nb), 0, nb);
+ nb = Count * sizeof(*refs);
+ refs = memset(alloca(nb), -1, nb);
+
+ /* Calculate dependency color and reference count. */
+ fi = rpmfiInit(fi, 0);
+ if (fi != NULL)
+ while (rpmfiNext(fi) >= 0) {
+ /* XXX ignore all but lsnibble for now. */
+ val = (rpmfiFColor(fi) & 0x0f);
+ 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;
+assert (ix < Count);
+ colors[ix] |= val;
+ refs[ix]++;
+ }
+ }
+
+ /* Set color/refs values in dependency set. */
+ ds = rpmdsInit(ds);
+ while ((i = rpmdsNext(ds)) >= 0) {
+ val = colors[i];
+ (void) rpmdsSetColor(ds, val);
+ val = refs[i];
+ if (val >= 0)
+ val++;
+ (void) rpmdsSetRefs(ds, val);
+ }
+}
int rpmtsiOc(rpmtsi tsi)
{
return tsi->ocsave;
diff --git a/lib/rpmte.h b/lib/rpmte.h
index 6ee4dcca0..61d374992 100644
--- a/lib/rpmte.h
+++ b/lib/rpmte.h
@@ -437,13 +437,21 @@ rpmds rpmteDS(rpmte te, rpmTag tag)
/**
* Retrieve file info tag set from transaction element.
* @param te transaction element
- * @param tag file info tag
+ * @param tag file info tag (RPMTAG_BASENAMES)
* @return file info tag set
*/
rpmfi rpmteFI(rpmte te, rpmTag tag)
/*@*/;
/**
+ * Calculate transaction lemnt dependency colors/refs from file info.
+ * @param te transaction element
+ * @param tag dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
+ */
+void rpmteColorDS(rpmte te, rpmTag tagN)
+ /*@modifies te @*/;
+
+/**
* Return transaction element index.
* @param tsi transaction element iterator
* @return transaction element index