From db06cd121f2efb95d678273031368101e08ae9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=98yvind=20Karlsen?= Date: Tue, 8 Mar 2011 06:25:20 +0000 Subject: use a common convert_header() function in stead.. --- URPM.xs | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/URPM.xs b/URPM.xs index 25d5ad3..e2434ab 100644 --- a/URPM.xs +++ b/URPM.xs @@ -369,6 +369,19 @@ remap_suggests(Header header) { } } +static void +convert_header(Header header) { + if (header) { + if (headerIsEntry(header, RPMTAG_DISTEPOCH)) { + strip_distepoch(header, RPMTAG_PROVIDEVERSION); + strip_distepoch(header, RPMTAG_REQUIREVERSION); + strip_distepoch(header, RPMTAG_OBSOLETEVERSION); + strip_distepoch(header, RPMTAG_CONFLICTVERSION); + } + remap_suggests(header); + } +} + static int sigsize_to_filesize(int sigsize) { return sigsize + 440; /* 440 is the rpm header size (?) empirical, but works */ @@ -1462,11 +1475,7 @@ 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); + convert_header(header); basename = strrchr(filename, '/'); #ifndef RPM_ORG @@ -1497,13 +1506,7 @@ update_header(char *filename, URPM__Package pkg, __attribute__((unused)) int kee if (pkg->h && !(pkg->flag & FLAG_NO_HEADER_FREE)) pkg->h = headerFree(pkg->h); pkg->h = headerRead(fd, HEADER_MAGIC_YES); - if (pkg->h) { - strip_distepoch(pkg->h, RPMTAG_PROVIDEVERSION); - strip_distepoch(pkg->h, RPMTAG_REQUIREVERSION); - strip_distepoch(pkg->h, RPMTAG_OBSOLETEVERSION); - strip_distepoch(pkg->h, RPMTAG_CONFLICTVERSION); - remap_suggests(pkg->h); - } + convert_header(pkg->h); pkg->flag &= ~FLAG_NO_HEADER_FREE; Fclose(fd); @@ -3794,11 +3797,7 @@ Urpm_parse_hdlist__XS(urpm, filename, ...) struct s_Package pkg, *_pkg; SV *sv_pkg; - strip_distepoch(header, RPMTAG_PROVIDEVERSION); - strip_distepoch(header, RPMTAG_REQUIREVERSION); - strip_distepoch(header, RPMTAG_OBSOLETEVERSION); - strip_distepoch(header, RPMTAG_CONFLICTVERSION); - remap_suggests(header); + convert_header(header); memset(&pkg, 0, sizeof(struct s_Package)); pkg.flag = 1 + av_len(depslist); @@ -4161,11 +4160,7 @@ Urpm_stream2header(fp) if (pkg->h) { SV *sv_pkg; - strip_distepoch(pkg->h, RPMTAG_PROVIDEVERSION); - strip_distepoch(pkg->h, RPMTAG_REQUIREVERSION); - strip_distepoch(pkg->h, RPMTAG_OBSOLETEVERSION); - strip_distepoch(pkg->h, RPMTAG_CONFLICTVERSION); - remap_suggests(pkg->h); + convert_header(pkg->h); EXTEND(SP, 1); sv_pkg = sv_newmortal(); -- cgit v1.2.1