]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-suggestions.patch
- rpm-devel Requires: gzip, tar
[packages/rpm.git] / rpm-suggestions.patch
CommitLineData
9fb661f0 1diff -Nur rpm-4.0.2/lib/depends.c rpm-4.0.2-patched/lib/depends.c
2--- rpm-4.0.2/lib/depends.c Sat Mar 17 23:18:31 2001
3+++ rpm-4.0.2-patched/lib/depends.c Sat Mar 17 23:20:15 2001
4@@ -894,27 +894,22 @@
5 free((void *)conflicts[i].byRelease);
6 free((void *)conflicts[i].needsName);
7 free((void *)conflicts[i].needsVersion);
8+ /* TODO: suggestedPackage_s_ */
9 }
10
11 free(conflicts);
12 }
13
14-/**
15- * Check added package file lists for a file.
16- * @param al available list
17- * @param keyType type of dependency
18- * @param fileName file name to search for
19- * @return available package pointer
20- */
21-/*@dependent@*/ /*@null@*/ static struct availablePackage *
22-alFileSatisfiesDepend(struct availableList * al,
23+/*@dependent@*/ /*@null@*/ static struct availablePackage **
24+alAllFileSatisfiesDepend(struct availableList * al,
25 const char * keyType, const char * fileName)
26 {
27- int i;
28+ int i, found;
29 const char * dirName;
30 const char * baseName;
31 struct dirInfo dirNeedle;
32 struct dirInfo * dirMatch;
33+ struct availablePackage **ret;
34
35 if (al->numDirs == 0) /* Solaris 2.6 bsearch sucks down on this. */
36 return NULL;
37@@ -930,52 +925,80 @@
38 dirNeedle.dirNameLen = strlen(dirName);
39 dirMatch = bsearch(&dirNeedle, al->dirs, al->numDirs,
40 sizeof(dirNeedle), dirInfoCompare);
41+ if (!dirMatch){
42+ free((void *)dirName);
43+ return NULL;
44+ }
45+
46+ /* rewind to the first match */
47+ while(dirMatch > al->dirs && dirInfoCompare(dirMatch-1,&dirNeedle)==0)
48+ dirMatch--;
49+
50 free((void *)dirName);
51- if (!dirMatch) return NULL;
52
53 baseName = strrchr(fileName, '/') + 1;
54
55+ for(found=0, ret=NULL; dirMatch <= al->dirs + al->numDirs &&
56+ dirInfoCompare(dirMatch,&dirNeedle)==0;dirMatch++){
57 /* XXX FIXME: these file lists should be sorted and bsearched */
58- for (i = 0; i < dirMatch->numFiles; i++) {
59- if (!strcmp(dirMatch->files[i].baseName, baseName)) {
60+ for (i = 0; i < dirMatch->numFiles; i++) {
61+ if (!strcmp(dirMatch->files[i].baseName, baseName)) {
62
63- /* If a file dependency would be satisfied by a file
64- we are not going to install, skip it. */
65- if (al->list[dirMatch->files[i].pkgNum].multiLib &&
66- !isFileMULTILIB(dirMatch->files[i].fileFlags))
67- continue;
68-
69- if (keyType)
70- rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"),
71- keyType, fileName);
72- return al->list + dirMatch->files[i].pkgNum;
73- }
74+ /* If a file dependency would be satisfied by a file
75+ we are not going to install, skip it. */
76+ if (al->list[dirMatch->files[i].pkgNum].multiLib &&
77+ !isFileMULTILIB(dirMatch->files[i].fileFlags))
78+ continue;
79+
80+ if (keyType)
81+ rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"),
82+ keyType, fileName);
83+ ret=realloc(ret,sizeof(struct aviablePackage* )*(found+2));
84+ ret[found++] = al->list + dirMatch->files[i].pkgNum;
85+ break ; /* next iteration of for(found=0....) loop */
86+
87+ }
88+ }
89 }
90-
91- return NULL;
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+
153+ for(ret=NULL, found=0; indexcmp(match,&needle) == 0 &&
154+ match <= al->index.index + al->index.size;
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;
315diff -Nur rpm-4.0.2/lib/rpmlib.h rpm-4.0.2-patched/lib/rpmlib.h
316--- rpm-4.0.2/lib/rpmlib.h Tue Jan 16 00:10:04 2001
317+++ rpm-4.0.2-patched/lib/rpmlib.h Sat Mar 17 23:17:42 2001
318@@ -771,6 +771,8 @@
319 const char * needsVersion;
320 int needsFlags;
321 /*@observer@*/ /*@null@*/ const void * suggestedPackage; /* NULL if none */
322+/*@observer@*/ /*@null@*/ const void ** suggestedPackages; /* terminated by
323+ NULL */
324 enum {
325 RPMDEP_SENSE_REQUIRES, /*!< requirement not satisfied. */
326 RPMDEP_SENSE_CONFLICTS /*!< conflict was found. */
This page took 0.193416 seconds and 4 git commands to generate.