]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-pld-autodep.patch
e4a6d72bec128cb23cd9ad4db48c820e2a608c47
[packages/rpm.git] / rpm-pld-autodep.patch
1 --- rpm-4.4.8/lib/rpmfc.h.orig  2005-11-18 23:08:14.231293000 +0100
2 +++ rpm-4.4.8/lib/rpmfc.h       2005-11-18 23:55:16.694214392 +0100
3 @@ -1,6 +1,7 @@
4  #ifndef _H_RPMFC_
5  #define _H_RPMFC_
6  
7 +#include <regex.h>
8  #undef FILE_RCSID
9  #include "magic.h"
10  
11 @@ -44,6 +45,11 @@
12      StringBuf sb_python;/*!< concatenated list of python colored files. */
13      StringBuf sb_php;   /*!< concatenated list of php colored files. */
14  
15 +    int findprov, findreq;
16 +    regex_t *noautoprov;
17 +    int noautoprov_c;
18 +    regex_t *noautoreq;
19 +    int noautoreq_c;
20  };
21  
22  /**
23 --- rpm-4.4.8/lib/rpmfc.c.orig  2007-04-08 18:54:35.134367044 +0200
24 +++ rpm-4.4.8/lib/rpmfc.c       2007-04-08 19:10:18.196109070 +0200
25 @@ -11,6 +11,8 @@
26  #define        _RPMDS_INTERNAL
27  #include <rpmds.h>
28  #include <rpmfi.h>
29 +#include <rpmts.h>
30 +#include <rpmdb.h>
31  
32  #include "debug.h"
33  
34 @@ -305,14 +307,83 @@
35      return buf;
36  };
37  
38 +static regex_t * rpmfcExpandRegexps(const char * str,int *count){
39 +    int i,j,r;
40 +    const char *s;
41 +    ARGV_t patterns=NULL;
42 +    regex_t *compiled=NULL;
43 +
44 +    s=rpmExpand(str,NULL);
45 +    if (s) {
46 +       poptParseArgvString(s,count,(const char ***)&patterns);
47 +       s = _free(s);
48 +    }
49 +    if (patterns==NULL){
50 +               *count=0;
51 +       return NULL;
52 +    }
53 +    if (*count==0){
54 +       _free(patterns);
55 +       return NULL;
56 +    }
57 +
58 +    compiled=malloc(sizeof(regex_t)*(*count));
59 +    j=0;
60 +    for(i=0;i<*count;i++){
61 +       r=regcomp(&compiled[j],patterns[i],REG_NOSUB);
62 +       if (r==0) j++;
63 +       else {
64 +               rpmMessage(RPMMESS_NORMAL, 
65 +                       _("Compilation of regular expresion '%s'"
66 +                       " (expanded from '%s') failed. Skipping it.\n"),
67 +                       patterns[i],str);
68 +       }
69 +    }
70 +    patterns=_free(patterns);
71 +    if (j==0) {
72 +       compiled=_free(compiled);
73 +       *count=0;
74 +       return NULL;
75 +    }
76 +    *count=j;
77 +    return compiled;
78 +}
79 +
80 +static int rpmfcMatchRegexps(regex_t *regexps, int count, const char *str, char deptype)
81 +{
82 +    int j;
83 +    for(j = 0; j < count; j++) {
84 +       rpmMessage(RPMMESS_DEBUG,
85 +           _("Checking %c: '%s' against _noauto expr. #%i\n"), deptype, str, j);
86 +       if (!regexec(&regexps[j], str, 0, NULL, 0)) {
87 +           rpmMessage(RPMMESS_NORMAL,
88 +               _("Skipping %c: '%s' as it matches _noauto expr. #%i\n"), deptype, str, j);
89 +           return 1;
90 +       }
91 +    }
92 +    return 0;
93 +}
94 +
95 +static regex_t * rpmfcFreeRegexps(regex_t *regexps,int count){
96 +    int i;
97 +       
98 +    if (regexps)
99 +        for(i=0;i<count;i++)
100 +           regfree(&regexps[i]);
101 +    return _free(regexps);
102 +}
103 +
104  /**
105   * Run per-interpreter dependency helper.
106   * @param fc           file classifier
107   * @param deptype      'P' == Provides:, 'R' == Requires:, helper
108   * @param nsdep                class name for interpreter (e.g. "perl")
109 + * @param noauto       _noauto* regexps
110 + * @param noauto_c     # of _noauto* regexps
111   * @return             0 on success
112   */
113 -static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep)
114 +static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep,
115 +    regex_t * noauto, int noauto_c)
116         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
117         /*@modifies fc, rpmGlobalMacroContext, fileSystem, internalState @*/
118  {
119 @@ -398,6 +469,8 @@
120             }
121  /*@=branchstate@*/
122  
123 +           if(rpmfcMatchRegexps(noauto, noauto_c, N, deptype))
124 +               continue;
125  
126             /* Add tracking dependency for versioned Provides: */
127             if (!fc->tracked && deptype == 'P' && *EVR != '\0') {
128 @@ -710,7 +783,7 @@
129         *se = '\0';
130         se++;
131  
132 -       if (is_executable) {
133 +       if (is_executable && fc->findreq && !rpmfcMatchRegexps(fc->noautoreq, fc->noautoreq_c, s, 'R')) {
134             /* Add to package requires. */
135             ds = rpmdsSingle(RPMTAG_REQUIRENAME, s, "", RPMSENSE_FIND_REQUIRES);
136             xx = rpmdsMerge(&fc->requires, ds);
137 @@ -738,43 +811,51 @@
138      (void) fclose(fp);
139  
140      if (fc->fcolor->vals[fc->ix] & RPMFC_PERL) {
141 -       if (fc->fcolor->vals[fc->ix] & RPMFC_MODULE)
142 -           xx = rpmfcHelper(fc, 'P', "perl");
143 -       if (is_executable || (fc->fcolor->vals[fc->ix] & RPMFC_MODULE))
144 -           xx = rpmfcHelper(fc, 'R', "perl");
145 +       if (fc->findprov && (fc->fcolor->vals[fc->ix] & RPMFC_MODULE))
146 +           xx = rpmfcHelper(fc, 'P', "perl", fc->noautoprov, fc->noautoprov_c);
147 +       if (fc->findreq && (is_executable || (fc->fcolor->vals[fc->ix] & RPMFC_MODULE)))
148 +           xx = rpmfcHelper(fc, 'R', "perl", fc->noautoreq, fc->noautoreq_c);
149      } else
150      if (fc->fcolor->vals[fc->ix] & RPMFC_PYTHON) {
151 -       xx = rpmfcHelper(fc, 'P', "python");
152 +       if (fc->findprov)
153 +       xx = rpmfcHelper(fc, 'P', "python", fc->noautoprov, fc->noautoprov_c);
154  #ifdef NOTYET
155         if (is_executable)
156  #endif
157 -           xx = rpmfcHelper(fc, 'R', "python");
158 +       if (fc->findreq)
159 +           xx = rpmfcHelper(fc, 'R', "python", fc->noautoreq, fc->noautoreq_c);
160      } else
161      if (fc->fcolor->vals[fc->ix] & RPMFC_LIBTOOL) {
162 -       xx = rpmfcHelper(fc, 'P', "libtool");
163 +       if (fc->findprov)
164 +       xx = rpmfcHelper(fc, 'P', "libtool", fc->noautoprov, fc->noautoprov_c);
165  #ifdef NOTYET
166         if (is_executable)
167  #endif
168 -           xx = rpmfcHelper(fc, 'R', "libtool");
169 +       if (fc->findreq)
170 +           xx = rpmfcHelper(fc, 'R', "libtool", fc->noautoreq, fc->noautoreq_c);
171      } else
172      if (fc->fcolor->vals[fc->ix] & RPMFC_PKGCONFIG) {
173 -       xx = rpmfcHelper(fc, 'P', "pkgconfig");
174 +       if (fc->findprov)
175 +       xx = rpmfcHelper(fc, 'P', "pkgconfig", fc->noautoprov, fc->noautoprov_c);
176  #ifdef NOTYET
177         if (is_executable)
178  #endif
179 -           xx = rpmfcHelper(fc, 'R', "pkgconfig");
180 +       if (fc->findreq)
181 +           xx = rpmfcHelper(fc, 'R', "pkgconfig", fc->noautoreq, fc->noautoreq_c);
182      } else
183      if (fc->fcolor->vals[fc->ix] & RPMFC_BOURNE) {
184  #ifdef NOTYET
185         xx = rpmfcHelper(fc, 'P', "executable");
186  #endif
187 -       if (is_executable)
188 -           xx = rpmfcHelper(fc, 'R', "executable");
189 +       if (fc->findreq && is_executable)
190 +           xx = rpmfcHelper(fc, 'R', "executable", fc->noautoreq, fc->noautoreq_c);
191      } else
192      if (fc->fcolor->vals[fc->ix] & RPMFC_PHP) {
193 -       xx = rpmfcHelper(fc, 'P', "php");
194 +       if (fc->findprov)
195 +       xx = rpmfcHelper(fc, 'P', "php", fc->noautoprov, fc->noautoprov_c);
196         /* not only executable, files run by httpd usually are not */
197 -           xx = rpmfcHelper(fc, 'R', "php");
198 +       if (fc->findreq)
199 +           xx = rpmfcHelper(fc, 'R', "php", fc->noautoreq, fc->noautoreq_c);
200      }
201  
202      return 0;
203 @@ -802,20 +883,26 @@
204      default:
205         break;
206      case RPMTAG_PROVIDENAME:
207 +       if (fc->findprov && !rpmfcMatchRegexps(fc->noautoprov, fc->noautoprov_c, ds->N[0], 'P')) {
208         /* Add to package provides. */
209         rc = rpmdsMerge(&fc->provides, ds);
210  
211         /* Add to file dependencies. */
212         buf[0] = '\0';
213         rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
214 +       } else
215 +               rc = 0;
216         break;
217      case RPMTAG_REQUIRENAME:
218 +       if (fc->findreq && !rpmfcMatchRegexps(fc->noautoreq, fc->noautoreq_c, ds->N[0], 'R')) {
219         /* Add to package requires. */
220         rc = rpmdsMerge(&fc->requires, ds);
221  
222         /* Add to file dependencies. */
223         buf[0] = '\0';
224         rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
225 +       } else
226 +               rc = 0;
227         break;
228      }
229      return rc;
230 @@ -856,6 +943,109 @@
231      { NULL, 0 }
232  };
233  
234 +static int rpmfcFindRequiredPackages(rpmfc fc) 
235 +{
236 +    rpmts ts=NULL;
237 +    const char * s;
238 +    char * se;
239 +    rpmds ds;
240 +    const char * N;
241 +    const char * EVR;
242 +    int_32 Flags;
243 +    unsigned char deptype;
244 +    int nddict;
245 +    int previx;
246 +    int ix;
247 +    int i;
248 +    int j;
249 +    int xx;
250 +    int r;
251 +    const char * hname;
252 +    rpmdbMatchIterator it;
253 +    Header hdr;
254 +    regex_t *noautoreqdep;
255 +    int noautoreqdep_c;
256 +
257 +    noautoreqdep=rpmfcExpandRegexps("%{__noautoreqdep}", &noautoreqdep_c);
258 +    
259 +    ts = rpmtsCreate(); /* XXX ts created in main() should be used */
260 +    
261 +    rpmMessage(RPMMESS_NORMAL, _("Searching for required packages....\n"));
262 +
263 +    nddict = argvCount(fc->ddict);
264 +    previx = -1;
265 +    for (i = 0; i < nddict; i++) {
266 +        s = fc->ddict[i];
267 +
268 +        /* Parse out (file#,deptype,N,EVR,Flags) */
269 +        ix = strtol(s, &se, 10);
270 +        assert(se != NULL);
271 +        deptype = *se++;
272 +        se++;
273 +        N = se;
274 +        while (*se && *se != ' ')
275 +            se++;
276 +        *se++ = '\0';
277 +        EVR = se;
278 +        while (*se && *se != ' ')
279 +            se++;
280 +        *se++ = '\0';
281 +        Flags = strtol(se, NULL, 16);
282 +
283 +        if (deptype!='R') continue;
284 +
285 +        rpmMessage(RPMMESS_DEBUG, _("#%i requires: %s,%s,%i\n"),ix,N,EVR,Flags);
286 +        if (EVR && EVR[0]) {
287 +            rpmMessage(RPMMESS_DEBUG, _("skipping #%i require\n"));
288 +            continue;
289 +        }
290 +        for(j=0;j<noautoreqdep_c;j++) 
291 +            if (!regexec(&noautoreqdep[j],N,0,NULL,0)) {
292 +                rpmMessage(RPMMESS_NORMAL, 
293 +                        _("skipping %s requirement processing"
294 +                       " (matches noautoreqdep pattern #%i)\n"),N,j);
295 +                break;
296 +            }
297 +        if (j<noautoreqdep_c) continue;
298 +        if (N[0]=='/') {
299 +            rpmMessage(RPMMESS_DEBUG, _("skipping #%i require (is file requirement)\n"));
300 +            continue;
301 +        }
302 +        it=rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, N, 0);
303 +        if (!it) {
304 +            rpmMessage(RPMMESS_DEBUG, _("%s -> not found\n"),N);
305 +            continue;
306 +        }
307 +        rpmMessage(RPMMESS_DEBUG, _("Iterator: %p\n"),it);
308 +        if (rpmdbGetIteratorCount(it)>1) {
309 +            rpmMessage(RPMMESS_DEBUG, _("%s -> multiple (skipping)\n"),N);
310 +            rpmdbFreeIterator(it);
311 +            continue;
312 +        }
313 +        hdr=rpmdbNextIterator(it);
314 +        assert(hdr!=NULL);
315 +        r=headerGetEntry(hdr,RPMTAG_NAME,NULL,(void **)&hname, NULL);
316 +        assert(r<2);
317 +        if (!strcmp(hname,N)) {
318 +            rpmMessage(RPMMESS_DEBUG, _("%s -> %s (skipping)\n"),N,hname);
319 +            rpmdbFreeIterator(it);
320 +            continue;
321 +        }
322 +            
323 +        rpmMessage(RPMMESS_DEBUG, "%s -> %s\n",N,hname);
324 +        
325 +               ds = rpmdsSingle(RPMTAG_REQUIRENAME, hname, "", RPMSENSE_FIND_REQUIRES);
326 +               xx = rpmdsMerge(&fc->requires, ds);
327 +               ds = rpmdsFree(ds);
328 +
329 +        rpmdbFreeIterator(it);
330 +    }
331 +
332 +    noautoreqdep = rpmfcFreeRegexps(noautoreqdep, noautoreqdep_c);
333 +    ts = rpmtsFree(ts);
334 +    return 0;
335 +}
336 +
337  int rpmfcApply(rpmfc fc)
338  {
339      rpmfcApplyTbl fcat;
340 @@ -874,6 +1064,26 @@
341      int i;
342      int xx;
343      int skipping;
344 +    int j;
345 +    regex_t *noautoprovfiles = NULL;
346 +    int noautoprovfiles_c;
347 +    regex_t *noautoreqfiles = NULL;
348 +    int noautoreqfiles_c;
349 +    const char *buildroot;
350 +    int buildroot_l;
351 +
352 +    fc->noautoprov = NULL;
353 +    fc->noautoreq = NULL;
354 +
355 +    buildroot = rpmExpand("%{buildroot}",NULL);
356 +    buildroot_l = strlen(buildroot);
357 +    
358 +    noautoprovfiles = rpmfcExpandRegexps("%{__noautoprovfiles}", &noautoprovfiles_c);
359 +    noautoreqfiles = rpmfcExpandRegexps("%{__noautoreqfiles}", &noautoreqfiles_c);
360 +    fc->noautoprov = rpmfcExpandRegexps("%{__noautoprov}", &fc->noautoprov_c);
361 +    fc->noautoreq = rpmfcExpandRegexps("%{__noautoreq}", &fc->noautoreq_c);
362 +    rpmMessage(RPMMESS_DEBUG, _("%i _noautoprov patterns.\n"), fc->noautoprov_c);
363 +    rpmMessage(RPMMESS_DEBUG, _("%i _noautoreq patterns.\n"), fc->noautoreq_c);
364  
365      /* Generate package and per-file dependencies. */
366      for (fc->ix = 0; fc->fn[fc->ix] != NULL; fc->ix++) {
367 @@ -894,9 +1104,43 @@
368         for (fcat = rpmfcApplyTable; fcat->func != NULL; fcat++) {
369             if (!(fc->fcolor->vals[fc->ix] & fcat->colormask))
370                 /*@innercontinue@*/ continue;
371 +           fc->findprov = 1;
372 +           fc->findreq = 1;
373 +           if (strncmp(fc->fn[fc->ix],buildroot,buildroot_l)==0) {/* sanity check */
374 +                   for(j = 0; j < noautoprovfiles_c; j++) {
375 +                           if (!regexec(&noautoprovfiles[j],
376 +                                                   fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
377 +                                   rpmMessage(RPMMESS_NORMAL,
378 +                                                   _("skipping %s provides detection"
379 +                                                           " (matches noautoprovfiles pattern #%i)\n"),
380 +                                                   fc->fn[fc->ix], j);
381 +                                   fc->findprov = 0;
382 +                                   break;
383 +                           }
384 +                   }
385 +                   for(j = 0; j < noautoreqfiles_c; j++) {
386 +                           if (!regexec(&noautoreqfiles[j],
387 +                                                   fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
388 +                                   rpmMessage(RPMMESS_NORMAL,
389 +                                                   _("skipping %s requires detection"
390 +                                                           " (matches noautoreqfiles pattern #%i)\n"),
391 +                                                   fc->fn[fc->ix], j);
392 +                                   fc->findreq = 0;
393 +                                   break;
394 +                           }
395 +                   }
396 +           }
397 +
398             xx = (*fcat->func) (fc);
399         }
400      }
401 +    noautoprovfiles = rpmfcFreeRegexps(noautoprovfiles, noautoprovfiles_c);
402 +    noautoreqfiles = rpmfcFreeRegexps(noautoreqfiles, noautoreqfiles_c);
403 +    fc->noautoprov = rpmfcFreeRegexps(fc->noautoprov, fc->noautoprov_c);
404 +    fc->noautoreq = rpmfcFreeRegexps(fc->noautoreq, fc->noautoreq_c);
405 +#ifdef AUTODEP_PKGNAMES /* define to use package names in R */
406 +    rpmfcFindRequiredPackages(fc);
407 +#endif
408  
409  /*@-boundswrite@*/
410      /* Generate per-file indices into package dependencies. */
411 --- rpm-4.3/po/pl.po.orig       2004-02-01 20:53:10.000000000 +0100
412 +++ rpm-4.3/po/pl.po    2004-02-01 21:20:36.532561576 +0100
413 @@ -1295,6 +1295,86 @@
414  msgid "lookup i18N strings in specfile catalog"
415  msgstr "wyszukaj wpisy I18N w katalogu pliku spec"
416  
417 +#: lib/rpmfc.c:334
418 +#, c-format
419 +msgid "Compilation of regular expresion '%s' (expanded from '%s') failed. Skipping it.\n"
420 +msgstr "Kompilacja wyra¿enia regularnego '%s' (powsta³ego z '%s') nie powiod³a siê; pominiêto.\n"
421 +
422 +#: lib/rpmfc.c:395
423 +#, c-format
424 +msgid "%i _noautoprov patterns.\n"
425 +msgstr "%i wzorców _noautoprov.\n"
426 +
427 +#: lib/rpmfc.c:405
428 +#, c-format
429 +msgid "%i _noautoreq patterns.\n"
430 +msgstr "%i wzorców _noautoreq.\n"
431 +
432 +#: lib/rpmfc.c:459
433 +#, c-format
434 +msgid "Checking %c: '%s' against _noauto expr. #%i\n"
435 +msgstr "Sprawdzanie %c: '%s' z wyra¿eniem _noauto #%i\n"
436 +
437 +#: lib/rpmfc.c:462
438 +#, c-format
439 +msgid "Skipping %c: '%s' as it matches _noauto expr. #%i\n"
440 +msgstr "Pominiêto %c: '%s' pasuj±ce do wyra¿enia _noauto #%i\n"
441 +
442 +#. XXX ts created in main() should be used
443 +#: lib/rpmfc.c:1173
444 +msgid "Searching for required packages....\n"
445 +msgstr "Poszukiwanie wymaganych pakietów...\n"
446 +
447 +#: lib/rpmfc.c:1197
448 +#, c-format
449 +msgid "#%i requires: %s,%s,%i\n"
450 +msgstr "#%i wymaga: %s,%s,%i\n"
451 +
452 +#: lib/rpmfc.c:1199
453 +#, c-format
454 +msgid "skipping #%i require\n"
455 +msgstr "pominiêto zale¿no¶æ #%i\n"
456 +
457 +#: lib/rpmfc.c:1205
458 +#, c-format
459 +msgid "skipping %s requirement processing (matches noautoreqdep pattern #%i)\n"
460 +msgstr "pominiêto przetwarzanie zale¿no¶ci %s (pasuje do wzorca noautoreqdep #%i)\n"
461 +
462 +#: lib/rpmfc.c:1211
463 +#, c-format
464 +msgid "skipping #%i require (is file requirement)\n"
465 +msgstr "pominiêto zale¿no¶æ #%i (zale¿no¶æ od pliku)\n"
466 +
467 +#: lib/rpmfc.c:1216
468 +#, c-format
469 +msgid "%s -> not found\n"
470 +msgstr "%s -> nie znaleziono\n"
471 +
472 +#: lib/rpmfc.c:1219
473 +#, c-format
474 +msgid "Iterator: %p\n"
475 +msgstr "Iterator: %p\n"
476 +
477 +#: lib/rpmfc.c:1221
478 +#, c-format
479 +msgid "%s -> multiple (skipping)\n"
480 +msgstr "%s -> wiele (pominiêto)\n"
481 +
482 +#: lib/rpmfc.c:1230
483 +#, c-format
484 +msgid "%s -> %s (skipping)\n"
485 +msgstr "%s -> %s (pominiêto)\n"
486 +
487 +#: lib/rpmfc.c:1295
488 +#, c-format
489 +msgid "skipping %s provides detection (matches noautoprovfiles pattern #%i)\n"
490 +msgstr "pominiêto wykrywanie w³asno¶ci %s (pasuje do wzorca noautoprovfiles #%i)\n"
491 +
492 +#: lib/rpmfc.c:1306
493 +#, c-format
494 +msgid "skipping %s requires detection (matches noautoreqfiles pattern #%i)\n"
495 +msgstr "pominiêto wykrywanie w³asno¶ci %s (pasuje do wzorca noautoreqfiles #%i)\n"
496 +
497  #: build/spec.c:237
498  #, c-format
499  msgid "line %d: Bad number: %s\n"
500 --- rpm/configure.ac.orig       2004-08-22 13:02:30.000000000 +0200
501 +++ rpm/configure.ac    2004-08-22 13:25:37.000000000 +0200
502 @@ -971,6 +971,18 @@
503  AC_SUBST(__CHGRP_RHF)
504  
505  dnl
506 +dnl enable generating autorequires containing packages names 
507 +dnl
508 +AC_ARG_ENABLE([adding-packages-names-in-autogenerated-dependancies],
509 +             [  --enable-adding-packages-names-in-autogenerated-dependancies   Add packages names for autogenerated dependancies to requires],
510 +        
511 +               AC_MSG_RESULT([Using packages names in autogerated requires is enabled])
512 +               AC_DEFINE(AUTODEP_PKGNAMES, 1, "Generating autorequires containing packages names.") 
513 +       
514 +             )
515 +
516 +
517 +dnl
518  dnl figure out what root's primary group is
519  dnl
520  AC_MSG_CHECKING(root's primary group)
This page took 0.068076 seconds and 3 git commands to generate.