rpm-build/lib/rpmlibprov.c
Vitaly Chikunov 785ae7a9a2 Backport: Add support for dpkg-style sorting of tilde in version/release
Original commit message:

- This allows much nicer handling some common scenarios such as
  upstream pre-releases where the pre-release version would normally
  appear newer than final release, eg 1.0-rc1 vs 1.0. Previously this
  required mapping the pre-release tag into the release tag to achieve
  desired sorting, with tilde this becomes simply 1.0~rc1 < 1.0.
- Add a rpmlib() tracking dependency to prevent older rpm versions
  from getting confused with packages relying on the new behavior.

Picked: db28221a4a ("Add support for dpkg-style sorting of tilde in version/release")
Authored-by: Michael Schroeder <mls@suse.de>
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
Picked: 8002b3f985 ("Spelling fixes.")
Authored-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
Link: https://bugzilla.altlinux.org/46585
[ vt: Change to parseRCPOT is not applied because no rpmCharCheck call.
  Unsupported RPM tags (ORDERVERSION, SUGGESTSVERSION, ENHANCESVERSION)
  are removed. haveTildeDep is reworked because we don't have headerGet
  API. ]
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
2023-09-10 21:33:18 +03:00

135 lines
4.2 KiB
C

/** \ingroup rpmdep
* \file lib/rpmlibprov.c
*/
#include "system.h"
#include "rpmlib.h"
#include "debug.h"
static struct rpmlibProvides_s {
/*@observer@*/ /*@null@*/ const char * featureName;
/*@observer@*/ /*@null@*/ const char * featureEVR;
int featureFlags;
/*@observer@*/ /*@null@*/ const char * featureDescription;
} rpmlibProvides[] = {
{ "rpmlib(VersionedDependencies)", "3.0.3-1",
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("PreReq:, Provides:, and Obsoletes: dependencies support versions.") },
{ "rpmlib(CompressedFileNames)", "3.0.4-1",
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("file name(s) are stored as (dirName,baseName,dirIndex) tuple, not as path.")},
#ifdef HAVE_BZLIB_H
{ "rpmlib(PayloadIsBzip2)", "3.0.5-1",
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("package payload is compressed using bzip2.") },
#endif
{ "rpmlib(PayloadIsLzma)", "4.4.2-1",
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("package payload can be compressed using lzma.") },
{ "rpmlib(PayloadIsXz)", "5.2-1",
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("package payload can be compressed using xz.") },
{ "rpmlib(PayloadFilesHavePrefix)", "4.0-1",
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("package payload file(s) have \"./\" prefix.") },
{ "rpmlib(ExplicitPackageProvide)", "4.0-1",
(RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("package name-version-release is not implicitly provided.") },
{ "rpmlib(HeaderLoadSortsTags)", "4.0.1-1",
( RPMSENSE_EQUAL),
N_("header tags are always sorted after being loaded.") },
{ "rpmlib(ScriptletInterpreterArgs)", "4.0.3-1",
( RPMSENSE_EQUAL),
N_("the scriptlet interpreter can use arguments from header.") },
{ "rpmlib(PartialHardlinkSets)", "4.0.4-1",
( RPMSENSE_EQUAL),
N_("a hardlink file set may be installed without being complete.") },
{ "rpmlib(PosttransFiletriggers)", "4.0.4",
( RPMSENSE_EQUAL),
N_("package installs post-transaction filetrigger.") },
{ "rpmlib(SetVersions)", "4.0.4-alt98",
( RPMSENSE_EQUAL),
N_("dependencies support set/subset versions.") },
{ "rpmlib(TildeInVersions)", "4.10.0-1",
( RPMSENSE_EQUAL),
N_("dependency comparison supports versions with tilde.") },
{ NULL, NULL, 0, NULL }
};
void rpmShowRpmlibProvides(FILE * fp)
{
const struct rpmlibProvides_s * rlp;
for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
fprintf(fp, " %s", rlp->featureName);
if (rlp->featureEVR && rlp->featureFlags)
printDepFlags(fp, rlp->featureEVR, rlp->featureFlags);
fprintf(fp, "\n");
if (rlp->featureDescription)
fprintf(fp, "\t%s\n", rlp->featureDescription);
}
}
int rpmCheckRpmlibProvides(const char * keyName, const char * keyEVR,
int keyFlags)
{
const struct rpmlibProvides_s * rlp;
int rc = 0;
for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
if (rlp->featureEVR && rlp->featureFlags)
rc = rpmRangesOverlap(keyName, keyEVR, keyFlags,
rlp->featureName, rlp->featureEVR, rlp->featureFlags);
if (rc)
break;
}
return rc;
}
int rpmGetRpmlibProvides(const char *** provNames, int ** provFlags,
const char *** provVersions)
{
const char ** names, ** versions;
int * flags;
int n = 0;
while (rpmlibProvides[n].featureName != NULL)
n++;
names = xcalloc((n+1), sizeof(*names));
versions = xcalloc((n+1), sizeof(*versions));
flags = xcalloc((n+1), sizeof(*flags));
for (n = 0; rpmlibProvides[n].featureName != NULL; n++) {
names[n] = rpmlibProvides[n].featureName;
flags[n] = rpmlibProvides[n].featureFlags;
versions[n] = rpmlibProvides[n].featureEVR;
}
/*@-branchstate@*/
if (provNames)
*provNames = names;
else
names = _free(names);
/*@=branchstate@*/
/*@-branchstate@*/
if (provFlags)
*provFlags = flags;
else
flags = _free(flags);
/*@=branchstate@*/
/*@-branchstate@*/
if (provVersions)
*provVersions = versions;
else
versions = _free(versions);
/*@=branchstate@*/
/*@-compmempass@*/ /* FIX: rpmlibProvides[] reachable */
return n;
/*@=compmempass@*/
}