diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-08-07 09:52:15 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-10-03 10:13:11 +0300 |
commit | e534be1be760c73b17596a1816c26dc63b83a25d (patch) | |
tree | dbf04afa58c30c160294c98d7cae52caf4487586 | |
parent | 31255e410b3bb16dd73c3919b9285638f5d71abb (diff) | |
download | rpm-e534be1be760c73b17596a1816c26dc63b83a25d.tar.gz rpm-e534be1be760c73b17596a1816c26dc63b83a25d.tar.bz2 rpm-e534be1be760c73b17596a1816c26dc63b83a25d.zip |
Fix RPMPROB_FILTER_FORCERELOCATE aka --badreloc (RhBug:828784)
- As noted (but since then blissfully forgotten) in the commit message,
commit e696b409fe836bf39cbf639bac4321d658d0952d broke --badreloc
so its been broken since rpm >= 4.9.x :-/
- Transaction problem filter is only available during rpmtsRun() so
we have no clue whether bad relocations should be filtered or not
during rpmte creation. Instead of creating the problems at rpmteNew()
time, remember any bad relocations that were found and check +
create the actual problems (unless filtered) along with other
problems during rpmtsRun().
- Passing an "allow bad relocations" flag to rpmtsAddInstallElement()
would be a saner option but this is a back-portable way of handling it.
(cherry picked from commit 4fbb58c7e6ee7d1bb565b27e4f81dcf2fee93995)
-rw-r--r-- | lib/rpmte.c | 20 | ||||
-rw-r--r-- | lib/rpmte_internal.h | 3 | ||||
-rw-r--r-- | lib/transaction.c | 3 |
3 files changed, 24 insertions, 2 deletions
diff --git a/lib/rpmte.c b/lib/rpmte.c index 65d65afdd..72b6eba4c 100644 --- a/lib/rpmte.c +++ b/lib/rpmte.c @@ -57,6 +57,7 @@ struct rpmte_s { fnpyKey key; /*!< (TR_ADDED) Retrieval key. */ rpmRelocation * relocs; /*!< (TR_ADDED) Payload file relocations. */ int nrelocs; /*!< (TR_ADDED) No. of relocations. */ + uint8_t *badrelocs; /*!< (TR_ADDED) Bad relocations (or NULL) */ FD_t fd; /*!< (TR_ADDED) Payload file descriptor. */ #define RPMTE_HAVE_PRETRANS (1 << 0) @@ -178,8 +179,9 @@ static void buildRelocs(rpmte p, Header h, rpmRelocation *relocs) } if (!valid) { - rpmteAddProblem(p, RPMPROB_BADRELOCATE, NULL, - p->relocs[i].oldPath, 0); + if (p->badrelocs == NULL) + p->badrelocs = xcalloc(p->nrelocs, sizeof(*p->badrelocs)); + p->badrelocs[i] = 1; } } else { p->relocs[i].newPath = NULL; @@ -228,6 +230,7 @@ static int addTE(rpmte p, Header h, fnpyKey key, rpmRelocation * relocs) p->nrelocs = 0; p->relocs = NULL; + p->badrelocs = NULL; if (relocs != NULL) buildRelocs(p, h, relocs); @@ -294,6 +297,7 @@ rpmte rpmteFree(rpmte te) free(te->relocs[i].newPath); } free(te->relocs); + free(te->badrelocs); } free(te->os); @@ -837,6 +841,18 @@ void rpmteAddDepProblem(rpmte te, const char * altNEVR, rpmds ds, } } +void rpmteAddRelocProblems(rpmte te) +{ + if (te && te->badrelocs) { + for (int i = 0; i < te->nrelocs; i++) { + if (te->badrelocs[i]) { + rpmteAddProblem(te, RPMPROB_BADRELOCATE, NULL, + te->relocs[i].oldPath, 0); + } + } + } +} + const char * rpmteTypeString(rpmte te) { switch(rpmteType(te)) { diff --git a/lib/rpmte_internal.h b/lib/rpmte_internal.h index 8a8df2a8b..66f9788cb 100644 --- a/lib/rpmte_internal.h +++ b/lib/rpmte_internal.h @@ -67,6 +67,9 @@ void rpmteAddDepProblem(rpmte te, const char * pkgNEVR, rpmds ds, fnpyKey * suggestedKeys); RPM_GNUC_INTERNAL +void rpmteAddRelocProblems(rpmte te); + +RPM_GNUC_INTERNAL const char * rpmteTypeString(rpmte te); RPM_GNUC_INTERNAL diff --git a/lib/transaction.c b/lib/transaction.c index 46999d42a..9a7e4a283 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1045,6 +1045,9 @@ static rpmps checkProblems(rpmts ts) } rpmdbFreeIterator(mi); } + + if (!(probFilter & RPMPROB_FILTER_FORCERELOCATE)) + rpmteAddRelocProblems(p); } rpmtsiFree(pi); return rpmtsProblems(ts); |