summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-12 12:30:44 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-12 12:30:44 +0300
commit141c898cba6f7c862f34afc939e888edee6b056e (patch)
tree788663bc3ef94939f7a0d54e63b00ddf4f30399c
parent8a1f9c13fddb6c39a11950f6f934c71e050ae441 (diff)
downloadrpm-141c898cba6f7c862f34afc939e888edee6b056e.tar.gz
rpm-141c898cba6f7c862f34afc939e888edee6b056e.tar.bz2
rpm-141c898cba6f7c862f34afc939e888edee6b056e.zip
Add an nternal rpmal create+populate helper function, use for erased packages
- We'll need this shortly for added packages too...
-rw-r--r--lib/depends.c16
-rw-r--r--lib/order.c9
-rw-r--r--lib/rpmts_internal.h3
3 files changed, 21 insertions, 7 deletions
diff --git a/lib/depends.c b/lib/depends.c
index ad9b57777..42c3b8ec0 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 0c8d1cb9f..c0ef5470a 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 60daf47aa..5d3240cf0 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);