diff options
-rw-r--r-- | lib/depends.c | 393 | ||||
-rw-r--r-- | lib/depends.h | 44 | ||||
-rw-r--r-- | lib/problems.c | 14 | ||||
-rw-r--r-- | lib/rpmal.c | 28 | ||||
-rw-r--r-- | lib/rpmal.h | 41 | ||||
-rw-r--r-- | po/rpm.pot | 78 |
6 files changed, 384 insertions, 214 deletions
diff --git a/lib/depends.c b/lib/depends.c index b38df3016..c9a5ec642 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -19,7 +19,7 @@ /*@access Header@*/ /* XXX compared with NULL */ /*@access FD_t@*/ /* XXX compared with NULL */ /*@access rpmdb@*/ /* XXX compared with NULL */ -/*@access rpmdbMatchIterator@*/ /* XXX compared with NULL */ +/*@access rpmdbMatchIterator@*/ /* XXX compared with NULL */ /*@access rpmTransactionSet@*/ /*@access rpmDepSet@*/ @@ -29,16 +29,15 @@ /*@access orderListIndex@*/ /*@access tsortInfo@*/ -#ifndef DYING -/*@access availablePackage@*/ -#endif - /*@unchecked@*/ static int _cacheDependsRC = 1; /*@unchecked@*/ int _ts_debug = 0; +/*@unchecked@*/ +static int _te_debug = 0; + /** * Return formatted dependency string. * @param depend type of dependency ("R" == Requires, "C" == Conflcts) @@ -529,8 +528,10 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd, if ((p = alGetPkg(ts->addedPackages, i)) == NULL) break; + /*@-type@*/ /* FIX: availablePackage excision */ if (strcmp(p->name, name)) continue; + /*@=type@*/ pkgNVR = alGetNVR(ts->addedPackages, i); if (pkgNVR == NULL) /* XXX can't happen */ continue; @@ -609,9 +610,11 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd, if (oldmultiLibMask && multiLibMask && !(oldmultiLibMask & multiLibMask)) { + /*@-type@*/ /* FIX: availablePackage excision */ availablePackage alp = alGetPkg(ts->addedPackages, alNum); if (alp != NULL) alp->multiLib = multiLibMask; + /*@=type@*/ } } /*@=branchstate@*/ @@ -840,7 +843,7 @@ static int unsatisfiedDepend(rpmTransactionSet ts, goto unsatisfied; } - if (alSatisfiesDepend(ts->addedPackages, keyType, keyDepend, key) != NULL) + if (alSatisfiesDepend(ts->addedPackages, keyType, keyDepend, key) != -1L) { goto exit; } @@ -1011,8 +1014,10 @@ static int checkPackageDeps(rpmTransactionSet ts, problemsSet psp, {}; pp->suggestedPackages = xmalloc( (j + 1) * sizeof(*pp->suggestedPackages) ); + /*@-type@*/ /* FIX: availablePackage excision */ for (j = 0; suggestion[j] != NULL; j++) pp->suggestedPackages[j] = suggestion[j]->key; + /*@=type@*/ pp->suggestedPackages[j] = NULL; } else { pp->suggestedPackages = NULL; @@ -1213,17 +1218,19 @@ static struct badDeps_s { { NULL, NULL } }; -static int ignoreDep(const availablePackage p, - const availablePackage q) +static int ignoreDep(const transactionElement p, + const transactionElement q) /*@*/ { struct badDeps_s * bdp = badDeps; + /*@-nullpass@*/ /* FIX: {p,q}->name may be NULL. */ while (bdp->pname != NULL && bdp->qname != NULL) { if (!strcmp(p->name, bdp->pname) && !strcmp(q->name, bdp->qname)) return 1; bdp++; } + /*@=nullpass@*/ return 0; } #endif @@ -1233,23 +1240,25 @@ static int ignoreDep(const availablePackage p, * @param tsi successor chain * @param q predecessor */ -static void markLoop(/*@special@*/ tsortInfo tsi, availablePackage q) +static void markLoop(/*@special@*/ tsortInfo tsi, transactionElement q) /*@globals internalState @*/ /*@uses tsi @*/ /*@modifies internalState @*/ { - availablePackage p; + transactionElement p; + /*@-branchstate@*/ /* FIX: q is kept */ while (tsi != NULL && (p = tsi->tsi_suc) != NULL) { tsi = tsi->tsi_next; - if (p->tsi.tsi_pkg != NULL) + if (p->tsi.tsi_chain != NULL) continue; - /*@-assignexpose@*/ - p->tsi.tsi_pkg = q; - /*@=assignexpose@*/ + /*@-assignexpose -temptrans@*/ + p->tsi.tsi_chain = q; + /*@=assignexpose =temptrans@*/ if (p->tsi.tsi_next != NULL) markLoop(p->tsi.tsi_next, p); } + /*@=branchstate@*/ } static inline /*@observer@*/ const char * const identifyDepend(int_32 f) @@ -1285,7 +1294,7 @@ static inline /*@observer@*/ const char * const identifyDepend(int_32 f) * @return (possibly NULL) formatted "q <- p" releation (malloc'ed) */ static /*@owned@*/ /*@null@*/ const char * -zapRelation(availablePackage q, availablePackage p, rpmDepSet requires, +zapRelation(transactionElement q, transactionElement p, rpmDepSet requires, int zap, /*@in@*/ /*@out@*/ int * nzaps) /*@modifies q, p, *nzaps, requires @*/ { @@ -1305,7 +1314,7 @@ zapRelation(availablePackage q, availablePackage p, rpmDepSet requires, if (requires->N == NULL) continue; /* XXX can't happen */ if (requires->EVR == NULL) continue; /* XXX can't happen */ - if (requires->Flags == NULL) continue;/* XXX can't happen */ + if (requires->Flags == NULL) continue; /* XXX can't happen */ requires->i = tsi->tsi_reqx; /* XXX hack */ dp = printDepend( identifyDepend(requires->Flags[requires->i]), requires); @@ -1316,8 +1325,8 @@ zapRelation(availablePackage q, availablePackage p, rpmDepSet requires, /*@-branchstate@*/ if (zap && !(requires->Flags[requires->i] & RPMSENSE_PREREQ)) { rpmMessage(RPMMESS_DEBUG, - _("removing %s-%s-%s \"%s\" from tsort relations.\n"), - p->name, p->version, p->release, dp); + _("removing %s \"%s\" from tsort relations.\n"), + (p->NEVR ? p->NEVR : "???"), dp); p->tsi.tsi_count--; if (tsi_prev) tsi_prev->tsi_next = tsi->tsi_next; tsi->tsi_next = NULL; @@ -1335,6 +1344,18 @@ zapRelation(availablePackage q, availablePackage p, rpmDepSet requires, return dp; } +static void prtTSI(const char * msg, tsortInfo tsi) + /*@globals fileSystem@*/ + /*@modifies fileSystem@*/ +{ +/*@-nullpass@*/ +if (_te_debug) { + if (msg) fprintf(stderr, "%s", msg); + fprintf(stderr, " tsi %p suc %p next %p chain %p reqx %d qcnt %d\n", tsi, tsi->tsi_suc, tsi->tsi_next, tsi->tsi_chain, tsi->tsi_reqx, tsi->tsi_qcnt); +} +/*@=nullpass@*/ +} + /** * Record next "q <- p" relation (i.e. "p" requires "q"). * @param ts transaction set @@ -1344,53 +1365,97 @@ zapRelation(availablePackage q, availablePackage p, rpmDepSet requires, * @return 0 always */ static inline int addRelation(const rpmTransactionSet ts, - availablePackage p, unsigned char * selected, + transactionElement p, unsigned char * selected, rpmDepSet requires) /*@modifies p, *selected @*/ { - availablePackage q; + transactionElement q; tsortInfo tsi; - int matchNum; + long matchNum; + int i = 0; if (!requires->N || !requires->EVR || !requires->Flags) return 0; - q = alSatisfiesDepend(ts->addedPackages, NULL, NULL, requires); + matchNum = alSatisfiesDepend(ts->addedPackages, NULL, NULL, requires); +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "addRelation: matchNum %d\n", (int)matchNum); +/*@=modfilesystem =nullpass@*/ /* Ordering depends only on added package relations. */ - if (q == NULL) + if (matchNum == -1L) return 0; +/* XXX set q to the added package that has matchNum == q->u.addedIndex */ +/* XXX FIXME: bsearch is possible/needed here */ + if ((q = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, q++) { + if (q->type == TR_ADDED && matchNum == q->u.addedIndex) + break; + } +/*@-modfilesystem -nullpass -nullderef@*/ +if (_te_debug) +fprintf(stderr, "addRelation: q %p(%s) from %p[%d:%d]\n", q, q->name, ts->order, i, ts->orderCount); +/*@=modfilesystem =nullpass =nullderef@*/ + assert(i < ts->orderCount); + +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "addRelation: requires[%d] %s\n", requires->i, requires->N[requires->i]); +/*@=modfilesystem =nullpass@*/ /* Avoid rpmlib feature dependencies. */ if (!strncmp(requires->N[requires->i], "rpmlib(", sizeof("rpmlib(")-1)) return 0; #if defined(DEPENDENCY_WHITEOUT) /* Avoid certain dependency relations. */ - if (ignoreDep(p, q)) + if (q == NULL || ignoreDep(p, q)) return 0; #endif /* Avoid redundant relations. */ /* XXX TODO: add control bit. */ - matchNum = alGetPkgIndex(ts->addedPackages, q); - if (selected[matchNum] != 0) + i = q - ts->order; + if (selected[i] != 0) return 0; - selected[matchNum] = 1; + selected[i] = 1; +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "addRelation: selected[%d] = 1\n", i); +/*@=modfilesystem =nullpass@*/ /* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */ p->tsi.tsi_count++; /* bump p predecessor count */ if (p->depth <= q->depth) /* Save max. depth in dependency tree */ p->depth = q->depth + 1; +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "addRelation: p %p(%s) depth %d", p, p->name, p->depth); +prtTSI(NULL, &p->tsi); +/*@=modfilesystem =nullpass@*/ - tsi = xmalloc(sizeof(*tsi)); + tsi = xcalloc(1, sizeof(*tsi)); /*@-assignexpose@*/ tsi->tsi_suc = p; /*@=assignexpose@*/ tsi->tsi_reqx = requires->i; tsi->tsi_next = q->tsi.tsi_next; +/*@-modfilesystem -nullpass -compmempass@*/ +prtTSI("addRelation: new", tsi); +if (_te_debug) +fprintf(stderr, "addRelation: BEFORE q %p(%s)\n", q, q->name); +prtTSI(NULL, &q->tsi); +/*@=modfilesystem =nullpass =compmempass@*/ +/*@-mods@*/ q->tsi.tsi_next = tsi; q->tsi.tsi_qcnt++; /* bump q successor count */ +/*@=mods@*/ +/*@-modfilesystem -nullpass -compmempass@*/ +if (_te_debug) +fprintf(stderr, "addRelation: AFTER q %p(%s)\n", q, q->name); +prtTSI(NULL, &q->tsi); +/*@=modfilesystem =nullpass =compmempass@*/ return 0; } @@ -1415,12 +1480,12 @@ static int orderListIndexCmp(const void * one, const void * two) /*@*/ * @retval qp address of first element * @retval rp address of last element */ -static void addQ(availablePackage p, - /*@in@*/ /*@out@*/ availablePackage * qp, - /*@in@*/ /*@out@*/ availablePackage * rp) +static void addQ(transactionElement p, + /*@in@*/ /*@out@*/ transactionElement * qp, + /*@in@*/ /*@out@*/ transactionElement * rp) /*@modifies p, *qp, *rp @*/ { - availablePackage q, qprev; + transactionElement q, qprev; if ((*rp) == NULL) { /* 1st element */ (*rp) = (*qp) = p; @@ -1446,16 +1511,16 @@ static void addQ(availablePackage p, int rpmdepOrder(rpmTransactionSet ts) { - int npkgs = alGetSize(ts->addedPackages); + int nadded = alGetSize(ts->addedPackages); int chainsaw = ts->transFlags & RPMTRANS_FLAG_CHAINSAW; - availablePackage p; - availablePackage q; - availablePackage r; + transactionElement p; + transactionElement q; + transactionElement r; tsortInfo tsi; tsortInfo tsi_next; - int * ordering = alloca(sizeof(*ordering) * (npkgs + 1)); + int * ordering = alloca(sizeof(*ordering) * (nadded + 1)); int orderingCount = 0; - unsigned char * selected = alloca(sizeof(*selected) * (npkgs + 1)); + unsigned char * selected = alloca(sizeof(*selected) * (ts->orderCount + 1)); int loopcheck; transactionElement newOrder; int newOrderCount = 0; @@ -1466,39 +1531,88 @@ int rpmdepOrder(rpmTransactionSet ts) int i, j; alMakeIndex(ts->addedPackages); - alMakeIndex(ts->availablePackages); + +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "*** rpmdepOrder(%p) order %p[%d]\n", ts, ts->order, ts->orderCount); +/*@=modfilesystem =nullpass@*/ /* T1. Initialize. */ - loopcheck = npkgs; + loopcheck = ts->orderCount; + if ((p = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, p++) { + + /* Initialize tsortInfo. */ + memset(&p->tsi, 0, sizeof(p->tsi)); + p->npreds = 0; + p->depth = 0; + p->NEVR = NULL; + p->name = NULL; + p->version = NULL; + p->release = NULL; + + /* XXX Only added packages are ordered (for now). */ + switch(p->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } + + /* Retrieve info from addedPackages. */ + p->NEVR = alGetNVR(ts->addedPackages, p->u.addedIndex); + p->name = alGetNVR(ts->addedPackages, p->u.addedIndex); +/*@-nullpass@*/ + if ((p->release = strrchr(p->name, '-')) != NULL) + *p->release++ = '\0'; + if ((p->version = strrchr(p->name, '-')) != NULL) + *p->version++ = '\0'; +/*@-modfilesystem@*/ +prtTSI(p->NEVR, &p->tsi); +/*@=modfilesystem@*/ +/*@=nullpass@*/ + } /* Record all relations. */ rpmMessage(RPMMESS_DEBUG, _("========== recording tsort relations\n")); - for (i = 0; i < npkgs; i++) { + if ((p = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, p++) { rpmDepSet requires; - int matchNum; - if ((p = alGetPkg(ts->addedPackages, i)) == NULL) - break; + /* XXX Only added packages are ordered (for now). */ + switch(p->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } - requires = alGetRequires(ts->addedPackages, i); + requires = alGetRequires(ts->addedPackages, p->u.addedIndex); if (requires->Count <= 0) continue; + if (requires->Flags == NULL) /* XXX can't happen */ + continue; - memset(selected, 0, sizeof(*selected) * npkgs); +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "\t+++ %p[%d] %s %s-%s-%s requires[%d] %p[%d] Flags %p\n", p, i, p->NEVR, p->name, p->version, p->release, p->u.addedIndex, requires, requires->Count, requires->Flags); +/*@=modfilesystem =nullpass@*/ + + memset(selected, 0, sizeof(*selected) * ts->orderCount); /* Avoid narcisstic relations. */ - matchNum = alGetPkgIndex(ts->addedPackages, p); - selected[matchNum] = 1; + selected[i] = 1; /* T2. Next "q <- p" relation. */ /* First, do pre-requisites. */ for (requires->i = 0; requires->i < requires->Count; requires->i++) { - if (requires->Flags == NULL) /* XXX can't happen */ - /*@innercontinue@*/ continue; - /* Skip if not %pre/%post requires or legacy prereq. */ if (isErasePreReq(requires->Flags[requires->i]) || @@ -1514,9 +1628,6 @@ int rpmdepOrder(rpmTransactionSet ts) /* Then do co-requisites. */ for (requires->i = 0; requires->i < requires->Count; requires->i++) { - if (requires->Flags == NULL) /* XXX can't happen */ - /*@innercontinue@*/ continue; - /* Skip if %pre/%post requires or legacy prereq. */ if (isErasePreReq(requires->Flags[requires->i]) || @@ -1531,12 +1642,24 @@ int rpmdepOrder(rpmTransactionSet ts) } /* Save predecessor count. */ - for (i = 0; i < npkgs; i++) { - - if ((p = alGetPkg(ts->addedPackages, i)) == NULL) - break; + if ((p = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, p++) { + /* XXX Only added packages are ordered (for now). */ + switch(p->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } p->npreds = p->tsi.tsi_count; +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "\t+++ %p[%d] %s npreds %d\n", p, i, p->NEVR, p->npreds); +/*@=modfilesystem =nullpass@*/ + } /* T4. Scan for zeroes. */ @@ -1545,30 +1668,53 @@ int rpmdepOrder(rpmTransactionSet ts) rescan: q = r = NULL; qlen = 0; - for (i = 0; i < npkgs; i++) { + if ((p = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, p++) { - if ((p = alGetPkg(ts->addedPackages, i)) == NULL) - break; + /* XXX Only added packages are ordered (for now). */ + switch(p->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } /* Prefer packages in presentation order. */ if (!chainsaw) - p->tsi.tsi_qcnt = (npkgs - i); + p->tsi.tsi_qcnt = (ts->orderCount - i); if (p->tsi.tsi_count != 0) continue; p->tsi.tsi_suc = NULL; addQ(p, &q, &r); qlen++; +/*@-modfilesystem -nullpass@*/ +if (_te_debug) +fprintf(stderr, "\t+++ %p[%d] %s addQ ++ q %p %d\n", p, i, p->NEVR, q, qlen); +/*@=modfilesystem =nullpass@*/ } /* T5. Output front of queue (T7. Remove from queue.) */ + /*@-branchstate@*/ /* FIX: r->tsi.tsi_next released */ for (; q != NULL; q = q->tsi.tsi_suc) { - rpmMessage(RPMMESS_DEBUG, "%5d%5d%5d%3d %*s %s-%s-%s\n", + /* XXX Only added packages are ordered (for now). */ + switch(q->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } + + rpmMessage(RPMMESS_DEBUG, "%5d%5d%5d%3d %*s %s\n", orderingCount, q->npreds, q->tsi.tsi_qcnt, q->depth, - 2*q->depth, "", - q->name, q->version, q->release); - ordering[orderingCount++] = alGetPkgIndex(ts->addedPackages, q); + (2 * q->depth), "", + (q->NEVR ? q->NEVR : "???")); + ordering[orderingCount++] = q->u.addedIndex; qlen--; loopcheck--; @@ -1595,6 +1741,7 @@ rescan: _("========== successors only (presentation order)\n")); } } + /*@=branchstate@*/ /* T8. End of process. Check for loops. */ if (loopcheck != 0) { @@ -1602,12 +1749,20 @@ rescan: /* T9. Initialize predecessor chain. */ nzaps = 0; - for (i = 0; i < npkgs; i++) { - - if ((q = alGetPkg(ts->addedPackages, i)) == NULL) - break; + if ((q = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, q++) { + + /* XXX Only added packages are ordered (for now). */ + switch(q->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } - q->tsi.tsi_pkg = NULL; + q->tsi.tsi_chain = NULL; q->tsi.tsi_reqx = 0; /* Mark packages already sorted. */ if (q->tsi.tsi_count == 0) @@ -1615,10 +1770,18 @@ rescan: } /* T10. Mark all packages with their predecessors. */ - for (i = 0; i < npkgs; i++) { - - if ((q = alGetPkg(ts->addedPackages, i)) == NULL) - break; + if ((q = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, q++) { + + /* XXX Only added packages are ordered (for now). */ + switch(q->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } if ((tsi = q->tsi.tsi_next) == NULL) continue; @@ -1629,28 +1792,36 @@ rescan: /* T11. Print all dependency loops. */ /*@-branchstate@*/ - for (i = 0; i < npkgs; i++) { + if ((r = ts->order) != NULL) + for (i = 0; i < ts->orderCount; i++, r++) { int printed; - if ((r = alGetPkg(ts->addedPackages, i)) == NULL) - break; + /* XXX Only added packages are ordered (for now). */ + switch(r->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; + } printed = 0; /* T12. Mark predecessor chain, looking for start of loop. */ - for (q = r->tsi.tsi_pkg; q != NULL; q = q->tsi.tsi_pkg) { + for (q = r->tsi.tsi_chain; q != NULL; q = q->tsi.tsi_chain) { if (q->tsi.tsi_reqx) /*@innerbreak@*/ break; q->tsi.tsi_reqx = 1; } /* T13. Print predecessor chain from start of loop. */ - while ((p = q) != NULL && (q = p->tsi.tsi_pkg) != NULL) { + while ((p = q) != NULL && (q = p->tsi.tsi_chain) != NULL) { const char * dp; char buf[4096]; /* Unchain predecessor loop. */ - p->tsi.tsi_pkg = NULL; + p->tsi.tsi_chain = NULL; if (!printed) { rpmMessage(RPMMESS_DEBUG, _("LOOP:\n")); @@ -1658,10 +1829,14 @@ rescan: } /* Find (and destroy if co-requisite) "q <- p" relation. */ - dp = zapRelation(q, p, &p->requires, 1, &nzaps); + dp = zapRelation(q, p, + alGetRequires(ts->addedPackages, p->u.addedIndex), + 1, &nzaps); /* Print next member of loop. */ - sprintf(buf, "%s-%s-%s", p->name, p->version, p->release); + buf[0] = '\0'; + if (p->NEVR != NULL) + (void) stpcpy(buf, p->NEVR); rpmMessage(RPMMESS_DEBUG, " %-40s %s\n", buf, (dp ? dp : "not found!?!")); @@ -1669,12 +1844,12 @@ rescan: } /* Walk (and erase) linear part of predecessor chain as well. */ - for (p = r, q = r->tsi.tsi_pkg; + for (p = r, q = r->tsi.tsi_chain; q != NULL; - p = q, q = q->tsi.tsi_pkg) + p = q, q = q->tsi.tsi_chain) { /* Unchain linear part of predecessor loop. */ - p->tsi.tsi_pkg = NULL; + p->tsi.tsi_chain = NULL; p->tsi.tsi_reqx = 0; } } @@ -1695,17 +1870,39 @@ rescan: * the new package. This would be easier if we could sort the * addedPackages array, but we store indexes into it in various places. */ - orderList = xcalloc(npkgs, sizeof(*orderList)); - for (i = 0, j = 0; i < ts->orderCount; i++) { - if (ts->order[i].type == TR_ADDED) { - orderList[j].alIndex = ts->order[i].u.addedIndex; - orderList[j].orIndex = i; - j++; + nadded = alGetSize(ts->addedPackages); + orderList = xcalloc(nadded, sizeof(*orderList)); + j = 0; + if ((p = ts->order) != NULL) + for (i = 0, j = 0; i < ts->orderCount; i++, p++) { + + /* XXX Only added packages are ordered (for now). */ + switch(p->type) { + case TR_ADDED: + /*@switchbreak@*/ break; + case TR_REMOVED: + default: + continue; + /*@notreached@*/ /*@switchbreak@*/ break; } + + /* Clean up tsort remnants (if any). */ + while ((tsi = p->tsi.tsi_next) != NULL) { + p->tsi.tsi_next = tsi->tsi_next; + tsi->tsi_next = NULL; + tsi = _free(tsi); + } + p->NEVR = _free(p->NEVR); + p->name = _free(p->name); + + /* Prepare added package partial ordering permutation. */ + orderList[j].alIndex = p->u.addedIndex; + orderList[j].orIndex = i; + j++; } - assert(j <= npkgs); + assert(j <= nadded); - qsort(orderList, npkgs, sizeof(*orderList), orderListIndexCmp); + qsort(orderList, nadded, sizeof(*orderList), orderListIndexCmp); newOrder = xcalloc(ts->orderCount, sizeof(*newOrder)); for (i = 0, newOrderCount = 0; i < orderingCount; i++) { @@ -1713,7 +1910,7 @@ rescan: orderListIndex needle; key.alIndex = ordering[i]; - needle = bsearch(&key, orderList, npkgs, sizeof(key),orderListIndexCmp); + needle = bsearch(&key, orderList, nadded, sizeof(key),orderListIndexCmp); /* bsearch should never, ever fail */ if (needle == NULL) continue; @@ -1790,7 +1987,7 @@ int rpmdepCheck(rpmTransactionSet ts, Header h = NULL; availablePackage p; problemsSet ps = NULL; - int npkgs; + int nadded; int closeatexit = 0; int i, j, xx; int rc; @@ -1802,7 +1999,7 @@ int rpmdepCheck(rpmTransactionSet ts, closeatexit = 1; } - npkgs = alGetSize(ts->addedPackages); + nadded = alGetSize(ts->addedPackages); ps = xcalloc(1, sizeof(*ps)); ps->alloced = 5; @@ -1819,7 +2016,7 @@ int rpmdepCheck(rpmTransactionSet ts, * Look at all of the added packages and make sure their dependencies * are satisfied. */ - for (i = 0; i < npkgs; i++) + for (i = 0; i < nadded; i++) { char * pkgNVR, * n, * v, * r; rpmDepSet provides; diff --git a/lib/depends.h b/lib/depends.h index 52f2a57dc..9cab805d5 100644 --- a/lib/depends.h +++ b/lib/depends.h @@ -9,31 +9,65 @@ #include <header.h> #include <rpmhash.h> -typedef /*@abstract@*/ struct availableList_s * availableList; -typedef /*@abstract@*/ struct problemsSet_s * problemsSet; +typedef /*@abstract@*/ struct tsortInfo_s * tsortInfo; typedef /*@abstract@*/ struct orderListIndex_s * orderListIndex; typedef /*@abstract@*/ struct transactionElement_s * transactionElement; +typedef /*@abstract@*/ struct availableList_s * availableList; +typedef /*@abstract@*/ struct problemsSet_s * problemsSet; + /*@unchecked@*/ /*@-exportlocal@*/ extern int _ts_debug; /*@=exportlocal@*/ +/** \ingroup rpmdep + * Dependncy ordering information. + */ +/*@-fielduse@*/ /* LCL: confused by union? */ +struct tsortInfo_s { + union { + int count; + /*@kept@*/ /*@null@*/ transactionElement suc; + } tsi_u; +#define tsi_count tsi_u.count +#define tsi_suc tsi_u.suc +/*@owned@*/ /*@null@*/ + struct tsortInfo_s * tsi_next; +/*@null@*/ + transactionElement tsi_chain; + int tsi_reqx; + int tsi_qcnt; +}; +/*@=fielduse@*/ + +/** + */ struct orderListIndex_s { int alIndex; int orIndex; }; - /** \ingroup rpmdep * A single package instance to be installed/removed atomically. */ -/*@-fielduse@*/ /* LCL: confused by union? */ struct transactionElement_s { +/*@only@*/ /*@null@*/ + char * NEVR; +/*@owned@*/ /*@null@*/ + char * name; +/*@dependent@*/ /*@null@*/ + char * version; +/*@dependent@*/ /*@null@*/ + char * release; + int npreds; /*!< No. of predecessors. */ + int depth; /*!< Max. depth in dependency tree. */ + struct tsortInfo_s tsi; enum rpmTransactionType { TR_ADDED, /*!< Package will be installed. */ TR_REMOVED /*!< Package will be removed. */ } type; /*!< Package disposition (installed/removed). */ +/*@-fielduse@*/ /* LCL: confused by union? */ union { /*@unused@*/ int addedIndex; /*@unused@*/ struct { @@ -41,8 +75,8 @@ struct transactionElement_s { int dependsOnIndex; } removed; } u; -} ; /*@=fielduse@*/ +}; /** * A package dependency set. diff --git a/lib/problems.c b/lib/problems.c index 8d917dfe6..34b87aeb1 100644 --- a/lib/problems.c +++ b/lib/problems.c @@ -7,7 +7,6 @@ #include <rpmlib.h> #include "depends.h" -#include "rpmal.h" #include "misc.h" #include "debug.h" @@ -64,15 +63,14 @@ void rpmProblemSetAppend(rpmProblemSet tsprobs, rpmProblemType type, memset(p, 0, sizeof(*p)); p->type = type; - p->key = key; - p->ulong1 = ulong1; p->ignoreProblem = 0; - p->str1 = NULL; - p->pkgNEVR = NULL; - p->altNEVR = NULL; + p->pkgNEVR = pkgNEVR; /* XXX FIXME: xstrdup */ + p->altNEVR = altNEVR; /* XXX FIXME: xstrdup */ + + p->str1 = NULL; if (dn != NULL || bn != NULL) { t = xcalloc(1, (dn != NULL ? strlen(dn) : 0) + (bn != NULL ? strlen(bn) : 0) + 1); @@ -80,10 +78,6 @@ void rpmProblemSetAppend(rpmProblemSet tsprobs, rpmProblemType type, if (dn != NULL) t = stpcpy(t, dn); if (bn != NULL) t = stpcpy(t, bn); } - - p->pkgNEVR = pkgNEVR; - p->altNEVR = altNEVR; - } #define XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b)))) diff --git a/lib/rpmal.c b/lib/rpmal.c index 2c65f4014..5eb690a33 100644 --- a/lib/rpmal.c +++ b/lib/rpmal.c @@ -26,6 +26,7 @@ typedef /*@abstract@*/ struct availableIndex_s * availableIndex; /*@access availableList@*/ /*@access availablePackage@*/ +/*@access tsortInfo@*/ /*@access rpmDepSet@*/ @@ -152,14 +153,6 @@ rpmDepSet alGetRequires(const availableList al, int pkgNum) /*@=immediatetrans =retexpose@*/ } -tsortInfo alGetTSI(const availableList al, int pkgNum) -{ - availablePackage alp = alGetPkg(al, pkgNum); - /*@-immediatetrans -retexpose@*/ - return (alp != NULL ? &alp->tsi : 0); - /*@=immediatetrans =retexpose@*/ -} - Header alGetHeader(availableList al, int pkgNum, int unlink) { availablePackage alp = alGetPkg(al, pkgNum); @@ -279,14 +272,6 @@ availableList alFree(availableList al) if ((p = al->list) != NULL) for (i = 0; i < al->size; i++, p++) { - { tsortInfo tsi; - while ((tsi = p->tsi.tsi_next) != NULL) { - p->tsi.tsi_next = tsi->tsi_next; - tsi->tsi_next = NULL; - tsi = _free(tsi); - } - } - p->provides.N = hfd(p->provides.N, -1); p->provides.EVR = hfd(p->provides.EVR, -1); p->requires.N = hfd(p->requires.N, -1); @@ -463,8 +448,6 @@ alAddPackage(availableList al, int pkgNum, p = al->list + pkgNum; p->h = headerLink(h); /* XXX reference held by transaction set */ - p->depth = p->npreds = 0; - memset(&p->tsi, 0, sizeof(p->tsi)); p->multiLib = 0; /* MULTILIB */ xx = headerNVR(p->h, &p->name, &p->version, &p->release); @@ -877,17 +860,16 @@ alAllSatisfiesDepend(const availableList al, return ret; } -availablePackage alSatisfiesDepend(const availableList al, +long alSatisfiesDepend(const availableList al, const char * keyType, const char * keyDepend, const rpmDepSet key) { - availablePackage ret; availablePackage * tmp = alAllSatisfiesDepend(al, keyType, keyDepend, key); if (tmp) { - ret = tmp[0]; + availablePackage ret = tmp[0]; tmp = _free(tmp); - return ret; + return (ret - al->list); } - return NULL; + return -1; } diff --git a/lib/rpmal.h b/lib/rpmal.h index 6d687c217..787c68f9d 100644 --- a/lib/rpmal.h +++ b/lib/rpmal.h @@ -6,30 +6,6 @@ * Structures used for managing added/available package lists. */ -/** - */ -typedef /*@abstract@*/ struct tsortInfo_s * tsortInfo; - -/** \ingroup rpmdep - * Dependncy ordering information. - */ -/*@-fielduse@*/ /* LCL: confused by union? */ -struct tsortInfo_s { - union { - int count; - /*@kept@*/ /*@null@*/ availablePackage suc; - } tsi_u; -#define tsi_count tsi_u.count -#define tsi_suc tsi_u.suc -/*@owned@*/ /*@null@*/ - struct tsortInfo_s * tsi_next; -/*@kept@*/ /*@null@*/ - availablePackage tsi_pkg; - int tsi_reqx; - int tsi_qcnt; -}; -/*@=fielduse@*/ - /** \ingroup rpmdep * Info about a single package to be installed. */ @@ -43,9 +19,6 @@ struct availablePackage_s { /*@owned@*//*@null@*/ const char ** baseNames; /*!< Header file basenames. */ /*@dependent@*//*@null@*/ int_32 * epoch; /*!< Header epoch (if any). */ int filesCount; /*!< No. of files in header. */ - int npreds; /*!< No. of predecessors. */ - int depth; /*!< Max. depth in dependency tree. */ - struct tsortInfo_s tsi; /*!< Dependency tsort data. */ uint_32 multiLib; /* MULTILIB */ /*@kept@*//*@null@*/ const void * key; /*!< Private data associated with a package (e.g. file name of package). */ /*@null@*/ rpmRelocation * relocs; @@ -111,15 +84,6 @@ rpmDepSet alGetRequires(/*@null@*/ const availableList al, int pkgNum) /*@*/; /** - * Return available package tsort info. - * @param al available list - * @param pkgNum available package index - * @return available package tsort info - */ -tsortInfo alGetTSI(/*@null@*/ const availableList al, int pkgNum) - /*@*/; - -/** * Return available package header. * @param al available list * @param pkgNum available package index @@ -279,10 +243,9 @@ availablePackage * alAllSatisfiesDepend(const availableList al, * @param keyType type of dependency * @param keyDepend dependency string representation * @param key dependency - * @return available package pointer + * @return available package index, -1 on not found */ -/*@only@*/ /*@null@*/ -availablePackage alSatisfiesDepend(const availableList al, +long alSatisfiesDepend(const availableList al, const char * keyType, const char * keyDepend, const rpmDepSet key) /*@*/; diff --git a/po/rpm.pot b/po/rpm.pot index d53797c01..8fe1bffd6 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-10-30 22:54-0500\n" +"POT-Creation-Date: 2001-10-31 17:15-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -1411,82 +1411,82 @@ msgid " failed - " msgstr "" #. XXX legacy epoch-less requires/conflicts compatibility -#: lib/depends.c:184 +#: lib/depends.c:183 #, c-format msgid "" "the \"B\" dependency needs an epoch (assuming same as \"A\")\n" "\tA %s\tB %s\n" msgstr "" -#: lib/depends.c:213 +#: lib/depends.c:212 #, c-format msgid " %s A %s\tB %s\n" msgstr "" -#: lib/depends.c:214 lib/depends.c:791 lib/depends.c:923 +#: lib/depends.c:213 lib/depends.c:794 lib/depends.c:926 msgid "YES" msgstr "" -#: lib/depends.c:214 lib/depends.c:791 lib/depends.c:923 +#: lib/depends.c:213 lib/depends.c:794 lib/depends.c:926 msgid "NO " msgstr "" -#: lib/depends.c:356 +#: lib/depends.c:355 #, c-format msgid "cannot open Packages database in %s\n" msgstr "" -#: lib/depends.c:544 +#: lib/depends.c:545 #, c-format msgid "newer package %s already added, skipping %s\n" msgstr "" -#: lib/depends.c:549 +#: lib/depends.c:550 #, c-format msgid "package %s already added, ignoring\n" msgstr "" -#: lib/depends.c:554 +#: lib/depends.c:555 #, c-format msgid "older package %s already added, replacing with %s\n" msgstr "" -#: lib/depends.c:790 +#: lib/depends.c:793 #, c-format msgid "%s: %-45s %-s (cached)\n" msgstr "" -#: lib/depends.c:819 +#: lib/depends.c:822 #, c-format msgid "%s: %-45s YES (rpmrc provides)\n" msgstr "" -#: lib/depends.c:836 +#: lib/depends.c:839 #, c-format msgid "%s: %-45s YES (rpmlib provides)\n" msgstr "" -#: lib/depends.c:859 +#: lib/depends.c:862 #, c-format msgid "%s: %-45s YES (db files)\n" msgstr "" -#: lib/depends.c:872 +#: lib/depends.c:875 #, c-format msgid "%s: %-45s YES (db provides)\n" msgstr "" -#: lib/depends.c:886 +#: lib/depends.c:889 #, c-format msgid "%s: %-45s YES (db package)\n" msgstr "" -#: lib/depends.c:902 +#: lib/depends.c:905 #, c-format msgid "%s: %-45s NO\n" msgstr "" -#: lib/depends.c:923 +#: lib/depends.c:926 #, c-format msgid "%s: (%s, %s) added to Depends cache.\n" msgstr "" @@ -1494,42 +1494,42 @@ msgstr "" #. requirements are satisfied. #. @switchbreak@ #. requirements are not satisfied. -#: lib/depends.c:989 +#: lib/depends.c:992 #, c-format msgid "package %s-%s-%s require not satisfied: %s\n" msgstr "" #. conflicts exist. -#: lib/depends.c:1067 +#: lib/depends.c:1072 #, c-format msgid "package %s conflicts: %s\n" msgstr "" -#: lib/depends.c:1319 +#: lib/depends.c:1328 #, c-format -msgid "removing %s-%s-%s \"%s\" from tsort relations.\n" +msgid "removing %s \"%s\" from tsort relations.\n" msgstr "" #. Record all relations. -#: lib/depends.c:1475 +#: lib/depends.c:1579 msgid "========== recording tsort relations\n" msgstr "" #. T4. Scan for zeroes. -#: lib/depends.c:1543 +#: lib/depends.c:1666 msgid "" "========== tsorting packages (order, #predecessors, #succesors, depth)\n" msgstr "" -#: lib/depends.c:1595 +#: lib/depends.c:1741 msgid "========== successors only (presentation order)\n" msgstr "" -#: lib/depends.c:1656 +#: lib/depends.c:1827 msgid "LOOP:\n" msgstr "" -#: lib/depends.c:1686 +#: lib/depends.c:1861 msgid "========== continuing tsort ...\n" msgstr "" @@ -2137,67 +2137,67 @@ msgstr "" msgid "generate signature" msgstr "" -#: lib/problems.c:208 +#: lib/problems.c:202 #, c-format msgid " is needed by %s-%s-%s\n" msgstr "" -#: lib/problems.c:211 +#: lib/problems.c:205 #, c-format msgid " conflicts with %s-%s-%s\n" msgstr "" -#: lib/problems.c:251 +#: lib/problems.c:245 #, c-format msgid "package %s is for a different architecture" msgstr "" -#: lib/problems.c:256 +#: lib/problems.c:250 #, c-format msgid "package %s is for a different operating system" msgstr "" -#: lib/problems.c:261 +#: lib/problems.c:255 #, c-format msgid "package %s is already installed" msgstr "" -#: lib/problems.c:266 +#: lib/problems.c:260 #, c-format msgid "path %s in package %s is not relocateable" msgstr "" -#: lib/problems.c:271 +#: lib/problems.c:265 #, c-format msgid "file %s conflicts between attempted installs of %s and %s" msgstr "" -#: lib/problems.c:276 +#: lib/problems.c:270 #, c-format msgid "file %s from install of %s conflicts with file from package %s" msgstr "" -#: lib/problems.c:281 +#: lib/problems.c:275 #, c-format msgid "package %s (which is newer than %s) is already installed" msgstr "" -#: lib/problems.c:286 +#: lib/problems.c:280 #, c-format msgid "installing package %s needs %ld%cb on the %s filesystem" msgstr "" -#: lib/problems.c:296 +#: lib/problems.c:290 #, c-format msgid "installing package %s needs %ld inodes on the %s filesystem" msgstr "" -#: lib/problems.c:301 +#: lib/problems.c:295 #, c-format msgid "package %s pre-transaction syscall(s): %s failed: %s" msgstr "" -#: lib/problems.c:308 +#: lib/problems.c:302 #, c-format msgid "unknown error %d encountered while manipulating package %s" msgstr "" |