]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-pld-autodep.patch
- no provides script currently on HEAD
[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.9/lib/rpmfc.c.orig  2007-05-22 08:11:41.155736775 +0200
24 +++ rpm-4.4.9/lib/rpmfc.c       2007-05-22 08:23:39.964699364 +0200
25 @@ -15,6 +15,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 @@ -309,14 +311,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 @@ -402,6 +473,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 @@ -714,7 +787,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 @@ -743,44 +816,52 @@
138  
139      if (fc->fcolor->vals[fc->ix] & RPMFC_PERL) {
140         if (strncmp(fn, "/usr/share/doc/", sizeof("/usr/share/doc/")-1)) {
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         }
150      } else
151      if (fc->fcolor->vals[fc->ix] & RPMFC_PYTHON) {
152 -       xx = rpmfcHelper(fc, 'P', "python");
153 +       if (fc->findprov)
154 +       xx = rpmfcHelper(fc, 'P', "python", fc->noautoprov, fc->noautoprov_c);
155  #ifdef NOTYET
156         if (is_executable)
157  #endif
158 -           xx = rpmfcHelper(fc, 'R', "python");
159 +       if (fc->findreq)
160 +           xx = rpmfcHelper(fc, 'R', "python", fc->noautoreq, fc->noautoreq_c);
161      } else
162      if (fc->fcolor->vals[fc->ix] & RPMFC_LIBTOOL) {
163 -       xx = rpmfcHelper(fc, 'P', "libtool");
164 +       if (fc->findprov)
165 +       xx = rpmfcHelper(fc, 'P', "libtool", fc->noautoprov, fc->noautoprov_c);
166  #ifdef NOTYET
167         if (is_executable)
168  #endif
169 -           xx = rpmfcHelper(fc, 'R', "libtool");
170 +       if (fc->findreq)
171 +           xx = rpmfcHelper(fc, 'R', "libtool", fc->noautoreq, fc->noautoreq_c);
172      } else
173      if (fc->fcolor->vals[fc->ix] & RPMFC_PKGCONFIG) {
174 -       xx = rpmfcHelper(fc, 'P', "pkgconfig");
175 +       if (fc->findprov)
176 +       xx = rpmfcHelper(fc, 'P', "pkgconfig", fc->noautoprov, fc->noautoprov_c);
177  #ifdef NOTYET
178         if (is_executable)
179  #endif
180 -           xx = rpmfcHelper(fc, 'R', "pkgconfig");
181 +       if (fc->findreq)
182 +           xx = rpmfcHelper(fc, 'R', "pkgconfig", fc->noautoreq, fc->noautoreq_c);
183      } else
184      if (fc->fcolor->vals[fc->ix] & RPMFC_BOURNE) {
185  #ifdef NOTYET
186         xx = rpmfcHelper(fc, 'P', "executable");
187  #endif
188 -       if (is_executable)
189 -           xx = rpmfcHelper(fc, 'R', "executable");
190 +       if (fc->findreq && is_executable)
191 +           xx = rpmfcHelper(fc, 'R', "executable", fc->noautoreq, fc->noautoreq_c);
192      } else
193      if (fc->fcolor->vals[fc->ix] & RPMFC_PHP) {
194 -       xx = rpmfcHelper(fc, 'P', "php");
195 +       if (fc->findprov)
196 +       xx = rpmfcHelper(fc, 'P', "php", fc->noautoprov, fc->noautoprov_c);
197         /* not only executable, files run by httpd usually are not */
198 -           xx = rpmfcHelper(fc, 'R', "php");
199 +       if (fc->findreq)
200 +           xx = rpmfcHelper(fc, 'R', "php", fc->noautoreq, fc->noautoreq_c);
201      }
202  
203      return 0;
204 @@ -808,20 +889,26 @@
205      default:
206         break;
207      case RPMTAG_PROVIDENAME:
208 +       if (fc->findprov && !rpmfcMatchRegexps(fc->noautoprov, fc->noautoprov_c, ds->N[0], 'P')) {
209         /* Add to package provides. */
210         rc = rpmdsMerge(&fc->provides, ds);
211  
212         /* Add to file dependencies. */
213         buf[0] = '\0';
214         rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
215 +       } else
216 +               rc = 0;
217         break;
218      case RPMTAG_REQUIRENAME:
219 +       if (fc->findreq && !rpmfcMatchRegexps(fc->noautoreq, fc->noautoreq_c, ds->N[0], 'R')) {
220         /* Add to package requires. */
221         rc = rpmdsMerge(&fc->requires, ds);
222  
223         /* Add to file dependencies. */
224         buf[0] = '\0';
225         rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
226 +       } else
227 +               rc = 0;
228         break;
229      }
230      return rc;
231 @@ -862,6 +949,109 @@
232      { NULL, 0 }
233  };
234  
235 +static int rpmfcFindRequiredPackages(rpmfc fc) 
236 +{
237 +    rpmts ts=NULL;
238 +    const char * s;
239 +    char * se;
240 +    rpmds ds;
241 +    const char * N;
242 +    const char * EVR;
243 +    int_32 Flags;
244 +    unsigned char deptype;
245 +    int nddict;
246 +    int previx;
247 +    int ix;
248 +    int i;
249 +    int j;
250 +    int xx;
251 +    int r;
252 +    const char * hname;
253 +    rpmdbMatchIterator it;
254 +    Header hdr;
255 +    regex_t *noautoreqdep;
256 +    int noautoreqdep_c;
257 +
258 +    noautoreqdep=rpmfcExpandRegexps("%{__noautoreqdep}", &noautoreqdep_c);
259 +    
260 +    ts = rpmtsCreate(); /* XXX ts created in main() should be used */
261 +    
262 +    rpmMessage(RPMMESS_NORMAL, _("Searching for required packages....\n"));
263 +
264 +    nddict = argvCount(fc->ddict);
265 +    previx = -1;
266 +    for (i = 0; i < nddict; i++) {
267 +        s = fc->ddict[i];
268 +
269 +        /* Parse out (file#,deptype,N,EVR,Flags) */
270 +        ix = strtol(s, &se, 10);
271 +        assert(se != NULL);
272 +        deptype = *se++;
273 +        se++;
274 +        N = se;
275 +        while (*se && *se != ' ')
276 +            se++;
277 +        *se++ = '\0';
278 +        EVR = se;
279 +        while (*se && *se != ' ')
280 +            se++;
281 +        *se++ = '\0';
282 +        Flags = strtol(se, NULL, 16);
283 +
284 +        if (deptype!='R') continue;
285 +
286 +        rpmMessage(RPMMESS_DEBUG, _("#%i requires: %s,%s,%i\n"),ix,N,EVR,Flags);
287 +        if (EVR && EVR[0]) {
288 +            rpmMessage(RPMMESS_DEBUG, _("skipping #%i require\n"));
289 +            continue;
290 +        }
291 +        for(j=0;j<noautoreqdep_c;j++) 
292 +            if (!regexec(&noautoreqdep[j],N,0,NULL,0)) {
293 +                rpmMessage(RPMMESS_NORMAL, 
294 +                        _("skipping %s requirement processing"
295 +                       " (matches noautoreqdep pattern #%i)\n"),N,j);
296 +                break;
297 +            }
298 +        if (j<noautoreqdep_c) continue;
299 +        if (N[0]=='/') {
300 +            rpmMessage(RPMMESS_DEBUG, _("skipping #%i require (is file requirement)\n"));
301 +            continue;
302 +        }
303 +        it=rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, N, 0);
304 +        if (!it) {
305 +            rpmMessage(RPMMESS_DEBUG, _("%s -> not found\n"),N);
306 +            continue;
307 +        }
308 +        rpmMessage(RPMMESS_DEBUG, _("Iterator: %p\n"),it);
309 +        if (rpmdbGetIteratorCount(it)>1) {
310 +            rpmMessage(RPMMESS_DEBUG, _("%s -> multiple (skipping)\n"),N);
311 +            rpmdbFreeIterator(it);
312 +            continue;
313 +        }
314 +        hdr=rpmdbNextIterator(it);
315 +        assert(hdr!=NULL);
316 +        r=headerGetEntry(hdr,RPMTAG_NAME,NULL,(void **)&hname, NULL);
317 +        assert(r<2);
318 +        if (!strcmp(hname,N)) {
319 +            rpmMessage(RPMMESS_DEBUG, _("%s -> %s (skipping)\n"),N,hname);
320 +            rpmdbFreeIterator(it);
321 +            continue;
322 +        }
323 +            
324 +        rpmMessage(RPMMESS_DEBUG, "%s -> %s\n",N,hname);
325 +        
326 +               ds = rpmdsSingle(RPMTAG_REQUIRENAME, hname, "", RPMSENSE_FIND_REQUIRES);
327 +               xx = rpmdsMerge(&fc->requires, ds);
328 +               ds = rpmdsFree(ds);
329 +
330 +        rpmdbFreeIterator(it);
331 +    }
332 +
333 +    noautoreqdep = rpmfcFreeRegexps(noautoreqdep, noautoreqdep_c);
334 +    ts = rpmtsFree(ts);
335 +    return 0;
336 +}
337 +
338  int rpmfcApply(rpmfc fc)
339  {
340      rpmfcApplyTbl fcat;
341 @@ -880,6 +1070,26 @@
342      int i;
343      int xx;
344      int skipping;
345 +    int j;
346 +    regex_t *noautoprovfiles = NULL;
347 +    int noautoprovfiles_c;
348 +    regex_t *noautoreqfiles = NULL;
349 +    int noautoreqfiles_c;
350 +    const char *buildroot;
351 +    int buildroot_l;
352 +
353 +    fc->noautoprov = NULL;
354 +    fc->noautoreq = NULL;
355 +
356 +    buildroot = rpmExpand("%{buildroot}",NULL);
357 +    buildroot_l = strlen(buildroot);
358 +    
359 +    noautoprovfiles = rpmfcExpandRegexps("%{__noautoprovfiles}", &noautoprovfiles_c);
360 +    noautoreqfiles = rpmfcExpandRegexps("%{__noautoreqfiles}", &noautoreqfiles_c);
361 +    fc->noautoprov = rpmfcExpandRegexps("%{__noautoprov}", &fc->noautoprov_c);
362 +    fc->noautoreq = rpmfcExpandRegexps("%{__noautoreq}", &fc->noautoreq_c);
363 +    rpmMessage(RPMMESS_DEBUG, _("%i _noautoprov patterns.\n"), fc->noautoprov_c);
364 +    rpmMessage(RPMMESS_DEBUG, _("%i _noautoreq patterns.\n"), fc->noautoreq_c);
365  
366      /* Generate package and per-file dependencies. */
367      for (fc->ix = 0; fc->fn[fc->ix] != NULL; fc->ix++) {
368 @@ -900,9 +1110,43 @@
369         for (fcat = rpmfcApplyTable; fcat->func != NULL; fcat++) {
370             if (!(fc->fcolor->vals[fc->ix] & fcat->colormask))
371                 /*@innercontinue@*/ continue;
372 +           fc->findprov = 1;
373 +           fc->findreq = 1;
374 +           if (strncmp(fc->fn[fc->ix],buildroot,buildroot_l)==0) {/* sanity check */
375 +                   for(j = 0; j < noautoprovfiles_c; j++) {
376 +                           if (!regexec(&noautoprovfiles[j],
377 +                                                   fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
378 +                                   rpmMessage(RPMMESS_NORMAL,
379 +                                                   _("skipping %s provides detection"
380 +                                                           " (matches noautoprovfiles pattern #%i)\n"),
381 +                                                   fc->fn[fc->ix], j);
382 +                                   fc->findprov = 0;
383 +                                   break;
384 +                           }
385 +                   }
386 +                   for(j = 0; j < noautoreqfiles_c; j++) {
387 +                           if (!regexec(&noautoreqfiles[j],
388 +                                                   fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
389 +                                   rpmMessage(RPMMESS_NORMAL,
390 +                                                   _("skipping %s requires detection"
391 +                                                           " (matches noautoreqfiles pattern #%i)\n"),
392 +                                                   fc->fn[fc->ix], j);
393 +                                   fc->findreq = 0;
394 +                                   break;
395 +                           }
396 +                   }
397 +           }
398 +
399             xx = (*fcat->func) (fc);
400         }
401      }
402 +    noautoprovfiles = rpmfcFreeRegexps(noautoprovfiles, noautoprovfiles_c);
403 +    noautoreqfiles = rpmfcFreeRegexps(noautoreqfiles, noautoreqfiles_c);
404 +    fc->noautoprov = rpmfcFreeRegexps(fc->noautoprov, fc->noautoprov_c);
405 +    fc->noautoreq = rpmfcFreeRegexps(fc->noautoreq, fc->noautoreq_c);
406 +#ifdef AUTODEP_PKGNAMES /* define to use package names in R */
407 +    rpmfcFindRequiredPackages(fc);
408 +#endif
409  
410  /*@-boundswrite@*/
411      /* Generate per-file indices into package dependencies. */
412 --- rpm-4.4.9/po/pl.po.orig     2007-05-22 08:11:40.947724921 +0200
413 +++ rpm-4.4.9/po/pl.po  2007-05-22 08:24:24.091213990 +0200
414 @@ -2937,6 +2937,86 @@
415  msgid "Failed to find %s:\n"
416  msgstr "Nie uda³o siê odnale¼æ %s:\n"
417  
418 +#: lib/rpmfc.c:334
419 +#, c-format
420 +msgid "Compilation of regular expresion '%s' (expanded from '%s') failed. Skipping it.\n"
421 +msgstr "Kompilacja wyra¿enia regularnego '%s' (powsta³ego z '%s') nie powiod³a siê; pominiêto.\n"
422 +
423 +#: lib/rpmfc.c:395
424 +#, c-format
425 +msgid "%i _noautoprov patterns.\n"
426 +msgstr "%i wzorców _noautoprov.\n"
427 +
428 +#: lib/rpmfc.c:405
429 +#, c-format
430 +msgid "%i _noautoreq patterns.\n"
431 +msgstr "%i wzorców _noautoreq.\n"
432 +
433 +#: lib/rpmfc.c:459
434 +#, c-format
435 +msgid "Checking %c: '%s' against _noauto expr. #%i\n"
436 +msgstr "Sprawdzanie %c: '%s' z wyra¿eniem _noauto #%i\n"
437 +
438 +#: lib/rpmfc.c:462
439 +#, c-format
440 +msgid "Skipping %c: '%s' as it matches _noauto expr. #%i\n"
441 +msgstr "Pominiêto %c: '%s' pasuj±ce do wyra¿enia _noauto #%i\n"
442 +
443 +#. XXX ts created in main() should be used
444 +#: lib/rpmfc.c:1173
445 +msgid "Searching for required packages....\n"
446 +msgstr "Poszukiwanie wymaganych pakietów...\n"
447 +
448 +#: lib/rpmfc.c:1197
449 +#, c-format
450 +msgid "#%i requires: %s,%s,%i\n"
451 +msgstr "#%i wymaga: %s,%s,%i\n"
452 +
453 +#: lib/rpmfc.c:1199
454 +#, c-format
455 +msgid "skipping #%i require\n"
456 +msgstr "pominiêto zale¿no¶æ #%i\n"
457 +
458 +#: lib/rpmfc.c:1205
459 +#, c-format
460 +msgid "skipping %s requirement processing (matches noautoreqdep pattern #%i)\n"
461 +msgstr "pominiêto przetwarzanie zale¿no¶ci %s (pasuje do wzorca noautoreqdep #%i)\n"
462 +
463 +#: lib/rpmfc.c:1211
464 +#, c-format
465 +msgid "skipping #%i require (is file requirement)\n"
466 +msgstr "pominiêto zale¿no¶æ #%i (zale¿no¶æ od pliku)\n"
467 +
468 +#: lib/rpmfc.c:1216
469 +#, c-format
470 +msgid "%s -> not found\n"
471 +msgstr "%s -> nie znaleziono\n"
472 +
473 +#: lib/rpmfc.c:1219
474 +#, c-format
475 +msgid "Iterator: %p\n"
476 +msgstr "Iterator: %p\n"
477 +
478 +#: lib/rpmfc.c:1221
479 +#, c-format
480 +msgid "%s -> multiple (skipping)\n"
481 +msgstr "%s -> wiele (pominiêto)\n"
482 +
483 +#: lib/rpmfc.c:1230
484 +#, c-format
485 +msgid "%s -> %s (skipping)\n"
486 +msgstr "%s -> %s (pominiêto)\n"
487 +
488 +#: lib/rpmfc.c:1295
489 +#, c-format
490 +msgid "skipping %s provides detection (matches noautoprovfiles pattern #%i)\n"
491 +msgstr "pominiêto wykrywanie w³asno¶ci %s (pasuje do wzorca noautoprovfiles #%i)\n"
492 +
493 +#: lib/rpmfc.c:1306
494 +#, c-format
495 +msgid "skipping %s requires detection (matches noautoreqfiles pattern #%i)\n"
496 +msgstr "pominiêto wykrywanie w³asno¶ci %s (pasuje do wzorca noautoreqfiles #%i)\n"
497 +
498  #: lib/rpmfi.c:622
499  #, c-format
500  msgid "%s skipped due to missingok flag\n"
501 --- rpm/configure.ac.orig       2004-08-22 13:02:30.000000000 +0200
502 +++ rpm/configure.ac    2004-08-22 13:25:37.000000000 +0200
503 @@ -971,6 +971,18 @@
504  AC_SUBST(__CHGRP_RHF)
505  
506  dnl
507 +dnl enable generating autorequires containing packages names 
508 +dnl
509 +AC_ARG_ENABLE([adding-packages-names-in-autogenerated-dependancies],
510 +             [  --enable-adding-packages-names-in-autogenerated-dependancies   Add packages names for autogenerated dependancies to requires],
511 +        
512 +               AC_MSG_RESULT([Using packages names in autogerated requires is enabled])
513 +               AC_DEFINE(AUTODEP_PKGNAMES, 1, "Generating autorequires containing packages names.") 
514 +       
515 +             )
516 +
517 +
518 +dnl
519  dnl figure out what root's primary group is
520  dnl
521  AC_MSG_CHECKING(root's primary group)
This page took 0.087026 seconds and 3 git commands to generate.