summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-04-23 11:04:02 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-04-23 11:04:02 +0300
commitdb28221a4a48f6ee3c804c92314330637c808638 (patch)
tree46fd4d1866729a65ba419c74668276551e27e96d /build
parent4935f4853227d3981ba86d5557ae36704a1f67f2 (diff)
downloadlibrpm-tizen-db28221a4a48f6ee3c804c92314330637c808638.tar.gz
librpm-tizen-db28221a4a48f6ee3c804c92314330637c808638.tar.bz2
librpm-tizen-db28221a4a48f6ee3c804c92314330637c808638.zip
Add support for dpkg-style sorting of tilde in version/release
- 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 tild 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. Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
Diffstat (limited to 'build')
-rw-r--r--build/pack.c40
-rw-r--r--build/parsePreamble.c2
-rw-r--r--build/parseReqs.c2
3 files changed, 42 insertions, 2 deletions
diff --git a/build/pack.c b/build/pack.c
index 000d47688..ebfee5723 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -231,6 +231,42 @@ static rpmRC copyPayload(FD_t ifd, const char *ifn, FD_t ofd, const char *ofn)
return rc;
}
+static int depContainsTilde(Header h, rpmTagVal tagEVR)
+{
+ struct rpmtd_s evrs;
+ const char *evr = NULL;
+
+ if (headerGet(h, tagEVR, &evrs, HEADERGET_MINMEM)) {
+ while ((evr = rpmtdNextString(&evrs)) != NULL)
+ if (strchr(evr, '~'))
+ break;
+ rpmtdFreeData(&evrs);
+ }
+ return evr != NULL;
+}
+
+static rpmTagVal depevrtags[] = {
+ RPMTAG_PROVIDEVERSION,
+ RPMTAG_REQUIREVERSION,
+ RPMTAG_OBSOLETEVERSION,
+ RPMTAG_CONFLICTVERSION,
+ RPMTAG_ORDERVERSION,
+ RPMTAG_TRIGGERVERSION,
+ RPMTAG_SUGGESTSVERSION,
+ RPMTAG_ENHANCESVERSION,
+ 0
+};
+
+static int haveTildeDep(Header h)
+{
+ int i;
+
+ for (i = 0; depevrtags[i] != 0; i++)
+ if (depContainsTilde(h, depevrtags[i]))
+ return 1;
+ return 0;
+}
+
static rpmRC writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
CSA_t csa, char **cookie)
{
@@ -305,6 +341,10 @@ static rpmRC writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileNam
free(buf);
}
+ /* check if the package has a dependency with a '~' */
+ if (haveTildeDep(h))
+ (void) rpmlibNeedsFeature(h, "TildeInVersions", "4.10.0-1");
+
/* Create and add the cookie */
if (cookie) {
rasprintf(cookie, "%s %d", buildHost(), (int) (*getBuildTime()));
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 9944513c0..3ba035f05 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -699,7 +699,7 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
case RPMTAG_VERSION:
case RPMTAG_RELEASE:
SINGLE_TOKEN_ONLY;
- if (rpmCharCheck(spec, field, strlen(field), "._+%{}"))
+ if (rpmCharCheck(spec, field, strlen(field), "._+%{}~"))
goto exit;
headerPutString(pkg->header, tag, field);
break;
diff --git a/build/parseReqs.c b/build/parseReqs.c
index de2680cca..5ad0501e4 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -156,7 +156,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
}
EVR = xmalloc((ve-v) + 1);
rstrlcpy(EVR, v, (ve-v) + 1);
- if (rpmCharCheck(spec, EVR, ve-v, ".-_+:%{}")) goto exit;
+ if (rpmCharCheck(spec, EVR, ve-v, ".-_+:%{}~")) goto exit;
re = ve; /* ==> next token after EVR string starts here */
} else
EVR = NULL;