]>
Commit | Line | Data |
---|---|---|
55d531d8 MM |
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 | |
3 | @@ -77,6 +77,7 @@ | |
4 | const char * arch; /*!< Architecture hint. */ | |
5 | /*@only@*/ /*@null@*/ | |
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. */ | |
10 | ||
11 | @@ -238,6 +239,15 @@ | |
12 | /*@*/; | |
13 | ||
14 | /** | |
15 | + * Retrieve distribution string of transaction element. | |
16 | + * @param te transaction element | |
17 | + * @return distribution string | |
18 | + */ | |
19 | +/*@observer@*/ /*@null@*/ | |
20 | +extern const char * rpmteDist(rpmte te) | |
21 | + /*@*/; | |
22 | + | |
23 | +/** | |
24 | * Retrieve color bits of transaction element. | |
25 | * @param te transaction element | |
26 | * @return color bits | |
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 | |
29 | @@ -36,7 +36,8 @@ | |
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 /*!< */ | |
36 | } rpmProblemType; | |
37 | ||
38 | /** | |
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 | |
41 | @@ -268,6 +268,11 @@ | |
42 | altNEVR+2, | |
43 | (prob->ulong1 ? "" : _("(installed) ")), pkgNEVR); | |
44 | break; | |
45 | + case RPMPROB_OLDDISTRO: | |
46 | + rc = snprintf(buf, nb, | |
47 | + _("package %s is for older distribution than already installed %s"), | |
48 | + pkgNEVR, altNEVR); | |
49 | + break; | |
50 | default: | |
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 | |
55 | @@ -1021,6 +1021,8 @@ | |
56 | int rpmvercmp(const char * a, const char * b) | |
57 | /*@*/; | |
58 | ||
59 | +int rpmdistcmp(const char *a, const char *b); | |
60 | + | |
61 | /** \ingroup rpmtrans | |
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 | |
66 | @@ -8,6 +8,28 @@ | |
67 | ||
68 | #include "debug.h" | |
69 | ||
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 */ | |
74 | + | |
75 | +int rpmdistcmp(const char *a, const char *b) | |
76 | +{ | |
77 | + const char *dist = rpmExpand("%{?distribution}", NULL); | |
78 | + | |
79 | + if (dist == NULL || *dist == '\0') | |
80 | + return 0; | |
81 | + | |
82 | + if ((strcmp(a,dist) == 0) || (strcmp(b,dist) == 0)) | |
83 | + return 0; | |
84 | + | |
85 | + if ((strncmp(a,dist,strlen(dist)) == 0) && | |
86 | + (strncmp(b,dist,strlen(dist)) == 0)) | |
87 | + return (rpmvercmp(a,b)); | |
88 | + | |
89 | + return 0; | |
90 | +} | |
91 | + | |
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 | |
97 | @@ -650,6 +650,31 @@ | |
98 | } | |
99 | ||
100 | /** | |
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 | |
107 | + */ | |
108 | +static int compareDistVersion(const rpmte p, const Header h) | |
109 | +{ | |
110 | + const char * cdist; /* current package */ | |
111 | + const char * idist; /* installed package */ | |
112 | + | |
ef86dd51 | 113 | + int rc = rpmExpandNumeric("%{?_dont_compare_distversion}"); |
55d531d8 | 114 | + if (rc == 1) |
9d84627a | 115 | + return 0; |
55d531d8 MM |
116 | + |
117 | + if (!headerGetEntry(h, RPMTAG_DISTRIBUTION, NULL, (void **) &idist, NULL)) | |
118 | + return 0; | |
119 | + if (!(cdist = rpmteDist(p))) | |
120 | + return 0; | |
121 | + | |
122 | + return (rpmdistcmp(cdist,idist)); | |
123 | +} | |
124 | + | |
125 | +/** | |
126 | * Ensure that current package is newer than installed package. | |
127 | * @param ts transaction set | |
128 | * @param p current transaction element | |
129 | @@ -670,6 +695,23 @@ | |
130 | if (p == NULL || h == NULL) | |
131 | return 1; | |
132 | ||
133 | + rc = compareDistVersion(p, h); | |
134 | + if (rc == 1) | |
135 | + return 1; | |
136 | + else if (rc == -1) | |
137 | + { | |
138 | + rpmps ps = rpmtsProblems(ts); | |
139 | + const char * altNEVR = hGetNEVR(h, NULL); | |
140 | + rpmpsAppend(ps, RPMPROB_OLDDISTRO, | |
141 | + rpmteNEVR(p), rpmteKey(p), | |
142 | + NULL, NULL, | |
143 | + altNEVR, | |
144 | + 0); | |
145 | + altNEVR = _free(altNEVR); | |
146 | + ps = rpmpsFree(ps); | |
147 | + return 0; | |
148 | + } | |
149 | + | |
150 | /*@-boundswrite@*/ | |
151 | nb = strlen(rpmteNEVR(p)) + (rpmteE(p) != NULL ? strlen(rpmteE(p)) : 0) + 1; | |
152 | t = alloca(nb); | |
153 | @@ -695,9 +737,9 @@ | |
154 | 0); | |
155 | altNEVR = _free(altNEVR); | |
156 | ps = rpmpsFree(ps); | |
157 | - rc = 1; | |
158 | - } else | |
159 | rc = 0; | |
160 | + } else | |
161 | + rc = 1; | |
162 | ||
163 | return rc; | |
164 | } | |
165 | @@ -1521,12 +1563,15 @@ | |
166 | rpmteO(p)); | |
167 | } | |
168 | ||
169 | - while (rpmdbNextIterator(mi) != NULL) { | |
170 | - rpmpsAppend(ps, RPMPROB_PKG_INSTALLED, | |
171 | - rpmteNEVR(p), rpmteKey(p), | |
172 | - NULL, NULL, | |
173 | - NULL, 0); | |
174 | - /*@innerbreak@*/ break; | |
175 | + Header h; | |
176 | + while ((h = rpmdbNextIterator(mi)) != NULL) { | |
177 | + if(compareDistVersion(p, h) == 0) { | |
178 | + rpmpsAppend(ps, RPMPROB_PKG_INSTALLED, | |
179 | + rpmteNEVR(p), rpmteKey(p), | |
180 | + NULL, NULL, | |
181 | + NULL, 0); | |
182 | + /*@innerbreak@*/ break; | |
183 | + } | |
184 | } | |
185 | mi = rpmdbFreeIterator(mi); | |
186 | } | |
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 | |
189 | @@ -60,6 +60,7 @@ | |
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); | |
196 | ||
197 | @@ -93,7 +94,7 @@ | |
198 | HGE_t hge = (HGE_t)headerGetEntryMinMemory; | |
199 | rpmte savep; | |
200 | int_32 * ep; | |
201 | - const char * arch, * os; | |
202 | + const char * arch, * os, * dist; | |
203 | char * t; | |
204 | size_t nb; | |
205 | int xx; | |
206 | @@ -110,6 +111,13 @@ | |
207 | */ | |
208 | p->db_instance = 0; | |
209 | ||
210 | + dist = NULL; | |
211 | + xx = hge(h, RPMTAG_DISTRIBUTION, NULL, (void **)&dist, NULL); | |
212 | + if (dist != NULL) | |
213 | + p->dist = xstrdup(dist); | |
214 | + else | |
215 | + p->dist = NULL; | |
216 | + | |
217 | arch = NULL; | |
218 | xx = hge(h, RPMTAG_ARCH, NULL, (void **)&arch, NULL); | |
219 | if (arch != NULL) { | |
220 | @@ -279,6 +287,11 @@ | |
221 | return (te != NULL ? te->os : NULL); | |
222 | } | |
223 | ||
224 | +const char * rpmteDist(rpmte te) | |
225 | +{ | |
226 | + return (te != NULL ? te->dist : NULL); | |
227 | +} | |
228 | + | |
229 | uint_32 rpmteColor(rpmte te) | |
230 | { | |
231 | return (te != NULL ? te->color : 0); |