]>
Commit | Line | Data |
---|---|---|
5f8c53f0 JK |
1 | diff -dur rpm-4.3.orig/build/rpmfc.c rpm-4.3/build/rpmfc.c |
2 | --- rpm-4.3.orig/build/rpmfc.c 2004-01-16 14:21:42.283166337 +0100 | |
3 | +++ rpm-4.3/build/rpmfc.c 2004-01-16 14:38:10.000000000 +0100 | |
4 | @@ -1,6 +1,7 @@ | |
5 | #include "system.h" | |
6 | ||
7 | #include <signal.h> /* getOutputFrom() */ | |
8 | +#include <regex.h> | |
9 | ||
10 | #include <rpmbuild.h> | |
11 | #include <argv.h> | |
12 | @@ -9,6 +10,8 @@ | |
13 | #define _RPMDS_INTERNAL | |
14 | #include <rpmds.h> | |
15 | #include <rpmfi.h> | |
16 | +#include <rpmts.h> | |
17 | +#include <rpmdb.h> | |
18 | ||
19 | #if HAVE_GELF_H | |
20 | #include <gelf.h> | |
21 | @@ -301,6 +304,57 @@ | |
22 | return buf; | |
23 | }; | |
24 | ||
25 | +regex_t * rpmfcExpandRegexps(const char * str,int *count){ | |
26 | + int i,j,r; | |
27 | + const char *s; | |
28 | + ARGV_t patterns=NULL; | |
29 | + regex_t *compiled=NULL; | |
30 | + | |
31 | + s=rpmExpand(str,NULL); | |
32 | + if (s) { | |
33 | + poptParseArgvString(s,count,(const char ***)&patterns); | |
34 | + s = _free(s); | |
35 | + } | |
36 | + if (patterns==NULL){ | |
37 | + *count=0; | |
38 | + return NULL; | |
39 | + } | |
40 | + if (*count==0){ | |
41 | + _free(patterns); | |
42 | + return NULL; | |
43 | + } | |
44 | + | |
45 | + compiled=malloc(sizeof(regex_t)*(*count)); | |
46 | + j=0; | |
47 | + for(i=0;i<*count;i++){ | |
48 | + r=regcomp(&compiled[j],patterns[i],REG_NOSUB); | |
49 | + if (r==0) j++; | |
50 | + else { | |
51 | + rpmMessage(RPMMESS_NORMAL, | |
d327d730 JB |
52 | + _("Compilation of regular expresion '%s'" |
53 | + " (expanded from '%s') failed. Skipping it.\n"), | |
5f8c53f0 JK |
54 | + patterns[i],str); |
55 | + } | |
56 | + } | |
57 | + patterns=_free(patterns); | |
58 | + if (j==0) { | |
59 | + compiled=_free(compiled); | |
60 | + *count=0; | |
61 | + return NULL; | |
62 | + } | |
63 | + *count=j; | |
64 | + return compiled; | |
65 | +} | |
66 | + | |
67 | +regex_t * rpmfcFreeRegexps(regex_t *regexps,int count){ | |
68 | + int i; | |
69 | + | |
70 | + if (regexps) | |
71 | + for(i=0;i<count;i++) | |
72 | + regfree(®exps[i]); | |
73 | + return _free(regexps); | |
74 | +} | |
75 | + | |
76 | /** | |
77 | * Run per-interpreter dependency helper. | |
78 | * @param fc file classifier | |
79 | @@ -326,6 +380,9 @@ | |
80 | int pac; | |
81 | int xx; | |
82 | int i; | |
83 | + int noauto_c=0; | |
84 | + regex_t *noauto=NULL; | |
85 | + int j; | |
86 | ||
87 | switch (deptype) { | |
88 | default: | |
89 | @@ -334,6 +391,8 @@ | |
90 | case 'P': | |
91 | if (fc->skipProv) | |
92 | return 0; | |
93 | + noauto=rpmfcExpandRegexps("%{_noautoprov}",&noauto_c); | |
d327d730 | 94 | + rpmMessage(RPMMESS_DEBUG, _("%i _noautoprov patterns.\n"),noauto_c); |
5f8c53f0 JK |
95 | xx = snprintf(buf, sizeof(buf), "%%{?__%s_provides}", nsdep); |
96 | depsp = &fc->provides; | |
97 | dsContext = RPMSENSE_FIND_PROVIDES; | |
98 | @@ -342,6 +401,8 @@ | |
99 | case 'R': | |
100 | if (fc->skipReq) | |
101 | return 0; | |
102 | + noauto=rpmfcExpandRegexps("%{_noautoreq}",&noauto_c); | |
d327d730 | 103 | + rpmMessage(RPMMESS_DEBUG, _("%i _noautoreq patterns.\n"),noauto_c); |
5f8c53f0 JK |
104 | xx = snprintf(buf, sizeof(buf), "%%{?__%s_requires}", nsdep); |
105 | depsp = &fc->requires; | |
106 | dsContext = RPMSENSE_FIND_REQUIRES; | |
107 | @@ -394,6 +455,16 @@ | |
108 | } | |
109 | /*@=branchstate@*/ | |
110 | ||
111 | + for(j=0;j<noauto_c;j++){ | |
d327d730 JB |
112 | + rpmMessage(RPMMESS_DEBUG, _("Checking %c: '%s'" |
113 | + " against _noauto expr. #%i\n"),deptype,N,j); | |
5f8c53f0 | 114 | + if (!regexec(&noauto[j],N,0,NULL,0)) { |
d327d730 JB |
115 | + rpmMessage(RPMMESS_NORMAL, _("Skipping %c: '%s'" |
116 | + " as it matches _noauto expr. #%i\n"),deptype,N,j); | |
5f8c53f0 JK |
117 | + break; |
118 | + } | |
119 | + } | |
120 | + if (j<noauto_c) continue; | |
121 | ||
122 | /* Add tracking dependency for versioned Provides: */ | |
123 | if (!fc->tracked && deptype == 'P' && *EVR != '\0') { | |
124 | @@ -422,6 +493,7 @@ | |
125 | } | |
126 | sb_stdout = freeStringBuf(sb_stdout); | |
127 | ||
128 | + noauto=rpmfcFreeRegexps(noauto,noauto_c); | |
129 | return 0; | |
130 | } | |
131 | ||
132 | @@ -637,9 +709,11 @@ | |
133 | /** | |
134 | * Extract script dependencies. | |
135 | * @param fc file classifier | |
136 | + * @param findprov 1 to enable provides | |
137 | + * @param findreq 1 to enable requires | |
138 | * @return 0 on success | |
139 | */ | |
140 | -static int rpmfcSCRIPT(rpmfc fc) | |
141 | +static int rpmfcSCRIPT(rpmfc fc,int findprov,int findreq) | |
142 | /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ | |
143 | /*@modifies fc, rpmGlobalMacroContext, fileSystem, internalState @*/ | |
144 | { | |
145 | @@ -691,7 +765,7 @@ | |
146 | *se = '\0'; | |
147 | se++; | |
148 | ||
149 | - if (is_executable) { | |
150 | + if (is_executable && findreq) { | |
151 | /* Add to package requires. */ | |
152 | ds = rpmdsSingle(RPMTAG_REQUIRENAME, s, "", RPMSENSE_FIND_REQUIRES); | |
153 | xx = rpmdsMerge(&fc->requires, ds); | |
154 | @@ -718,19 +792,22 @@ | |
155 | (void) fclose(fp); | |
156 | ||
157 | if (fc->fcolor->vals[fc->ix] & RPMFC_PERL) { | |
158 | - if (fc->fcolor->vals[fc->ix] & RPMFC_MODULE) | |
159 | + if (findprov && fc->fcolor->vals[fc->ix] & RPMFC_MODULE) | |
160 | xx = rpmfcHelper(fc, 'P', "perl"); | |
161 | - if (is_executable || (fc->fcolor->vals[fc->ix] & RPMFC_MODULE)) | |
162 | + if (findreq && (is_executable || (fc->fcolor->vals[fc->ix] & RPMFC_MODULE))) | |
163 | xx = rpmfcHelper(fc, 'R', "perl"); | |
164 | } | |
165 | if (fc->fcolor->vals[fc->ix] & RPMFC_PYTHON) { | |
166 | - xx = rpmfcHelper(fc, 'P', "python"); | |
167 | - if (is_executable) | |
168 | + if (findprov) | |
169 | + xx = rpmfcHelper(fc, 'P', "python"); | |
170 | + if (findreq && is_executable) | |
171 | xx = rpmfcHelper(fc, 'R', "python"); | |
172 | } | |
173 | if (fc->fcolor->vals[fc->ix] & RPMFC_PHP) { | |
174 | + if (findprov) | |
175 | xx = rpmfcHelper(fc, 'P', "php"); | |
176 | - xx = rpmfcHelper(fc, 'R', "php"); | |
177 | + if (findreq) | |
178 | + xx = rpmfcHelper(fc, 'R', "php"); | |
179 | } | |
180 | ||
181 | return 0; | |
182 | @@ -739,9 +816,11 @@ | |
183 | /** | |
184 | * Extract Elf dependencies. | |
185 | * @param fc file classifier | |
186 | + * @param findprov 1 to enable provides | |
187 | + * @param findreq 1 to enable requires | |
188 | * @return 0 on success | |
189 | */ | |
190 | -static int rpmfcELF(rpmfc fc) | |
191 | +static int rpmfcELF(rpmfc fc,int findprov,int findreq) | |
192 | /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ | |
193 | /*@modifies fc, rpmGlobalMacroContext, fileSystem, internalState @*/ | |
194 | { | |
195 | @@ -853,17 +932,19 @@ | |
196 | t = stpcpy(t, "(64bit)"); | |
197 | #endif | |
198 | t++; | |
199 | + | |
200 | + if (findprov) { | |
201 | + /* Add to package provides. */ | |
202 | + ds = rpmdsSingle(RPMTAG_PROVIDES, | |
203 | + buf, "", RPMSENSE_FIND_PROVIDES); | |
204 | + xx = rpmdsMerge(&fc->provides, ds); | |
205 | ||
206 | - /* Add to package provides. */ | |
207 | - ds = rpmdsSingle(RPMTAG_PROVIDES, | |
208 | - buf, "", RPMSENSE_FIND_PROVIDES); | |
209 | - xx = rpmdsMerge(&fc->provides, ds); | |
210 | - | |
211 | - /* Add to file dependencies. */ | |
212 | - xx = rpmfcSaveArg(&fc->ddict, | |
213 | - rpmfcFileDep(t, fc->ix, ds)); | |
214 | + /* Add to file dependencies. */ | |
215 | + xx = rpmfcSaveArg(&fc->ddict, | |
216 | + rpmfcFileDep(t, fc->ix, ds)); | |
217 | ||
218 | - ds = rpmdsFree(ds); | |
219 | + ds = rpmdsFree(ds); | |
220 | + } | |
221 | } | |
222 | auxoffset += aux->vda_next; | |
223 | } | |
224 | @@ -914,15 +995,17 @@ | |
225 | #endif | |
226 | t++; | |
227 | ||
228 | - /* Add to package dependencies. */ | |
229 | - ds = rpmdsSingle(RPMTAG_REQUIRENAME, | |
230 | - buf, "", RPMSENSE_FIND_REQUIRES); | |
231 | - xx = rpmdsMerge(&fc->requires, ds); | |
232 | + if (findreq) { | |
233 | + /* Add to package dependencies. */ | |
234 | + ds = rpmdsSingle(RPMTAG_REQUIRENAME, | |
235 | + buf, "", RPMSENSE_FIND_REQUIRES); | |
236 | + xx = rpmdsMerge(&fc->requires, ds); | |
237 | ||
238 | - /* Add to file dependencies. */ | |
239 | - xx = rpmfcSaveArg(&fc->ddict, | |
240 | - rpmfcFileDep(t, fc->ix, ds)); | |
241 | - ds = rpmdsFree(ds); | |
242 | + /* Add to file dependencies. */ | |
243 | + xx = rpmfcSaveArg(&fc->ddict, | |
244 | + rpmfcFileDep(t, fc->ix, ds)); | |
245 | + ds = rpmdsFree(ds); | |
246 | + } | |
247 | } | |
248 | auxoffset += aux->vna_next; | |
249 | } | |
250 | @@ -947,6 +1030,7 @@ | |
251 | /* Files with executable bit set only. */ | |
252 | if (fc->skipReq || !(st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))) | |
253 | /*@innercontinue@*/ continue; | |
254 | + if (!findreq) continue; | |
255 | /* Add to package requires. */ | |
256 | depsp = &fc->requires; | |
257 | tagN = RPMTAG_REQUIRENAME; | |
258 | @@ -959,6 +1043,7 @@ | |
259 | /* Add to package provides. */ | |
260 | if (fc->skipProv) | |
261 | /*@innercontinue@*/ continue; | |
262 | + if (!findprov) continue; | |
263 | depsp = &fc->provides; | |
264 | tagN = RPMTAG_PROVIDENAME; | |
265 | dsContext = RPMSENSE_FIND_PROVIDES; | |
266 | @@ -997,7 +1082,7 @@ | |
267 | /*@=branchstate =uniondef @*/ | |
268 | ||
269 | /* For DSO's, provide the basename of the file if DT_SONAME not found. */ | |
270 | - if (!fc->skipProv && isDSO && !gotSONAME) { | |
271 | + if (findprov && !fc->skipProv && isDSO && !gotSONAME) { | |
272 | depsp = &fc->provides; | |
273 | tagN = RPMTAG_PROVIDENAME; | |
274 | dsContext = RPMSENSE_FIND_PROVIDES; | |
275 | @@ -1045,7 +1130,7 @@ | |
276 | } | |
277 | ||
278 | typedef struct rpmfcApplyTbl_s { | |
279 | - int (*func) (rpmfc fc); | |
280 | + int (*func) (rpmfc fc,int findprov,int findreq); | |
281 | int colormask; | |
282 | } * rpmfcApplyTbl; | |
283 | ||
284 | @@ -1058,6 +1143,109 @@ | |
285 | { NULL, 0 } | |
286 | }; | |
287 | ||
288 | +int rpmfcFindRequiredPackages(rpmfc fc) | |
289 | +{ | |
290 | + rpmts ts=NULL; | |
291 | + const char * s; | |
292 | + char * se; | |
293 | + rpmds ds; | |
294 | + const char * N; | |
295 | + const char * EVR; | |
296 | + int_32 Flags; | |
297 | + unsigned char deptype; | |
298 | + int nddict; | |
299 | + int previx; | |
300 | + int ix; | |
301 | + int i; | |
302 | + int j; | |
303 | + int xx; | |
304 | + int r; | |
305 | + const char * hname; | |
306 | + rpmdbMatchIterator it; | |
307 | + Header hdr; | |
308 | + regex_t *noautoreqdep; | |
309 | + int noautoreqdep_c; | |
310 | + | |
311 | + noautoreqdep=rpmfcExpandRegexps("%{_noautoreqdep}",&noautoreqdep_c); | |
312 | + | |
313 | + ts = rpmtsCreate(); /* XXX ts created in main() should be used */ | |
314 | + | |
d327d730 | 315 | + rpmMessage(RPMMESS_NORMAL, _("Searching for required packages....\n")); |
5f8c53f0 JK |
316 | + |
317 | + nddict = argvCount(fc->ddict); | |
318 | + previx = -1; | |
319 | + for (i = 0; i < nddict; i++) { | |
320 | + s = fc->ddict[i]; | |
321 | + | |
322 | + /* Parse out (file#,deptype,N,EVR,Flags) */ | |
323 | + ix = strtol(s, &se, 10); | |
324 | + assert(se != NULL); | |
325 | + deptype = *se++; | |
326 | + se++; | |
327 | + N = se; | |
328 | + while (*se && *se != ' ') | |
329 | + se++; | |
330 | + *se++ = '\0'; | |
331 | + EVR = se; | |
332 | + while (*se && *se != ' ') | |
333 | + se++; | |
334 | + *se++ = '\0'; | |
335 | + Flags = strtol(se, NULL, 16); | |
336 | + | |
337 | + if (deptype!='R') continue; | |
338 | + | |
d327d730 | 339 | + rpmMessage(RPMMESS_DEBUG, _("#%i requires: %s,%s,%i\n"),ix,N,EVR,Flags); |
5f8c53f0 | 340 | + if (EVR && EVR[0]) { |
d327d730 | 341 | + rpmMessage(RPMMESS_DEBUG, _("skipping #%i require\n")); |
5f8c53f0 JK |
342 | + continue; |
343 | + } | |
344 | + for(j=0;j<noautoreqdep_c;j++) | |
345 | + if (!regexec(&noautoreqdep[j],N,0,NULL,0)) { | |
346 | + rpmMessage(RPMMESS_NORMAL, | |
d327d730 JB |
347 | + _("skipping %s requirement processing" |
348 | + " (matches noautoreqdep pattern #%i)\n"),N,j); | |
5f8c53f0 JK |
349 | + break; |
350 | + } | |
351 | + if (j<noautoreqdep_c) continue; | |
352 | + if (N[0]=='/') { | |
d327d730 | 353 | + rpmMessage(RPMMESS_DEBUG, _("skipping #%i require (is file requirement)\n")); |
5f8c53f0 JK |
354 | + continue; |
355 | + } | |
356 | + it=rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, N, 0); | |
357 | + if (!it) { | |
d327d730 | 358 | + rpmMessage(RPMMESS_DEBUG, _("%s -> not found\n"),N); |
5f8c53f0 JK |
359 | + continue; |
360 | + } | |
d327d730 | 361 | + rpmMessage(RPMMESS_DEBUG, _("Iterator: %p\n"),it); |
5f8c53f0 | 362 | + if (rpmdbGetIteratorCount(it)>1) { |
d327d730 | 363 | + rpmMessage(RPMMESS_DEBUG, _("%s -> multiple (skipping)\n"),N); |
5f8c53f0 JK |
364 | + rpmdbFreeIterator(it); |
365 | + continue; | |
366 | + } | |
367 | + hdr=rpmdbNextIterator(it); | |
368 | + assert(hdr!=NULL); | |
369 | + r=rpmHeaderGetEntry(hdr,RPMTAG_NAME,NULL,(void **)&hname, NULL); | |
370 | + assert(r<2); | |
371 | + if (!strcmp(hname,N)) { | |
d327d730 | 372 | + rpmMessage(RPMMESS_DEBUG, _("%s -> %s (skipping)\n"),N,hname); |
5f8c53f0 JK |
373 | + rpmdbFreeIterator(it); |
374 | + continue; | |
375 | + } | |
376 | + | |
377 | + rpmMessage(RPMMESS_DEBUG, "%s -> %s\n",N,hname); | |
378 | + | |
379 | + ds = rpmdsSingle(RPMTAG_REQUIRENAME, hname, "", RPMSENSE_FIND_REQUIRES); | |
380 | + xx = rpmdsMerge(&fc->requires, ds); | |
381 | + ds = rpmdsFree(ds); | |
382 | + | |
383 | + rpmdbFreeIterator(it); | |
384 | + } | |
385 | + | |
386 | + noautoreqdep=rpmfcFreeRegexps(noautoreqdep,noautoreqdep_c); | |
387 | + ts = rpmtsFree(ts); | |
388 | + return 0; | |
389 | +} | |
390 | + | |
391 | int rpmfcApply(rpmfc fc) | |
392 | { | |
393 | rpmfcApplyTbl fcat; | |
394 | @@ -1075,6 +1263,21 @@ | |
395 | int ix; | |
396 | int i; | |
397 | int xx; | |
398 | + int j; | |
399 | + int findprov; | |
400 | + int findreq; | |
401 | + regex_t *noautoreqfiles=NULL; | |
402 | + int noautoreqfiles_c; | |
403 | + regex_t *noautoprovfiles=NULL; | |
404 | + int noautoprovfiles_c; | |
405 | + const char *buildroot; | |
406 | + int buildroot_l; | |
407 | + | |
408 | + buildroot=rpmExpand("%{buildroot}",NULL); | |
409 | + buildroot_l=strlen(buildroot); | |
410 | + | |
411 | + noautoreqfiles=rpmfcExpandRegexps("%{_noautoreqfiles}",&noautoreqfiles_c); | |
412 | + noautoprovfiles=rpmfcExpandRegexps("%{_noautoprovfiles}",&noautoprovfiles_c); | |
413 | ||
414 | /* Generate package and per-file dependencies. */ | |
415 | for (fc->ix = 0; fc->fn[fc->ix] != NULL; fc->ix++) { | |
416 | @@ -1082,10 +1285,41 @@ | |
417 | for (fcat = rpmfcApplyTable; fcat->func != NULL; fcat++) { | |
418 | if (!(fc->fcolor->vals[fc->ix] & fcat->colormask)) | |
419 | /*@innercontinue@*/ continue; | |
420 | - xx = (*fcat->func) (fc); | |
421 | + findprov=1; | |
422 | + findreq=1; | |
423 | + if (strncmp(fc->fn[fc->ix],buildroot,buildroot_l)==0) {/* sanity check */ | |
424 | + for(j=0;j<noautoprovfiles_c;j++) { | |
425 | + if (!regexec(&noautoprovfiles[j], | |
426 | + fc->fn[fc->ix]+buildroot_l,0,NULL,0)) { | |
427 | + rpmMessage(RPMMESS_NORMAL, | |
d327d730 JB |
428 | + _("skipping %s provides detection" |
429 | + " (matches noautoprovfiles pattern #%i)\n"), | |
5f8c53f0 JK |
430 | + fc->fn[fc->ix],j); |
431 | + findprov=0; | |
432 | + break; | |
433 | + } | |
434 | + } | |
435 | + for(j=0;j<noautoreqfiles_c;j++) { | |
436 | + if (!regexec(&noautoreqfiles[j], | |
437 | + fc->fn[fc->ix]+buildroot_l,0,NULL,0)) { | |
438 | + rpmMessage(RPMMESS_NORMAL, | |
d327d730 JB |
439 | + _("skipping %s requires detection" |
440 | + " (matches noautoreqfiles pattern #%i)\n"), | |
5f8c53f0 JK |
441 | + fc->fn[fc->ix],j); |
442 | + findreq=0; | |
443 | + break; | |
444 | + } | |
445 | + } | |
446 | + } | |
447 | + xx = (*fcat->func) (fc,findprov,findreq); | |
448 | } | |
449 | } | |
450 | ||
451 | + noautoreqfiles=rpmfcFreeRegexps(noautoreqfiles,noautoreqfiles_c); | |
452 | + noautoprovfiles=rpmfcFreeRegexps(noautoprovfiles,noautoprovfiles_c); | |
453 | + | |
454 | + rpmfcFindRequiredPackages(fc); | |
455 | + | |
456 | /*@-boundswrite@*/ | |
457 | /* Generate per-file indices into package dependencies. */ | |
458 | nddict = argvCount(fc->ddict); | |
d327d730 JB |
459 | --- rpm-4.3/po/POTFILES.in.orig 2004-01-04 03:13:02.000000000 +0100 |
460 | +++ rpm-4.3/po/POTFILES.in 2004-02-01 21:05:50.567248776 +0100 | |
461 | @@ -22,6 +22,7 @@ | |
462 | build/parseSpec.c | |
463 | build/poptBT.c | |
464 | build/reqprov.c | |
465 | +build/rpmfc.c | |
466 | build/spec.c | |
467 | lib/cpio.c | |
468 | lib/depends.c | |
469 | --- rpm-4.3/po/pl.po.orig 2004-02-01 20:53:10.000000000 +0100 | |
470 | +++ rpm-4.3/po/pl.po 2004-02-01 21:20:36.532561576 +0100 | |
471 | @@ -1295,6 +1295,127 @@ | |
472 | msgid "lookup i18N strings in specfile catalog" | |
473 | msgstr "wyszukaj wpisy I18N w katalogu pliku spec" | |
474 | ||
475 | +#: build/rpmfc.c:94 | |
476 | +#, c-format | |
477 | +msgid "\texecv(%s) pid %d\n" | |
478 | +msgstr "\texecv(%s) pid %d\n" | |
479 | + | |
480 | +#. XXX this error message is probably not seen. | |
481 | +#: build/rpmfc.c:100 | |
482 | +#, c-format | |
483 | +msgid "Couldn't exec %s: %s\n" | |
484 |