]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-5.4.9-update-rpmfc-when-removing-dependencies-on-self.patch
- rpm-db-ver cap moved to -lib; release 57
[packages/rpm.git] / rpm-5.4.9-update-rpmfc-when-removing-dependencies-on-self.patch
CommitLineData
70f8787d
JR
1--- rpm-5.4.9/lib/rpmfc.c.fc_deps~ 2012-05-15 02:23:23.157740011 +0200
2+++ rpm-5.4.9/lib/rpmfc.c 2012-05-15 02:24:42.863147557 +0200
3@@ -1763,12 +1763,14 @@ static int rpmfcGenerateScriptletDeps(co
4 return rc;
5 }
6
7-static void removeSillyDeps(Header h) {
8+static unsigned removeSillyDeps(Header h, rpmfc fc) {
9 HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
10- int xx, i, rnum, removed = 0;
11+ int xx;
12+ unsigned i, rnum, removed = 0;
13 const char **deps = NULL;
14 const char **versions = NULL;
15 evrFlags *flags = NULL;
16+ int *newpos = NULL, *ddictxPos = NULL;
17
18 he->tag = RPMTAG_REQUIRENAME;
19 xx = headerGet(h, he, 0);
20@@ -1783,18 +1785,32 @@ static void removeSillyDeps(Header h) {
21 xx = headerGet(h, he, 0);
22 flags = (evrFlags*)he->p.ui32p;
23
24+ if (fc && fc->requires != NULL && fc->ddictx != NULL) {
25+ newpos = alloca(he->c*sizeof(newpos[0]));
26+ if (fc->ddictx)
27+ ddictxPos = alloca(fc->ddictx->nvals*sizeof(ddictxPos[0]));
28+ }
29 for (i = 0; i < rnum-removed; i++) {
30 if (removed) {
31 deps[i] = deps[i+removed];
32 versions[i] = versions[i+removed];
33 flags[i] = flags[i+removed];
34+ if (fc) {
35+ fc->requires->N[i] = fc->requires->N[i+removed];
36+ fc->requires->EVR[i] = fc->requires->EVR[i+removed];
37+ fc->requires->Flags[i] = fc->requires->Flags[i+removed];
38+ }
39 }
40+ if (fc && fc->requires != NULL && fc->ddictx != NULL)
41+ newpos[i+removed] = i;
42 rpmds req = rpmdsSingle(RPMTAG_REQUIRENAME, deps[i], versions[i], flags[i]);
43 rpmds prov = rpmdsNew(h, (*deps[i] == '/' && !*versions[i]) ? RPMTAG_BASENAMES : RPMTAG_PROVIDENAME, 0);
44 if (rpmdsMatch(req, prov)) {
45 if (flags[i] & RPMSENSE_SCRIPT_PRE)
46 rpmlog(RPMLOG_ERR, "Requires(pre): on dependency provided by self: %s\n", rpmdsDNEVR(req));
47 else {
48+ if (fc && fc->requires != NULL && fc->ddictx != NULL)
49+ newpos[i+removed] = -1;
50 rpmlog(RPMLOG_NOTICE, "Removing dependency on self: %s\n", rpmdsDNEVR(req));
51 removed++;
52 i--;
53@@ -1803,6 +1819,52 @@ static void removeSillyDeps(Header h) {
54 req = rpmdsFree(req);
55 prov = rpmdsFree(prov);
56 }
57+ if (fc && fc->requires != NULL && fc->ddictx != NULL && removed) {
58+ fc->requires->Count -= removed;
59+ unsigned rx = 0;
60+ for (i = 0; i < fc->ddictx->nvals-rx; i++) {
61+ unsigned ix;
62+ unsigned char deptype;
63+
64+ ix = fc->ddictx->vals[i+rx];
65+ deptype = ((ix >> 24) & 0xff);
66+ ix &= 0x00ffffff;
67+
68+ if (deptype == 'P') {
69+ ddictxPos[i+rx] = i;
70+ fc->ddictx->vals[i] = fc->ddictx->vals[i+rx];
71+ continue;
72+ }
73+ if (newpos[ix] == -1) {
74+ ddictxPos[i+rx] = -1;
75+ i--, rx++;
76+ }
77+ else
78+ {
79+ ddictxPos[i+rx] = i;
80+ fc->ddictx->vals[i] = (deptype << 24) | (newpos[ix] & 0x00ffffff);
81+ }
82+ }
83+ fc->ddictx->nvals -= rx;
84+
85+ for (i = 0; i < fc->fddictn->nvals; i++) {
86+ rx = 0;
87+ if (fc->fddictn->vals[i]) {
88+ unsigned j, ix = fc->fddictx->vals[i];
89+ for (j = 0, rx = 0; j < fc->fddictn->vals[i]; j++, ix++) {
90+ if (ddictxPos[ix] == -1)
91+ rx++;
92+ if (j == 0 || fc->fddictx->vals[i] == -1)
93+ fc->fddictx->vals[i] = ddictxPos[ix];
94+ }
95+ }
96+ if (rx)
97+ fc->fddictn->vals[i] -= rx;
98+ if (fc->fddictn->vals[i] == 0)
99+ fc->fddictx->vals[i] = 0;
100+ }
101+ }
102+
103 if (removed) {
104 he->tag = RPMTAG_REQUIRENAME;
105 he->t = RPM_STRING_ARRAY_TYPE;
106@@ -1820,6 +1882,7 @@ static void removeSillyDeps(Header h) {
107 headerMod(h, he, 0);
108 }
109
110+ return removed;
111 }
112
113 rpmRC rpmfcGenerateDepends(void * _spec, void * _pkg)
114@@ -1855,7 +1918,7 @@ rpmRC rpmfcGenerateDepends(void * _spec,
115 if (internaldeps == 0) {
116 /* ... then generate dependencies using %{__find_requires} et al. */
117 rc = rpmfcGenerateDependsHelper(spec, pkg, fi);
118- removeSillyDeps(pkg->header);
119+ removeSillyDeps(pkg->header, NULL);
120 printDeps(pkg->header);
121 return rc;
122 }
123@@ -2045,6 +2108,8 @@ assert(he->p.ptr != NULL);
124 /*@=nullpass@*/
125 }
126
127+ removeSillyDeps(pkg->header, fc);
128+
129 /* Add dependency dictionary(#dependencies) */
130 he->tag = RPMTAG_DEPENDSDICT;
131 he->t = RPM_UINT32_TYPE;
132@@ -2073,8 +2138,6 @@ assert(ac == (int)he->c);
133 xx = headerPut(pkg->header, he, 0);
134 }
135
136- removeSillyDeps(pkg->header);
137-
138 printDeps(pkg->header);
139
140 if (fc != NULL && _rpmfc_debug) {
This page took 0.053615 seconds and 4 git commands to generate.