1 --- rpm.orig/lib/rpmte.h 2004-04-03 12:30:57.000000000 +0000
2 +++ rpm/lib/rpmte.h 2004-08-27 15:00:40.000000000 +0000
4 const char * arch; /*!< Architecture hint. */
6 const char * os; /*!< Operating system hint. */
7 + const char * dist; /*!< Distribution. */
8 int archScore; /*!< (TR_ADDED) Arch score. */
9 int osScore; /*!< (TR_ADDED) Os score. */
15 + * Retrieve distribution string of transaction element.
16 + * @param te transaction element
17 + * @return distribution string
19 +/*@observer@*/ /*@null@*/
20 +extern const char * rpmteDist(rpmte te)
24 * Retrieve color bits of transaction element.
25 * @param te transaction element
27 --- rpm.orig/lib/rpmps.h 2003-12-30 13:14:50.000000000 +0000
28 +++ rpm/lib/rpmps.h 2004-08-25 19:57:22.000000000 +0000
30 RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) is already installed */
31 RPMPROB_DISKSPACE, /*!< installing package ... needs ... on the ... filesystem */
32 RPMPROB_DISKNODES, /*!< installing package ... needs ... on the ... filesystem */
33 - RPMPROB_BADPRETRANS /*!< (unimplemented) */
34 + RPMPROB_BADPRETRANS, /*!< (unimplemented) */
35 + RPMPROB_OLDDISTRO /*!< */
39 --- rpm.orig/lib/rpmps.c 2003-12-30 13:14:50.000000000 +0000
40 +++ rpm/lib/rpmps.c 2004-08-25 20:20:19.000000000 +0000
43 (prob->ulong1 ? "" : _("(installed) ")), pkgNEVR);
45 + case RPMPROB_OLDDISTRO:
46 + rc = snprintf(buf, nb,
47 + _("package %s is for older distribution than already installed %s"),
51 rc = snprintf(buf, nb,
52 _("unknown error %d encountered while manipulating package %s"),
53 --- rpm.orig/lib/rpmlib.h 2004-06-14 00:39:06.000000000 +0000
54 +++ rpm/lib/rpmlib.h 2004-09-02 16:34:46.000000000 +0000
56 int rpmvercmp(const char * a, const char * b)
59 +int rpmdistcmp(const char *a, const char *b);
62 * Check dependency against internal rpmlib feature provides.
63 * @param key dependency
64 --- rpm.orig/lib/rpmvercmp.c 2004-03-25 21:01:22.000000000 +0000
65 +++ rpm/lib/rpmvercmp.c 2004-09-02 16:42:34.000000000 +0000
70 +/* choose which distro is newer */
71 +/* return 1: a is newer than b */
72 +/* 0: a and b are the same version */
73 +/* -1: b is newer than a */
75 +int rpmdistcmp(const char *a, const char *b)
77 + const char *dist = rpmExpand("%{?distribution}", NULL);
79 + if (dist == NULL || *dist == '\0')
82 + if ((strcmp(a,dist) == 0) || (strcmp(b,dist) == 0))
85 + if ((strncmp(a,dist,strlen(dist)) == 0) &&
86 + (strncmp(b,dist,strlen(dist)) == 0))
87 + return (rpmvercmp(a,b));
92 /* compare alpha and numeric segments of two versions */
93 /* return 1: a is newer than b */
94 /* 0: a and b are the same version */
95 --- rpm.orig/lib/transaction.c 2004-05-20 21:23:01.000000000 +0000
96 +++ rpm/lib/transaction.c 2004-09-02 16:41:31.000000000 +0000
101 + * Check if current package is from a newer distribution than installed one.
102 + * @param p current transaction element
103 + * @param h installed header
104 + * @return 1: current is newer than installed
105 + * 0: dist comparison doesn't apply for any reason
106 + * -1: current is older than installed
108 +static int compareDistVersion(const rpmte p, const Header h)
110 + const char * cdist; /* current package */
111 + const char * idist; /* installed package */
113 + int rc = rpmExpandNumeric("%{?_dont_compare_distversion}");
117 + if (!headerGetEntry(h, RPMTAG_DISTRIBUTION, NULL, (void **) &idist, NULL))
119 + if (!(cdist = rpmteDist(p)))
122 + return (rpmdistcmp(cdist,idist));
126 * Ensure that current package is newer than installed package.
127 * @param ts transaction set
128 * @param p current transaction element
130 if (p == NULL || h == NULL)
133 + rc = compareDistVersion(p, h);
138 + rpmps ps = rpmtsProblems(ts);
139 + const char * altNEVR = hGetNEVR(h, NULL);
140 + rpmpsAppend(ps, RPMPROB_OLDDISTRO,
141 + rpmteNEVR(p), rpmteKey(p),
145 + altNEVR = _free(altNEVR);
146 + ps = rpmpsFree(ps);
151 nb = strlen(rpmteNEVR(p)) + (rpmteE(p) != NULL ? strlen(rpmteE(p)) : 0) + 1;
155 altNEVR = _free(altNEVR);
165 @@ -1521,12 +1563,15 @@
169 - while (rpmdbNextIterator(mi) != NULL) {
170 - rpmpsAppend(ps, RPMPROB_PKG_INSTALLED,
171 - rpmteNEVR(p), rpmteKey(p),
174 - /*@innerbreak@*/ break;
176 + while ((h = rpmdbNextIterator(mi)) != NULL) {
177 + if(compareDistVersion(p, h) == 0) {
178 + rpmpsAppend(ps, RPMPROB_PKG_INSTALLED,
179 + rpmteNEVR(p), rpmteKey(p),
182 + /*@innerbreak@*/ break;
185 mi = rpmdbFreeIterator(mi);
187 --- rpm.orig/lib/rpmte.c 2004-04-03 12:30:57.000000000 +0000
188 +++ rpm/lib/rpmte.c 2004-08-27 15:05:56.000000000 +0000
190 p->arch = _free(p->arch);
191 p->epoch = _free(p->epoch);
192 p->name = _free(p->name);
193 + p->dist = _free(p->dist);
194 p->NEVR = _free(p->NEVR);
195 p->NEVRA = _free(p->NEVRA);
198 HGE_t hge = (HGE_t)headerGetEntryMinMemory;
201 - const char * arch, * os;
202 + const char * arch, * os, * dist;
211 + xx = hge(h, RPMTAG_DISTRIBUTION, NULL, (void **)&dist, NULL);
213 + p->dist = xstrdup(dist);
218 xx = hge(h, RPMTAG_ARCH, NULL, (void **)&arch, NULL);
221 return (te != NULL ? te->os : NULL);
224 +const char * rpmteDist(rpmte te)
226 + return (te != NULL ? te->dist : NULL);
229 uint_32 rpmteColor(rpmte te)
231 return (te != NULL ? te->color : 0);