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