aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2011-03-06 09:59:15 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2011-03-06 09:59:15 +0000
commit6bf7004286a594401b6eac3e65501db908f86c04 (patch)
tree3870d9c39dd6582111cf7d311ba1124cf69e4270
parentdc11e8acceef06ea80b2b312a1ba45a3773616b7 (diff)
downloadperl-URPM-6bf7004286a594401b6eac3e65501db908f86c04.tar
perl-URPM-6bf7004286a594401b6eac3e65501db908f86c04.tar.gz
perl-URPM-6bf7004286a594401b6eac3e65501db908f86c04.tar.bz2
perl-URPM-6bf7004286a594401b6eac3e65501db908f86c04.tar.xz
perl-URPM-6bf7004286a594401b6eac3e65501db908f86c04.zip
convert suggests to compatible tags when loading package headers
-rw-r--r--NEWS1
-rw-r--r--URPM.xs83
2 files changed, 79 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 2a36401..3c237e4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
Version 3.37.2 - 6 March 2011, by Per Øyvind Karlsen
+- 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
handle upgrade
diff --git a/URPM.xs b/URPM.xs
index 9ce50b6..4d86858 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -244,6 +244,75 @@ strip_distepoch(Header header, int32_t tag) {
}
headerMod(header, &val);
}
+
+static void
+remap_suggests(Header header) {
+ struct rpmtd_s list, flags, list_evr;
+
+ if (headerGet(header, RPMTAG_REQUIREFLAGS, &flags, HEADERGET_DEFAULT)) {
+ rpm_count_t count = 0;
+ for(flags.ix = 0; flags.ix < (int)flags.count; flags.ix++)
+ if(((uint32_t*)flags.data)[flags.ix] & RPMSENSE_MISSINGOK)
+ count++;
+
+ if(count) {
+ if(headerGet(header, RPMTAG_REQUIRENAME, &list, HEADERGET_DEFAULT)) {
+ headerGet(header, RPMTAG_REQUIREVERSION, &list_evr, HEADERGET_DEFAULT);
+ struct rpmtd_s list_sug, flags_sug, list_evr_sug;
+
+ list_sug.tag = RPMTAG_SUGGESTSNAME;
+ flags_sug.tag = RPMTAG_SUGGESTSFLAGS;
+ list_evr_sug.tag = RPMTAG_SUGGESTSVERSION;
+ list_sug.count = flags_sug.count = list_evr_sug.count = count;
+ list_sug.type = list.type;
+ flags_sug.type = flags_sug.type;
+ list_evr_sug.type = list_evr_sug.type;
+ list_sug.flags = list.flags;
+ flags_sug.flags = flags.flags;
+ list_evr_sug.flags = list_evr.flags;
+ list_sug.data = malloc(count * sizeof(char*));
+ flags_sug.data = malloc(count * sizeof(uint32_t));
+ list_evr_sug.data = malloc(count * sizeof(char*));
+
+ for(list.ix = flags.ix = flags_sug.ix = 0; flags.ix < (int)flags.count; flags.ix++) {
+ if(((uint32_t*)flags.data)[flags.ix] & RPMSENSE_MISSINGOK) {
+ ((char**)list_sug.data)[flags_sug.ix] = ((char**)list.data)[flags.ix];
+ ((uint32_t*)flags_sug.data)[flags_sug.ix] = ((uint32_t*)flags.data)[flags.ix];
+ ((char**)list_evr_sug.data)[flags_sug.ix] = ((char**)list_evr.data)[flags.ix];
+
+ flags_sug.ix++;
+ list.count--;
+ }
+ else {
+ ((char**)list.data)[list.ix] = ((char**)list.data)[flags.ix];
+ ((uint32_t*)flags.data)[list.ix] = ((uint32_t*)flags.data)[flags.ix];
+ ((char**)list_evr.data)[list.ix] = ((char**)list_evr.data)[flags.ix];
+ list.ix++;
+ }
+ }
+ flags.count = list_evr.count = list.count;
+
+ headerMod(header, &list);
+ headerMod(header, &flags);
+ headerMod(header, &list_evr);
+ headerPut(header, &list_sug, HEADERPUT_DEFAULT);
+ /* XXX: unused
+ headerPut(header, &flags_sug, HEADERPUT_DEFAULT);
+ headerPut(header, &list_evr_sug, HEADERPUT_DEFAULT);
+ */
+
+ rpmtdFreeData(&list);
+ rpmtdFreeData(&list_evr);
+
+ rpmtdFreeData(&list_sug);
+ rpmtdFreeData(&flags_sug);
+ rpmtdFreeData(&list_evr_sug);
+ }
+ rpmtdFreeData(&flags);
+ }
+ }
+}
+
static int
sigsize_to_filesize(int sigsize) {
return sigsize + 440; /* 440 is the rpm header size (?) empirical, but works */
@@ -1327,11 +1396,6 @@ update_header(char *filename, URPM__Package pkg, __attribute__((unused)) int kee
ts = rpmtsCreate();
rpmtsSetVSFlags(ts, _RPMVSF_NOSIGNATURES | vsflags);
if (fd != NULL && rpmReadPackageFile(ts, fd, filename, &header) == 0 && header) {
- strip_distepoch(header, RPMTAG_PROVIDEVERSION);
- strip_distepoch(header, RPMTAG_REQUIREVERSION);
- strip_distepoch(header, RPMTAG_OBSOLETEVERSION);
- strip_distepoch(header, RPMTAG_CONFLICTVERSION);
-
char *basename;
#ifndef RPM_ORG
struct stat sb;
@@ -1339,6 +1403,12 @@ update_header(char *filename, URPM__Package pkg, __attribute__((unused)) int kee
int32_t size;
#endif
+ strip_distepoch(header, RPMTAG_PROVIDEVERSION);
+ strip_distepoch(header, RPMTAG_REQUIREVERSION);
+ strip_distepoch(header, RPMTAG_OBSOLETEVERSION);
+ strip_distepoch(header, RPMTAG_CONFLICTVERSION);
+ remap_suggests(header);
+
basename = strrchr(filename, '/');
#ifndef RPM_ORG
Fstat(fd, &sb);
@@ -1373,6 +1443,7 @@ update_header(char *filename, URPM__Package pkg, __attribute__((unused)) int kee
strip_distepoch(pkg->h, RPMTAG_REQUIREVERSION);
strip_distepoch(pkg->h, RPMTAG_OBSOLETEVERSION);
strip_distepoch(pkg->h, RPMTAG_CONFLICTVERSION);
+ remap_suggests(pkg->h);
}
pkg->flag &= ~FLAG_NO_HEADER_FREE;
@@ -3658,6 +3729,7 @@ Urpm_parse_hdlist__XS(urpm, filename, ...)
strip_distepoch(header, RPMTAG_REQUIREVERSION);
strip_distepoch(header, RPMTAG_OBSOLETEVERSION);
strip_distepoch(header, RPMTAG_CONFLICTVERSION);
+ remap_suggests(header);
memset(&pkg, 0, sizeof(struct s_Package));
pkg.flag = 1 + av_len(depslist);
@@ -4024,6 +4096,7 @@ Urpm_stream2header(fp)
strip_distepoch(pkg->h, RPMTAG_REQUIREVERSION);
strip_distepoch(pkg->h, RPMTAG_OBSOLETEVERSION);
strip_distepoch(pkg->h, RPMTAG_CONFLICTVERSION);
+ remap_suggests(pkg->h);
EXTEND(SP, 1);
sv_pkg = sv_newmortal();