]>
Commit | Line | Data |
---|---|---|
1e24f4c6 | 1 | --- ./lib/depends.c.org Sun Mar 25 12:55:25 2001 |
2 | +++ ./lib/depends.c Sun Mar 25 12:57:15 2001 | |
9fb661f0 | 3 | @@ -894,27 +894,22 @@ |
4 | free((void *)conflicts[i].byRelease); | |
5 | free((void *)conflicts[i].needsName); | |
6 | free((void *)conflicts[i].needsVersion); | |
1e24f4c6 | 7 | + if(conflicts[i].suggestedPackages) free(conflicts[i].suggestedPackages); |
9fb661f0 | 8 | } |
9 | ||
10 | free(conflicts); | |
11 | } | |
12 | ||
13 | -/** | |
14 | - * Check added package file lists for a file. | |
15 | - * @param al available list | |
16 | - * @param keyType type of dependency | |
17 | - * @param fileName file name to search for | |
18 | - * @return available package pointer | |
19 | - */ | |
20 | -/*@dependent@*/ /*@null@*/ static struct availablePackage * | |
21 | -alFileSatisfiesDepend(struct availableList * al, | |
22 | +/*@dependent@*/ /*@null@*/ static struct availablePackage ** | |
23 | +alAllFileSatisfiesDepend(struct availableList * al, | |
24 | const char * keyType, const char * fileName) | |
25 | { | |
26 | - int i; | |
27 | + int i, found; | |
28 | const char * dirName; | |
29 | const char * baseName; | |
30 | struct dirInfo dirNeedle; | |
31 | struct dirInfo * dirMatch; | |
32 | + struct availablePackage **ret; | |
33 | ||
34 | if (al->numDirs == 0) /* Solaris 2.6 bsearch sucks down on this. */ | |
35 | return NULL; | |
36 | @@ -930,52 +925,80 @@ | |
37 | dirNeedle.dirNameLen = strlen(dirName); | |
38 | dirMatch = bsearch(&dirNeedle, al->dirs, al->numDirs, | |
39 | sizeof(dirNeedle), dirInfoCompare); | |
1e24f4c6 | 40 | - free((void *)dirName); |
41 | - if (!dirMatch) return NULL; | |
9fb661f0 | 42 | + if (!dirMatch){ |
43 | + free((void *)dirName); | |
44 | + return NULL; | |
45 | + } | |
46 | + | |
47 | + /* rewind to the first match */ | |
48 | + while(dirMatch > al->dirs && dirInfoCompare(dirMatch-1,&dirNeedle)==0) | |
49 | + dirMatch--; | |
9fb661f0 | 50 | |
51 | baseName = strrchr(fileName, '/') + 1; | |
52 | ||
53 | + for(found=0, ret=NULL; dirMatch <= al->dirs + al->numDirs && | |
54 | + dirInfoCompare(dirMatch,&dirNeedle)==0;dirMatch++){ | |
55 | /* XXX FIXME: these file lists should be sorted and bsearched */ | |
56 | - for (i = 0; i < dirMatch->numFiles; i++) { | |
57 | - if (!strcmp(dirMatch->files[i].baseName, baseName)) { | |
1e24f4c6 | 58 | - |
9fb661f0 | 59 | - /* If a file dependency would be satisfied by a file |
60 | - we are not going to install, skip it. */ | |
61 | - if (al->list[dirMatch->files[i].pkgNum].multiLib && | |
62 | - !isFileMULTILIB(dirMatch->files[i].fileFlags)) | |
63 | - continue; | |
1e24f4c6 | 64 | + for (i = 0; i < dirMatch->numFiles; i++) { |
65 | + if (!strcmp(dirMatch->files[i].baseName, baseName)) { | |
66 | ||
9fb661f0 | 67 | - if (keyType) |
68 | - rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"), | |
69 | - keyType, fileName); | |
70 | - return al->list + dirMatch->files[i].pkgNum; | |
71 | - } | |
72 | + /* If a file dependency would be satisfied by a file | |
73 | + we are not going to install, skip it. */ | |
74 | + if (al->list[dirMatch->files[i].pkgNum].multiLib && | |
75 | + !isFileMULTILIB(dirMatch->files[i].fileFlags)) | |
76 | + continue; | |
77 | + | |
78 | + if (keyType) | |
79 | + rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"), | |
80 | + keyType, fileName); | |
81 | + ret=realloc(ret,sizeof(struct aviablePackage* )*(found+2)); | |
82 | + ret[found++] = al->list + dirMatch->files[i].pkgNum; | |
83 | + break ; /* next iteration of for(found=0....) loop */ | |
84 | + | |
85 | + } | |
86 | + } | |
87 | } | |
88 | - | |
89 | - return NULL; | |
1e24f4c6 | 90 | + |
91 | + free((void *)dirName); | |
9fb661f0 | 92 | + if(ret) |
93 | + ret[found]=NULL; | |
94 | + return ret; | |
95 | } | |
96 | ||
97 | /** | |
98 | - * Check added package file lists for a provide. | |
99 | + * Check added package file lists for a file. | |
100 | * @param al available list | |
101 | * @param keyType type of dependency | |
102 | - * @param keyDepend dependency string representation | |
103 | - * @param keyName dependency name string | |
104 | - * @param keyEVR dependency [epoch:]version[-release] string | |
105 | - * @param keyFlags dependency logical range qualifiers | |
106 | + * @param fileName file name to search for | |
107 | * @return available package pointer | |
108 | */ | |
109 | -/*@dependent@*/ /*@null@*/ static struct availablePackage * alSatisfiesDepend( | |
110 | +/*@dependent@*/ /*@null@*/ static struct availablePackage * | |
111 | +alFileSatisfiesDepend(struct availableList * al, | |
112 | + const char * keyType, const char * fileName) | |
113 | +{ | |
114 | + struct availablePackage *ret, **tmp; | |
115 | + | |
116 | + tmp = alAllFileSatisfiesDepend(al, keyType, fileName); | |
117 | + if(tmp){ | |
118 | + ret = tmp[0]; | |
119 | + free( tmp); | |
120 | + return ret; | |
121 | + } | |
122 | + return NULL; | |
123 | +} | |
124 | + | |
125 | +static struct availablePackage ** alAllSatisfiesDepend( | |
126 | struct availableList * al, | |
127 | const char * keyType, const char * keyDepend, | |
128 | const char * keyName, const char * keyEVR, int keyFlags) | |
129 | { | |
130 | + | |
131 | struct availableIndexEntry needle, * match; | |
132 | - struct availablePackage * p; | |
133 | - int i, rc; | |
134 | + struct availablePackage * p, **ret=NULL; | |
135 | + int i, rc, found; | |
136 | ||
137 | if (*keyName == '/') | |
138 | - return alFileSatisfiesDepend(al, keyType, keyName); | |
139 | + return alAllFileSatisfiesDepend(al, keyType, keyName); | |
140 | ||
141 | if (!al->index.size) return NULL; | |
142 | ||
143 | @@ -985,37 +1008,76 @@ | |
144 | sizeof(*al->index.index), indexcmp); | |
145 | ||
146 | if (match == NULL) return NULL; | |
147 | - | |
148 | + | |
149 | + /* rewind to the first match */ | |
150 | + while( match > al->index.index && indexcmp(match-1,&needle) == 0 ) | |
151 | + match--; | |
152 | + | |
1e24f4c6 | 153 | + for(ret=NULL, found=0; match <= al->index.index + al->index.size && |
154 | + indexcmp(match,&needle) == 0; | |
9fb661f0 | 155 | + match++){ |
156 | p = match->package; | |
157 | rc = 0; | |
158 | switch (match->type) { | |
159 | - case IET_PROVIDES: | |
160 | - for (i = 0; i < p->providesCount; i++) { | |
161 | - const char *proEVR; | |
162 | - int proFlags; | |
163 | - | |
164 | - /* Filter out provides that came along for the ride. */ | |
165 | - if (strcmp(p->provides[i], keyName)) | |
166 | - continue; | |
167 | - | |
168 | - proEVR = (p->providesEVR ? p->providesEVR[i] : NULL); | |
169 | - proFlags = (p->provideFlags ? p->provideFlags[i] : 0); | |
170 | - rc = rpmRangesOverlap(p->provides[i], proEVR, proFlags, | |
171 | - keyName, keyEVR, keyFlags); | |
172 | - if (rc) break; | |
173 | + case IET_PROVIDES: | |
174 | + for (i = 0; i < p->providesCount; i++) { | |
175 | + const char *proEVR; | |
176 | + int proFlags; | |
177 | + | |
178 | + /* Filter out provides that came along for the ride. */ | |
179 | + if (strcmp(p->provides[i], keyName)) | |
180 | + continue; | |
181 | + | |
182 | + proEVR = (p->providesEVR ? p->providesEVR[i] : NULL); | |
183 | + proFlags = (p->provideFlags ? p->provideFlags[i] : 0); | |
184 | + rc = rpmRangesOverlap(p->provides[i], proEVR, proFlags, | |
185 | + keyName, keyEVR, keyFlags); | |
186 | + if (rc) break; | |
187 | + } | |
188 | + if (keyType && keyDepend && rc) | |
189 | + rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added provide)\n"), | |
190 | + keyType, keyDepend+2); | |
191 | + break; | |
192 | + } | |
193 | + | |
194 | + if (rc){ | |
195 | + ret=realloc(ret,sizeof(struct aviablePackage *)*(found+2)); | |
196 | + ret[found++]=p; | |
197 | } | |
198 | - if (keyType && keyDepend && rc) | |
199 | - rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added provide)\n"), | |
200 | - keyType, keyDepend+2); | |
201 | - break; | |
202 | } | |
203 | + if(ret) | |
204 | + ret[found]=NULL; | |
205 | ||
206 | - if (rc) | |
207 | - return p; | |
208 | + return ret; | |
209 | +} | |
210 | ||
211 | - return NULL; | |
212 | +/** | |
213 | + * Check added package file lists for a provide. | |
214 | + * @param al available list | |
215 | + * @param keyType type of dependency | |
216 | + * @param keyDepend dependency string representation | |
217 | + * @param keyName dependency name string | |
218 | + * @param keyEVR dependency [epoch:]version[-release] string | |
219 | + * @param keyFlags dependency logical range qualifiers | |
220 | + * @return available package pointer | |
221 | + */ | |
222 | +/*@dependent@*/ /*@null@*/ static struct availablePackage * alSatisfiesDepend( | |
223 | + struct availableList * al, | |
224 | + const char * keyType, const char * keyDepend, | |
225 | + const char * keyName, const char * keyEVR, int keyFlags) | |
226 | +{ | |
227 | + struct availablePackage *ret, **tmp ; | |
228 | + tmp=alAllSatisfiesDepend(al, keyType, keyDepend, keyName, keyEVR, | |
229 | + keyFlags); | |
230 | + if(tmp){ | |
231 | + ret=tmp[0]; | |
232 | + free(tmp); | |
233 | + return ret; | |
234 | + } | |
235 | + return NULL; | |
236 | } | |
237 | ||
238 | + | |
239 | /** | |
240 | * Check key for an unsatisfied dependency. | |
241 | * @param al available list | |
242 | @@ -1024,13 +1086,13 @@ | |
243 | * @param keyName dependency name string | |
244 | * @param keyEVR dependency [epoch:]version[-release] string | |
245 | * @param keyFlags dependency logical range qualifiers | |
246 | - * @retval suggestion possible package to resolve dependency | |
247 | + * @retval suggestion possible packages to resolve dependency | |
248 | * @return 0 if satisfied, 1 if not satisfied, 2 if error | |
249 | */ | |
250 | static int unsatisfiedDepend(rpmTransactionSet ts, | |
251 | const char * keyType, const char * keyDepend, | |
252 | const char * keyName, const char * keyEVR, int keyFlags, | |
253 | - /*@out@*/ struct availablePackage ** suggestion) | |
254 | + /*@out@*/ struct availablePackage *** suggestion) | |
255 | { | |
256 | static int _cacheDependsRC = 1; | |
257 | rpmdbMatchIterator mi; | |
258 | @@ -1156,7 +1218,7 @@ | |
259 | } | |
260 | ||
261 | if (suggestion) | |
262 | - *suggestion = alSatisfiesDepend(&ts->availablePackages, NULL, NULL, | |
263 | + *suggestion = alAllSatisfiesDepend(&ts->availablePackages, NULL, NULL, | |
264 | keyName, keyEVR, keyFlags); | |
265 | ||
266 | unsatisfied: | |
267 | @@ -1204,7 +1266,7 @@ | |
268 | int type; | |
269 | int i, rc; | |
270 | int ourrc = 0; | |
271 | - struct availablePackage * suggestion; | |
272 | + struct availablePackage ** suggestion; | |
273 | ||
274 | headerNVR(h, &name, &version, &release); | |
275 | ||
276 | @@ -1256,10 +1318,23 @@ | |
277 | psp->problems[psp->num].needsFlags = requireFlags[i]; | |
278 | psp->problems[psp->num].sense = RPMDEP_SENSE_REQUIRES; | |
279 | ||
280 | - if (suggestion) | |
281 | - psp->problems[psp->num].suggestedPackage = suggestion->key; | |
282 | - else | |
283 | - psp->problems[psp->num].suggestedPackage = NULL; | |
284 | + if (suggestion){ | |
285 | + int i; | |
286 | + for(i=0;suggestion[i];i++) | |
287 | + ; | |
288 | + psp->problems[psp->num].suggestedPackages = | |
289 | + malloc( sizeof(void *) * (i+1)); | |
290 | + for(i=0;suggestion[i];i++) | |
291 | + psp->problems[psp->num].suggestedPackages[i] | |
292 | + = suggestion[i]->key; | |
293 | + psp->problems[psp->num].suggestedPackages[i]=NULL; | |
294 | + | |
295 | + psp->problems[psp->num].suggestedPackage = suggestion[0]->key; | |
296 | + } | |
297 | + else{ | |
298 | + psp->problems[psp->num].suggestedPackages = NULL; | |
299 | + psp->problems[psp->num].suggestedPackage = NULL; | |
300 | + } | |
301 | ||
302 | psp->num++; | |
303 | break; | |
304 | @@ -1322,7 +1397,9 @@ | |
305 | psp->problems[psp->num].needsVersion = xstrdup(conflictsEVR[i]); | |
306 | psp->problems[psp->num].needsFlags = conflictFlags[i]; | |
307 | psp->problems[psp->num].sense = RPMDEP_SENSE_CONFLICTS; | |
308 | - psp->problems[psp->num].suggestedPackage = NULL; | |
309 | + psp->problems[psp->num].suggestedPackages = NULL; | |
310 | + psp->problems[psp->num].suggestedPackage = NULL; | |
311 | + | |
312 | ||
313 | psp->num++; | |
314 | break; | |
1e24f4c6 | 315 | --- ./lib/rpmlib.h.org Sun Mar 25 12:55:35 2001 |
316 | +++ ./lib/rpmlib.h Sun Mar 25 12:55:38 2001 | |
9fb661f0 | 317 | @@ -771,6 +771,8 @@ |
318 | const char * needsVersion; | |
319 | int needsFlags; | |
320 | /*@observer@*/ /*@null@*/ const void * suggestedPackage; /* NULL if none */ | |
321 | +/*@observer@*/ /*@null@*/ const void ** suggestedPackages; /* terminated by | |
322 | + NULL */ | |
323 | enum { | |
324 | RPMDEP_SENSE_REQUIRES, /*!< requirement not satisfied. */ | |
325 | RPMDEP_SENSE_CONFLICTS /*!< conflict was found. */ |