avatar
ngompa has added fb49a705c7
Port Recommends tag and behavior from rpm.org rpm 4.12

This is being introduced as a way to provide forward compatibility
to rpm.org rpm used in OpenMandriva Lx 4, ROSA 2019.1, PLD (from 2020
onward), and most other RPM-based Linux distributions.

With this change, spec files can use 'Recommends' the same way that
'Suggests' was used. With the tag ID matching what rpm.org RPM
defines it as, it will be read properly by rpm.org RPM too.

This is not being put in a vendor conditional, since this feature
is common to all distributions using rpm.org's RPM.

view file @ fb49a705c7
... ... --- a/build/parsePreamble.c
... ... +++ b/build/parsePreamble.c
... ... @@ -845,6 +845,7 @@ static rpmRC handlePreambleTag(Spec spec, Package pkg, rpmTag tag,
845 845
	    return rc;
846 846
	break;
847 847
    /* Aliases for Requires(hint): */
848
    case RPMTAG_RECOMMENDSFLAGS:
848 849
    case RPMTAG_SUGGESTSFLAGS:
849 850
    case RPMTAG_ENHANCESFLAGS:
850 851
	tag = RPMTAG_REQUIREFLAGS;
... ... @@ -980,6 +981,7 @@ static struct PreambleRec_s preambleList[] = {
981 981
    {RPMTAG_BUGURL,		0, 0, "bugurl"},
982 982
    {RPMTAG_CVSID,		0, 0, "cvsid"},
983 983
    {RPMTAG_SVNID,		0, 0, "svnid"},
984
    {RPMTAG_RECOMMENDSFLAGS,	0, 0, "recommends"},
984 985
    {RPMTAG_SUGGESTSFLAGS,	0, 0, "suggests"},
985 986
    {RPMTAG_ENHANCESFLAGS,	0, 0, "enhances"},
986 987
    {RPMTAG_BUILDSUGGESTS,	0, 0, "buildsuggests"},
... ... --- a/lib/formats.c
... ... +++ b/lib/formats.c
... ... @@ -296,6 +296,8 @@ static struct headerSprintfExtension_s _rpmHeaderFormats[] = {
296 296
    { HEADER_EXT_TAG, "RPMTAG_RECONTEXTS",
297 297
	{ .tagFunction = recontextsTag } },
298 298
#endif
299
    { HEADER_EXT_TAG, "RPMTAG_RECOMMENDS",
300
	{ .tagFunction = missingokTag } },
299 301
    { HEADER_EXT_TAG, "RPMTAG_SUGGESTS",
300 302
	{ .tagFunction = missingokTag } },
301 303
    { HEADER_EXT_MORE, NULL,		{ (void *) &headerCompoundFormats } }
... ... --- a/lib/rpmds.c
... ... +++ b/lib/rpmds.c
... ... @@ -149,6 +149,7 @@ static const char * rpmdsTagName(rpmTag tagN)
149 149
    case RPMTAG_CONFLICTNAME:	Type = "Conflicts";	break;
150 150
    case RPMTAG_OBSOLETENAME:	Type = "Obsoletes";	break;
151 151
    case RPMTAG_TRIGGERNAME:	Type = "Triggers";	break;
152
    case RPMTAG_RECOMMENDSNAME:	Type = "Recommends";	break;
152 153
    case RPMTAG_SUGGESTSNAME:	Type = "Suggests";	break;
153 154
    case RPMTAG_ENHANCESNAME:	Type = "Enhances";	break;
154 155
    case RPMTAG_DIRNAMES:	Type = "Dirs";		break;
... ... @@ -276,6 +277,10 @@ assert(scareMem == 0); /* XXX always allocate memory */
277 277
	tagEVR = RPMTAG_TRIGGERVERSION;
278 278
	tagF = RPMTAG_TRIGGERFLAGS;
279 279
	break;
280
    case RPMTAG_RECOMMENDSNAME:
281
	tagEVR = RPMTAG_RECOMMENDSVERSION;
282
	tagF = RPMTAG_RECOMMENDSFLAGS;
283
	break;
280 284
    case RPMTAG_SUGGESTSNAME:
281 285
	tagEVR = RPMTAG_SUGGESTSVERSION;
282 286
	tagF = RPMTAG_SUGGESTSFLAGS;
view file @ fb49a705c7
... ... --- a/rpmconstant/rpmconstanttbl.c
... ... +++ b/rpmconstant/rpmconstanttbl.c
... ... @@ -1016,6 +1016,10 @@ static const struct rpmconstant_s rpmTagctbl[] = {
1016 1016
	{ "RPMTAG_PRETRANSPROG", RPMTAG_PRETRANSPROG }, /* s */
1017 1017
	{ "RPMTAG_POSTTRANSPROG", RPMTAG_POSTTRANSPROG }, /* s */
1018 1018
	{ "RPMTAG_DISTTAG", RPMTAG_DISTTAG }, /* s */
1019
	{ "RPMTAG_RECOMMENDSNAME", RPMTAG_RECOMMENDSNAME }, /* s[] extension */
1020
	{ "RPMTAG_RECOMMENDS", RPMTAG_RECOMMENDS }, /* s[] */
1021
	{ "RPMTAG_RECOMMENDSVERSION", RPMTAG_RECOMMENDSVERSION }, /* s[] extension */
1022
	{ "RPMTAG_RECOMMENDSFLAGS", RPMTAG_RECOMMENDSFLAGS }, /* i[] extension */
1019 1023
	{ "RPMTAG_SUGGESTSNAME", RPMTAG_SUGGESTSNAME }, /* s[] extension */
1020 1024
	{ "RPMTAG_SUGGESTS", RPMTAG_SUGGESTS }, /* s[] */
1021 1025
	{ "RPMTAG_SUGGESTSVERSION", RPMTAG_SUGGESTSVERSION }, /* s[] extension */
view file @ fb49a705c7
... ... --- a/rpmdb/rpmtag.h
... ... +++ b/rpmdb/rpmtag.h
... ... @@ -423,6 +423,13 @@ enum rpmTag_e {
423 423
    RPMTAG_FILEDIGESTALGO	= 5011, /* i file checksum algorithm */
424 424
    RPMTAG_BUGURL		= 5012, /* s */
425 425
426
/* for forward-compat with rpm.org rpm 4.12+ */
427
    RPMTAG_RECOMMENDSNAME	= 5046,	/* s[] extension */
428
#define	RPMTAG_RECOMMENDS RPMTAG_RECOMMENDSNAME	/* s[] */
429
    RPMTAG_RECOMMENDSVERSION	= 5047,	/* s[] extension */
430
    RPMTAG_RECOMMENDSFLAGS	= 5048,	/* i[] extension */
431
432
426 433
/*@-enummemuse@*/
427 434
    RPMTAG_FIRSTFREE_TAG,	/*!< internal */
428 435
/*@=enummemuse@*/
view file @ fb49a705c7
... ... --- a/rpmdb/tagtbl.c
... ... +++ b/rpmdb/tagtbl.c
... ... @@ -208,6 +208,10 @@ static const struct headerTagTableEntry_s _rpmTagTable[] = {
208 208
	{ "RPMTAG_SOURCEPKGID",	1146,	RPM_BIN_TYPE + RPM_SCALAR_RETURN_TYPE },
209 209
	{ "RPMTAG_SOURCERPM",	1044,	RPM_STRING_TYPE + RPM_SCALAR_RETURN_TYPE },
210 210
	{ "RPMTAG_STAT",	1208,	RPM_STRING_ARRAY_TYPE + RPM_ARRAY_RETURN_TYPE },
211
	{ "RPMTAG_RECOMMENDS",	RPMTAG_RECOMMENDSNAME,	RPM_STRING_ARRAY_TYPE + RPM_ARRAY_RETURN_TYPE  },
212
	{ "RPMTAG_RECOMMENDSFLAGS",	5048,	RPM_UINT32_TYPE + RPM_ARRAY_RETURN_TYPE },
213
	{ "RPMTAG_RECOMMENDSNAME",	5046,	RPM_STRING_ARRAY_TYPE + RPM_ARRAY_RETURN_TYPE },
214
	{ "RPMTAG_RECOMMENDSVERSION",	5047,	RPM_STRING_ARRAY_TYPE + RPM_ARRAY_RETURN_TYPE },
211 215
	{ "RPMTAG_SUGGESTS",	RPMTAG_SUGGESTSNAME,	RPM_STRING_ARRAY_TYPE + RPM_ARRAY_RETURN_TYPE  },
212 216
	{ "RPMTAG_SUGGESTSFLAGS",	1158,	RPM_UINT32_TYPE + RPM_ARRAY_RETURN_TYPE },
213 217
	{ "RPMTAG_SUGGESTSNAME",	1156,	RPM_STRING_ARRAY_TYPE + RPM_ARRAY_RETURN_TYPE },
... ... --- a/rpmpopt.in
... ... +++ b/rpmpopt.in
... ... @@ -103,6 +103,9 @@ rpm alias --requires --qf \
103 103
	--POPTdesc=$"list capabilities required by package(s)"
104 104
rpm	alias -R --requires
105 105
106
rpm	alias --recommends	--qf "[%{recommends}\n]" \
107
	--POPTdesc=$"list enhancements suggested by package(s)"
108
106 109
rpm	alias --suggests	--qf "[%{suggests}\n]" \
107 110
	--POPTdesc=$"list enhancements suggested by package(s)"
108 111
view file @ fb49a705c7
... ... --- a/tests/ref/querytags
... ... +++ b/tests/ref/querytags
... ... @@ -199,6 +199,10 @@ SOURCEPACKAGE 1106 uint32
199 199
SOURCEPKGID            1146 octets
200 200
SOURCERPM              1044 string
201 201
STAT                   1208 argv array
202
RECOMMENDS             5046 argv array
203
RECOMMENSFLAGS         5048 uint32 array
204
RECOMMENDSNAME         5046 argv array
205
RECOMMENDSVERSION      5047 argv array
202 206
SUGGESTS               1156 argv array
203 207
SUGGESTSFLAGS          1158 uint32 array
204 208
SUGGESTSNAME           1156 argv array

Comments