]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find_required_pkgs_on_build.patch
- package requirements based on capability requirements are back, reimplemented in...
[packages/rpm.git] / rpm-find_required_pkgs_on_build.patch
1 diff -durN rpm-4.3.orig/build/rpmfc.c rpm-4.3/build/rpmfc.c
2 --- rpm-4.3.orig/build/rpmfc.c  2004-01-04 13:53:29.000000000 +0100
3 +++ rpm-4.3/build/rpmfc.c       2004-01-04 13:54:54.860259000 +0100
4 @@ -9,6 +9,8 @@
5  #define        _RPMDS_INTERNAL
6  #include <rpmds.h>
7  #include <rpmfi.h>
8 +#include <rpmts.h>
9 +#include <rpmdb.h>
10  
11  #if HAVE_GELF_H
12  #include <gelf.h>
13 @@ -1058,6 +1060,97 @@
14      { NULL, 0 }
15  };
16  
17 +int rpmfcFindRequiredPackages(rpmfc fc) 
18 +{
19 +    rpmts ts=NULL;
20 +    const char * s;
21 +    char * se;
22 +    rpmds ds;
23 +    const char * N;
24 +    const char * EVR;
25 +    int_32 Flags;
26 +    unsigned char deptype;
27 +    int nddict;
28 +    int previx;
29 +    unsigned int val;
30 +    int dix;
31 +    int ix;
32 +    int i;
33 +    int xx;
34 +    int r;
35 +    const char * hname;
36 +    rpmdbMatchIterator it;
37 +    Header hdr;
38 +
39 +    ts = rpmtsCreate(); /* XXX ts created in main() should be used */
40 +    
41 +    rpmMessage(RPMMESS_NORMAL, "Searching for required packages....\n");
42 +
43 +    nddict = argvCount(fc->ddict);
44 +    previx = -1;
45 +    for (i = 0; i < nddict; i++) {
46 +        s = fc->ddict[i];
47 +
48 +        /* Parse out (file#,deptype,N,EVR,Flags) */
49 +        ix = strtol(s, &se, 10);
50 +        assert(se != NULL);
51 +        deptype = *se++;
52 +        se++;
53 +        N = se;
54 +        while (*se && *se != ' ')
55 +            se++;
56 +        *se++ = '\0';
57 +        EVR = se;
58 +        while (*se && *se != ' ')
59 +            se++;
60 +        *se++ = '\0';
61 +        Flags = strtol(se, NULL, 16);
62 +
63 +        if (deptype!='R') continue;
64 +
65 +        rpmMessage(RPMMESS_DEBUG, "#%i requires: %s,%s,%i\n",ix,N,EVR,Flags);
66 +        if (EVR && EVR[0]) {
67 +            rpmMessage(RPMMESS_DEBUG, "skipping #%i require\n");
68 +            continue;
69 +        }
70 +        if (N[0]=='/') {
71 +            rpmMessage(RPMMESS_DEBUG, "skipping #%i require (is file requirement)\n");
72 +            continue;
73 +        }
74 +        it=rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, N, 0);
75 +        if (!it) {
76 +            rpmMessage(RPMMESS_DEBUG, "%s -> not found\n",N);
77 +            continue;
78 +        }
79 +        rpmMessage(RPMMESS_NORMAL, "Iterator: %p\n",it);
80 +        if (rpmdbGetIteratorCount(it)>1) {
81 +            rpmMessage(RPMMESS_DEBUG, "%s -> multiple (skipping)\n",N);
82 +            rpmdbFreeIterator(it);
83 +            continue;
84 +        }
85 +        hdr=rpmdbNextIterator(it);
86 +        assert(hdr!=NULL);
87 +        r=rpmHeaderGetEntry(hdr,RPMTAG_NAME,NULL,(void **)&hname, NULL);
88 +        assert(r<2);
89 +        if (!strcmp(hname,N)) {
90 +            rpmMessage(RPMMESS_DEBUG, "%s -> %s (skipping)\n",N,hname);
91 +            rpmdbFreeIterator(it);
92 +            continue;
93 +        }
94 +            
95 +        rpmMessage(RPMMESS_DEBUG, "%s -> %s\n",N,hname);
96 +        
97 +               ds = rpmdsSingle(RPMTAG_REQUIRENAME, hname, "", RPMSENSE_FIND_REQUIRES);
98 +               xx = rpmdsMerge(&fc->requires, ds);
99 +               ds = rpmdsFree(ds);
100 +
101 +        rpmdbFreeIterator(it);
102 +    }
103 +
104 +    ts = rpmtsFree(ts);
105 +    return 0;
106 +}
107 +
108  int rpmfcApply(rpmfc fc)
109  {
110      rpmfcApplyTbl fcat;
111 @@ -1086,6 +1179,8 @@
112         }
113      }
114  
115 +    rpmfcFindRequiredPackages(fc);
116 +
117  /*@-boundswrite@*/
118      /* Generate per-file indices into package dependencies. */
119      nddict = argvCount(fc->ddict);
This page took 0.090379 seconds and 3 git commands to generate.