rpm/weakdeps.diff
OBS User autobuild a76d6c30a2 Accepting request 18841 from Base:System
Copy from Base:System/rpm based on submit request 18841 from user mlschroe

OBS-URL: https://build.opensuse.org/request/show/18841
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpm?expand=0&rev=84
2009-08-28 13:54:03 +00:00

297 lines
11 KiB
Diff

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
+++ build/parsePreamble.c
@@ -122,6 +122,8 @@ static struct tokenBits_s const installS
{ "post", RPMSENSE_SCRIPT_POST },
{ "rpmlib", RPMSENSE_RPMLIB },
{ "verify", RPMSENSE_SCRIPT_VERIFY },
+ { "hint", RPMSENSE_MISSINGOK },
+ { "strong", RPMSENSE_STRONG },
{ NULL, 0 }
};
@@ -132,6 +134,8 @@ static const struct tokenBits_s const bu
{ "build", RPMSENSE_SCRIPT_BUILD },
{ "install", RPMSENSE_SCRIPT_INSTALL },
{ "clean", RPMSENSE_SCRIPT_CLEAN },
+ { "hint", RPMSENSE_MISSINGOK },
+ { "strong", RPMSENSE_STRONG },
{ NULL, 0 }
};
@@ -637,6 +641,18 @@ static int handlePreambleTag(rpmSpec spe
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:
@@ -734,6 +750,14 @@ static struct PreambleRec_s preambleList
{RPMTAG_AUTOPROV, 0, 0, 0, "autoprov"},
{RPMTAG_DOCDIR, 0, 0, 0, "docdir"},
{RPMTAG_DISTTAG, 0, 0, 0, "disttag"},
+ {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"},
/* LCL: can't add null annotation */
{0, 0, 0, 0, 0}
};
Index: build/parseReqs.c
===================================================================
--- build/parseReqs.c.orig
+++ build/parseReqs.c
@@ -84,6 +84,14 @@ rpmRC parseRCPOT(rpmSpec spec, Package p
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
+++ build/reqprov.c
@@ -43,6 +43,16 @@ int addReqProv(rpmSpec spec, Header h, r
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
+++ build/rpmfc.c
@@ -1377,6 +1377,12 @@ static struct DepMsg_s depMsgs[] = {
{ "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 }
};
@@ -1467,6 +1473,14 @@ static int rpmfcGenerateDependsHelper(co
failnonzero = 0;
tagflags = RPMSENSE_FIND_REQUIRES;
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;
+ break;
default:
continue;
break;
Index: python/rpmmodule.c
===================================================================
--- python/rpmmodule.c.orig
+++ python/rpmmodule.c
@@ -387,7 +387,7 @@ void init_rpm(void)
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
+++ lib/rpmds.c
@@ -73,6 +73,10 @@ static int dsType(rpmTag tag,
t = "Trigger";
evr = RPMTAG_TRIGGERVERSION;
f = RPMTAG_TRIGGERFLAGS;
+ } else if (tag == RPMTAG_ENHANCESNAME) {
+ t = "Enhances";
+ evr = RPMTAG_ENHANCESVERSION;
+ f = RPMTAG_ENHANCESFLAGS;
} else {
rc = 1;
}
Index: rpmpopt.in
===================================================================
--- rpmpopt.in.orig
+++ rpmpopt.in
@@ -65,6 +65,22 @@ rpm alias --requires --qf \
--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\
Index: lib/formats.c
===================================================================
--- lib/formats.c.orig
+++ lib/formats.c
@@ -601,6 +601,25 @@ static char * depflagsFormat(rpmtd td, c
return val;
}
+static char * depflag_strongFormat(rpmtd td, char * formatPrefix)
+{
+ char * val = NULL;
+
+ if (rpmtdType(td) != RPM_NUMERIC_CLASS) {
+ val = xstrdup(_("(not a number)"));
+ } else {
+ uint64_t anint = rpmtdGetNumber(td);
+ char buf[10];
+ buf[0] = '\0';
+ if (anint & RPMSENSE_STRONG)
+ strcat(buf, "strong");
+ strcat(formatPrefix, "s");
+ rasprintf(&val, formatPrefix, buf);
+ }
+
+ return val;
+}
+
/**
* Return tag container array size.
* @param td tag data container
@@ -661,5 +680,6 @@ static const struct headerFormatFunc_s r
{ RPMTD_FORMAT_DAY, "day", dayFormat },
{ RPMTD_FORMAT_SHESCAPE, "shescape", shescapeFormat },
{ RPMTD_FORMAT_ARRAYSIZE, "arraysize", arraysizeFormat },
+ { RPMTD_FORMAT_DEPFLAG_STRONG, "depflag_strong", { depflag_strongFormat } },
{ -1, NULL, NULL }
};
Index: lib/rpmds.h
===================================================================
--- lib/rpmds.h.orig
+++ lib/rpmds.h
@@ -55,7 +55,7 @@ typedef enum rpmsenseFlags_e {
RPMSENSE_RPMLIB = (1 << 24), /*!< rpmlib(feature) dependency. */
RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< %triggerprein dependency. */
RPMSENSE_KEYRING = (1 << 26),
- RPMSENSE_PATCHES = (1 << 27),
+ RPMSENSE_STRONG = (1 << 27),
RPMSENSE_CONFIG = (1 << 28)
} rpmsenseFlags;
@@ -74,6 +74,7 @@ typedef enum rpmsenseFlags_e {
RPMSENSE_SCRIPT_VERIFY | \
RPMSENSE_FIND_REQUIRES | \
RPMSENSE_MISSINGOK | \
+ RPMSENSE_STRONG | \
RPMSENSE_SCRIPT_PREP | \
RPMSENSE_SCRIPT_BUILD | \
RPMSENSE_SCRIPT_INSTALL | \
Index: lib/rpmtd.h
===================================================================
--- lib/rpmtd.h.orig
+++ lib/rpmtd.h
@@ -214,6 +214,7 @@ typedef enum rpmtdFormats_e {
RPMTD_FORMAT_SHESCAPE = 13, /* shell escaped (any type) */
RPMTD_FORMAT_ARRAYSIZE = 14, /* size of contained array (any type) */
RPMTD_FORMAT_DEPTYPE = 15, /* dependency types (int32 types) */
+ RPMTD_FORMAT_DEPFLAG_STRONG = 16, /* strong dependency */
} rpmtdFormats;
/** \ingroup rpmtd
Index: lib/rpmtag.h
===================================================================
--- lib/rpmtag.h.orig
+++ lib/rpmtag.h
@@ -228,14 +228,14 @@ typedef enum rpmTag_e {
RPMTAG_PRETRANSPROG = 1153, /* s */
RPMTAG_POSTTRANSPROG = 1154, /* s */
RPMTAG_DISTTAG = 1155, /* s */
- RPMTAG_SUGGESTSNAME = 1156, /* s[] extension (unimplemented) */
-#define RPMTAG_SUGGESTS RPMTAG_SUGGESTSNAME /* s[] (unimplemented) */
- RPMTAG_SUGGESTSVERSION = 1157, /* s[] extension (unimplemented) */
- RPMTAG_SUGGESTSFLAGS = 1158, /* i[] extension (unimplemented) */
- RPMTAG_ENHANCESNAME = 1159, /* s[] extension placeholder (unimplemented) */
-#define RPMTAG_ENHANCES RPMTAG_ENHANCESNAME /* s[] (unimplemented) */
- RPMTAG_ENHANCESVERSION = 1160, /* s[] extension placeholder (unimplemented) */
- RPMTAG_ENHANCESFLAGS = 1161, /* i[] extension placeholder (unimplemented) */
+ RPMTAG_SUGGESTSNAME = 1156, /* s[] extension */
+#define RPMTAG_SUGGESTS RPMTAG_SUGGESTSNAME /* s[] */
+ RPMTAG_SUGGESTSVERSION = 1157, /* s[] extension */
+ RPMTAG_SUGGESTSFLAGS = 1158, /* i[] extension */
+ RPMTAG_ENHANCESNAME = 1159, /* s[] extension */
+#define RPMTAG_ENHANCES RPMTAG_ENHANCESNAME /* s[] */
+ RPMTAG_ENHANCESVERSION = 1160, /* s[] extension */
+ RPMTAG_ENHANCESFLAGS = 1161, /* i[] extension */
RPMTAG_PRIORITY = 1162, /* i[] extension placeholder (unimplemented) */
RPMTAG_CVSID = 1163, /* s (unimplemented) */
#define RPMTAG_SVNID RPMTAG_CVSID /* s (unimplemented) */