From 1fd571fe46baa6bbd3b371b3e00ae53d8bdfb9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=98yvind=20Karlsen?= Date: Sun, 6 Mar 2011 04:59:18 +0000 Subject: always strip distepoch right away when loading package headers --- URPM.xs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/URPM.xs b/URPM.xs index e1b43e1..0c962ed 100644 --- a/URPM.xs +++ b/URPM.xs @@ -1310,6 +1310,11 @@ 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; @@ -1345,6 +1350,14 @@ update_header(char *filename, URPM__Package pkg, __attribute__((unused)) int kee if (fd != NULL) { 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); + } + pkg->flag &= ~FLAG_NO_HEADER_FREE; Fclose(fd); return 1; @@ -3148,10 +3161,6 @@ Trans_add(trans, 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); RETVAL = rpmtsAddInstallElement(trans->ts, pkg->h, (fnpyKey)(1+(long)(pkg->flag & FLAG_ID)), update, relocations) == 0; /* free allocated memory, check rpm is copying it just above, at least in 4.0.4 */ @@ -3628,6 +3637,11 @@ 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); + memset(&pkg, 0, sizeof(struct s_Package)); pkg.flag = 1 + av_len(depslist); pkg.h = header; @@ -3988,6 +4002,12 @@ Urpm_stream2header(fp) pkg->h = headerRead(fd, HEADER_MAGIC_YES); 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); + EXTEND(SP, 1); sv_pkg = sv_newmortal(); sv_setref_pv(sv_pkg, "URPM::Package", (void*)pkg); -- cgit v1.2.1