summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2004-03-28 14:57:53 +0000
committerjbj <devnull@localhost>2004-03-28 14:57:53 +0000
commitdff80a94cc80be4aa9e6a71ca271c8640fcea323 (patch)
tree1a530c9af70495b78f24b83dd9b82d14713f8678 /lib
parent94c663d938df4c866bcb70ba5266d55d68a9bdc6 (diff)
downloadlibrpm-tizen-dff80a94cc80be4aa9e6a71ca271c8640fcea323.tar.gz
librpm-tizen-dff80a94cc80be4aa9e6a71ca271c8640fcea323.tar.bz2
librpm-tizen-dff80a94cc80be4aa9e6a71ca271c8640fcea323.zip
- use package build time as EVR comparison tie breaker.
CVS patchset: 7201 CVS date: 2004/03/28 14:57:53
Diffstat (limited to 'lib')
-rw-r--r--lib/psm.c30
-rw-r--r--lib/rpmds.c27
-rw-r--r--lib/rpmds.h17
3 files changed, 68 insertions, 6 deletions
diff --git a/lib/psm.c b/lib/psm.c
index c521d1185..7e6ef2de7 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -62,7 +62,8 @@ int rpmVersionCompare(Header first, Header second)
{
const char * one, * two;
int_32 * epochOne, * epochTwo;
- int rc;
+ int_32 * btOne, * btTwo;
+ int rc = 0;
if (!headerGetEntry(first, RPMTAG_EPOCH, NULL, (void **) &epochOne, NULL))
epochOne = NULL;
@@ -70,17 +71,19 @@ int rpmVersionCompare(Header first, Header second)
epochTwo = NULL;
if (epochOne != NULL && epochTwo == NULL)
- return 1;
+ rc = 1;
else if (epochOne == NULL && epochTwo != NULL)
- return -1;
+ rc = -1;
else if (epochOne != NULL && epochTwo != NULL) {
/*@-boundsread@*/
if (*epochOne < *epochTwo)
- return -1;
+ rc = -1;
else if (*epochOne > *epochTwo)
- return 1;
+ rc = 1;
/*@=boundsread@*/
}
+ if (rc)
+ return rc;
rc = headerGetEntry(first, RPMTAG_VERSION, NULL, (void **) &one, NULL);
rc = headerGetEntry(second, RPMTAG_VERSION, NULL, (void **) &two, NULL);
@@ -92,7 +95,22 @@ int rpmVersionCompare(Header first, Header second)
rc = headerGetEntry(first, RPMTAG_RELEASE, NULL, (void **) &one, NULL);
rc = headerGetEntry(second, RPMTAG_RELEASE, NULL, (void **) &two, NULL);
- return rpmvercmp(one, two);
+ rc = rpmvercmp(one, two);
+ if (rc)
+ return rc;
+
+ if (!headerGetEntry(first, RPMTAG_BUILDTIME, NULL, (void **) &btOne, NULL))
+ btOne = NULL;
+ if (!headerGetEntry(second, RPMTAG_BUILDTIME, NULL, (void **) &btTwo, NULL))
+ btTwo = NULL;
+
+ if (btOne != NULL && btTwo != NULL && *btOne > 0 && *btTwo > 0) {
+/*@-boundsread@*/
+ rc = (*btOne < *btTwo ? -1 : (*btOne == *btTwo ? 0 : -1));
+/*@=boundsread@*/
+ }
+
+ return rc;
}
/**
diff --git a/lib/rpmds.c b/lib/rpmds.c
index 2677e20a9..1c8dc44f8 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -118,6 +118,8 @@ rpmds rpmdsNew(Header h, rpmTag tagN, int scareMem)
{
HGE_t hge =
(scareMem ? (HGE_t) headerGetEntryMinMemory : (HGE_t) headerGetEntry);
+ rpmTag tagBT = RPMTAG_BUILDTIME;
+ int_32 BTt, * BTp;
rpmTag tagEVR, tagF;
rpmds ds = NULL;
const char * Type;
@@ -175,6 +177,8 @@ rpmds rpmdsNew(Header h, rpmTag tagN, int scareMem)
if (!scareMem && ds->Flags != NULL)
ds->Flags = memcpy(xmalloc(ds->Count * sizeof(*ds->Flags)),
ds->Flags, ds->Count * sizeof(*ds->Flags));
+ xx = hge(h, tagBT, &BTt, (void **) &BTp, NULL);
+ ds->BT = (xx && BTp != NULL && BTt == RPM_INT32_TYPE ? *BTp : 0);
/*@=boundsread@*/
ds->Color = xcalloc(Count, sizeof(*ds->Color));
ds->Refs = xcalloc(Count, sizeof(*ds->Refs));
@@ -347,6 +351,9 @@ rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, int_32 Flags)
ds->h = NULL;
ds->Type = Type;
ds->tagN = tagN;
+ { time_t now = time(NULL);
+ ds->BT = now;
+ }
ds->Count = 1;
/*@-assignexpose@*/
/*@-boundswrite@*/
@@ -452,6 +459,24 @@ rpmTag rpmdsTagN(const rpmds ds)
return tagN;
}
+time_t rpmdsBT(const rpmds ds)
+{
+ time_t BT = 0;
+ if (ds != NULL && ds->BT > 0)
+ BT = ds->BT;
+ return BT;
+}
+
+time_t rpmdsSetBT(const rpmds ds, time_t BT)
+{
+ time_t oBT = 0;
+ if (ds != NULL) {
+ oBT = ds->BT;
+ ds->BT = BT;
+ }
+ return oBT;
+}
+
int rpmdsNoPromote(const rpmds ds)
{
int nopromote = 0;
@@ -879,6 +904,8 @@ int rpmdsCompare(const rpmds A, const rpmds B)
sense = rpmvercmp(aV, bV);
if (sense == 0 && aR && *aR && bR && *bR) {
sense = rpmvercmp(aR, bR);
+ if (sense == 0 && A->BT > 0 && B->BT > 0)
+ sense = (A->BT < B->BT ? -1 : (A->BT == B->BT ? 0 : -1));
}
}
/*@=boundsread@*/
diff --git a/lib/rpmds.h b/lib/rpmds.h
index 9a027f0cd..eddcd3202 100644
--- a/lib/rpmds.h
+++ b/lib/rpmds.h
@@ -43,6 +43,7 @@ struct rpmds_s {
uint_32 * Color; /*!< Bit(s) calculated from file color(s). */
/*@only@*/ /*@null@*/
int_32 * Refs; /*!< No. of file refs. */
+ int_32 BT; /*!< Package build time tie breaker. */
rpmTag tagN; /*!< Header tag. */
rpmTagType Nt, EVRt, Ft; /*!< Tag data types. */
int_32 Count; /*!< No. of elements */
@@ -217,6 +218,22 @@ rpmTag rpmdsTagN(/*@null@*/ const rpmds ds)
/*@*/;
/**
+ * Return dependency build time.
+ * @param ds dependency set
+ * @return dependency build time, 0 on invalid
+ */
+time_t rpmdsBT(/*@null@*/ const rpmds ds)
+ /*@*/;
+
+/**
+ * Set dependency build time.
+ * @param ds dependency set
+ * @return dependency build time, 0 on invalid
+ */
+time_t rpmdsSetBuildtime(/*@null@*/ const rpmds ds, time_t BT)
+ /*@modifies ds @*/;
+
+/**
* Return current "Don't promote Epoch:" flag.
*
* This flag controls for Epoch: promotion when a dependency set is