From 457e2912533375cf84c5ca5a4428fd61b9f77cff Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 22 Mar 2010 10:37:32 +0200 Subject: [PATCH] Use package NEVRA for replaced/skipped messages, simplify - dependency strings look funny when we're talking about packages, use the full NEVRA instead - unify the logging calls --- lib/depends.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/lib/depends.c b/lib/depends.c index c5b6c48..1cdf128 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -197,8 +197,6 @@ static int findPos(rpmts ts, rpm_color_t tscolor, Header h, int upgrade) /* XXX can't use rpmtsiNext() filter or oc will have wrong value. */ for (oc = 0; (p = rpmtsiNext(pi, 0)) != NULL; oc++) { rpmds this; - const char *pkgNEVR, *addNEVR; - int skip = 0; /* Only added binary packages need checking */ if (rpmteType(p) == TR_REMOVED || rpmteIsSource(p)) @@ -222,38 +220,28 @@ static int findPos(rpmts ts, rpm_color_t tscolor, Header h, int upgrade) * Always skip identical NEVR. * On upgrade, if newer NEVR was previously added, skip adding older. */ - if (rpmdsCompare(sameChk, this)) { - skip = 1; - addNEVR = rpmdsDNEVR(sameChk); - } else if (upgrade && rpmdsCompare(newChk, this)) { - skip = 1; - addNEVR = rpmdsDNEVR(newChk); - } - - if (skip) { - pkgNEVR = rpmdsDNEVR(this); - if (rpmIsVerbose()) - rpmlog(RPMLOG_WARNING, - _("package %s was already added, skipping %s\n"), - (pkgNEVR ? pkgNEVR + 2 : "?pkgNEVR?"), - (addNEVR ? addNEVR + 2 : "?addNEVR?")); + if (rpmdsCompare(sameChk, this) || + (upgrade && rpmdsCompare(newChk, this))) { oc = -1; break;; } /* On upgrade, if older NEVR was previously added, replace with new */ if (upgrade && rpmdsCompare(oldChk, this) != 0) { - pkgNEVR = rpmdsDNEVR(this); - addNEVR = rpmdsDNEVR(newChk); - if (rpmIsVerbose()) - rpmlog(RPMLOG_WARNING, - _("package %s was already added, replacing with %s\n"), - (pkgNEVR ? pkgNEVR + 2 : "?pkgNEVR?"), - (addNEVR ? addNEVR + 2 : "?addNEVR?")); break; } } + /* If we broke out of the loop early we've something to say */ + if (p != NULL && rpmIsVerbose()) { + char *nevra = headerGetAsString(h, RPMTAG_NEVRA); + const char *msg = (oc < 0) ? + _("package %s was already added, skipping %s\n") : + _("package %s was already added, replacing with %s\n"); + rpmlog(RPMLOG_WARNING, msg, rpmteNEVRA(p), nevra); + free(nevra); + } + rpmtsiFree(pi); rpmdsFree(oldChk); rpmdsFree(newChk); -- 2.7.4