1 --- ./lib/depends.c.org Sun Mar 25 12:55:25 2001
2 +++ ./lib/depends.c Sun Mar 25 12:57:15 2001
4 free((void *)conflicts[i].byRelease);
5 free((void *)conflicts[i].needsName);
6 free((void *)conflicts[i].needsVersion);
7 + if(conflicts[i].suggestedPackages) free(conflicts[i].suggestedPackages);
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
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)
29 const char * baseName;
30 struct dirInfo dirNeedle;
31 struct dirInfo * dirMatch;
32 + struct availablePackage **ret;
34 if (al->numDirs == 0) /* Solaris 2.6 bsearch sucks down on this. */
37 dirNeedle.dirNameLen = strlen(dirName);
38 dirMatch = bsearch(&dirNeedle, al->dirs, al->numDirs,
39 sizeof(dirNeedle), dirInfoCompare);
40 - free((void *)dirName);
41 - if (!dirMatch) return NULL;
43 + free((void *)dirName);
47 + /* rewind to the first match */
48 + while(dirMatch > al->dirs && dirInfoCompare(dirMatch-1,&dirNeedle)==0)
51 baseName = strrchr(fileName, '/') + 1;
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)) {
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))
64 + for (i = 0; i < dirMatch->numFiles; i++) {
65 + if (!strcmp(dirMatch->files[i].baseName, baseName)) {
68 - rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"),
70 - return al->list + dirMatch->files[i].pkgNum;
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))
79 + rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"),
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 */
91 + free((void *)dirName);
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
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)
114 + struct availablePackage *ret, **tmp;
116 + tmp = alAllFileSatisfiesDepend(al, keyType, fileName);
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)
131 struct availableIndexEntry needle, * match;
132 - struct availablePackage * p;
134 + struct availablePackage * p, **ret=NULL;
138 - return alFileSatisfiesDepend(al, keyType, keyName);
139 + return alAllFileSatisfiesDepend(al, keyType, keyName);
141 if (!al->index.size) return NULL;
143 @@ -985,37 +1008,76 @@
144 sizeof(*al->index.index), indexcmp);
146 if (match == NULL) return NULL;
149 + /* rewind to the first match */
150 + while( match > al->index.index && indexcmp(match-1,&needle) == 0 )
153 + for(ret=NULL, found=0; match <= al->index.index + al->index.size &&
154 + indexcmp(match,&needle) == 0;
158 switch (match->type) {
160 - for (i = 0; i < p->providesCount; i++) {
161 - const char *proEVR;
164 - /* Filter out provides that came along for the ride. */
165 - if (strcmp(p->provides[i], keyName))
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);
174 + for (i = 0; i < p->providesCount; i++) {
175 + const char *proEVR;
178 + /* Filter out provides that came along for the ride. */
179 + if (strcmp(p->provides[i], keyName))
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);
188 + if (keyType && keyDepend && rc)
189 + rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added provide)\n"),
190 + keyType, keyDepend+2);
195 + ret=realloc(ret,sizeof(struct aviablePackage *)*(found+2));
198 - if (keyType && keyDepend && rc)
199 - rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added provide)\n"),
200 - keyType, keyDepend+2);
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
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)
227 + struct availablePackage *ret, **tmp ;
228 + tmp=alAllSatisfiesDepend(al, keyType, keyDepend, keyName, keyEVR,
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
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)
256 static int _cacheDependsRC = 1;
257 rpmdbMatchIterator mi;
258 @@ -1156,7 +1218,7 @@
262 - *suggestion = alSatisfiesDepend(&ts->availablePackages, NULL, NULL,
263 + *suggestion = alAllSatisfiesDepend(&ts->availablePackages, NULL, NULL,
264 keyName, keyEVR, keyFlags);
267 @@ -1204,7 +1266,7 @@
271 - struct availablePackage * suggestion;
272 + struct availablePackage ** suggestion;
274 headerNVR(h, &name, &version, &release);
276 @@ -1256,10 +1318,23 @@
277 psp->problems[psp->num].needsFlags = requireFlags[i];
278 psp->problems[psp->num].sense = RPMDEP_SENSE_REQUIRES;
281 - psp->problems[psp->num].suggestedPackage = suggestion->key;
283 - psp->problems[psp->num].suggestedPackage = NULL;
286 + for(i=0;suggestion[i];i++)
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;
295 + psp->problems[psp->num].suggestedPackage = suggestion[0]->key;
298 + psp->problems[psp->num].suggestedPackages = NULL;
299 + psp->problems[psp->num].suggestedPackage = NULL;
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;
315 --- ./lib/rpmlib.h.org Sun Mar 25 12:55:35 2001
316 +++ ./lib/rpmlib.h Sun Mar 25 12:55:38 2001
318 const char * needsVersion;
320 /*@observer@*/ /*@null@*/ const void * suggestedPackage; /* NULL if none */
321 +/*@observer@*/ /*@null@*/ const void ** suggestedPackages; /* terminated by
324 RPMDEP_SENSE_REQUIRES, /*!< requirement not satisfied. */
325 RPMDEP_SENSE_CONFLICTS /*!< conflict was found. */