From: Panu Matilainen Date: Wed, 12 Sep 2012 09:30:44 +0000 (+0300) Subject: Add an nternal rpmal create+populate helper function, use for erased packages X-Git-Tag: rpm-4.11.0-alpha~158 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=141c898cba6f7c862f34afc939e888edee6b056e;p=platform%2Fupstream%2Frpm.git Add an nternal rpmal create+populate helper function, use for erased packages - We'll need this shortly for added packages too... --- diff --git a/lib/depends.c b/lib/depends.c index ad9b577..42c3b8e 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -313,6 +313,22 @@ static int findPos(rpmts ts, rpm_color_t tscolor, Header h, int upgrade) return oc; } +rpmal rpmtsCreateAl(rpmts ts, rpmElementTypes types) +{ + rpmal al = NULL; + if (ts) { + rpmte p; + rpmtsi pi; + + al = rpmalCreate((rpmtsNElements(ts) / 4) + 1, rpmtsFlags(ts), + rpmtsColor(ts), rpmtsPrefColor(ts)); + pi = rpmtsiInit(ts); + while ((p = rpmtsiNext(pi, types))) + rpmalAdd(al, p); + rpmtsiFree(pi); + } + return al; +} int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation * relocs) diff --git a/lib/order.c b/lib/order.c index 0c8d1cb..c0ef547 100644 --- a/lib/order.c +++ b/lib/order.c @@ -548,8 +548,7 @@ int rpmtsOrder(rpmts ts) rpmte * newOrder; int newOrderCount = 0; int rc; - rpmal erasedPackages = rpmalCreate(5, rpmtsFlags(ts), - rpmtsColor(ts), prefcolor); + rpmal erasedPackages; scc SCCs; int nelem = rpmtsNElements(ts); tsortInfo sortInfo = xcalloc(nelem, sizeof(struct tsortInfo_s)); @@ -558,11 +557,7 @@ int rpmtsOrder(rpmts ts) (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_ORDER), 0); /* Create erased package index. */ - pi = rpmtsiInit(ts); - while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) { - rpmalAdd(erasedPackages, p); - } - rpmtsiFree(pi); + erasedPackages = rpmtsCreateAl(ts, TR_REMOVED); for (int i = 0; i < nelem; i++) { sortInfo[i].te = tsmem->order[i]; diff --git a/lib/rpmts_internal.h b/lib/rpmts_internal.h index 60daf47..5d3240c 100644 --- a/lib/rpmts_internal.h +++ b/lib/rpmts_internal.h @@ -74,6 +74,9 @@ extern "C" { RPM_GNUC_INTERNAL tsMembers rpmtsMembers(rpmts ts); +RPM_GNUC_INTERNAL +rpmal rpmtsCreateAl(rpmts ts, rpmElementTypes types); + /* returns -1 for retry, 0 for ignore and 1 for not found */ RPM_GNUC_INTERNAL int rpmtsSolve(rpmts ts, rpmds key);