aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2011-03-08 06:19:30 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2011-03-08 06:19:30 +0000
commitc5f6ddcc09def76b630a83fa5ee387c30a8393c2 (patch)
treec7695071eff827aeecb737d657f88155069eb3d1
parented8e3672c3f810eea37547a2a32e23a6441525aa (diff)
downloadperl-URPM-c5f6ddcc09def76b630a83fa5ee387c30a8393c2.tar
perl-URPM-c5f6ddcc09def76b630a83fa5ee387c30a8393c2.tar.gz
perl-URPM-c5f6ddcc09def76b630a83fa5ee387c30a8393c2.tar.bz2
perl-URPM-c5f6ddcc09def76b630a83fa5ee387c30a8393c2.tar.xz
perl-URPM-c5f6ddcc09def76b630a83fa5ee387c30a8393c2.zip
add support for doing comparision against provides with distepoch
-rw-r--r--NEWS2
-rw-r--r--URPM.xs61
2 files changed, 63 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 3c237e4..add7968 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
Version 3.37.2 - 6 March 2011, by Per Øyvind Karlsen
+- add support for doing comparision against provides with distepoch to allow
+ fresh install of newer releases into chroots
- convert suggests to compatible tags when loading package headers
- fix incorrect arch returned for packages without any (ie. public keys)
- eliminate disttag & distepoch when extracting name, version, release to
diff --git a/URPM.xs b/URPM.xs
index 960b225..25d5ad3 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -251,6 +251,57 @@ strip_distepoch(Header header, int32_t tag) {
}
static void
+pretend_distepoch(Header header, int32_t flags_tag, int32_t versions_tag) {
+ struct rpmtd_s names, flags, versions;
+ char *EVR = headerFormat(header, "%|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}", NULL);
+
+ headerGet(header, flags_tag, &flags, HEADERGET_DEFAULT);
+ headerGet(header, versions_tag, &versions, HEADERGET_DEFAULT);
+
+ char **name = NULL;
+ char **name2 = NULL;
+ int32_t *flag = flags.data;
+ int32_t *flag2 = NULL;
+ char **version = versions.data;
+ char **version2 = NULL;
+
+ for (flags.ix = 0; flags.ix < (int)flags.count; flags.ix++) {
+ if(!(flag[flags.ix] & ((RPMSENSE_LESS|RPMSENSE_GREATER|~RPMSENSE_EQUAL))) && version[flags.ix] && *version[flags.ix] && !strcmp(EVR, version[flags.ix])) {
+ if(!name) {
+ headerGet(header, RPMTAG_REQUIRENAME, &names, HEADERGET_DEFAULT);
+
+ name = names.data;
+ name2 = malloc(++names.count * sizeof(*name));
+ names.data = memcpy(name2, name, sizeof(*name)*names.count);
+ flag2 = malloc(names.count * sizeof(flag));
+ flags.data = memcpy(flag2, flag, sizeof(flag)*names.count);
+ version2 = malloc(names.count * sizeof(*version));
+ versions.data = memcpy(version2, version, sizeof(*version)*names.count);
+ } else {
+ names.data = name2 = realloc(name2, sizeof(*name) * ++names.count);
+ flags.data = flag2 = realloc(flag2, sizeof(flag) * names.count);
+ versions.data = version2 = realloc(version2, sizeof(*version) * names.count);
+ }
+ name2[names.count-1] = name[flags.ix];
+ flag2[names.count-1] = flag[flags.ix] | RPMSENSE_LESS;
+ flag2[flags.ix] |= RPMSENSE_GREATER;
+ version2[names.count-1] = strdup(version[flags.ix]);
+ char *v = version2[names.count-1];
+ (*(&v[strlen(v)-1]))++;
+ }
+ }
+ if(name) {
+ flags.count = versions.count = names.count;
+ headerMod(header, &names);
+ headerMod(header, &flags);
+ headerMod(header, &versions);
+ /*rpmtdFree(&names);*/
+ }
+ /*rpmtdFree(&flags);
+ rpmtdFree(&versions);*/
+}
+
+static void
remap_suggests(Header header) {
struct rpmtd_s list, flags, list_evr;
@@ -3258,7 +3309,17 @@ Trans_add(trans, pkg, ...)
}
}
+ if(headerIsEntry(pkg->h, RPMTAG_DISTEPOCH)) {
+ pretend_distepoch(pkg->h, RPMTAG_REQUIREFLAGS, RPMTAG_REQUIREVERSION);
+ }
+
RETVAL = rpmtsAddInstallElement(trans->ts, pkg->h, (fnpyKey)(1+(long)(pkg->flag & FLAG_ID)), update, relocations) == 0;
+
+ rpmte te = rpmtsElement(trans->ts, 0);
+ headerLink(pkg->h);
+ rpmteSetHeader(te, pkg->h);
+ headerUnlink(pkg->h);
+
/* free allocated memory, check rpm is copying it just above, at least in 4.0.4 */
#ifndef RPM_ORG
rpmfiFreeRelocations(relocations);