/** * Ensure that current package is newer than installed package. * @param ts transaction set * @param p current transaction element * @param h installed header * @return 0 if not newer, 1 if okay */ static int ensureOlder(rpmts ts, const rpmte p, const Header h) { rpmsenseFlags reqFlags = (RPMSENSE_LESS | RPMSENSE_EQUAL); rpmds req; int rc; if (p == NULL || h == NULL) return 1; req = rpmdsSingle(RPMTAG_REQUIRENAME, rpmteN(p), rpmteEVR(p), reqFlags); rc = rpmdsNVRMatchesDep(h, req, _rpmds_nopromote); req = rpmdsFree(req); if (rc == 0) { rpmps ps = rpmtsProblems(ts); char * altNEVR = headerGetNEVRA(h, NULL); rpmpsAppend(ps, RPMPROB_OLDPACKAGE, rpmteNEVRA(p), rpmteKey(p), NULL, NULL, altNEVR, 0); altNEVR = _free(altNEVR); ps = rpmpsFree(ps); rc = 1; } else rc = 0; return rc; }
/** * Ensure that current package is newer than installed package. * @param p current transaction element * @param h installed header * @param ps problem set */ static void ensureOlder(const rpmte p, const Header h) { rpmsenseFlags reqFlags = (RPMSENSE_LESS | RPMSENSE_EQUAL); rpmds req; req = rpmdsSingle(RPMTAG_REQUIRENAME, rpmteN(p), rpmteEVR(p), reqFlags); if (rpmdsNVRMatchesDep(h, req, _rpmds_nopromote) == 0) { char * altNEVR = headerGetAsString(h, RPMTAG_NEVRA); rpmteAddProblem(p, RPMPROB_OLDPACKAGE, altNEVR, NULL, headerGetInstance(h)); free(altNEVR); } rpmdsFree(req); }
/* * Check for previously added versions and obsoletions. * Return index where to place this element, or -1 to skip. * XXX OBSOLETENAME is a bit of a hack, but gives us what * we want from rpmal: we're only interested in added package * names here, not their provides. */ static int findPos(rpmts ts, rpm_color_t tscolor, rpmte te, int upgrade) { tsMembers tsmem = rpmtsMembers(ts); int oc = tsmem->orderCount; int skip = 0; const char * name = rpmteN(te); const char * evr = rpmteEVR(te); rpmte p; rpmstrPool tspool = rpmtsPool(ts); rpmds oldChk = rpmdsSinglePool(tspool, RPMTAG_OBSOLETENAME, name, evr, (RPMSENSE_LESS)); rpmds newChk = rpmdsSinglePool(tspool, RPMTAG_OBSOLETENAME, name, evr, (RPMSENSE_GREATER)); rpmds sameChk = rpmdsSinglePool(tspool, RPMTAG_OBSOLETENAME, name, evr, (RPMSENSE_EQUAL)); rpmds obsChk = rpmteDS(te, RPMTAG_OBSOLETENAME); /* If obsoleting package has already been added, skip this. */ if ((p = checkObsoleted(tsmem->addedPackages, rpmteDS(te, RPMTAG_NAME)))) { skip = 1; goto exit; } /* If obsoleted package has already been added, replace with this. */ rpmdsInit(obsChk); while (rpmdsNext(obsChk) >= 0) { /* XXX Obsoletes are not colored */ if ((p = checkAdded(tsmem->addedPackages, 0, te, obsChk))) { goto exit; } } /* If same NEVR has already been added, skip this. */ if ((p = checkAdded(tsmem->addedPackages, tscolor, te, sameChk))) { skip = 1; goto exit; } /* On upgrades... */ if (upgrade) { /* ...if newer NEVR has already been added, skip this. */ if ((p = checkAdded(tsmem->addedPackages, tscolor, te, newChk))) { skip = 1; goto exit; } /* ...if older NEVR has already been added, replace with this. */ if ((p = checkAdded(tsmem->addedPackages, tscolor, te, oldChk))) { goto exit; } } exit: /* If we found a previous element we've something to say */ if (p != NULL && rpmIsVerbose()) { const char *msg = skip ? _("package %s was already added, skipping %s\n") : _("package %s was already added, replacing with %s\n"); rpmlog(RPMLOG_WARNING, msg, rpmteNEVRA(p), rpmteNEVRA(te)); } /* If replacing a previous element, find out where it is. Pooh. */ if (!skip && p != NULL) { for (oc = 0; oc < tsmem->orderCount; oc++) { if (p == tsmem->order[oc]) break; } } rpmdsFree(oldChk); rpmdsFree(newChk); rpmdsFree(sameChk); return (skip) ? -1 : oc; }