summaryrefslogtreecommitdiffstats
path: root/recipes/rpm/files/weakdeps.patch
blob: a013b75542da939726a3095006d8a5a4f31faa43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
Taken from OpenSUSE 11 rpm source file - RP 26/8/08

Add support for weak dependencies:

A) use RPMTAG_SUGGESTS and RPMTAG_ENHANCES to store them.

   This is different to upstream, which uses RPMSENSE_MISSINGOK
   and RPMTAG_REQUIRES/RPMTAG_PROVIDES instead. I chose different
   tags because I wanted to be compatible. The point is that
   applications that don't know about the new MISSINGOK semantics
   will mis-interpret the provides/requires otherwise, which
   I deemed to risky.

B) use RPMSENSE_STRONG to support a "strong" version, "Recommends"
   instead of "Suggests" and "Supplements" instead of "Enhances".

Needs extcond.diff for query operations.

Index: build/parsePreamble.c
===================================================================
--- build/parsePreamble.c.orig	2008-04-01 08:28:21.000000000 +0100
+++ build/parsePreamble.c	2008-08-26 16:58:09.000000000 +0100
@@ -129,6 +129,8 @@
     { "post",		RPMSENSE_SCRIPT_POST },
     { "rpmlib",		RPMSENSE_RPMLIB },
     { "verify",		RPMSENSE_SCRIPT_VERIFY },
+    { "hint",		RPMSENSE_MISSINGOK },
+    { "strong",		RPMSENSE_STRONG },
     { NULL, 0 }
 };
 
@@ -140,6 +142,8 @@
     { "build",		RPMSENSE_SCRIPT_BUILD },
     { "install",	RPMSENSE_SCRIPT_INSTALL },
     { "clean",		RPMSENSE_SCRIPT_CLEAN },
+    { "hint",		RPMSENSE_MISSINGOK },
+    { "strong",		RPMSENSE_STRONG },
     { NULL, 0 }
 };
 
@@ -692,6 +696,18 @@
 	if ((rc = parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
 	    return rc;
 	break;
+    case RPMTAG_SUGGESTSFLAGS:
+    case RPMTAG_ENHANCESFLAGS:
+    case RPMTAG_BUILDSUGGESTS:
+    case RPMTAG_BUILDENHANCES:
+	tagflags = RPMSENSE_MISSINGOK;
+	if (macro && (!strcmp(macro, "recommends") || !strcmp(macro, "buildrecommends")))
+	    tagflags |= RPMSENSE_STRONG;
+	if (macro && (!strcmp(macro, "supplements") || !strcmp(macro, "buildsupplements")))
+	    tagflags |= RPMSENSE_STRONG;
+	if ((rc = parseRCPOT(spec, pkg, field, tag, 0, tagflags)))
+	    return rc;
+	break;
     case RPMTAG_EXCLUDEARCH:
     case RPMTAG_EXCLUSIVEARCH:
     case RPMTAG_EXCLUDEOS:
@@ -783,6 +799,14 @@
     {RPMTAG_DISTTAG,		0, 0, 0, "disttag"},
     {RPMTAG_CVSID,		0, 0, 0, "cvsid"},
     {RPMTAG_SVNID,		0, 0, 0, "svnid"},
+    {RPMTAG_SUGGESTSFLAGS,	0, 0, 0, "recommends"},
+    {RPMTAG_SUGGESTSFLAGS,	0, 0, 0, "suggests"},
+    {RPMTAG_ENHANCESFLAGS,	0, 0, 0, "supplements"},
+    {RPMTAG_ENHANCESFLAGS,	0, 0, 0, "enhances"},
+    {RPMTAG_BUILDSUGGESTS,	0, 0, 0, "buildrecommends"},
+    {RPMTAG_BUILDSUGGESTS,	0, 0, 0, "buildsuggests"},
+    {RPMTAG_BUILDENHANCES,	0, 0, 0, "buildsupplements"},
+    {RPMTAG_BUILDENHANCES,	0, 0, 0, "buildenhances"},
     /*@-nullassign@*/	/* LCL: can't add null annotation */
     {0, 0, 0, 0, 0}
     /*@=nullassign@*/
Index: build/parseReqs.c
===================================================================
--- build/parseReqs.c.orig	2008-04-01 08:28:21.000000000 +0100
+++ build/parseReqs.c	2008-08-26 16:58:09.000000000 +0100
@@ -85,6 +85,14 @@
 	tagflags |= RPMSENSE_ANY;
 	h = spec->buildRestrictions;
 	break;
+    case RPMTAG_SUGGESTSFLAGS:
+    case RPMTAG_ENHANCESFLAGS:
+	h = pkg->header;
+	break;
+    case RPMTAG_BUILDSUGGESTS:
+    case RPMTAG_BUILDENHANCES:
+        h = spec->buildRestrictions;
+        break;
     default:
     case RPMTAG_REQUIREFLAGS:
 	tagflags |= RPMSENSE_ANY;
Index: build/reqprov.c
===================================================================
--- build/reqprov.c.orig	2008-04-01 08:28:21.000000000 +0100
+++ build/reqprov.c	2008-08-26 16:58:09.000000000 +0100
@@ -48,6 +48,16 @@
 	flagtag = RPMTAG_TRIGGERFLAGS;
 	indextag = RPMTAG_TRIGGERINDEX;
 	extra = Flags & RPMSENSE_TRIGGER;
+    } else if (tagN == RPMTAG_SUGGESTSFLAGS || tagN == RPMTAG_BUILDSUGGESTS) {
+	nametag = RPMTAG_SUGGESTSNAME;
+	versiontag = RPMTAG_SUGGESTSVERSION;
+	flagtag = RPMTAG_SUGGESTSFLAGS;
+	extra = Flags & _ALL_REQUIRES_MASK;
+    } else if (tagN == RPMTAG_ENHANCESFLAGS || tagN == RPMTAG_BUILDENHANCES) {
+	nametag = RPMTAG_ENHANCESNAME;
+	versiontag = RPMTAG_ENHANCESVERSION;
+	flagtag = RPMTAG_ENHANCESFLAGS;
+	extra = Flags & _ALL_REQUIRES_MASK;
     } else {
 	nametag = RPMTAG_REQUIRENAME;
 	versiontag = RPMTAG_REQUIREVERSION;
Index: build/rpmfc.c
===================================================================
--- build/rpmfc.c.orig	2008-04-01 08:28:21.000000000 +0100
+++ build/rpmfc.c	2008-08-26 16:58:09.000000000 +0100
@@ -1385,6 +1385,12 @@
   { "Obsoletes",	{ "%{?__find_obsoletes}", NULL, NULL, NULL },
 	RPMTAG_OBSOLETENAME, RPMTAG_OBSOLETEVERSION, RPMTAG_OBSOLETEFLAGS,
 	0, -1 },
+  { "Enhances",		{ "%{?__find_enhances}", NULL, NULL, NULL },
+	RPMTAG_ENHANCESNAME, RPMTAG_ENHANCESVERSION, RPMTAG_ENHANCESFLAGS,
+	RPMSENSE_STRONG, RPMSENSE_STRONG },
+  { "Supplements",	{ "%{?__find_supplements}", NULL, NULL, NULL },
+	RPMTAG_ENHANCESNAME, RPMTAG_ENHANCESVERSION, RPMTAG_ENHANCESFLAGS,
+	RPMSENSE_STRONG, 0 },
   { NULL,		{ NULL, NULL, NULL, NULL },	0, 0, 0, 0, 0 }
 };
 
@@ -1480,6 +1486,14 @@
 	    failnonzero = 0;
 	    tagflags = RPMSENSE_FIND_REQUIRES;
 	    /*@switchbreak@*/ break;
+	case RPMTAG_ENHANCESFLAGS:
+	    if (!pkg->autoProv)
+		continue;
+	    failnonzero = 0;
+	    tagflags = RPMSENSE_FIND_REQUIRES | RPMSENSE_MISSINGOK;
+	    if (strcmp(dm->msg, "Supplements") == 0)
+		tagflags |= RPMSENSE_STRONG;
+	    /*@switchbreak@*/ break;
 	default:
 	    continue;
 	    /*@notreached@*/ /*@switchbreak@*/ break;
Index: lib/rpmlib.h
===================================================================
--- lib/rpmlib.h.orig	2008-04-01 08:28:22.000000000 +0100
+++ lib/rpmlib.h	2008-08-26 17:00:37.000000000 +0100
@@ -530,7 +530,7 @@
     RPMSENSE_TRIGGERPREIN = (1 << 25),	/*!< @todo Implement %triggerprein. */
 /*@=enummemuse@*/
     RPMSENSE_KEYRING	= (1 << 26),
-    RPMSENSE_PATCHES	= (1 << 27),
+    RPMSENSE_STRONG	= (1 << 27),
     RPMSENSE_CONFIG	= (1 << 28)
 } rpmsenseFlags;
 
Index: python/rpmmodule.c
===================================================================
--- python/rpmmodule.c.orig	2008-04-01 08:28:22.000000000 +0100
+++ python/rpmmodule.c	2008-08-26 16:58:09.000000000 +0100
@@ -433,7 +433,7 @@
     REGISTER_ENUM(RPMSENSE_RPMLIB);
     REGISTER_ENUM(RPMSENSE_TRIGGERPREIN);
     REGISTER_ENUM(RPMSENSE_KEYRING);
-    REGISTER_ENUM(RPMSENSE_PATCHES);
+    REGISTER_ENUM(RPMSENSE_STRONG);
     REGISTER_ENUM(RPMSENSE_CONFIG);
 
     REGISTER_ENUM(RPMTRANS_FLAG_TEST);
Index: lib/rpmds.c
===================================================================
--- lib/rpmds.c.orig	2008-04-01 08:28:22.000000000 +0100
+++ lib/rpmds.c	2008-08-26 16:58:09.000000000 +0100
@@ -320,6 +320,11 @@
 	tagEVR = RPMTAG_TRIGGERVERSION;
 	tagF = RPMTAG_TRIGGERFLAGS;
     } else
+    if (tagN == RPMTAG_ENHANCESNAME) {
+	Type = "Enhances";
+	tagEVR = RPMTAG_ENHANCESVERSION;
+	tagF = RPMTAG_ENHANCESFLAGS;
+    } else
 	goto exit;
 
     /*@-branchstate@*/
Index: rpmpopt.in
===================================================================
--- rpmpopt.in.orig	2008-04-01 08:28:22.000000000 +0100
+++ rpmpopt.in	2008-08-26 16:58:09.000000000 +0100
@@ -68,6 +68,22 @@
 	--POPTdesc=$"list capabilities required by package(s)"
 rpm	alias -R --requires
 
+rpm	alias --suggests	--qf \
+  "[%|SUGGESTSFLAGS:depflag_strong?{}:{%{SUGGESTSNAME} %{SUGGESTSFLAGS:depflags} %{SUGGESTSVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package suggests"
+
+rpm	alias --recommends	--qf \
+  "[%|SUGGESTSFLAGS:depflag_strong?{%{SUGGESTSNAME} %{SUGGESTSFLAGS:depflags} %{SUGGESTSVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package recommends"
+
+rpm	alias --enhances	--qf \
+  "[%|ENHANCESFLAGS:depflag_strong?{}:{%{ENHANCESNAME} %{ENHANCESFLAGS:depflags} %{ENHANCESVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package enhances"
+
+rpm	alias --supplements	--qf \
+  "[%|ENHANCESFLAGS:depflag_strong?{%{ENHANCESNAME} %{ENHANCESFLAGS:depflags} %{ENHANCESVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package supplements"
+
 rpm	alias --info --qf 'Name        : %-27{NAME}  Relocations: %|PREFIXES?{[%{PREFIXES} ]}:{(not relocatable)}|\n\
 Version     : %-27{VERSION}       Vendor: %{VENDOR}\n\
 Release     : %-27{RELEASE}   Build Date: %{BUILDTIME:date}\n\
@@ -351,6 +367,22 @@
 	--POPTdesc=$"list capabilities required by package(s)"
 rpmq	alias -R --requires
 
+rpmq	alias --suggests	--qf \
+  "[%|SUGGESTSFLAGS:depflag_strong?{}:{%{SUGGESTSNAME} %{SUGGESTSFLAGS:depflags} %{SUGGESTSVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package suggests"
+
+rpmq	alias --recommends	--qf \
+  "[%|SUGGESTSFLAGS:depflag_strong?{%{SUGGESTSNAME} %{SUGGESTSFLAGS:depflags} %{SUGGESTSVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package recommends"
+
+rpmq	alias --enhances	--qf \
+  "[%|ENHANCESFLAGS:depflag_strong?{}:{%{ENHANCESNAME} %{ENHANCESFLAGS:depflags} %{ENHANCESVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package enhances"
+
+rpmq	alias --supplements	--qf \
+  "[%|ENHANCESFLAGS:depflag_strong?{%{ENHANCESNAME} %{ENHANCESFLAGS:depflags} %{ENHANCESVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package supplements"
+
 rpmq	alias --info --qf 'Name        : %-27{NAME}  Relocations: %|PREFIXES?{[%{PREFIXES} ]}:{(not relocatable)}|\n\
 Version     : %-27{VERSION}       Vendor: %{VENDOR}\n\
 Release     : %-27{RELEASE}   Build Date: %{BUILDTIME:date}\n\
@@ -452,6 +484,22 @@
 	--POPTdesc=$"list capabilities required by package(s)"
 rpmquery	alias -R --requires
 
+rpmquery	alias --suggests	--qf \
+  "[%|SUGGESTSFLAGS:depflag_strong?{}:{%{SUGGESTSNAME} %{SUGGESTSFLAGS:depflags} %{SUGGESTSVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package suggests"
+
+rpmquery	alias --recommends	--qf \
+  "[%|SUGGESTSFLAGS:depflag_strong?{%{SUGGESTSNAME} %{SUGGESTSFLAGS:depflags} %{SUGGESTSVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package recommends"
+
+rpmquery	alias --enhances	--qf \
+  "[%|ENHANCESFLAGS:depflag_strong?{}:{%{ENHANCESNAME} %{ENHANCESFLAGS:depflags} %{ENHANCESVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package enhances"
+
+rpmquery	alias --supplements	--qf \
+  "[%|ENHANCESFLAGS:depflag_strong?{%{ENHANCESNAME} %{ENHANCESFLAGS:depflags} %{ENHANCESVERSION}\n}|]" \
+	--POPTdesc=$"list capabilities this package supplements"
+
 rpmquery	alias --info --qf 'Name        : %-27{NAME}  Relocations: %|PREFIXES?{[%{PREFIXES} ]}:{(not relocatable)}|\n\
 Version     : %-27{VERSION}       Vendor: %{VENDOR}\n\
 Release     : %-27{RELEASE}   Build Date: %{BUILDTIME:date}\n\
Index: lib/formats.c
===================================================================
--- lib/formats.c.orig	2008-04-01 08:28:22.000000000 +0100
+++ lib/formats.c	2008-08-26 16:58:09.000000000 +0100
@@ -543,6 +543,38 @@
     return val;
 }
 
+static /*@only@*/ char * depflag_strongFormat(int_32 type, const void * data,
+		char * formatPrefix, int padding, /*@unused@*/ int element)
+	/*@modifies formatPrefix @*/
+	/*@requires maxRead(data) >= 0 @*/
+{
+    char * val;
+    char buf[10];
+    int anint;
+
+    if (type != RPM_INT32_TYPE) {
+	val = xstrdup(_("(not a number)"));
+    } else {
+	anint = *((int_32 *) data);
+	buf[0] = '\0';
+
+/*@-boundswrite@*/
+	if (anint & RPMSENSE_STRONG)
+	    strcat(buf, "strong");
+/*@=boundswrite@*/
+
+	val = xmalloc(7 + padding);
+/*@-boundswrite@*/
+	strcat(formatPrefix, "s");
+/*@=boundswrite@*/
+	/*@-formatconst@*/
+	sprintf(val, formatPrefix, buf);
+	/*@=formatconst@*/
+    }
+
+    return val;
+}
+
 /**
  * Retrieve mounted file system paths.
  * @param h		header
@@ -1171,6 +1203,7 @@
     { HEADER_EXT_FORMAT, "base64",		{ base64Format } },
     { HEADER_EXT_FORMAT, "pgpsig",		{ pgpsigFormat } },
     { HEADER_EXT_FORMAT, "depflags",		{ depflagsFormat } },
+    { HEADER_EXT_FORMAT, "depflag_strong",	{ depflag_strongFormat } },
     { HEADER_EXT_FORMAT, "fflags",		{ fflagsFormat } },
     { HEADER_EXT_FORMAT, "perms",		{ permsFormat } },
     { HEADER_EXT_FORMAT, "permissions",		{ permsFormat } },