]> git.pld-linux.org Git - packages/rpm.git/blame_incremental - rpm-pld-autodep.patch
- missing line continuation
[packages/rpm.git] / rpm-pld-autodep.patch
... / ...
CommitLineData
1diff -ur rpm.org/configure.ac rpm/configure.ac
2--- rpm.org/configure.ac 2007-10-02 14:48:58.200734000 +0200
3+++ rpm/configure.ac 2007-10-02 14:49:18.697896240 +0200
4@@ -979,6 +979,14 @@
5
6 AC_MSG_HEADER([INSTALLATION PARAMETERS])
7
8+dnl enable generating autorequires containing packages names
9+dnl
10+AC_ARG_ENABLE([adding-packages-names-in-autogenerated-dependancies],
11+ [ --enable-adding-packages-names-in-autogenerated-dependancies Add packages names for autogenerated dependancies to requires],
12+ AC_MSG_RESULT([Using packages names in autogerated requires is enabled])
13+ AC_DEFINE_UNQUOTED([AUTODEP_PKGNAMES], [1], ["Generating autorequires containing packages names."]))
14+dnl
15+
16 dnl # figure out what root's primary group is
17 AC_MSG_CHECKING([root's primary group])
18 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
19--- rpm.org/lib/rpmfc.c 2007-10-02 14:48:58.244068000 +0200
20+++ rpm/lib/rpmfc.c 2007-10-02 14:52:24.222380740 +0200
21@@ -17,6 +17,8 @@
22 #define _RPMDS_INTERNAL
23 #include <rpmds.h>
24 #include <rpmfi.h>
25+#include <rpmts.h>
26+#include <rpmdb.h>
27
28 #include "debug.h"
29
30@@ -311,14 +313,83 @@
31 return buf;
32 };
33
34+static regex_t * rpmfcExpandRegexps(const char * str,int *count){
35+ int i,j,r;
36+ const char *s;
37+ ARGV_t patterns=NULL;
38+ regex_t *compiled=NULL;
39+
40+ s=rpmExpand(str,NULL);
41+ if (s) {
42+ poptParseArgvString(s,count,(const char ***)&patterns);
43+ s = _free(s);
44+ }
45+ if (patterns==NULL){
46+ *count=0;
47+ return NULL;
48+ }
49+ if (*count==0){
50+ _free(patterns);
51+ return NULL;
52+ }
53+
54+ compiled=malloc(sizeof(regex_t)*(*count));
55+ j=0;
56+ for(i=0;i<*count;i++){
57+ r=regcomp(&compiled[j],patterns[i],REG_NOSUB);
58+ if (r==0) j++;
59+ else {
60+ rpmlog(RPMLOG_NOTICE,
61+ _("Compilation of regular expresion '%s'"
62+ " (expanded from '%s') failed. Skipping it.\n"),
63+ patterns[i],str);
64+ }
65+ }
66+ patterns=_free(patterns);
67+ if (j==0) {
68+ compiled=_free(compiled);
69+ *count=0;
70+ return NULL;
71+ }
72+ *count=j;
73+ return compiled;
74+}
75+
76+static int rpmfcMatchRegexps(regex_t *regexps, int count, const char *str, char deptype)
77+{
78+ int j;
79+ for(j = 0; j < count; j++) {
80+ rpmlog(RPMLOG_DEBUG,
81+ _("Checking %c: '%s' against _noauto expr. #%i\n"), deptype, str, j);
82+ if (!regexec(&regexps[j], str, 0, NULL, 0)) {
83+ rpmlog(RPMLOG_NOTICE,
84+ _("Skipping %c: '%s' as it matches _noauto expr. #%i\n"), deptype, str, j);
85+ return 1;
86+ }
87+ }
88+ return 0;
89+}
90+
91+static regex_t * rpmfcFreeRegexps(regex_t *regexps,int count){
92+ int i;
93+
94+ if (regexps)
95+ for(i=0;i<count;i++)
96+ regfree(&regexps[i]);
97+ return _free(regexps);
98+}
99+
100 /**
101 * Run per-interpreter dependency helper.
102 * @param fc file classifier
103 * @param deptype 'P' == Provides:, 'R' == Requires:, helper
104 * @param nsdep class name for interpreter (e.g. "perl")
105+ * @param noauto _noauto* regexps
106+ * @param noauto_c # of _noauto* regexps
107 * @return 0 on success
108 */
109-static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep)
110+static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep,
111+ regex_t * noauto, int noauto_c)
112 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
113 /*@modifies fc, rpmGlobalMacroContext, fileSystem, internalState @*/
114 {
115@@ -404,6 +475,8 @@
116 }
117 /*@=branchstate@*/
118
119+ if(rpmfcMatchRegexps(noauto, noauto_c, N, deptype))
120+ continue;
121
122 /* Add tracking dependency for versioned Provides: */
123 if (!fc->tracked && deptype == 'P' && *EVR != '\0') {
124@@ -718,7 +791,7 @@
125 *se = '\0';
126 se++;
127
128- if (is_executable) {
129+ if (is_executable && fc->findreq && !rpmfcMatchRegexps(fc->noautoreq, fc->noautoreq_c, s, 'R')) {
130 /* Add to package requires. */
131 ds = rpmdsSingle(RPMTAG_REQUIRENAME, s, "", RPMSENSE_FIND_REQUIRES);
132 xx = rpmdsMerge(&fc->requires, ds);
133@@ -747,49 +820,61 @@
134
135 if (fc->fcolor->vals[fc->ix] & RPMFC_PERL) {
136 if (strncmp(fn, "/usr/share/doc/", sizeof("/usr/share/doc/")-1)) {
137- if (fc->fcolor->vals[fc->ix] & RPMFC_MODULE)
138- xx = rpmfcHelper(fc, 'P', "perl");
139- if (is_executable || (fc->fcolor->vals[fc->ix] & RPMFC_MODULE))
140- xx = rpmfcHelper(fc, 'R', "perl");
141+ if (fc->findprov && fc->fcolor->vals[fc->ix] & RPMFC_MODULE)
142+ xx = rpmfcHelper(fc, 'P', "perl", fc->noautoprov, fc->noautoprov_c);
143+ if (fc->findreq && is_executable || (fc->fcolor->vals[fc->ix] & RPMFC_MODULE))
144+ xx = rpmfcHelper(fc, 'R', "perl", fc->noautoreq, fc->noautoreq_c);
145 }
146 } else
147 if (fc->fcolor->vals[fc->ix] & RPMFC_PYTHON) {
148- xx = rpmfcHelper(fc, 'P', "python");
149+ if (fc->findprov)
150+ xx = rpmfcHelper(fc, 'P', "python", fc->noautoprov, fc->noautoprov_c);
151 #ifdef NOTYET
152 if (is_executable)
153 #endif
154- xx = rpmfcHelper(fc, 'R', "python");
155+ if (fc->findreq)
156+ xx = rpmfcHelper(fc, 'R', "python", fc->noautoreq, fc->noautoreq_c);
157 } else
158 if (fc->fcolor->vals[fc->ix] & RPMFC_LIBTOOL) {
159- xx = rpmfcHelper(fc, 'P', "libtool");
160+ if (fc->findprov)
161+ xx = rpmfcHelper(fc, 'P', "libtool", fc->noautoprov, fc->noautoprov_c);
162 #ifdef NOTYET
163 if (is_executable)
164 #endif
165- xx = rpmfcHelper(fc, 'R', "libtool");
166+ if (fc->findreq)
167+ xx = rpmfcHelper(fc, 'R', "libtool", fc->noautoreq, fc->noautoreq_c);
168 } else
169 if (fc->fcolor->vals[fc->ix] & RPMFC_PKGCONFIG) {
170- xx = rpmfcHelper(fc, 'P', "pkgconfig");
171+ if (fc->findprov)
172+ xx = rpmfcHelper(fc, 'P', "pkgconfig", fc->noautoprov, fc->noautoprov_c);
173 #ifdef NOTYET
174 if (is_executable)
175 #endif
176- xx = rpmfcHelper(fc, 'R', "pkgconfig");
177+ if (fc->findreq)
178+ xx = rpmfcHelper(fc, 'R', "pkgconfig", fc->noautoreq, fc->noautoreq_c);
179 } else
180 if (fc->fcolor->vals[fc->ix] & RPMFC_BOURNE) {
181 #ifdef NOTYET
182- xx = rpmfcHelper(fc, 'P', "executable");
183+ if (fc->findprov)
184+ xx = rpmfcHelper(fc, 'P', "executable", fc->noautoprov, fc->noautoprov_c);
185 #endif
186 if (is_executable)
187- xx = rpmfcHelper(fc, 'R', "executable");
188+ if (fc->findreq)
189+ xx = rpmfcHelper(fc, 'R', "executable", fc->noautoreq, fc->noautoreq_c);
190 } else
191 if (fc->fcolor->vals[fc->ix] & RPMFC_PHP) {
192- xx = rpmfcHelper(fc, 'P', "php");
193+ if (fc->findprov)
194+ xx = rpmfcHelper(fc, 'P', "php", fc->noautoprov, fc->noautoprov_c);
195 /* not only executable, files run by httpd usually are not */
196- xx = rpmfcHelper(fc, 'R', "php");
197+ if (fc->findreq)
198+ xx = rpmfcHelper(fc, 'R', "php", fc->noautoreq, fc->noautoreq_c);
199 } else
200 if (fc->fcolor->vals[fc->ix] & RPMFC_MONO) {
201- xx = rpmfcHelper(fc, 'P', "mono");
202+ if (fc->findprov)
203+ xx = rpmfcHelper(fc, 'P', "mono", fc->noautoprov, fc->noautoprov_c);
204 if (is_executable)
205- xx = rpmfcHelper(fc, 'R', "mono");
206+ if (fc->findreq)
207+ xx = rpmfcHelper(fc, 'R', "mono", fc->noautoreq, fc->noautoreq_c);
208 }
209 return 0;
210 }
211@@ -816,20 +901,26 @@
212 default:
213 break;
214 case RPMTAG_PROVIDENAME:
215+ if (fc->findprov && !rpmfcMatchRegexps(fc->noautoprov, fc->noautoprov_c, ds->N[0], 'P')) {
216 /* Add to package provides. */
217 rc = rpmdsMerge(&fc->provides, ds);
218
219 /* Add to file dependencies. */
220 buf[0] = '\0';
221 rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
222+ } else
223+ rc = 0;
224 break;
225 case RPMTAG_REQUIRENAME:
226+ if (fc->findreq && !rpmfcMatchRegexps(fc->noautoreq, fc->noautoreq_c, ds->N[0], 'R')) {
227 /* Add to package requires. */
228 rc = rpmdsMerge(&fc->requires, ds);
229
230 /* Add to file dependencies. */
231 buf[0] = '\0';
232 rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
233+ } else
234+ rc = 0;
235 break;
236 }
237 return rc;
238@@ -870,6 +961,111 @@
239 { NULL, 0 }
240 };
241
242+#ifdef AUTODEP_PKGNAMES /* define to use package names in R */
243+static int rpmfcFindRequiredPackages(rpmfc fc)
244+{
245+ rpmts ts=NULL;
246+ const char * s;
247+ char * se;
248+ rpmds ds;
249+ const char * N;
250+ const char * EVR;
251+ int32_t Flags;
252+ unsigned char deptype;
253+ int nddict;
254+ int previx;
255+ int ix;
256+ int i;
257+ int j;
258+ int xx;
259+ int r;
260+ const char * hname;
261+ rpmdbMatchIterator it;
262+ Header hdr;
263+ regex_t *noautoreqdep;
264+ int noautoreqdep_c;
265+
266+ noautoreqdep=rpmfcExpandRegexps("%{__noautoreqdep}", &noautoreqdep_c);
267+
268+ ts = rpmtsCreate(); /* XXX ts created in main() should be used */
269+
270+ rpmlog(RPMLOG_NOTICE, _("Searching for required packages....\n"));
271+
272+ nddict = argvCount(fc->ddict);
273+ previx = -1;
274+ for (i = 0; i < nddict; i++) {
275+ s = fc->ddict[i];
276+
277+ /* Parse out (file#,deptype,N,EVR,Flags) */
278+ ix = strtol(s, &se, 10);
279+ assert(se != NULL);
280+ deptype = *se++;
281+ se++;
282+ N = se;
283+ while (*se && *se != ' ')
284+ se++;
285+ *se++ = '\0';
286+ EVR = se;
287+ while (*se && *se != ' ')
288+ se++;
289+ *se++ = '\0';
290+ Flags = strtol(se, NULL, 16);
291+
292+ if (deptype!='R') continue;
293+
294+ rpmlog(RPMLOG_DEBUG, _("#%i requires: %s,%s,%i\n"),ix,N,EVR,Flags);
295+ if (EVR && EVR[0]) {
296+ rpmlog(RPMLOG_DEBUG, _("skipping #%i require\n"));
297+ continue;
298+ }
299+ for(j=0;j<noautoreqdep_c;j++)
300+ if (!regexec(&noautoreqdep[j],N,0,NULL,0)) {
301+ rpmlog(RPMLOG_NOTICE,
302+ _("skipping %s requirement processing"
303+ " (matches noautoreqdep pattern #%i)\n"),N,j);
304+ break;
305+ }
306+ if (j<noautoreqdep_c) continue;
307+ if (N[0]=='/') {
308+ rpmlog(RPMLOG_DEBUG, _("skipping #%i require (is file requirement)\n"));
309+ continue;
310+ }
311+ it=rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, N, 0);
312+ if (!it) {
313+ rpmlog(RPMLOG_DEBUG, _("%s -> not found\n"),N);
314+ continue;
315+ }
316+ rpmlog(RPMLOG_DEBUG, _("Iterator: %p\n"),it);
317+ if (rpmdbGetIteratorCount(it)>1) {
318+ rpmlog(RPMLOG_DEBUG, _("%s -> multiple (skipping)\n"),N);
319+ rpmdbFreeIterator(it);
320+ continue;
321+ }
322+ hdr=rpmdbNextIterator(it);
323+ assert(hdr!=NULL);
324+ r=headerGetEntry(hdr,RPMTAG_NAME,NULL,(void **)&hname, NULL);
325+ assert(r<2);
326+ if (!strcmp(hname,N)) {
327+ rpmlog(RPMLOG_DEBUG, _("%s -> %s (skipping)\n"),N,hname);
328+ rpmdbFreeIterator(it);
329+ continue;
330+ }
331+
332+ rpmlog(RPMLOG_DEBUG, "%s -> %s\n",N,hname);
333+
334+ ds = rpmdsSingle(RPMTAG_REQUIRENAME, hname, "", RPMSENSE_FIND_REQUIRES);
335+ xx = rpmdsMerge(&fc->requires, ds);
336+ ds = rpmdsFree(ds);
337+
338+ rpmdbFreeIterator(it);
339+ }
340+
341+ noautoreqdep = rpmfcFreeRegexps(noautoreqdep, noautoreqdep_c);
342+ ts = rpmtsFree(ts);
343+ return 0;
344+}
345+#endif
346+
347 rpmRC rpmfcApply(rpmfc fc)
348 {
349 rpmfcApplyTbl fcat;
350@@ -888,6 +1084,26 @@
351 int i;
352 int xx;
353 int skipping;
354+ int j;
355+ regex_t *noautoprovfiles = NULL;
356+ int noautoprovfiles_c;
357+ regex_t *noautoreqfiles = NULL;
358+ int noautoreqfiles_c;
359+ const char *buildroot;
360+ int buildroot_l;
361+
362+ fc->noautoprov = NULL;
363+ fc->noautoreq = NULL;
364+
365+ buildroot = rpmExpand("%{buildroot}",NULL);
366+ buildroot_l = strlen(buildroot);
367+
368+ noautoprovfiles = rpmfcExpandRegexps("%{__noautoprovfiles}", &noautoprovfiles_c);
369+ noautoreqfiles = rpmfcExpandRegexps("%{__noautoreqfiles}", &noautoreqfiles_c);
370+ fc->noautoprov = rpmfcExpandRegexps("%{__noautoprov}", &fc->noautoprov_c);
371+ fc->noautoreq = rpmfcExpandRegexps("%{__noautoreq}", &fc->noautoreq_c);
372+ rpmlog(RPMLOG_DEBUG, _("%i _noautoprov patterns.\n"), fc->noautoprov_c);
373+ rpmlog(RPMLOG_DEBUG, _("%i _noautoreq patterns.\n"), fc->noautoreq_c);
374
375 /* Make sure something didn't go wrong previously! */
376 assert(fc->fn != NULL);
377@@ -911,9 +1127,43 @@
378 for (fcat = rpmfcApplyTable; fcat->func != NULL; fcat++) {
379 if (!(fc->fcolor->vals[fc->ix] & fcat->colormask))
380 /*@innercontinue@*/ continue;
381+ fc->findprov = 1;
382+ fc->findreq = 1;
383+ if (strncmp(fc->fn[fc->ix],buildroot,buildroot_l)==0) {/* sanity check */
384+ for(j = 0; j < noautoprovfiles_c; j++) {
385+ if (!regexec(&noautoprovfiles[j],
386+ fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
387+ rpmlog(RPMLOG_NOTICE,
388+ _("skipping %s provides detection"
389+ " (matches noautoprovfiles pattern #%i)\n"),
390+ fc->fn[fc->ix], j);
391+ fc->findprov = 0;
392+ break;
393+ }
394+ }
395+ for(j = 0; j < noautoreqfiles_c; j++) {
396+ if (!regexec(&noautoreqfiles[j],
397+ fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
398+ rpmlog(RPMLOG_NOTICE,
399+ _("skipping %s requires detection"
400+ " (matches noautoreqfiles pattern #%i)\n"),
401+ fc->fn[fc->ix], j);
402+ fc->findreq = 0;
403+ break;
404+ }
405+ }
406+ }
407+
408 xx = (*fcat->func) (fc);
409 }
410 }
411+ noautoprovfiles = rpmfcFreeRegexps(noautoprovfiles, noautoprovfiles_c);
412+ noautoreqfiles = rpmfcFreeRegexps(noautoreqfiles, noautoreqfiles_c);
413+ fc->noautoprov = rpmfcFreeRegexps(fc->noautoprov, fc->noautoprov_c);
414+ fc->noautoreq = rpmfcFreeRegexps(fc->noautoreq, fc->noautoreq_c);
415+#ifdef AUTODEP_PKGNAMES /* define to use package names in R */
416+ rpmfcFindRequiredPackages(fc);
417+#endif
418
419 /*@-boundswrite@*/
420 /* Generate per-file indices into package dependencies. */
421--- rpm.org/lib/rpmfc.h 2007-07-14 05:22:44.000000000 +0200
422+++ rpm/lib/rpmfc.h 2007-10-02 14:49:18.731230377 +0200
423@@ -98,6 +98,11 @@
424 StringBuf sb_python;/*!< concatenated list of python colored files. */
425 StringBuf sb_php; /*!< concatenated list of php colored files. */
426
427+ int findprov, findreq;
428+ regex_t *noautoprov;
429+ int noautoprov_c;
430+ regex_t *noautoreq;
431+ int noautoreq_c;
432 };
433
434 /**
435--- rpm/lib/rpmfc.h.org 2007-10-02 15:05:48.028299804 +0200
436+++ rpm/lib/rpmfc.h 2007-10-02 15:06:03.052024633 +0200
437@@ -67,6 +67,13 @@
438 };
439
440 #if defined(_RPMFC_INTERNAL)
441+
442+#if defined(WITH_PCRE) && defined(HAVE_PCREPOSIX_H)
443+#include <pcreposix.h>
444+#else
445+#include <regex.h>
446+#endif
447+
448 /**
449 */
450 struct rpmfc_s {
This page took 0.095085 seconds and 4 git commands to generate.