]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-pld-autodep.patch
- compress debuginfo sections with zlib (reduce /usr/lib/debug size).
[packages/rpm.git] / rpm-pld-autodep.patch
CommitLineData
0513629a
JB
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
15bdd1bc
JB
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 @@
23e3bf9a
JB
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 /**
639079f5
ER
23--- rpm-4.5/lib/rpmfc.c~ 2008-06-10 14:06:23.000000000 +0300
24+++ rpm-4.5/lib/rpmfc.c 2008-06-10 14:21:53.097663262 +0300
1e8c552d 25@@ -15,6 +15,8 @@
5f8c53f0
JK
26 #define _RPMDS_INTERNAL
27 #include <rpmds.h>
28 #include <rpmfi.h>
29+#include <rpmts.h>
30+#include <rpmdb.h>
31
23e3bf9a
JB
32 #include "debug.h"
33
1e8c552d 34@@ -309,14 +311,83 @@
5f8c53f0
JK
35 return buf;
36 };
37
4bdd0c9c 38+static regex_t * rpmfcExpandRegexps(const char * str,int *count){
5f8c53f0
JK
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,
d327d730
JB
65+ _("Compilation of regular expresion '%s'"
66+ " (expanded from '%s') failed. Skipping it.\n"),
5f8c53f0
JK
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+
4bdd0c9c
JB
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){
5f8c53f0
JK
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
4bdd0c9c
JB
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 {
1e8c552d 119@@ -402,6 +473,8 @@
5f8c53f0
JK
120 }
121 /*@=branchstate@*/
122
4bdd0c9c
JB
123+ if(rpmfcMatchRegexps(noauto, noauto_c, N, deptype))
124+ continue;
5f8c53f0
JK
125
126 /* Add tracking dependency for versioned Provides: */
127 if (!fc->tracked && deptype == 'P' && *EVR != '\0') {
1e8c552d 128@@ -714,7 +787,7 @@
5f8c53f0
JK
129 *se = '\0';
130 se++;
131
132- if (is_executable) {
23e3bf9a 133+ if (is_executable && fc->findreq && !rpmfcMatchRegexps(fc->noautoreq, fc->noautoreq_c, s, 'R')) {
5f8c53f0
JK
134 /* Add to package requires. */
135 ds = rpmdsSingle(RPMTAG_REQUIRENAME, s, "", RPMSENSE_FIND_REQUIRES);
136 xx = rpmdsMerge(&fc->requires, ds);
1e8c552d 137@@ -808,20 +889,26 @@
23e3bf9a
JB
138 default:
139 break;
140 case RPMTAG_PROVIDENAME:
15bdd1bc 141+ if (fc->findprov && !rpmfcMatchRegexps(fc->noautoprov, fc->noautoprov_c, ds->N[0], 'P')) {
23e3bf9a
JB
142 /* Add to package provides. */
143 rc = rpmdsMerge(&fc->provides, ds);
4bdd0c9c 144
23e3bf9a
JB
145 /* Add to file dependencies. */
146 buf[0] = '\0';
147 rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
148+ } else
149+ rc = 0;
150 break;
151 case RPMTAG_REQUIRENAME:
15bdd1bc 152+ if (fc->findreq && !rpmfcMatchRegexps(fc->noautoreq, fc->noautoreq_c, ds->N[0], 'R')) {
23e3bf9a
JB
153 /* Add to package requires. */
154 rc = rpmdsMerge(&fc->requires, ds);
5f8c53f0 155
15bdd1bc
JB
156 /* Add to file dependencies. */
157 buf[0] = '\0';
158 rc = rpmfcSaveArg(&fc->ddict, rpmfcFileDep(buf, fc->ix, ds));
159+ } else
160+ rc = 0;
161 break;
162 }
163 return rc;
1e8c552d 164@@ -862,6 +949,109 @@
5f8c53f0
JK
165 { NULL, 0 }
166 };
167
4bdd0c9c 168+static int rpmfcFindRequiredPackages(rpmfc fc)
5f8c53f0
JK
169+{
170+ rpmts ts=NULL;
171+ const char * s;
172+ char * se;
173+ rpmds ds;
174+ const char * N;
175+ const char * EVR;
176+ int_32 Flags;
177+ unsigned char deptype;
178+ int nddict;
179+ int previx;
180+ int ix;
181+ int i;
182+ int j;
183+ int xx;
184+ int r;
185+ const char * hname;
186+ rpmdbMatchIterator it;
187+ Header hdr;
188+ regex_t *noautoreqdep;
189+ int noautoreqdep_c;
190+
7ce4c2db 191+ noautoreqdep=rpmfcExpandRegexps("%{__noautoreqdep}", &noautoreqdep_c);
5f8c53f0
JK
192+
193+ ts = rpmtsCreate(); /* XXX ts created in main() should be used */
194+
d327d730 195+ rpmMessage(RPMMESS_NORMAL, _("Searching for required packages....\n"));
5f8c53f0
JK
196+
197+ nddict = argvCount(fc->ddict);
198+ previx = -1;
199+ for (i = 0; i < nddict; i++) {
200+ s = fc->ddict[i];
201+
202+ /* Parse out (file#,deptype,N,EVR,Flags) */
203+ ix = strtol(s, &se, 10);
204+ assert(se != NULL);
205+ deptype = *se++;
206+ se++;
207+ N = se;
208+ while (*se && *se != ' ')
209+ se++;
210+ *se++ = '\0';
211+ EVR = se;
212+ while (*se && *se != ' ')
213+ se++;
214+ *se++ = '\0';
215+ Flags = strtol(se, NULL, 16);
216+
217+ if (deptype!='R') continue;
218+
d327d730 219+ rpmMessage(RPMMESS_DEBUG, _("#%i requires: %s,%s,%i\n"),ix,N,EVR,Flags);
5f8c53f0 220+ if (EVR && EVR[0]) {
d327d730 221+ rpmMessage(RPMMESS_DEBUG, _("skipping #%i require\n"));
5f8c53f0
JK
222+ continue;
223+ }
224+ for(j=0;j<noautoreqdep_c;j++)
225+ if (!regexec(&noautoreqdep[j],N,0,NULL,0)) {
226+ rpmMessage(RPMMESS_NORMAL,
d327d730
JB
227+ _("skipping %s requirement processing"
228+ " (matches noautoreqdep pattern #%i)\n"),N,j);
5f8c53f0
JK
229+ break;
230+ }
231+ if (j<noautoreqdep_c) continue;
232+ if (N[0]=='/') {
d327d730 233+ rpmMessage(RPMMESS_DEBUG, _("skipping #%i require (is file requirement)\n"));
5f8c53f0
JK
234+ continue;
235+ }
236+ it=rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, N, 0);
237+ if (!it) {
d327d730 238+ rpmMessage(RPMMESS_DEBUG, _("%s -> not found\n"),N);
5f8c53f0
JK
239+ continue;
240+ }
d327d730 241+ rpmMessage(RPMMESS_DEBUG, _("Iterator: %p\n"),it);
5f8c53f0 242+ if (rpmdbGetIteratorCount(it)>1) {
d327d730 243+ rpmMessage(RPMMESS_DEBUG, _("%s -> multiple (skipping)\n"),N);
5f8c53f0
JK
244+ rpmdbFreeIterator(it);
245+ continue;
246+ }
247+ hdr=rpmdbNextIterator(it);
248+ assert(hdr!=NULL);
6efed78b 249+ r=headerGetEntry(hdr,RPMTAG_NAME,NULL,(void **)&hname, NULL);
5f8c53f0
JK
250+ assert(r<2);
251+ if (!strcmp(hname,N)) {
d327d730 252+ rpmMessage(RPMMESS_DEBUG, _("%s -> %s (skipping)\n"),N,hname);
5f8c53f0
JK
253+ rpmdbFreeIterator(it);
254+ continue;
255+ }
256+
257+ rpmMessage(RPMMESS_DEBUG, "%s -> %s\n",N,hname);
258+
259+ ds = rpmdsSingle(RPMTAG_REQUIRENAME, hname, "", RPMSENSE_FIND_REQUIRES);
260+ xx = rpmdsMerge(&fc->requires, ds);
261+ ds = rpmdsFree(ds);
262+
263+ rpmdbFreeIterator(it);
264+ }
265+
23e3bf9a 266+ noautoreqdep = rpmfcFreeRegexps(noautoreqdep, noautoreqdep_c);
5f8c53f0
JK
267+ ts = rpmtsFree(ts);
268+ return 0;
269+}
270+
271 int rpmfcApply(rpmfc fc)
272 {
273 rpmfcApplyTbl fcat;
1e8c552d 274@@ -880,6 +1070,26 @@
5f8c53f0
JK
275 int i;
276 int xx;
505bb97c 277 int skipping;
5f8c53f0 278+ int j;
4bdd0c9c 279+ regex_t *noautoprovfiles = NULL;
5f8c53f0 280+ int noautoprovfiles_c;
4bdd0c9c
JB
281+ regex_t *noautoreqfiles = NULL;
282+ int noautoreqfiles_c;
5f8c53f0
JK
283+ const char *buildroot;
284+ int buildroot_l;
285+
23e3bf9a
JB
286+ fc->noautoprov = NULL;
287+ fc->noautoreq = NULL;
288+
4bdd0c9c
JB
289+ buildroot = rpmExpand("%{buildroot}",NULL);
290+ buildroot_l = strlen(buildroot);
5f8c53f0 291+
7ce4c2db
JB
292+ noautoprovfiles = rpmfcExpandRegexps("%{__noautoprovfiles}", &noautoprovfiles_c);
293+ noautoreqfiles = rpmfcExpandRegexps("%{__noautoreqfiles}", &noautoreqfiles_c);
23e3bf9a
JB
294+ fc->noautoprov = rpmfcExpandRegexps("%{__noautoprov}", &fc->noautoprov_c);
295+ fc->noautoreq = rpmfcExpandRegexps("%{__noautoreq}", &fc->noautoreq_c);
296+ rpmMessage(RPMMESS_DEBUG, _("%i _noautoprov patterns.\n"), fc->noautoprov_c);
297+ rpmMessage(RPMMESS_DEBUG, _("%i _noautoreq patterns.\n"), fc->noautoreq_c);
5f8c53f0
JK
298
299 /* Generate package and per-file dependencies. */
300 for (fc->ix = 0; fc->fn[fc->ix] != NULL; fc->ix++) {
1e8c552d 301@@ -900,9 +1110,43 @@
5f8c53f0
JK
302 for (fcat = rpmfcApplyTable; fcat->func != NULL; fcat++) {
303 if (!(fc->fcolor->vals[fc->ix] & fcat->colormask))
304 /*@innercontinue@*/ continue;
23e3bf9a
JB
305+ fc->findprov = 1;
306+ fc->findreq = 1;
5f8c53f0 307+ if (strncmp(fc->fn[fc->ix],buildroot,buildroot_l)==0) {/* sanity check */
c7d56820
AM
308+ for(j = 0; j < noautoprovfiles_c; j++) {
309+ if (!regexec(&noautoprovfiles[j],
310+ fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
311+ rpmMessage(RPMMESS_NORMAL,
312+ _("skipping %s provides detection"
313+ " (matches noautoprovfiles pattern #%i)\n"),
314+ fc->fn[fc->ix], j);
315+ fc->findprov = 0;
316+ break;
317+ }
5f8c53f0 318+ }
c7d56820
AM
319+ for(j = 0; j < noautoreqfiles_c; j++) {
320+ if (!regexec(&noautoreqfiles[j],
321+ fc->fn[fc->ix] + buildroot_l, 0, NULL, 0)) {
322+ rpmMessage(RPMMESS_NORMAL,
323+ _("skipping %s requires detection"
324+ " (matches noautoreqfiles pattern #%i)\n"),
325+ fc->fn[fc->ix], j);
326+ fc->findreq = 0;
327+ break;
328+ }
5f8c53f0 329+ }
5f8c53f0 330+ }
c7d56820 331+
23e3bf9a 332 xx = (*fcat->func) (fc);
5f8c53f0
JK
333 }
334 }
7ce4c2db
JB
335+ noautoprovfiles = rpmfcFreeRegexps(noautoprovfiles, noautoprovfiles_c);
336+ noautoreqfiles = rpmfcFreeRegexps(noautoreqfiles, noautoreqfiles_c);
23e3bf9a
JB
337+ fc->noautoprov = rpmfcFreeRegexps(fc->noautoprov, fc->noautoprov_c);
338+ fc->noautoreq = rpmfcFreeRegexps(fc->noautoreq, fc->noautoreq_c);
8e52eb7d 339+#ifdef AUTODEP_PKGNAMES /* define to use package names in R */
7ce4c2db
JB
340+ rpmfcFindRequiredPackages(fc);
341+#endif
c7d56820 342
5f8c53f0
JK
343 /*@-boundswrite@*/
344 /* Generate per-file indices into package dependencies. */
639079f5
ER
345#--- rpm-4.4.9/po/pl.po.orig 2007-05-22 08:11:40.947724921 +0200
346#+++ rpm-4.4.9/po/pl.po 2007-05-22 08:24:24.091213990 +0200
347#@@ -2937,6 +2937,86 @@
348# msgid "Failed to find %s:\n"
349