diff options
author | jbj <devnull@localhost> | 2002-06-28 21:54:24 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-06-28 21:54:24 +0000 |
commit | d89ce5854d39a9e896759fb96e6e303c67573bb6 (patch) | |
tree | 1c97bbd96403a0212535c0767abf32b987fc6484 /lib | |
parent | f5fc8957b433616cf5010e26866205985c385479 (diff) | |
download | librpm-tizen-d89ce5854d39a9e896759fb96e6e303c67573bb6.tar.gz librpm-tizen-d89ce5854d39a9e896759fb96e6e303c67573bb6.tar.bz2 librpm-tizen-d89ce5854d39a9e896759fb96e6e303c67573bb6.zip |
- disambiguate added/installed dependency failures (#50388).
CVS patchset: 5532
CVS date: 2002/06/28 21:54:24
Diffstat (limited to 'lib')
-rw-r--r-- | lib/depends.c | 26 | ||||
-rw-r--r-- | lib/rpmds.c | 14 | ||||
-rw-r--r-- | lib/rpmds.h | 6 | ||||
-rw-r--r-- | lib/rpminstall.c | 15 | ||||
-rw-r--r-- | lib/rpmlibprov.c | 18 | ||||
-rw-r--r-- | lib/rpmps.c | 79 | ||||
-rw-r--r-- | lib/rpmps.h | 38 |
7 files changed, 77 insertions, 119 deletions
diff --git a/lib/depends.c b/lib/depends.c index d535d2459..51fdc419e 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -550,18 +550,19 @@ exit: } /** - * Check header requires/conflicts against against installed+added packages. + * Check added requires/conflicts against against installed+added packages. * @param ts transaction set * @param pkgNEVR package name-version-release * @param requires Requires: dependencies (or NULL) * @param conflicts Conflicts: dependencies (or NULL) * @param depName dependency name to filter (or NULL) * @param multiLib skip multilib colored dependencies? + * @param adding dependency is from added package set? * @return 0 no problems found */ static int checkPackageDeps(rpmts ts, const char * pkgNEVR, /*@null@*/ rpmds requires, /*@null@*/ rpmds conflicts, - /*@null@*/ const char * depName, uint_32 multiLib) + /*@null@*/ const char * depName, uint_32 multiLib, int adding) /*@globals fileSystem @*/ /*@modifies ts, requires, conflicts, fileSystem */ { @@ -603,7 +604,7 @@ static int checkPackageDeps(rpmts ts, const char * pkgNEVR, } /*@=branchstate@*/ - rpmdsProblem(ts->probs, pkgNEVR, requires, suggestedKeys); + rpmdsProblem(ts->probs, pkgNEVR, requires, suggestedKeys, adding); } /*@switchbreak@*/ break; @@ -637,7 +638,7 @@ static int checkPackageDeps(rpmts ts, const char * pkgNEVR, /* 1 == unsatisfied, 0 == satsisfied */ switch (rc) { case 0: /* conflicts exist. */ - rpmdsProblem(ts->probs, pkgNEVR, conflicts, NULL); + rpmdsProblem(ts->probs, pkgNEVR, conflicts, NULL, adding); /*@switchbreak@*/ break; case 1: /* conflicts don't exist. */ /*@switchbreak@*/ break; @@ -658,10 +659,11 @@ static int checkPackageDeps(rpmts ts, const char * pkgNEVR, * @param ts transaction set * @param dep dependency name * @param mi rpm database iterator + * @param adding dependency is from added package set? * @return 0 no problems found */ -static int checkPackageSet(rpmts ts, - const char * dep, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi) +static int checkPackageSet(rpmts ts, const char * dep, + /*@only@*/ /*@null@*/ rpmdbMatchIterator mi, int adding) /*@globals fileSystem @*/ /*@modifies ts, mi, fileSystem @*/ { @@ -679,7 +681,7 @@ static int checkPackageSet(rpmts ts, pkgNEVR = hGetNEVR(h, NULL); requires = rpmdsNew(h, RPMTAG_REQUIRENAME, scareMem); conflicts = rpmdsNew(h, RPMTAG_CONFLICTNAME, scareMem); - rc = checkPackageDeps(ts, pkgNEVR, requires, conflicts, dep, 0); + rc = checkPackageDeps(ts, pkgNEVR, requires, conflicts, dep, 0, adding); conflicts = rpmdsFree(conflicts); requires = rpmdsFree(requires); pkgNEVR = _free(pkgNEVR); @@ -695,7 +697,7 @@ static int checkPackageSet(rpmts ts, } /** - * Erasing: check name/provides/filename dep against requiredby matches. + * Check to-be-erased dependencies against installed requires. * @param ts transaction set * @param dep requires name * @return 0 no problems found @@ -706,11 +708,11 @@ static int checkDependentPackages(rpmts ts, const char * dep) { rpmdbMatchIterator mi; mi = rpmtsInitIterator(ts, RPMTAG_REQUIRENAME, dep, 0); - return checkPackageSet(ts, dep, mi); + return checkPackageSet(ts, dep, mi, 0); } /** - * Adding: check name/provides dep against conflicts matches. + * Check to-be-added dependencies against installed conflicts. * @param ts transaction set * @param dep conflicts name * @return 0 no problems found @@ -724,7 +726,7 @@ static int checkDependentConflicts(rpmts ts, const char * dep) if (rpmtsGetRdb(ts) != NULL) { /* XXX is this necessary? */ rpmdbMatchIterator mi; mi = rpmtsInitIterator(ts, RPMTAG_CONFLICTNAME, dep, 0); - rc = checkPackageSet(ts, dep, mi); + rc = checkPackageSet(ts, dep, mi, 1); } return rc; @@ -1713,7 +1715,7 @@ int rpmtsCheck(rpmts ts) rpmteDS(p, RPMTAG_REQUIRENAME), rpmteDS(p, RPMTAG_CONFLICTNAME), NULL, - rpmteMultiLib(p)); + rpmteMultiLib(p), 1); if (rc) goto exit; diff --git a/lib/rpmds.c b/lib/rpmds.c index 5a90a554c..3dcd5c3ba 100644 --- a/lib/rpmds.c +++ b/lib/rpmds.c @@ -617,8 +617,8 @@ exit: return result; } -void rpmdsProblem(rpmps ps, const char * pkgNEVR, - const rpmds ds, const fnpyKey * suggestedKeys) +void rpmdsProblem(rpmps ps, const char * pkgNEVR, const rpmds ds, + const fnpyKey * suggestedKeys, int adding) { const char * Name = rpmdsN(ds); const char * DNEVR = rpmdsDNEVR(ds); @@ -637,10 +637,14 @@ void rpmdsProblem(rpmps ps, const char * pkgNEVR, rpmMessage(RPMMESS_DEBUG, _("package %s has unsatisfied %s: %s\n"), pkgNEVR, ds->Type, DNEVR+2); - type = (DNEVR[0] == 'C' && DNEVR[1] == ' ') - ? RPMPROB_CONFLICT : RPMPROB_REQUIRES; + switch ((unsigned)DNEVR[0]) { + case 'C': type = RPMPROB_CONFLICT; break; + default: + case 'R': type = RPMPROB_REQUIRES; break; + } + key = (suggestedKeys ? suggestedKeys[0] : NULL); - rpmpsAppend(ps, type, pkgNEVR, key, NULL, NULL, DNEVR, 0); + rpmpsAppend(ps, type, pkgNEVR, key, NULL, NULL, DNEVR, adding); } int rangeMatchesDepFlags (Header h, const rpmds req) diff --git a/lib/rpmds.h b/lib/rpmds.h index ab5573f85..391f57b62 100644 --- a/lib/rpmds.h +++ b/lib/rpmds.h @@ -246,10 +246,12 @@ int rpmdsCompare(const rpmds A, const rpmds B) * @param ps transaction set problems * @param pkgNEVR package name/epoch/version/release * @param ds dependency set - * @param suggestedKeys + * @param suggestedKeys filename or python object address + * @param adding dependency problem is from added package set? */ void rpmdsProblem(/*@null@*/ rpmps ps, const char * pkgNEVR, const rpmds ds, - /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys) + /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys, + int adding) /*@modifies ps @*/; /** diff --git a/lib/rpminstall.c b/lib/rpminstall.c index 43622d7df..a2ebd1389 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -543,7 +543,7 @@ restart: ps = rpmtsProblems(ts); if (!stopInstall && rpmpsNumProblems(ps) > 0) { rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n")); - printDepProblems(stderr, ps); + rpmpsPrint(NULL, ps); eiu->numFailed = eiu->numPkgs; stopInstall = 1; @@ -701,9 +701,8 @@ int rpmErase(rpmts ts, ps = rpmtsProblems(ts); if (!stopUninstall && rpmpsNumProblems(ps) > 0) { - rpmMessage(RPMMESS_ERROR, _("removing these packages would break " - "dependencies:\n")); - printDepProblems(stderr, ps); + rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n")); + rpmpsPrint(NULL, ps); numFailed += numPackages; stopUninstall = 1; } @@ -712,8 +711,12 @@ int rpmErase(rpmts ts, if (!stopUninstall) { (void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_REVERSE)); - numFailed += rpmtsRun(ts, NULL, 0); + numPackages = rpmtsRun(ts, NULL, 0); ps = rpmtsProblems(ts); + if (rpmpsNumProblems(ps) > 0) + rpmpsPrint(NULL, ps); + numFailed += numPackages; + stopUninstall = 1; ps = rpmpsFree(ps); } @@ -1073,7 +1076,7 @@ int rpmRollback(rpmts ts, ps = rpmtsProblems(ts); if (rc != 0 && rpmpsNumProblems(ps) > 0) { rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n")); - printDepProblems(stderr, ps); + rpmpsPrint(NULL, ps); ps = rpmpsFree(ps); goto exit; } diff --git a/lib/rpmlibprov.c b/lib/rpmlibprov.c index fc6e14c2f..dfd48828d 100644 --- a/lib/rpmlibprov.c +++ b/lib/rpmlibprov.c @@ -30,7 +30,7 @@ static struct rpmlibProvides_s rpmlibProvides[] = { N_("PreReq:, Provides:, and Obsoletes: dependencies support versions.") }, { "rpmlib(CompressedFileNames)", "3.0.4-1", (RPMSENSE_RPMLIB|RPMSENSE_EQUAL), - N_("file name(s) are stored as (dirName,baseName,dirIndex) tuple, not as path.")}, + N_("file name(s) stored as (dirName,baseName,dirIndex) tuple, not as path.")}, { "rpmlib(PayloadIsBzip2)", "3.0.5-1", (RPMSENSE_RPMLIB|RPMSENSE_EQUAL), N_("package payload is compressed using bzip2.") }, @@ -57,12 +57,16 @@ void rpmShowRpmlibProvides(FILE * fp) const struct rpmlibProvides_s * rlp; for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) { - fprintf(fp, " %s", rlp->featureName); - if (rlp->featureEVR && rlp->featureFlags) - printDepFlags(fp, rlp->featureEVR, rlp->featureFlags); - fprintf(fp, "\n"); - if (rlp->featureDescription) - fprintf(fp, "\t%s\n", rlp->featureDescription); + rpmds pro = rpmdsSingle(RPMTAG_PROVIDENAME, rlp->featureName, + rlp->featureEVR, rlp->featureFlags); + const char * DNEVR = rpmdsDNEVR(pro); + + if (pro != NULL && DNEVR != NULL) { + fprintf(fp, " %s\n", DNEVR+2); + if (rlp->featureDescription) + fprintf(fp, "\t%s\n", rlp->featureDescription); + } + pro = rpmdsFree(pro); } } diff --git a/lib/rpmps.c b/lib/rpmps.c index 51a84dd17..2a3898b9c 100644 --- a/lib/rpmps.c +++ b/lib/rpmps.c @@ -169,24 +169,6 @@ int rpmpsTrim(rpmps ps, rpmps filter) return gotProblems; } -/* XXX FIXME: merge into problems */ -/* XXX used in verify.c rpmlibprov.c */ -void printDepFlags(FILE * fp, const char * version, int flags) -{ - if (flags) - fprintf(fp, " "); - - if (flags & RPMSENSE_LESS) - fprintf(fp, "<"); - if (flags & RPMSENSE_GREATER) - fprintf(fp, ">"); - if (flags & RPMSENSE_EQUAL) - fprintf(fp, "="); - - if (flags) - fprintf(fp, " %s", version); -} - #if !defined(HAVE_VSNPRINTF) /*@-shadow -bufferoverflowhigh @*/ static inline int vsnprintf(/*@out@*/ char * buf, /*@unused@*/ int nb, @@ -213,7 +195,7 @@ const char * rpmProblemString(const rpmProblem prob) /*@observer@*/ const char * pkgNEVR = (prob->pkgNEVR ? prob->pkgNEVR : "?pkgNEVR?"); /*@observer@*/ - const char * altNEVR = (prob->altNEVR ? prob->altNEVR : "?altNEVR?"); + const char * altNEVR = (prob->altNEVR ? prob->altNEVR : "? ?altNEVR?"); /*@observer@*/ const char * str1 = (prob->str1 ? prob->str1 : N_("different")); int nb = strlen(pkgNEVR) + strlen(str1) + strlen(altNEVR) + 100; @@ -277,12 +259,14 @@ const char * rpmProblemString(const rpmProblem prob) pkgNEVR, str1, strerror(prob->ulong1)); break; case RPMPROB_REQUIRES: - rc = snprintf(buf, nb, _("package %s has unsatisfied Requires: %s\n"), - pkgNEVR, altNEVR+2); + rc = snprintf(buf, nb, _("%s is needed by %s%s"), + altNEVR+2, + (prob->ulong1 ? "" : _("(installed) ")), pkgNEVR); break; case RPMPROB_CONFLICT: - rc = snprintf(buf, nb, _("package %s has unsatisfied Conflicts: %s\n"), - pkgNEVR, altNEVR+2); + rc = snprintf(buf, nb, _("%s conflicts with %s%s"), + altNEVR+2, + (prob->ulong1 ? "" : _("(installed) ")), pkgNEVR); break; default: rc = snprintf(buf, nb, @@ -295,30 +279,6 @@ const char * rpmProblemString(const rpmProblem prob) return buf; } -void rpmProblemPrint(FILE *fp, rpmProblem prob) -{ - const char * msg = rpmProblemString(prob); - fprintf(fp, "%s\n", msg); - msg = _free(msg); -} - -void rpmpsPrint(FILE *fp, rpmps ps) -{ - int i; - - if (ps == NULL) - return; - - if (fp == NULL) - fp = stderr; - - for (i = 0; i < ps->numProblems; i++) { - rpmProblem myprob = ps->probs + i; - if (!myprob->ignoreProblem) - rpmProblemPrint(fp, myprob); - } -} - static int sameProblem(const rpmProblem ap, const rpmProblem bp) /*@*/ { @@ -340,20 +300,26 @@ static int sameProblem(const rpmProblem ap, const rpmProblem bp) return 0; } -/* XXX FIXME: merge into rpmpsPrint */ -void printDepProblems(FILE * fp, rpmps ps) +void rpmpsPrint(FILE *fp, rpmps ps) { + const char * msg; int i; - if (ps && ps->probs != NULL) + if (ps == NULL || ps->probs == NULL || ps->numProblems <= 0) + return; + + if (fp == NULL) + fp = stderr; + for (i = 0; i < ps->numProblems; i++) { - const char * pkgNEVR; - const char * altNEVR; rpmProblem p; int j; p = ps->probs + i; + if (p->ignoreProblem) + continue; + /* Filter already displayed problems. */ for (j = 0; j < i; j++) { if (!sameProblem(p, ps->probs + j)) @@ -362,12 +328,9 @@ void printDepProblems(FILE * fp, rpmps ps) if (j < i) continue; - pkgNEVR = (p->pkgNEVR ? p->pkgNEVR : "?pkgNEVR?"); - altNEVR = (p->altNEVR ? p->altNEVR : "? ?altNEVR?"); + msg = rpmProblemString(p); + fprintf(fp, "\t%s\n", msg); + msg = _free(msg); - fprintf(fp, "\t%s %s %s\n", altNEVR+2, - ((altNEVR[0] == 'C' && altNEVR[1] == ' ') - ? _("conflicts with") : _("is needed by")), - pkgNEVR); } } diff --git a/lib/rpmps.h b/lib/rpmps.h index 39c272d3a..39bef8349 100644 --- a/lib/rpmps.h +++ b/lib/rpmps.h @@ -65,21 +65,6 @@ extern "C" { #endif /** - */ -void printDepFlags(FILE *fp, const char *version, int flags) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/; - -/** - * Print a problem array. - * @param fp output file - * @param ps dependency problems - */ -void printDepProblems(FILE * fp, /*@null@*/ const rpmps ps) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/; - -/** * Return formatted string representation of a problem. * @param prob rpm problem * @return formatted string (malloc'd) @@ -152,28 +137,23 @@ rpmps rpmpsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmps ps) /*@modifies ps @*/; /** - * Output formatted string representation of a problem to file handle. - * @deprecated API: prob used to be passed by value, now passed by reference. - * @param fp file handle - * @param prob rpm problem - */ -/*@-exportlocal@*/ -void rpmProblemPrint(FILE *fp, rpmProblem prob) - /*@globals fileSystem @*/ - /*@modifies prob, *fp, fileSystem @*/; -/*@=exportlocal@*/ - -/** * Print problems to file handle. - * @param fp file handle + * @param fp file handle (NULL uses stderr) * @param ps problem set */ -void rpmpsPrint(FILE *fp, /*@null@*/ rpmps ps) +void rpmpsPrint(/*@null@*/ FILE *fp, /*@null@*/ rpmps ps) /*@globals fileSystem @*/ /*@modifies *fp, ps, fileSystem @*/; /** * Append a problem to set. + * @param ps problem set + * @param type type of problem + * @param pkgNEVR package name + * @param key filename or python object address + * @param dn directory name + * @param bn file base name + * @param ulong1 generic pointer/long attribute */ void rpmpsAppend(/*@null@*/ rpmps ps, rpmProblemType type, /*@null@*/ const char * pkgNEVR, |