2000-08-28 03:27:03 +08:00
|
|
|
/** \ingroup rpmdep
|
|
|
|
* \file lib/depends.c
|
|
|
|
*/
|
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "system.h"
|
|
|
|
|
1999-07-14 05:37:57 +08:00
|
|
|
#include <rpmlib.h>
|
2001-11-13 04:51:05 +08:00
|
|
|
#include <rpmmacro.h> /* XXX rpmtsOpenDB() needs rpmGetPath */
|
|
|
|
#include <rpmpgp.h> /* XXX rpmtransFree() needs pgpFreeDig */
|
1997-01-18 00:20:18 +08:00
|
|
|
|
2001-11-04 23:43:26 +08:00
|
|
|
#define _NEED_TEITERATOR 1
|
1998-03-28 00:46:39 +08:00
|
|
|
#include "depends.h"
|
2001-11-04 23:43:26 +08:00
|
|
|
|
2001-06-18 06:18:03 +08:00
|
|
|
#include "rpmdb.h" /* XXX response cache needs dbiOpen et al. */
|
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1996-06-10 10:36:07 +08:00
|
|
|
|
2001-11-11 10:50:31 +08:00
|
|
|
/*@access tsortInfo @*/
|
|
|
|
/*@access rpmTransactionSet @*/
|
2001-10-29 06:17:47 +08:00
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@access alKey @*/ /* XXX for reordering and RPMAL_NOMATCH assign */
|
2001-10-31 02:55:39 +08:00
|
|
|
|
2001-11-03 10:34:15 +08:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
typedef /*@abstract@*/ struct orderListIndex_s * orderListIndex;
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@access orderListIndex@*/
|
2001-11-03 10:34:15 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
struct orderListIndex_s {
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@dependent@*/
|
2001-11-05 06:00:11 +08:00
|
|
|
alKey pkgKey;
|
2001-11-03 10:34:15 +08:00
|
|
|
int orIndex;
|
|
|
|
};
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-11-03 10:34:15 +08:00
|
|
|
int _cacheDependsRC = 1;
|
2001-09-16 05:21:31 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@unchecked@*/
|
2001-11-03 10:34:15 +08:00
|
|
|
int _ts_debug = 0;
|
2001-11-01 06:19:42 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@observer@*/ /*@unchecked@*/
|
|
|
|
const char *rpmNAME = PACKAGE;
|
2001-10-18 00:43:36 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@observer@*/ /*@unchecked@*/
|
|
|
|
const char *rpmEVR = VERSION;
|
2001-10-18 00:43:36 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
1999-09-26 23:04:03 +08:00
|
|
|
int rpmFLAGS = RPMSENSE_EQUAL;
|
1999-07-23 01:48:31 +08:00
|
|
|
|
2001-10-29 06:17:47 +08:00
|
|
|
rpmTransactionSet XrpmtsUnlink(rpmTransactionSet ts, const char * msg, const char * fn, unsigned ln)
|
2001-10-28 06:31:10 +08:00
|
|
|
{
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@-modfilesystem@*/
|
|
|
|
if (_ts_debug)
|
|
|
|
fprintf(stderr, "--> ts %p -- %d %s at %s:%u\n", ts, ts->nrefs, msg, fn, ln);
|
|
|
|
/*@=modfilesystem@*/
|
2001-10-28 06:31:10 +08:00
|
|
|
ts->nrefs--;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-10-29 06:17:47 +08:00
|
|
|
rpmTransactionSet XrpmtsLink(rpmTransactionSet ts, const char * msg, const char * fn, unsigned ln)
|
|
|
|
{
|
|
|
|
ts->nrefs++;
|
2001-10-28 04:09:20 +08:00
|
|
|
/*@-modfilesystem@*/
|
2001-10-29 06:17:47 +08:00
|
|
|
if (_ts_debug)
|
|
|
|
fprintf(stderr, "--> ts %p ++ %d %s at %s:%u\n", ts, ts->nrefs, msg, fn, ln);
|
|
|
|
/*@=modfilesystem@*/
|
|
|
|
/*@-refcounttrans@*/ return ts; /*@=refcounttrans@*/
|
|
|
|
}
|
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
int rpmtsCloseDB(rpmTransactionSet ts)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (ts->rpmdb != NULL) {
|
|
|
|
rc = rpmdbClose(ts->rpmdb);
|
|
|
|
ts->rpmdb = NULL;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rpmtsOpenDB(rpmTransactionSet ts, int dbmode)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
2001-10-29 06:17:47 +08:00
|
|
|
if (ts->rpmdb != NULL && ts->dbmode == dbmode)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
(void) rpmtsCloseDB(ts);
|
|
|
|
|
|
|
|
/* XXX there's a lock race here. */
|
2001-10-28 04:09:20 +08:00
|
|
|
|
|
|
|
ts->dbmode = dbmode;
|
|
|
|
rc = rpmdbOpen(ts->rootDir, &ts->rpmdb, ts->dbmode, 0644);
|
|
|
|
if (rc) {
|
|
|
|
const char * dn;
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@-globs -mods@*/ /* FIX: rpmGlobalMacroContext for an error? shrug */
|
2001-10-28 04:09:20 +08:00
|
|
|
dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL);
|
|
|
|
/*@=globs =mods@*/
|
|
|
|
rpmMessage(RPMMESS_ERROR,
|
|
|
|
_("cannot open Packages database in %s\n"), dn);
|
|
|
|
dn = _free(dn);
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmdbMatchIterator rpmtsInitIterator(const rpmTransactionSet ts, int rpmtag,
|
|
|
|
const void * keyp, size_t keylen)
|
|
|
|
{
|
|
|
|
return rpmdbInitIterator(ts->rpmdb, rpmtag, keyp, keylen);
|
|
|
|
}
|
1996-06-10 10:36:07 +08:00
|
|
|
|
2001-11-11 03:24:19 +08:00
|
|
|
char * hGetNEVR(Header h, const char ** np)
|
|
|
|
{
|
|
|
|
const char * n, * v, * r;
|
|
|
|
char * NVR, * t;
|
|
|
|
|
|
|
|
(void) headerNVR(h, &n, &v, &r);
|
|
|
|
NVR = t = xcalloc(1, strlen(n) + strlen(v) + strlen(r) + sizeof("--"));
|
|
|
|
t = stpcpy(t, n);
|
|
|
|
t = stpcpy(t, "-");
|
|
|
|
t = stpcpy(t, v);
|
|
|
|
t = stpcpy(t, "-");
|
|
|
|
t = stpcpy(t, r);
|
|
|
|
if (np)
|
|
|
|
*np = n;
|
|
|
|
return NVR;
|
|
|
|
}
|
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * rootDir)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-01-16 07:09:42 +08:00
|
|
|
rpmTransactionSet ts;
|
2000-04-14 00:00:34 +08:00
|
|
|
int rootLen;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2000-07-09 23:17:11 +08:00
|
|
|
if (!rootDir) rootDir = "";
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
ts = xcalloc(1, sizeof(*ts));
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->filesystemCount = 0;
|
|
|
|
ts->filesystems = NULL;
|
|
|
|
ts->di = NULL;
|
2001-10-28 04:09:20 +08:00
|
|
|
if (db != NULL) {
|
2001-10-29 06:17:47 +08:00
|
|
|
ts->rpmdb = rpmdbLink(db, "tsCreate");
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@-type@*/ /* FIX: silly wrapper */
|
2001-10-28 04:09:20 +08:00
|
|
|
ts->dbmode = db->db_mode;
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@=type@*/
|
2001-10-28 04:09:20 +08:00
|
|
|
} else {
|
|
|
|
ts->rpmdb = NULL;
|
|
|
|
ts->dbmode = O_RDONLY;
|
|
|
|
}
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->scriptFd = NULL;
|
2001-10-24 04:52:51 +08:00
|
|
|
ts->id = (int_32) time(NULL);
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->delta = 5;
|
|
|
|
|
|
|
|
ts->numRemovedPackages = 0;
|
|
|
|
ts->allocedRemovedPackages = ts->delta;
|
|
|
|
ts->removedPackages = xcalloc(ts->allocedRemovedPackages,
|
|
|
|
sizeof(*ts->removedPackages));
|
1999-08-21 05:05:18 +08:00
|
|
|
|
|
|
|
/* This canonicalizes the root */
|
2000-07-09 23:17:11 +08:00
|
|
|
rootLen = strlen(rootDir);
|
|
|
|
if (!(rootLen && rootDir[rootLen - 1] == '/')) {
|
|
|
|
char * t;
|
|
|
|
|
|
|
|
t = alloca(rootLen + 2);
|
|
|
|
*t = '\0';
|
|
|
|
(void) stpcpy( stpcpy(t, rootDir), "/");
|
|
|
|
rootDir = t;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
ts->rootDir = (rootDir != NULL ? xstrdup(rootDir) : xstrdup(""));
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->currDir = NULL;
|
|
|
|
ts->chrootDone = 0;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-11-02 07:18:15 +08:00
|
|
|
ts->numAddedPackages = 0;
|
2001-10-30 04:12:35 +08:00
|
|
|
ts->addedPackages = alCreate(ts->delta);
|
|
|
|
|
2001-11-02 07:18:15 +08:00
|
|
|
ts->numAvailablePackages = 0;
|
2001-10-30 04:12:35 +08:00
|
|
|
ts->availablePackages = alCreate(ts->delta);
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->orderAlloced = ts->delta;
|
|
|
|
ts->orderCount = 0;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type -abstract@*/
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->order = xcalloc(ts->orderAlloced, sizeof(*ts->order));
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type =abstract@*/
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-10-24 04:52:51 +08:00
|
|
|
ts->sig = NULL;
|
|
|
|
ts->dig = NULL;
|
|
|
|
|
2001-10-29 06:17:47 +08:00
|
|
|
ts->nrefs = 0;
|
|
|
|
|
|
|
|
return rpmtsLink(ts, "tsCreate");
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-05-17 04:02:08 +08:00
|
|
|
/**
|
|
|
|
* Compare removed package instances (qsort/bsearch).
|
|
|
|
* @param a 1st instance address
|
|
|
|
* @param b 2nd instance address
|
|
|
|
* @return result of comparison
|
|
|
|
*/
|
2001-06-01 06:31:14 +08:00
|
|
|
static int intcmp(const void * a, const void * b) /*@*/
|
2001-05-17 04:02:08 +08:00
|
|
|
{
|
|
|
|
const int * aptr = a;
|
|
|
|
const int * bptr = b;
|
|
|
|
int rc = (*aptr - *bptr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Add removed package instance to ordered transaction set.
|
2001-01-16 07:09:42 +08:00
|
|
|
* @param ts transaction set
|
2001-11-10 09:39:50 +08:00
|
|
|
* @param h header
|
2000-08-23 20:39:49 +08:00
|
|
|
* @param dboffset rpm database instance
|
2001-11-05 06:00:11 +08:00
|
|
|
* @param depends installed package of pair (or RPMAL_NOMATCH on erase)
|
2001-07-07 04:37:42 +08:00
|
|
|
* @return 0 on success
|
2000-08-23 20:39:49 +08:00
|
|
|
*/
|
2001-11-10 09:39:50 +08:00
|
|
|
static int removePackage(rpmTransactionSet ts, Header h, int dboffset,
|
2001-11-05 06:00:11 +08:00
|
|
|
alKey depends)
|
2001-11-10 09:39:50 +08:00
|
|
|
/*@modifies ts, h @*/
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-11-02 07:18:15 +08:00
|
|
|
transactionElement p;
|
2001-05-17 03:19:15 +08:00
|
|
|
|
|
|
|
/* Filter out duplicate erasures. */
|
2001-05-17 04:02:08 +08:00
|
|
|
if (ts->numRemovedPackages > 0 && ts->removedPackages != NULL) {
|
|
|
|
if (bsearch(&dboffset, ts->removedPackages, ts->numRemovedPackages,
|
2001-10-16 22:58:57 +08:00
|
|
|
sizeof(*ts->removedPackages), intcmp) != NULL)
|
2001-07-07 04:37:42 +08:00
|
|
|
return 0;
|
2001-05-17 04:02:08 +08:00
|
|
|
}
|
2001-05-17 03:19:15 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
if (ts->numRemovedPackages == ts->allocedRemovedPackages) {
|
|
|
|
ts->allocedRemovedPackages += ts->delta;
|
|
|
|
ts->removedPackages = xrealloc(ts->removedPackages,
|
2001-10-16 22:58:57 +08:00
|
|
|
sizeof(ts->removedPackages) * ts->allocedRemovedPackages);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-05-17 04:02:08 +08:00
|
|
|
if (ts->removedPackages != NULL) { /* XXX can't happen. */
|
2001-11-02 04:15:10 +08:00
|
|
|
ts->removedPackages[ts->numRemovedPackages] = dboffset;
|
|
|
|
ts->numRemovedPackages++;
|
2001-10-16 22:58:57 +08:00
|
|
|
qsort(ts->removedPackages, ts->numRemovedPackages,
|
|
|
|
sizeof(*ts->removedPackages), intcmp);
|
2001-05-17 04:02:08 +08:00
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-11-16 08:26:30 +08:00
|
|
|
if (ts->orderCount >= ts->orderAlloced) {
|
|
|
|
ts->orderAlloced += (ts->orderCount - ts->orderAlloced) + ts->delta;
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-type +voidabstract @*/
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->order = xrealloc(ts->order, sizeof(*ts->order) * ts->orderAlloced);
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@=type =voidabstract @*/
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
p = teNew(ts, h, NULL, NULL);
|
|
|
|
ts->order[ts->orderCount] = p;
|
2001-11-10 09:39:50 +08:00
|
|
|
ts->orderCount++;
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/ /* FIX: transactionElement not opaque */
|
2001-11-02 07:18:15 +08:00
|
|
|
p->type = TR_REMOVED;
|
|
|
|
p->u.removed.dboffset = dboffset;
|
2001-11-05 06:00:11 +08:00
|
|
|
/*@-assignexpose -temptrans@*/
|
|
|
|
p->u.removed.dependsOnKey = depends;
|
|
|
|
/*@=assignexpose =temptrans@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
2001-07-07 04:37:42 +08:00
|
|
|
|
|
|
|
return 0;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-11-12 04:45:20 +08:00
|
|
|
int rpmtransAddPackage(rpmTransactionSet ts, Header h,
|
2001-11-08 08:12:49 +08:00
|
|
|
fnpyKey key, int upgrade, rpmRelocation * relocs)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
2001-11-10 09:39:50 +08:00
|
|
|
int isSource;
|
2001-11-02 07:18:15 +08:00
|
|
|
int duplicate = 0;
|
2001-11-11 03:24:19 +08:00
|
|
|
teIterator pi; transactionElement p;
|
2001-11-11 08:11:33 +08:00
|
|
|
rpmDepSet add;
|
2001-11-02 13:36:48 +08:00
|
|
|
rpmDepSet obsoletes;
|
2001-11-16 08:26:30 +08:00
|
|
|
const char * name;
|
2001-11-05 06:00:11 +08:00
|
|
|
alKey pkgKey; /* addedPackages key */
|
2001-10-16 22:58:57 +08:00
|
|
|
int xx;
|
2001-10-28 04:09:20 +08:00
|
|
|
int ec = 0;
|
|
|
|
int rc;
|
2001-11-11 03:24:19 +08:00
|
|
|
int oc;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
/*
|
2001-10-28 04:09:20 +08:00
|
|
|
* Check for previously added versions with the same name.
|
2001-11-11 08:11:33 +08:00
|
|
|
* FIXME: only catches previously added, older packages.
|
2001-01-25 20:58:03 +08:00
|
|
|
*/
|
2001-11-11 08:11:33 +08:00
|
|
|
add = dsThis(h, RPMTAG_REQUIRENAME, (RPMSENSE_EQUAL|RPMSENSE_LESS));
|
|
|
|
pkgKey = RPMAL_NOMATCH;
|
2001-11-17 06:42:19 +08:00
|
|
|
for (pi = teInitIterator(ts), oc = 0; (p = teNextIterator(pi)) != NULL; oc++) {
|
2001-11-17 08:52:45 +08:00
|
|
|
rpmDepSet this;
|
2001-11-17 06:42:19 +08:00
|
|
|
|
|
|
|
/* XXX Only added packages need be checked for dupes. */
|
|
|
|
if (teGetType(p) == TR_REMOVED)
|
|
|
|
continue;
|
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
if ((this = teGetDS(p, RPMTAG_NAME)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
|
|
|
rc = dsCompare(add, this);
|
2001-11-11 08:11:33 +08:00
|
|
|
if (rc != 0) {
|
2001-11-17 08:52:45 +08:00
|
|
|
const char * pkgNEVR = dsiGetDNEVR(this);
|
2001-11-11 08:11:33 +08:00
|
|
|
const char * addNEVR = dsiGetDNEVR(add);
|
2001-10-28 04:09:20 +08:00
|
|
|
rpmMessage(RPMMESS_WARNING,
|
2001-11-11 08:11:33 +08:00
|
|
|
_("package %s was already added, replacing with %s\n"),
|
|
|
|
(pkgNEVR ? pkgNEVR + 2 : "?pkgNEVR?"),
|
|
|
|
(addNEVR ? addNEVR + 2 : "?addNEVR?"));
|
2001-11-02 07:18:15 +08:00
|
|
|
duplicate = 1;
|
2001-11-17 03:26:33 +08:00
|
|
|
pkgKey = teGetAddedKey(p);
|
2001-11-11 08:11:33 +08:00
|
|
|
break;
|
2001-10-28 04:09:20 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-11 03:24:19 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2001-11-11 08:11:33 +08:00
|
|
|
add = dsFree(add);
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2001-11-10 09:39:50 +08:00
|
|
|
isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
|
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
if (p != NULL && duplicate && oc < ts->orderCount) {
|
|
|
|
/* XXX FIXME removed transaction element side effects need to be weeded */
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-type -unqualifiedtrans@*/
|
|
|
|
ts->order[oc] = teFree(ts->order[oc]);
|
|
|
|
/*@=type =unqualifiedtrans@*/
|
2001-11-13 04:51:05 +08:00
|
|
|
}
|
2001-11-11 03:24:19 +08:00
|
|
|
|
2001-11-16 08:26:30 +08:00
|
|
|
if (oc >= ts->orderAlloced) {
|
|
|
|
ts->orderAlloced += (oc - ts->orderAlloced) + ts->delta;
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-type +voidabstract @*/
|
2001-11-11 03:24:19 +08:00
|
|
|
ts->order = xrealloc(ts->order, ts->orderAlloced * sizeof(*ts->order));
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@=type =voidabstract @*/
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
2001-11-10 04:41:18 +08:00
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
p = teNew(ts, h, key, relocs);
|
|
|
|
ts->order[oc] = p;
|
2001-11-17 07:22:24 +08:00
|
|
|
if (!duplicate)
|
|
|
|
ts->orderCount++;
|
2001-11-11 03:24:19 +08:00
|
|
|
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-type@*/ /* FIX: transactionElement not opaque */
|
2001-11-11 03:24:19 +08:00
|
|
|
p->type = TR_ADDED;
|
2001-11-11 09:46:43 +08:00
|
|
|
pkgKey = alAddPackage(ts->addedPackages, pkgKey, p->key,
|
2001-11-12 06:51:00 +08:00
|
|
|
p->provides, p->fi);
|
2001-11-05 06:00:11 +08:00
|
|
|
if (pkgKey == RPMAL_NOMATCH) {
|
2001-11-17 07:22:24 +08:00
|
|
|
ts->order[oc] = teFree(ts->order[oc]);
|
2001-11-02 07:18:15 +08:00
|
|
|
ec = 1;
|
|
|
|
goto exit;
|
|
|
|
}
|
2001-11-05 06:00:11 +08:00
|
|
|
p->u.addedKey = pkgKey;
|
2001-11-02 07:18:15 +08:00
|
|
|
p->multiLib = 0;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
2001-11-02 07:18:15 +08:00
|
|
|
|
|
|
|
#ifdef NOYET
|
|
|
|
/* XXX this needs a search over ts->order, not ts->addedPackages */
|
|
|
|
{ uint_32 *pp = NULL;
|
|
|
|
/* XXX This should be added always so that packages look alike.
|
|
|
|
* XXX However, there is logic in files.c/depends.c that checks for
|
|
|
|
* XXX existence (rather than value) that will need to change as well.
|
|
|
|
*/
|
|
|
|
if (hge(h, RPMTAG_MULTILIBS, NULL, (void **) &pp, NULL))
|
|
|
|
multiLibMask = *pp;
|
|
|
|
|
|
|
|
if (multiLibMask) {
|
|
|
|
for (i = 0; i < pkgNum - 1; i++) {
|
|
|
|
if (!strcmp (p->name, al->list[i].name)
|
|
|
|
&& hge(al->list[i].h, RPMTAG_MULTILIBS, NULL,
|
|
|
|
(void **) &pp, NULL)
|
|
|
|
&& !rpmVersionCompare(p->h, al->list[i].h)
|
|
|
|
&& *pp && !(*pp & multiLibMask))
|
|
|
|
p->multiLib = multiLibMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2001-10-30 07:39:51 +08:00
|
|
|
|
2001-11-02 07:18:15 +08:00
|
|
|
if (!duplicate) {
|
|
|
|
ts->numAddedPackages++;
|
|
|
|
}
|
2001-10-28 04:09:20 +08:00
|
|
|
|
|
|
|
if (!upgrade)
|
|
|
|
goto exit;
|
2001-01-25 20:58:03 +08:00
|
|
|
|
|
|
|
/* XXX binary rpms always have RPMTAG_SOURCERPM, source rpms do not */
|
2001-11-10 09:39:50 +08:00
|
|
|
if (isSource)
|
2001-10-28 04:09:20 +08:00
|
|
|
goto exit;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-10-30 04:12:35 +08:00
|
|
|
/* Do lazy (readonly?) open of rpm database. */
|
2001-10-28 04:09:20 +08:00
|
|
|
if (ts->rpmdb == NULL) {
|
|
|
|
if ((ec = rpmtsOpenDB(ts, ts->dbmode)) != 0)
|
|
|
|
goto exit;
|
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
name = teGetN(p);
|
2001-11-16 21:58:21 +08:00
|
|
|
|
2000-04-13 17:07:08 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
|
|
|
Header h2;
|
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
/* XXX FIXME: obsolete all packages with same provide, not just name. */
|
2001-11-16 08:26:30 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
|
2000-04-13 17:07:08 +08:00
|
|
|
while((h2 = rpmdbNextIterator(mi)) != NULL) {
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2000-04-13 17:07:08 +08:00
|
|
|
if (rpmVersionCompare(h, h2))
|
2001-11-10 09:39:50 +08:00
|
|
|
xx = removePackage(ts, h2, rpmdbGetIteratorOffset(mi), pkgKey);
|
2000-07-06 04:39:15 +08:00
|
|
|
else {
|
2001-10-28 04:09:20 +08:00
|
|
|
uint_32 *pp, multiLibMask = 0, oldmultiLibMask = 0;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
if (hge(h2, RPMTAG_MULTILIBS, NULL, (void **) &pp, NULL))
|
|
|
|
oldmultiLibMask = *pp;
|
|
|
|
if (hge(h, RPMTAG_MULTILIBS, NULL, (void **) &pp, NULL))
|
|
|
|
multiLibMask = *pp;
|
2000-07-06 04:39:15 +08:00
|
|
|
if (oldmultiLibMask && multiLibMask
|
2001-10-30 07:39:51 +08:00
|
|
|
&& !(oldmultiLibMask & multiLibMask))
|
|
|
|
{
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/ /* FIX: transactionElement not opaque */
|
2001-11-02 07:18:15 +08:00
|
|
|
p->multiLib = multiLibMask;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
2000-07-06 04:39:15 +08:00
|
|
|
}
|
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2000-04-13 17:07:08 +08:00
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-13 17:07:08 +08:00
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
obsoletes = dsiInit(rpmdsLink(teGetDS(p, RPMTAG_OBSOLETENAME), "Obsoletes"));
|
2001-11-02 13:36:48 +08:00
|
|
|
if (obsoletes != NULL)
|
2001-11-03 05:01:25 +08:00
|
|
|
while (dsiNext(obsoletes) >= 0) {
|
2001-11-03 07:17:54 +08:00
|
|
|
const char * Name;
|
|
|
|
|
2001-11-03 10:34:15 +08:00
|
|
|
if ((Name = dsiGetN(obsoletes)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-11-02 13:36:48 +08:00
|
|
|
/* XXX avoid self-obsoleting packages. */
|
2001-11-16 08:26:30 +08:00
|
|
|
if (!strcmp(name, Name))
|
1999-09-12 07:57:59 +08:00
|
|
|
continue;
|
|
|
|
|
2001-11-02 13:36:48 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
2000-04-13 17:07:08 +08:00
|
|
|
Header h2;
|
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
/* XXX FIXME: obsolete all packages with same provide, not just name. */
|
2001-11-03 07:17:54 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, Name, 0);
|
2000-04-13 17:07:08 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = rpmdbPruneIterator(mi,
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->removedPackages, ts->numRemovedPackages, 1);
|
2000-05-07 08:53:11 +08:00
|
|
|
|
|
|
|
while((h2 = rpmdbNextIterator(mi)) != NULL) {
|
2000-04-13 17:07:08 +08:00
|
|
|
/*
|
|
|
|
* Rpm prior to 3.0.3 does not have versioned obsoletes.
|
|
|
|
* If no obsoletes version info is available, match all names.
|
|
|
|
*/
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-11-03 10:34:15 +08:00
|
|
|
if (dsiGetEVR(obsoletes) == NULL
|
2001-10-31 12:00:58 +08:00
|
|
|
|| headerMatchesDepFlags(h2, obsoletes))
|
2001-11-10 09:39:50 +08:00
|
|
|
xx = removePackage(ts, h2, rpmdbGetIteratorOffset(mi), pkgKey);
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2000-04-13 17:07:08 +08:00
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-02 13:36:48 +08:00
|
|
|
obsoletes = dsFree(obsoletes);
|
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
ec = 0;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
exit:
|
2001-11-11 03:24:19 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2001-10-28 04:09:20 +08:00
|
|
|
return ec;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-11-08 08:12:49 +08:00
|
|
|
void rpmtransAvailablePackage(rpmTransactionSet ts, Header h, fnpyKey key)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-11-17 07:22:24 +08:00
|
|
|
int scareMem = 0;
|
2001-11-10 04:41:18 +08:00
|
|
|
rpmDepSet provides = dsNew(h, RPMTAG_PROVIDENAME, scareMem);
|
2001-11-12 06:51:00 +08:00
|
|
|
TFI_t fi = fiNew(ts, NULL, h, RPMTAG_BASENAMES, scareMem);
|
2001-11-10 04:41:18 +08:00
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
/* XXX FIXME: return code RPMAL_NOMATCH is error */
|
2001-11-11 09:46:43 +08:00
|
|
|
(void) alAddPackage(ts->availablePackages, RPMAL_NOMATCH, key,
|
2001-11-12 06:51:00 +08:00
|
|
|
provides, fi);
|
|
|
|
fi = fiFree(fi, 1);
|
2001-11-10 09:39:50 +08:00
|
|
|
provides = dsFree(provides);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-11-10 09:39:50 +08:00
|
|
|
int rpmtransRemovePackage(rpmTransactionSet ts, Header h, int dboffset)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-11-10 09:39:50 +08:00
|
|
|
return removePackage(ts, h, dboffset, RPMAL_NOMATCH);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-10-26 12:16:19 +08:00
|
|
|
/*@-nullstate@*/ /* FIX: better annotations */
|
2001-10-24 21:48:55 +08:00
|
|
|
void rpmtransClean(rpmTransactionSet ts)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-07-07 04:37:42 +08:00
|
|
|
if (ts) {
|
2001-10-24 04:52:51 +08:00
|
|
|
HFD_t hfd = headerFreeData;
|
2001-10-25 09:36:32 +08:00
|
|
|
if (ts->sig != NULL)
|
|
|
|
ts->sig = hfd(ts->sig, ts->sigtype);
|
|
|
|
if (ts->dig != NULL)
|
|
|
|
ts->dig = pgpFreeDig(ts->dig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmTransactionSet rpmtransFree(rpmTransactionSet ts)
|
|
|
|
{
|
2001-10-29 06:17:47 +08:00
|
|
|
if (ts) {
|
2001-11-05 11:44:05 +08:00
|
|
|
teIterator pi; transactionElement p;
|
2001-11-17 06:42:19 +08:00
|
|
|
int oc;
|
2001-10-29 06:17:47 +08:00
|
|
|
|
|
|
|
(void) rpmtsUnlink(ts, "tsCreate");
|
|
|
|
|
|
|
|
/*@-usereleased@*/
|
|
|
|
if (ts->nrefs > 0)
|
|
|
|
return NULL;
|
2001-10-25 09:36:32 +08:00
|
|
|
|
2001-11-05 11:44:05 +08:00
|
|
|
pi = teInitIterator(ts);
|
2001-11-17 06:42:19 +08:00
|
|
|
for (pi = teInitIterator(ts), oc = 0; (p = teNextIterator(pi)) != NULL; oc++) {
|
|
|
|
/*@-type -unqualifiedtrans @*/
|
|
|
|
ts->order[oc] = teFree(ts->order[oc]);
|
|
|
|
/*@=type =unqualifiedtrans @*/
|
2001-11-05 11:44:05 +08:00
|
|
|
}
|
|
|
|
pi = teFreeIterator(pi);
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-type +voidabstract @*/
|
|
|
|
ts->order = _free(ts->order);
|
|
|
|
/*@=type =voidabstract @*/
|
2001-11-05 11:44:05 +08:00
|
|
|
|
2001-10-30 04:12:35 +08:00
|
|
|
ts->addedPackages = alFree(ts->addedPackages);
|
|
|
|
ts->availablePackages = alFree(ts->availablePackages);
|
2001-07-07 04:37:42 +08:00
|
|
|
ts->di = _free(ts->di);
|
|
|
|
ts->removedPackages = _free(ts->removedPackages);
|
2001-10-24 21:48:55 +08:00
|
|
|
if (ts->scriptFd != NULL) {
|
2001-07-07 04:37:42 +08:00
|
|
|
ts->scriptFd =
|
|
|
|
fdFree(ts->scriptFd, "rpmtransSetScriptFd (rpmtransFree");
|
2001-10-24 21:48:55 +08:00
|
|
|
ts->scriptFd = NULL;
|
|
|
|
}
|
2001-07-07 04:37:42 +08:00
|
|
|
ts->rootDir = _free(ts->rootDir);
|
|
|
|
ts->currDir = _free(ts->currDir);
|
|
|
|
|
2001-10-24 21:48:55 +08:00
|
|
|
rpmtransClean(ts);
|
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
(void) rpmtsCloseDB(ts);
|
2001-10-24 04:52:51 +08:00
|
|
|
|
2001-10-28 06:31:10 +08:00
|
|
|
/*@-refcounttrans@*/ ts = _free(ts); /*@=refcounttrans@*/
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@=usereleased@*/
|
2001-07-07 04:37:42 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
2001-10-26 12:16:19 +08:00
|
|
|
/*@=nullstate@*/
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Check key for an unsatisfied dependency.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @todo Eliminate rpmrc provides.
|
2000-08-23 20:39:49 +08:00
|
|
|
* @param al available list
|
2001-10-31 12:00:58 +08:00
|
|
|
* @param key dependency
|
2000-08-23 20:39:49 +08:00
|
|
|
* @return 0 if satisfied, 1 if not satisfied, 2 if error
|
|
|
|
*/
|
2001-11-05 06:00:11 +08:00
|
|
|
static int unsatisfiedDepend(rpmTransactionSet ts, rpmDepSet key)
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@globals _cacheDependsRC, fileSystem @*/
|
2001-11-05 06:00:11 +08:00
|
|
|
/*@modifies ts, _cacheDependsRC, fileSystem @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-04-14 00:00:34 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2001-11-03 10:34:15 +08:00
|
|
|
const char * Name;
|
2000-04-14 00:00:34 +08:00
|
|
|
Header h;
|
2001-11-03 07:17:54 +08:00
|
|
|
int rc;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2001-11-03 10:34:15 +08:00
|
|
|
if ((Name = dsiGetN(key)) == NULL)
|
|
|
|
return 0; /* XXX can't happen */
|
|
|
|
|
2000-05-02 16:30:31 +08:00
|
|
|
/*
|
|
|
|
* Check if dbiOpen/dbiPut failed (e.g. permissions), we can't cache.
|
|
|
|
*/
|
|
|
|
if (_cacheDependsRC) {
|
2000-05-07 08:53:11 +08:00
|
|
|
dbiIndex dbi;
|
2001-01-16 07:09:42 +08:00
|
|
|
dbi = dbiOpen(ts->rpmdb, RPMDBI_DEPENDS, 0);
|
2000-05-07 08:53:11 +08:00
|
|
|
if (dbi == NULL)
|
|
|
|
_cacheDependsRC = 0;
|
|
|
|
else {
|
2001-11-03 10:34:15 +08:00
|
|
|
const char * DNEVR;
|
2001-11-03 07:17:54 +08:00
|
|
|
|
|
|
|
rc = -1;
|
2001-11-03 10:34:15 +08:00
|
|
|
if ((DNEVR = dsiGetDNEVR(key)) != NULL) {
|
|
|
|
DBC * dbcursor = NULL;
|
|
|
|
void * datap = NULL;
|
|
|
|
size_t datalen = 0;
|
|
|
|
size_t DNEVRlen = strlen(DNEVR);
|
|
|
|
int xx;
|
|
|
|
|
|
|
|
xx = dbiCopen(dbi, &dbcursor, 0);
|
|
|
|
xx = dbiGet(dbi, dbcursor, (void **)&DNEVR, &DNEVRlen,
|
|
|
|
&datap, &datalen, 0);
|
|
|
|
if (xx == 0 && datap && datalen == 4)
|
|
|
|
memcpy(&rc, datap, datalen);
|
|
|
|
xx = dbiCclose(dbi, dbcursor, 0);
|
|
|
|
}
|
2001-11-03 07:17:54 +08:00
|
|
|
|
|
|
|
if (rc >= 0) {
|
|
|
|
dsiNotify(key, _("(cached)"), rc);
|
2000-05-07 08:53:11 +08:00
|
|
|
return rc;
|
|
|
|
}
|
2000-04-26 03:41:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
rc = 0; /* assume dependency is satisfied */
|
|
|
|
|
2001-10-18 00:43:36 +08:00
|
|
|
#if defined(DYING) || defined(__LCLINT__)
|
2001-05-17 03:19:15 +08:00
|
|
|
{ static /*@observer@*/ const char noProvidesString[] = "nada";
|
|
|
|
static /*@observer@*/ const char * rcProvidesString = noProvidesString;
|
2001-11-03 07:17:54 +08:00
|
|
|
int_32 Flags = dsiGetFlags(key);
|
1999-09-12 05:10:02 +08:00
|
|
|
const char * start;
|
2000-08-23 20:39:49 +08:00
|
|
|
int i;
|
2000-04-14 00:00:34 +08:00
|
|
|
|
2001-05-17 03:19:15 +08:00
|
|
|
if (rcProvidesString == noProvidesString)
|
|
|
|
rcProvidesString = rpmGetVar(RPMVAR_PROVIDES);
|
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
if (rcProvidesString != NULL && !(Flags & RPMSENSE_SENSEMASK)) {
|
|
|
|
|
|
|
|
i = strlen(Name);
|
2001-05-17 03:19:15 +08:00
|
|
|
/*@-observertrans -mayaliasunique@*/
|
2001-11-03 07:17:54 +08:00
|
|
|
while ((start = strstr(rcProvidesString, Name))) {
|
2001-05-17 03:19:15 +08:00
|
|
|
/*@=observertrans =mayaliasunique@*/
|
2001-04-29 09:05:43 +08:00
|
|
|
if (xisspace(start[i]) || start[i] == '\0' || start[i] == ',') {
|
2001-11-03 07:17:54 +08:00
|
|
|
dsiNotify(key, _("(rpmrc provides)"), rc);
|
1999-09-19 08:29:44 +08:00
|
|
|
goto exit;
|
1999-09-24 22:54:23 +08:00
|
|
|
}
|
1998-07-01 02:52:54 +08:00
|
|
|
rcProvidesString = start + 1;
|
1997-07-24 02:32:15 +08:00
|
|
|
}
|
|
|
|
}
|
1999-09-12 05:10:02 +08:00
|
|
|
}
|
2000-08-23 20:39:49 +08:00
|
|
|
#endif
|
1997-07-24 02:32:15 +08:00
|
|
|
|
2000-07-14 07:30:41 +08:00
|
|
|
/*
|
|
|
|
* New features in rpm packaging implicitly add versioned dependencies
|
|
|
|
* on rpmlib provides. The dependencies look like "rpmlib(YaddaYadda)".
|
|
|
|
* Check those dependencies now.
|
|
|
|
*/
|
2001-11-03 07:17:54 +08:00
|
|
|
if (!strncmp(Name, "rpmlib(", sizeof("rpmlib(")-1)) {
|
2001-10-31 12:00:58 +08:00
|
|
|
if (rpmCheckRpmlibProvides(key)) {
|
2001-11-03 07:17:54 +08:00
|
|
|
dsiNotify(key, _("(rpmlib provides)"), rc);
|
2000-07-14 07:30:41 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
2000-11-01 02:24:05 +08:00
|
|
|
goto unsatisfied;
|
2000-07-14 07:30:41 +08:00
|
|
|
}
|
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
/* Search added packages for the dependency. */
|
2001-11-08 08:12:49 +08:00
|
|
|
if (alSatisfiesDepend(ts->addedPackages, key, NULL) != NULL)
|
1999-09-19 08:29:44 +08:00
|
|
|
goto exit;
|
1996-06-10 10:36:07 +08:00
|
|
|
|
2000-07-17 08:40:17 +08:00
|
|
|
/* XXX only the installer does not have the database open here. */
|
2001-01-16 07:09:42 +08:00
|
|
|
if (ts->rpmdb != NULL) {
|
2001-11-03 07:17:54 +08:00
|
|
|
if (Name[0] == '/') {
|
1999-09-14 13:41:13 +08:00
|
|
|
/* keyFlags better be 0! */
|
1997-05-01 03:28:09 +08:00
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_BASENAMES, Name, 0);
|
2000-05-07 08:53:11 +08:00
|
|
|
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) rpmdbPruneIterator(mi,
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->removedPackages, ts->numRemovedPackages, 1);
|
2000-05-07 08:53:11 +08:00
|
|
|
|
2000-04-14 00:00:34 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
2001-11-03 07:17:54 +08:00
|
|
|
dsiNotify(key, _("(db files)"), rc);
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
1999-09-24 22:54:23 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
1996-07-18 10:25:13 +08:00
|
|
|
}
|
2000-04-13 18:11:32 +08:00
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, Name, 0);
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) rpmdbPruneIterator(mi,
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->removedPackages, ts->numRemovedPackages, 1);
|
2000-04-14 00:00:34 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
2001-10-31 12:00:58 +08:00
|
|
|
if (rangeMatchesDepFlags(h, key)) {
|
2001-11-03 07:17:54 +08:00
|
|
|
dsiNotify(key, _("(db provides)"), rc);
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-05-07 08:53:11 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
2000-04-14 00:00:34 +08:00
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-12-13 04:03:45 +08:00
|
|
|
|
2001-10-19 09:24:21 +08:00
|
|
|
#if defined(DYING) || defined(__LCLINT__)
|
2001-11-03 07:17:54 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, Name, 0);
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) rpmdbPruneIterator(mi,
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->removedPackages, ts->numRemovedPackages, 1);
|
2000-12-13 04:03:45 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
2001-10-31 12:00:58 +08:00
|
|
|
if (rangeMatchesDepFlags(h, key)) {
|
2001-11-03 07:17:54 +08:00
|
|
|
dsiNotify(key, _("(db package)"), rc);
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-12-13 04:03:45 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-12-13 04:03:45 +08:00
|
|
|
#endif
|
|
|
|
|
1996-06-10 10:36:07 +08:00
|
|
|
}
|
|
|
|
|
2000-11-01 02:24:05 +08:00
|
|
|
unsatisfied:
|
1999-09-19 08:29:44 +08:00
|
|
|
rc = 1; /* dependency is unsatisfied */
|
2001-11-03 07:17:54 +08:00
|
|
|
dsiNotify(key, NULL, rc);
|
1999-09-19 08:29:44 +08:00
|
|
|
|
|
|
|
exit:
|
2000-05-02 16:30:31 +08:00
|
|
|
/*
|
|
|
|
* If dbiOpen/dbiPut fails (e.g. permissions), we can't cache.
|
|
|
|
*/
|
|
|
|
if (_cacheDependsRC) {
|
|
|
|
dbiIndex dbi;
|
2001-01-16 07:09:42 +08:00
|
|
|
dbi = dbiOpen(ts->rpmdb, RPMDBI_DEPENDS, 0);
|
2000-05-02 16:30:31 +08:00
|
|
|
if (dbi == NULL) {
|
|
|
|
_cacheDependsRC = 0;
|
|
|
|
} else {
|
2001-11-03 10:34:15 +08:00
|
|
|
const char * DNEVR;
|
2001-11-03 05:01:25 +08:00
|
|
|
int xx = 0;
|
2001-11-03 10:34:15 +08:00
|
|
|
if ((DNEVR = dsiGetDNEVR(key)) != NULL) {
|
2001-11-03 05:01:25 +08:00
|
|
|
DBC * dbcursor = NULL;
|
2001-11-03 10:34:15 +08:00
|
|
|
size_t DNEVRlen = strlen(DNEVR);
|
2001-11-03 05:01:25 +08:00
|
|
|
xx = dbiCopen(dbi, &dbcursor, DBI_WRITECURSOR);
|
2001-11-03 10:34:15 +08:00
|
|
|
xx = dbiPut(dbi, dbcursor, DNEVR, DNEVRlen,
|
2001-11-03 05:01:25 +08:00
|
|
|
&rc, sizeof(rc), 0);
|
|
|
|
xx = dbiCclose(dbi, dbcursor, DBI_WRITECURSOR);
|
|
|
|
}
|
2000-05-07 08:53:11 +08:00
|
|
|
if (xx)
|
2000-05-02 16:30:31 +08:00
|
|
|
_cacheDependsRC = 0;
|
2000-05-07 08:53:11 +08:00
|
|
|
#if 0 /* XXX NOISY */
|
|
|
|
else
|
2001-11-03 05:01:25 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
_("%9s: (%s, %s) added to Depends cache.\n"),
|
|
|
|
key->Type, (key->DNEVR != NULL ? key->DNEVR : "???"),
|
|
|
|
(rc ? _("NO ") : _("YES")));
|
2000-05-07 08:53:11 +08:00
|
|
|
#endif
|
2000-04-28 23:14:47 +08:00
|
|
|
}
|
2000-04-26 03:41:37 +08:00
|
|
|
}
|
1999-09-19 08:29:44 +08:00
|
|
|
return rc;
|
1996-06-10 10:36:07 +08:00
|
|
|
}
|
1996-06-11 01:42:57 +08:00
|
|
|
|
2001-06-01 06:31:14 +08:00
|
|
|
/**
|
|
|
|
* Check header requires/conflicts against against installed+added packages.
|
|
|
|
* @param ts transaction set
|
2001-11-11 08:11:33 +08:00
|
|
|
* @param pkgNEVR package name-version-release
|
|
|
|
* @param requires Requires: dependencies (or NULL)
|
|
|
|
* @param conflicts Conflicts: dependencies (or NULL)
|
|
|
|
* @param keyName dependency name to filter (or NULL)
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param multiLib skip multilib colored dependencies?
|
|
|
|
* @return 0 no problems found
|
|
|
|
*/
|
2001-11-11 08:11:33 +08:00
|
|
|
static int checkPackageDeps(rpmTransactionSet ts, const char * pkgNEVR,
|
|
|
|
/*@null@*/ rpmDepSet requires, /*@null@*/ rpmDepSet conflicts,
|
|
|
|
/*@null@*/ const char * keyName, uint_32 multiLib)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-11-11 08:11:33 +08:00
|
|
|
/*@modifies ts, requires, conflicts, fileSystem */
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-11-03 07:17:54 +08:00
|
|
|
const char * Name;
|
|
|
|
int_32 Flags;
|
2001-11-11 08:11:33 +08:00
|
|
|
int rc;
|
1996-10-21 03:31:21 +08:00
|
|
|
int ourrc = 0;
|
1996-06-11 01:42:57 +08:00
|
|
|
|
2001-11-11 08:11:33 +08:00
|
|
|
requires = dsiInit(requires);
|
2001-11-02 13:36:48 +08:00
|
|
|
if (requires != NULL)
|
2001-11-03 05:01:25 +08:00
|
|
|
while (!ourrc && dsiNext(requires) >= 0) {
|
1999-09-14 13:41:13 +08:00
|
|
|
|
2001-11-03 10:34:15 +08:00
|
|
|
if ((Name = dsiGetN(requires)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
2001-11-03 07:17:54 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Filter out requires that came along for the ride. */
|
2001-11-17 08:52:45 +08:00
|
|
|
if (keyName != NULL && strcmp(keyName, Name))
|
1999-09-19 08:29:44 +08:00
|
|
|
continue;
|
|
|
|
|
2001-11-04 23:43:26 +08:00
|
|
|
Flags = dsiGetFlags(requires);
|
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
/* If this requirement comes from the core package only, not libraries,
|
|
|
|
then if we're installing the libraries only, don't count it in. */
|
2001-11-03 07:17:54 +08:00
|
|
|
if (multiLib && !isDependsMULTILIB(Flags))
|
2000-07-06 04:39:15 +08:00
|
|
|
continue;
|
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
rc = unsatisfiedDepend(ts, requires);
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
switch (rc) {
|
1999-09-19 08:29:44 +08:00
|
|
|
case 0: /* requirements are satisfied. */
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-09-19 08:29:44 +08:00
|
|
|
case 1: /* requirements are not satisfied. */
|
2001-11-08 08:12:49 +08:00
|
|
|
{ fnpyKey * suggestedKeys = NULL;
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2001-11-05 22:09:22 +08:00
|
|
|
/*@-branchstate@*/
|
2001-11-05 06:00:11 +08:00
|
|
|
if (ts->availablePackages != NULL) {
|
2001-11-08 08:12:49 +08:00
|
|
|
suggestedKeys = alAllSatisfiesDepend(ts->availablePackages,
|
|
|
|
requires, NULL);
|
2001-11-04 23:43:26 +08:00
|
|
|
}
|
2001-11-05 22:09:22 +08:00
|
|
|
/*@=branchstate@*/
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
dsProblem(ts->probs, pkgNEVR, requires, suggestedKeys);
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2001-11-04 23:43:26 +08:00
|
|
|
}
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-09-14 13:41:13 +08:00
|
|
|
case 2: /* something went wrong! */
|
|
|
|
default:
|
1996-10-21 03:31:21 +08:00
|
|
|
ourrc = 1;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1996-06-11 01:42:57 +08:00
|
|
|
}
|
1999-09-19 08:29:44 +08:00
|
|
|
}
|
|
|
|
|
2001-11-11 08:11:33 +08:00
|
|
|
conflicts = dsiInit(conflicts);
|
2001-11-02 13:36:48 +08:00
|
|
|
if (conflicts != NULL)
|
2001-11-03 05:01:25 +08:00
|
|
|
while (!ourrc && dsiNext(conflicts) >= 0) {
|
1999-09-14 13:41:13 +08:00
|
|
|
|
2001-11-03 10:34:15 +08:00
|
|
|
if ((Name = dsiGetN(conflicts)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
2001-11-03 07:17:54 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Filter out conflicts that came along for the ride. */
|
2001-11-03 10:34:15 +08:00
|
|
|
if (keyName != NULL && strcmp(keyName, Name))
|
1999-09-19 08:29:44 +08:00
|
|
|
continue;
|
|
|
|
|
2001-11-04 23:43:26 +08:00
|
|
|
Flags = dsiGetFlags(conflicts);
|
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
/* If this requirement comes from the core package only, not libraries,
|
|
|
|
then if we're installing the libraries only, don't count it in. */
|
2001-11-03 07:17:54 +08:00
|
|
|
if (multiLib && !isDependsMULTILIB(Flags))
|
2000-07-06 04:39:15 +08:00
|
|
|
continue;
|
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
rc = unsatisfiedDepend(ts, conflicts);
|
1996-10-21 03:31:21 +08:00
|
|
|
|
|
|
|
/* 1 == unsatisfied, 0 == satsisfied */
|
1999-09-14 13:41:13 +08:00
|
|
|
switch (rc) {
|
1999-09-19 08:29:44 +08:00
|
|
|
case 0: /* conflicts exist. */
|
2001-11-04 23:43:26 +08:00
|
|
|
/*@-mayaliasunique@*/ /* LCL: NULL may alias h ??? */
|
2001-11-13 04:51:05 +08:00
|
|
|
dsProblem(ts->probs, pkgNEVR, conflicts, NULL);
|
2001-11-04 23:43:26 +08:00
|
|
|
/*@=mayaliasunique@*/
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-09-19 08:29:44 +08:00
|
|
|
case 1: /* conflicts don't exist. */
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-09-14 13:41:13 +08:00
|
|
|
case 2: /* something went wrong! */
|
|
|
|
default:
|
1996-10-21 03:31:21 +08:00
|
|
|
ourrc = 1;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1996-10-21 03:31:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ourrc;
|
1996-06-11 01:42:57 +08:00
|
|
|
}
|
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/**
|
2001-06-01 06:31:14 +08:00
|
|
|
* Check dependency against installed packages.
|
2000-09-27 02:04:12 +08:00
|
|
|
* Adding: check name/provides key against each conflict match,
|
|
|
|
* Erasing: check name/provides/filename key against each requiredby match.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param ts transaction set
|
|
|
|
* @param key dependency name
|
|
|
|
* @param mi rpm database iterator
|
|
|
|
* @return 0 no problems found
|
2000-09-27 02:04:12 +08:00
|
|
|
*/
|
2001-11-09 06:04:35 +08:00
|
|
|
static int checkPackageSet(rpmTransactionSet ts,
|
2001-06-01 06:31:14 +08:00
|
|
|
const char * key, /*@only@*/ /*@null@*/ rpmdbMatchIterator mi)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-11-09 06:04:35 +08:00
|
|
|
/*@modifies ts, mi, fileSystem @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-11-11 08:11:33 +08:00
|
|
|
int scareMem = 1;
|
1999-07-14 06:00:05 +08:00
|
|
|
Header h;
|
2001-11-11 08:11:33 +08:00
|
|
|
int ec = 0;
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) rpmdbPruneIterator(mi,
|
|
|
|
ts->removedPackages, ts->numRemovedPackages, 1);
|
2000-04-13 18:11:32 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
2001-11-11 08:11:33 +08:00
|
|
|
const char * pkgNEVR;
|
|
|
|
rpmDepSet requires, conflicts;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
pkgNEVR = hGetNEVR(h, NULL);
|
|
|
|
requires = dsNew(h, RPMTAG_REQUIRENAME, scareMem);
|
|
|
|
conflicts = dsNew(h, RPMTAG_CONFLICTNAME, scareMem);
|
|
|
|
rc = checkPackageDeps(ts, pkgNEVR, requires, conflicts, key, 0);
|
|
|
|
conflicts = dsFree(conflicts);
|
|
|
|
requires = dsFree(requires);
|
|
|
|
pkgNEVR = _free(pkgNEVR);
|
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
ec = 1;
|
2000-04-13 18:11:32 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-13 18:11:32 +08:00
|
|
|
|
2001-11-11 08:11:33 +08:00
|
|
|
return ec;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/**
|
|
|
|
* Erasing: check name/provides/filename key against requiredby matches.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param ts transaction set
|
|
|
|
* @param key requires name
|
|
|
|
* @return 0 no problems found
|
2000-09-27 02:04:12 +08:00
|
|
|
*/
|
2001-11-09 06:04:35 +08:00
|
|
|
static int checkDependentPackages(rpmTransactionSet ts, const char * key)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-11-09 06:04:35 +08:00
|
|
|
/*@modifies ts, fileSystem @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-04-13 18:11:32 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_REQUIRENAME, key, 0);
|
2001-11-09 06:04:35 +08:00
|
|
|
return checkPackageSet(ts, key, mi);
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/**
|
|
|
|
* Adding: check name/provides key against conflicts matches.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param ts transaction set
|
|
|
|
* @param key conflicts name
|
|
|
|
* @return 0 no problems found
|
2000-09-27 02:04:12 +08:00
|
|
|
*/
|
2001-11-09 06:04:35 +08:00
|
|
|
static int checkDependentConflicts(rpmTransactionSet ts, const char * key)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-11-09 06:04:35 +08:00
|
|
|
/*@modifies ts, fileSystem @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-03-23 23:49:50 +08:00
|
|
|
int rc = 0;
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
if (ts->rpmdb != NULL) { /* XXX is this necessary? */
|
2000-04-13 18:11:32 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_CONFLICTNAME, key, 0);
|
2001-11-09 06:04:35 +08:00
|
|
|
rc = checkPackageSet(ts, key, mi);
|
2000-03-23 23:49:50 +08:00
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/*
|
|
|
|
* XXX Hack to remove known Red Hat dependency loops, will be removed
|
2000-12-21 05:08:18 +08:00
|
|
|
* as soon as rpm's legacy permits.
|
2000-11-12 19:11:49 +08:00
|
|
|
*/
|
|
|
|
#define DEPENDENCY_WHITEOUT
|
|
|
|
|
|
|
|
#if defined(DEPENDENCY_WHITEOUT)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@observer@*/ /*@unchecked@*/
|
2000-09-27 02:04:12 +08:00
|
|
|
static struct badDeps_s {
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@observer@*/ /*@null@*/ const char * pname;
|
|
|
|
/*@observer@*/ /*@null@*/ const char * qname;
|
2000-09-27 02:04:12 +08:00
|
|
|
} badDeps[] = {
|
|
|
|
{ "libtermcap", "bash" },
|
|
|
|
{ "modutils", "vixie-cron" },
|
|
|
|
{ "ypbind", "yp-tools" },
|
|
|
|
{ "ghostscript-fonts", "ghostscript" },
|
2001-08-29 04:33:06 +08:00
|
|
|
/* 7.2 only */
|
|
|
|
{ "libgnomeprint15", "gnome-print" },
|
|
|
|
{ "nautilus", "nautilus-mozilla" },
|
2000-12-21 05:08:18 +08:00
|
|
|
/* 7.1 only */
|
2001-01-17 05:54:59 +08:00
|
|
|
{ "arts", "kdelibs-sound" },
|
2000-11-12 19:11:49 +08:00
|
|
|
/* 7.0 only */
|
|
|
|
{ "pango-gtkbeta-devel", "pango-gtkbeta" },
|
|
|
|
{ "XFree86", "Mesa" },
|
|
|
|
{ "compat-glibc", "db2" },
|
|
|
|
{ "compat-glibc", "db1" },
|
|
|
|
{ "pam", "initscripts" },
|
|
|
|
{ "initscripts", "sysklogd" },
|
|
|
|
/* 6.2 */
|
|
|
|
{ "egcs-c++", "libstdc++" },
|
|
|
|
/* 6.1 */
|
|
|
|
{ "pilot-link-devel", "pilot-link" },
|
|
|
|
/* 5.2 */
|
|
|
|
{ "pam", "pamconfig" },
|
2000-09-27 02:04:12 +08:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
static int ignoreDep(const transactionElement p,
|
|
|
|
const transactionElement q)
|
2001-06-01 06:31:14 +08:00
|
|
|
/*@*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-06-06 03:26:22 +08:00
|
|
|
struct badDeps_s * bdp = badDeps;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2001-06-06 03:26:22 +08:00
|
|
|
while (bdp->pname != NULL && bdp->qname != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
if (!strcmp(teGetN(p), bdp->pname) && !strcmp(teGetN(q), bdp->qname))
|
2000-09-27 02:04:12 +08:00
|
|
|
return 1;
|
2001-06-06 03:26:22 +08:00
|
|
|
bdp++;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2000-09-27 02:04:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/**
|
|
|
|
* Recursively mark all nodes with their predecessors.
|
|
|
|
* @param tsi successor chain
|
|
|
|
* @param q predecessor
|
|
|
|
*/
|
2001-11-01 06:19:42 +08:00
|
|
|
static void markLoop(/*@special@*/ tsortInfo tsi, transactionElement q)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals internalState @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@uses tsi @*/
|
|
|
|
/*@modifies internalState @*/
|
2000-09-27 02:04:12 +08:00
|
|
|
{
|
2001-11-01 06:19:42 +08:00
|
|
|
transactionElement p;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@-branchstate@*/ /* FIX: q is kept */
|
2001-05-04 05:00:18 +08:00
|
|
|
while (tsi != NULL && (p = tsi->tsi_suc) != NULL) {
|
2000-09-27 02:04:12 +08:00
|
|
|
tsi = tsi->tsi_next;
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetTSI(p)->tsi_chain != NULL)
|
2000-09-27 02:04:12 +08:00
|
|
|
continue;
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@-assignexpose -temptrans@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_chain = q;
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@=assignexpose =temptrans@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetTSI(p)->tsi_next != NULL)
|
|
|
|
markLoop(teGetTSI(p)->tsi_next, p);
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@=branchstate@*/
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
1997-07-09 02:41:10 +08:00
|
|
|
|
2001-06-01 06:31:14 +08:00
|
|
|
static inline /*@observer@*/ const char * const identifyDepend(int_32 f)
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@*/
|
2001-06-01 06:31:14 +08:00
|
|
|
{
|
2000-11-12 19:11:49 +08:00
|
|
|
if (isLegacyPreReq(f))
|
|
|
|
return "PreReq:";
|
|
|
|
f = _notpre(f);
|
|
|
|
if (f & RPMSENSE_SCRIPT_PRE)
|
|
|
|
return "Requires(pre):";
|
|
|
|
if (f & RPMSENSE_SCRIPT_POST)
|
|
|
|
return "Requires(post):";
|
|
|
|
if (f & RPMSENSE_SCRIPT_PREUN)
|
|
|
|
return "Requires(preun):";
|
|
|
|
if (f & RPMSENSE_SCRIPT_POSTUN)
|
|
|
|
return "Requires(postun):";
|
|
|
|
if (f & RPMSENSE_SCRIPT_VERIFY)
|
|
|
|
return "Requires(verify):";
|
|
|
|
if (f & RPMSENSE_FIND_REQUIRES)
|
|
|
|
return "Requires(auto):";
|
|
|
|
return "Requires:";
|
|
|
|
}
|
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/**
|
2000-11-12 19:11:49 +08:00
|
|
|
* Find (and eliminate co-requisites) "q <- p" relation in dependency loop.
|
2000-09-27 02:04:12 +08:00
|
|
|
* Search all successors of q for instance of p. Format the specific relation,
|
2000-11-12 19:11:49 +08:00
|
|
|
* (e.g. p contains "Requires: q"). Unlink and free co-requisite (i.e.
|
|
|
|
* pure Requires: dependencies) successor node(s).
|
2000-09-27 02:04:12 +08:00
|
|
|
* @param q sucessor (i.e. package required by p)
|
|
|
|
* @param p predecessor (i.e. package that "Requires: q")
|
2000-11-12 19:11:49 +08:00
|
|
|
* @param zap max. no. of co-requisites to remove (-1 is all)?
|
|
|
|
* @retval nzaps address of no. of relations removed
|
2000-09-27 02:04:12 +08:00
|
|
|
* @return (possibly NULL) formatted "q <- p" releation (malloc'ed)
|
|
|
|
*/
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@-mustmod@*/ /* FIX: hack modifies, but -type disables */
|
2000-09-27 02:04:12 +08:00
|
|
|
static /*@owned@*/ /*@null@*/ const char *
|
2001-11-02 13:36:48 +08:00
|
|
|
zapRelation(transactionElement q, transactionElement p,
|
|
|
|
/*@null@*/ rpmDepSet requires,
|
2001-06-01 06:31:14 +08:00
|
|
|
int zap, /*@in@*/ /*@out@*/ int * nzaps)
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@modifies q, p, requires, *nzaps @*/
|
2000-09-27 02:04:12 +08:00
|
|
|
{
|
2001-10-30 04:12:35 +08:00
|
|
|
tsortInfo tsi_prev;
|
|
|
|
tsortInfo tsi;
|
2000-09-27 02:04:12 +08:00
|
|
|
const char *dp = NULL;
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
for (tsi_prev = teGetTSI(q), tsi = teGetTSI(q)->tsi_next;
|
2000-09-27 02:04:12 +08:00
|
|
|
tsi != NULL;
|
2001-05-04 05:00:18 +08:00
|
|
|
/* XXX Note: the loop traverses "not found", break on "found". */
|
|
|
|
/*@-nullderef@*/
|
2000-09-27 02:04:12 +08:00
|
|
|
tsi_prev = tsi, tsi = tsi->tsi_next)
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=nullderef@*/
|
2000-09-27 02:04:12 +08:00
|
|
|
{
|
2001-11-03 07:17:54 +08:00
|
|
|
int_32 Flags;
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-abstract@*/
|
2000-09-27 02:04:12 +08:00
|
|
|
if (tsi->tsi_suc != p)
|
|
|
|
continue;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=abstract@*/
|
2001-05-04 05:00:18 +08:00
|
|
|
|
2001-11-02 13:36:48 +08:00
|
|
|
if (requires == NULL) continue; /* XXX can't happen */
|
2001-10-31 12:00:58 +08:00
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
(void) dsiSetIx(requires, tsi->tsi_reqx);
|
2001-11-03 07:17:54 +08:00
|
|
|
|
|
|
|
Flags = dsiGetFlags(requires);
|
|
|
|
|
|
|
|
dp = dsDNEVR( identifyDepend(Flags), requires);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/*
|
2001-06-01 06:31:14 +08:00
|
|
|
* Attempt to unravel a dependency loop by eliminating Requires's.
|
2000-09-27 02:04:12 +08:00
|
|
|
*/
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-11-03 07:17:54 +08:00
|
|
|
if (zap && !(Flags & RPMSENSE_PREREQ)) {
|
2001-06-20 04:03:13 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
2001-11-01 06:19:42 +08:00
|
|
|
_("removing %s \"%s\" from tsort relations.\n"),
|
2001-11-17 03:26:33 +08:00
|
|
|
(teGetNEVR(p) ? teGetNEVR(p) : "???"), dp);
|
|
|
|
teGetTSI(p)->tsi_count--;
|
2001-06-01 06:31:14 +08:00
|
|
|
if (tsi_prev) tsi_prev->tsi_next = tsi->tsi_next;
|
2000-09-27 02:04:12 +08:00
|
|
|
tsi->tsi_next = NULL;
|
|
|
|
tsi->tsi_suc = NULL;
|
2001-04-21 14:02:09 +08:00
|
|
|
tsi = _free(tsi);
|
2000-09-27 02:04:12 +08:00
|
|
|
if (nzaps)
|
|
|
|
(*nzaps)++;
|
2000-11-12 19:11:49 +08:00
|
|
|
if (zap)
|
|
|
|
zap--;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2001-05-04 05:00:18 +08:00
|
|
|
/* XXX Note: the loop traverses "not found", get out now! */
|
2000-09-27 02:04:12 +08:00
|
|
|
break;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2000-09-27 02:04:12 +08:00
|
|
|
return dp;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@=mustmod@*/
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
static void prtTSI(const char * msg, tsortInfo tsi)
|
|
|
|
/*@globals fileSystem@*/
|
|
|
|
/*@modifies fileSystem@*/
|
|
|
|
{
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-nullpass -type -abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
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);
|
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=nullpass =type =abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
}
|
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/**
|
|
|
|
* Record next "q <- p" relation (i.e. "p" requires "q").
|
2001-01-16 07:09:42 +08:00
|
|
|
* @param ts transaction set
|
2000-11-12 19:11:49 +08:00
|
|
|
* @param p predecessor (i.e. package that "Requires: q")
|
|
|
|
* @param selected boolean package selected array
|
|
|
|
* @param j relation index
|
|
|
|
* @return 0 always
|
|
|
|
*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-mustmod@*/
|
2001-11-02 11:13:35 +08:00
|
|
|
static inline int addRelation(rpmTransactionSet ts,
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@dependent@*/ transactionElement p,
|
|
|
|
unsigned char * selected,
|
2001-10-31 12:00:58 +08:00
|
|
|
rpmDepSet requires)
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies ts, p, *selected, fileSystem @*/
|
2000-11-12 19:11:49 +08:00
|
|
|
{
|
2001-11-02 11:13:35 +08:00
|
|
|
teIterator qi; transactionElement q;
|
2001-10-30 04:12:35 +08:00
|
|
|
tsortInfo tsi;
|
2001-11-03 07:17:54 +08:00
|
|
|
const char * Name;
|
2001-11-08 08:12:49 +08:00
|
|
|
fnpyKey key;
|
2001-11-05 06:00:11 +08:00
|
|
|
alKey pkgKey;
|
2001-11-01 06:19:42 +08:00
|
|
|
int i = 0;
|
2000-11-12 19:11:49 +08:00
|
|
|
|
2001-11-05 11:44:05 +08:00
|
|
|
if ((Name = dsiGetN(requires)) == NULL)
|
|
|
|
return 0; /* XXX can't happen */
|
|
|
|
|
|
|
|
/* Avoid rpmlib feature dependencies. */
|
|
|
|
if (!strncmp(Name, "rpmlib(", sizeof("rpmlib(")-1))
|
|
|
|
return 0;
|
|
|
|
|
2001-11-08 08:12:49 +08:00
|
|
|
pkgKey = RPMAL_NOMATCH;
|
|
|
|
key = alSatisfiesDepend(ts->addedPackages, requires, &pkgKey);
|
2001-11-05 11:44:05 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
if (_te_debug)
|
2001-11-05 06:00:11 +08:00
|
|
|
fprintf(stderr, "addRelation: pkgKey %ld\n", (long)pkgKey);
|
2000-11-12 19:11:49 +08:00
|
|
|
|
|
|
|
/* Ordering depends only on added package relations. */
|
2001-11-05 06:00:11 +08:00
|
|
|
if (pkgKey == RPMAL_NOMATCH)
|
2000-11-12 19:11:49 +08:00
|
|
|
return 0;
|
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
/* XXX Set q to the added package that has pkgKey == q->u.addedKey */
|
2001-11-01 06:19:42 +08:00
|
|
|
/* XXX FIXME: bsearch is possible/needed here */
|
2001-11-17 06:42:19 +08:00
|
|
|
for (qi = teInitIterator(ts), i = 0; (q = teNextIterator(qi)) != NULL; i++) {
|
|
|
|
/* XXX Only added packages need be checked for matches. */
|
|
|
|
if (teGetType(q) == TR_REMOVED)
|
|
|
|
continue;
|
2001-11-17 03:26:33 +08:00
|
|
|
if (pkgKey == teGetAddedKey(q))
|
2001-11-01 06:19:42 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
qi = teFreeIterator(qi);
|
2001-11-17 06:42:19 +08:00
|
|
|
if (q == NULL || i == ts->orderCount)
|
2001-11-08 08:12:49 +08:00
|
|
|
return 0;
|
2000-11-12 19:11:49 +08:00
|
|
|
|
|
|
|
#if defined(DEPENDENCY_WHITEOUT)
|
|
|
|
/* Avoid certain dependency relations. */
|
2001-11-08 08:12:49 +08:00
|
|
|
if (ignoreDep(p, q))
|
2000-11-12 19:11:49 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-nullpass -nullderef -formattype@*/
|
2001-11-05 11:44:05 +08:00
|
|
|
if (_te_debug)
|
2001-11-17 03:26:33 +08:00
|
|
|
fprintf(stderr, "addRelation: q %p(%s) from %p[%d:%d]\n", q, teGetN(q), ts->order, i, ts->orderCount);
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@=nullpass =nullderef =formattype@*/
|
2001-11-05 11:44:05 +08:00
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/* Avoid redundant relations. */
|
2001-06-20 04:03:13 +08:00
|
|
|
/* XXX TODO: add control bit. */
|
2001-11-01 06:19:42 +08:00
|
|
|
if (selected[i] != 0)
|
2000-11-12 19:11:49 +08:00
|
|
|
return 0;
|
2001-11-01 06:19:42 +08:00
|
|
|
selected[i] = 1;
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@-nullpass@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
if (_te_debug)
|
|
|
|
fprintf(stderr, "addRelation: selected[%d] = 1\n", i);
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@=nullpass@*/
|
2000-11-12 19:11:49 +08:00
|
|
|
|
|
|
|
/* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_count++; /* bump p predecessor count */
|
|
|
|
/*@-type@*/
|
2001-04-21 14:02:09 +08:00
|
|
|
if (p->depth <= q->depth) /* Save max. depth in dependency tree */
|
|
|
|
p->depth = q->depth + 1;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
|
|
|
/*@-nullpass -type -abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
if (_te_debug)
|
2001-11-17 03:26:33 +08:00
|
|
|
fprintf(stderr, "addRelation: p %p(%s) depth %d", p, teGetN(p), p->depth);
|
|
|
|
prtTSI(NULL, teGetTSI(p));
|
|
|
|
/*@=nullpass =type =abstract@*/
|
2001-04-21 14:02:09 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
tsi = xcalloc(1, sizeof(*tsi));
|
2000-11-12 19:11:49 +08:00
|
|
|
tsi->tsi_suc = p;
|
2001-11-03 10:34:15 +08:00
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
tsi->tsi_reqx = dsiGetIx(requires);
|
2001-11-03 10:34:15 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
tsi->tsi_next = teGetTSI(q)->tsi_next;
|
|
|
|
/*@-nullpass -compmempass -type -abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
prtTSI("addRelation: new", tsi);
|
|
|
|
if (_te_debug)
|
2001-11-17 03:26:33 +08:00
|
|
|
fprintf(stderr, "addRelation: BEFORE q %p(%s)", q, teGetN(q));
|
|
|
|
prtTSI(NULL, teGetTSI(q));
|
|
|
|
/*@=nullpass =compmempass =type =abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@-mods@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(q)->tsi_next = tsi;
|
|
|
|
teGetTSI(q)->tsi_qcnt++; /* bump q successor count */
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@=mods@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-nullpass -compmempass -type -abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
if (_te_debug)
|
2001-11-17 03:26:33 +08:00
|
|
|
fprintf(stderr, "addRelation: AFTER q %p(%s)", q, teGetN(q));
|
|
|
|
prtTSI(NULL, teGetTSI(q));
|
|
|
|
/*@=nullpass =compmempass =type =abstract@*/
|
2000-11-12 19:11:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=mustmod@*/
|
2000-11-12 19:11:49 +08:00
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Compare ordered list entries by index (qsort/bsearch).
|
|
|
|
* @param a 1st ordered list entry
|
|
|
|
* @param b 2nd ordered list entry
|
|
|
|
* @return result of comparison
|
|
|
|
*/
|
2001-06-01 06:31:14 +08:00
|
|
|
static int orderListIndexCmp(const void * one, const void * two) /*@*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@-castexpose@*/
|
2001-11-05 06:00:11 +08:00
|
|
|
long a = (long) ((const orderListIndex)one)->pkgKey;
|
|
|
|
long b = (long) ((const orderListIndex)two)->pkgKey;
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@=castexpose@*/
|
2000-07-10 07:10:25 +08:00
|
|
|
return (a - b);
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
2001-01-09 12:07:49 +08:00
|
|
|
/**
|
|
|
|
* Add element to list sorting by initial successor count.
|
|
|
|
* @param p new element
|
|
|
|
* @retval qp address of first element
|
|
|
|
* @retval rp address of last element
|
|
|
|
*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-mustmod@*/
|
2001-11-13 04:51:05 +08:00
|
|
|
static void addQ(/*@dependent@*/ transactionElement p,
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@in@*/ /*@out@*/ transactionElement * qp,
|
|
|
|
/*@in@*/ /*@out@*/ transactionElement * rp)
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@modifies p, *qp, *rp @*/
|
2001-01-09 12:07:49 +08:00
|
|
|
{
|
2001-11-01 06:19:42 +08:00
|
|
|
transactionElement q, qprev;
|
2001-01-09 12:07:49 +08:00
|
|
|
|
|
|
|
if ((*rp) == NULL) { /* 1st element */
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@-dependenttrans@*/ /* FIX: double indirection */
|
2001-01-09 12:07:49 +08:00
|
|
|
(*rp) = (*qp) = p;
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@=dependenttrans@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
return;
|
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
for (qprev = NULL, q = (*qp); q != NULL; qprev = q, q = teGetTSI(q)->tsi_suc) {
|
|
|
|
if (teGetTSI(q)->tsi_qcnt <= teGetTSI(p)->tsi_qcnt)
|
2001-01-09 12:07:49 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (qprev == NULL) { /* insert at beginning of list */
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_suc = q;
|
|
|
|
/*@-dependenttrans@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
(*qp) = p; /* new head */
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=dependenttrans@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
} else if (q == NULL) { /* insert at end of list */
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(qprev)->tsi_suc = p;
|
|
|
|
/*@-dependenttrans@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
(*rp) = p; /* new tail */
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=dependenttrans@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
} else { /* insert between qprev and q */
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_suc = q;
|
|
|
|
teGetTSI(qprev)->tsi_suc = p;
|
2001-01-09 12:07:49 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=mustmod@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
|
2001-01-11 06:19:55 +08:00
|
|
|
int rpmdepOrder(rpmTransactionSet ts)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-11-11 08:11:33 +08:00
|
|
|
rpmDepSet requires;
|
|
|
|
int_32 Flags;
|
|
|
|
|
2001-11-11 03:24:19 +08:00
|
|
|
int numAddedPackages = ts->numAddedPackages;
|
2001-04-21 14:02:09 +08:00
|
|
|
int chainsaw = ts->transFlags & RPMTRANS_FLAG_CHAINSAW;
|
2001-11-02 11:13:35 +08:00
|
|
|
teIterator pi; transactionElement p;
|
|
|
|
teIterator qi; transactionElement q;
|
|
|
|
teIterator ri; transactionElement r;
|
2001-10-30 04:12:35 +08:00
|
|
|
tsortInfo tsi;
|
|
|
|
tsortInfo tsi_next;
|
2001-11-05 06:00:11 +08:00
|
|
|
alKey * ordering = alloca(sizeof(*ordering) * (numAddedPackages + 1));
|
2000-09-27 02:04:12 +08:00
|
|
|
int orderingCount = 0;
|
2001-11-01 06:19:42 +08:00
|
|
|
unsigned char * selected = alloca(sizeof(*selected) * (ts->orderCount + 1));
|
2000-09-27 02:04:12 +08:00
|
|
|
int loopcheck;
|
2001-11-17 06:42:19 +08:00
|
|
|
transactionElement * newOrder;
|
1999-04-05 05:26:36 +08:00
|
|
|
int newOrderCount = 0;
|
2001-10-29 06:17:47 +08:00
|
|
|
orderListIndex orderList;
|
2000-09-27 02:04:12 +08:00
|
|
|
int nrescans = 10;
|
2001-01-17 05:54:59 +08:00
|
|
|
int _printed = 0;
|
2001-01-09 12:07:49 +08:00
|
|
|
int qlen;
|
2000-09-27 02:04:12 +08:00
|
|
|
int i, j;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2001-10-30 04:12:35 +08:00
|
|
|
alMakeIndex(ts->addedPackages);
|
2001-11-01 06:19:42 +08:00
|
|
|
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-modfilesystem -nullpass -formattype@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
if (_te_debug)
|
|
|
|
fprintf(stderr, "*** rpmdepOrder(%p) order %p[%d]\n", ts, ts->order, ts->orderCount);
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@=modfilesystem =nullpass =formattype@*/
|
1997-07-16 09:39:54 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/* T1. Initialize. */
|
2001-11-02 04:15:10 +08:00
|
|
|
loopcheck = numAddedPackages; /* XXX TR_ADDED only: should be ts->orderCount */
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((p = teNext(pi, TR_ADDED)) != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/ /* FIX: transactionElement not opaque */
|
2001-11-07 06:46:26 +08:00
|
|
|
p->tsi = xcalloc(1, sizeof(*p->tsi));
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/* Record all relations. */
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("========== recording tsort relations\n"));
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((p = teNext(pi, TR_ADDED)) != NULL) {
|
1997-07-18 23:03:35 +08:00
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
if ((requires = teGetDS(p, RPMTAG_REQUIRENAME)) == NULL)
|
2001-11-02 13:36:48 +08:00
|
|
|
continue;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
memset(selected, 0, sizeof(*selected) * ts->orderCount);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* Avoid narcisstic relations. */
|
2001-11-17 03:26:33 +08:00
|
|
|
selected[teiGetOc(pi)] = 1;
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* T2. Next "q <- p" relation. */
|
2000-11-12 19:11:49 +08:00
|
|
|
|
|
|
|
/* First, do pre-requisites. */
|
2001-11-03 05:01:25 +08:00
|
|
|
requires = dsiInit(requires);
|
|
|
|
if (requires != NULL)
|
|
|
|
while (dsiNext(requires) >= 0) {
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
Flags = dsiGetFlags(requires);
|
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/* Skip if not %pre/%post requires or legacy prereq. */
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
if (isErasePreReq(Flags) ||
|
|
|
|
!( isInstallPreReq(Flags) ||
|
|
|
|
isLegacyPreReq(Flags) ))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */
|
2001-10-31 12:00:58 +08:00
|
|
|
(void) addRelation(ts, p, selected, requires);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Then do co-requisites. */
|
2001-11-03 05:01:25 +08:00
|
|
|
requires = dsiInit(requires);
|
|
|
|
if (requires != NULL)
|
|
|
|
while (dsiNext(requires) >= 0) {
|
2000-11-12 19:11:49 +08:00
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
Flags = dsiGetFlags(requires);
|
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/* Skip if %pre/%post requires or legacy prereq. */
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-11-03 07:17:54 +08:00
|
|
|
if (isErasePreReq(Flags) ||
|
|
|
|
( isInstallPreReq(Flags) ||
|
|
|
|
isLegacyPreReq(Flags) ))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */
|
2001-10-31 12:00:58 +08:00
|
|
|
(void) addRelation(ts, p, selected, requires);
|
2000-11-12 19:11:49 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
/* Save predecessor count. */
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((p = teNext(pi, TR_ADDED)) != NULL) {
|
2001-10-30 07:39:51 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/
|
|
|
|
p->npreds = teGetTSI(p)->tsi_count;
|
|
|
|
/*@=type@*/
|
|
|
|
|
|
|
|
/*@-modfilesystem -nullpass -type -abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
if (_te_debug)
|
2001-11-17 03:26:33 +08:00
|
|
|
fprintf(stderr, "\t+++ %p[%d] %s npreds %d\n", p, teiGetOc(pi), teGetNEVR(p), p->npreds);
|
|
|
|
/*@=modfilesystem =nullpass =type =abstract@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2001-04-21 14:02:09 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/* T4. Scan for zeroes. */
|
2001-04-24 04:56:59 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("========== tsorting packages (order, #predecessors, #succesors, depth)\n"));
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
rescan:
|
2001-11-17 04:26:01 +08:00
|
|
|
if (pi != NULL) pi = teFreeIterator(pi);
|
2000-09-27 02:04:12 +08:00
|
|
|
q = r = NULL;
|
2001-01-11 06:19:55 +08:00
|
|
|
qlen = 0;
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((p = teNext(pi, TR_ADDED)) != NULL) {
|
2001-01-17 01:33:59 +08:00
|
|
|
|
2001-11-02 11:13:35 +08:00
|
|
|
/* Prefer packages in chainsaw or presentation order. */
|
2001-04-21 14:02:09 +08:00
|
|
|
if (!chainsaw)
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_qcnt = (ts->orderCount - teiGetOc(pi));
|
2001-01-17 01:33:59 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetTSI(p)->tsi_count != 0)
|
2001-01-11 04:42:32 +08:00
|
|
|
continue;
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_suc = NULL;
|
2001-01-11 04:42:32 +08:00
|
|
|
addQ(p, &q, &r);
|
|
|
|
qlen++;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-modfilesystem -nullpass -type -abstract @*/
|
2001-11-01 06:19:42 +08:00
|
|
|
if (_te_debug)
|
2001-11-17 03:26:33 +08:00
|
|
|
fprintf(stderr, "\t+++ addQ ++ qlen %d p %p(%s)", qlen, p, teGetNEVR(p));
|
|
|
|
prtTSI(" p", teGetTSI(p));
|
|
|
|
/*@=modfilesystem =nullpass =type =abstract @*/
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-01-11 04:42:32 +08:00
|
|
|
/* T5. Output front of queue (T7. Remove from queue.) */
|
2001-11-07 06:46:26 +08:00
|
|
|
/*@-branchstate@*/ /* FIX: r->tsi->tsi_next released */
|
2001-11-17 03:26:33 +08:00
|
|
|
for (; q != NULL; q = teGetTSI(q)->tsi_suc) {
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-11-01 06:19:42 +08:00
|
|
|
/* XXX Only added packages are ordered (for now). */
|
2001-11-17 03:26:33 +08:00
|
|
|
switch (teGetType(q)) {
|
2001-11-01 06:19:42 +08:00
|
|
|
case TR_ADDED:
|
|
|
|
/*@switchbreak@*/ break;
|
|
|
|
case TR_REMOVED:
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
/*@notreached@*/ /*@switchbreak@*/ break;
|
|
|
|
}
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "%5d%5d%5d%3d %*s %s\n",
|
2001-11-17 03:26:33 +08:00
|
|
|
orderingCount, q->npreds, teGetTSI(q)->tsi_qcnt, q->depth,
|
2001-11-01 06:19:42 +08:00
|
|
|
(2 * q->depth), "",
|
2001-11-17 03:26:33 +08:00
|
|
|
(teGetNEVR(q) ? teGetNEVR(q) : "???"));
|
|
|
|
/*@=type@*/
|
|
|
|
ordering[orderingCount] = teGetAddedKey(q);
|
2001-11-02 04:15:10 +08:00
|
|
|
orderingCount++;
|
2001-01-11 04:42:32 +08:00
|
|
|
qlen--;
|
2000-09-27 02:04:12 +08:00
|
|
|
loopcheck--;
|
|
|
|
|
|
|
|
/* T6. Erase relations. */
|
2001-11-17 03:26:33 +08:00
|
|
|
tsi_next = teGetTSI(q)->tsi_next;
|
|
|
|
teGetTSI(q)->tsi_next = NULL;
|
2000-09-27 02:04:12 +08:00
|
|
|
while ((tsi = tsi_next) != NULL) {
|
|
|
|
tsi_next = tsi->tsi_next;
|
|
|
|
tsi->tsi_next = NULL;
|
|
|
|
p = tsi->tsi_suc;
|
2001-11-17 03:26:33 +08:00
|
|
|
if (p && (--teGetTSI(p)->tsi_count) <= 0) {
|
2001-06-20 04:03:13 +08:00
|
|
|
/* XXX TODO: add control bit. */
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_suc = NULL;
|
2001-11-07 06:46:26 +08:00
|
|
|
/*@-nullstate@*/ /* FIX: q->tsi->tsi_u.suc may be NULL */
|
2001-11-17 03:26:33 +08:00
|
|
|
addQ(p, &teGetTSI(q)->tsi_suc, &r);
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=nullstate@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
qlen++;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-modfilesystem -nullpass -type -abstract@*/
|
2001-11-02 07:18:15 +08:00
|
|
|
if (_te_debug)
|
2001-11-17 03:26:33 +08:00
|
|
|
fprintf(stderr, "\t+++ addQ ++ qlen %d p %p(%s)", qlen, p, teGetNEVR(p));
|
|
|
|
prtTSI(" p", teGetTSI(p));
|
|
|
|
/*@=modfilesystem =nullpass =type =abstract@*/
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2001-04-21 14:02:09 +08:00
|
|
|
tsi = _free(tsi);
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
if (!_printed && loopcheck == qlen && teGetTSI(q)->tsi_suc != NULL) {
|
2001-01-17 05:54:59 +08:00
|
|
|
_printed++;
|
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
_("========== successors only (presentation order)\n"));
|
|
|
|
}
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@=branchstate@*/
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/* T8. End of process. Check for loops. */
|
|
|
|
if (loopcheck != 0) {
|
|
|
|
int nzaps;
|
|
|
|
|
|
|
|
/* T9. Initialize predecessor chain. */
|
|
|
|
nzaps = 0;
|
2001-11-02 11:13:35 +08:00
|
|
|
qi = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((q = teNext(qi, TR_ADDED)) != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(q)->tsi_chain = NULL;
|
|
|
|
teGetTSI(q)->tsi_reqx = 0;
|
2000-09-27 02:04:12 +08:00
|
|
|
/* Mark packages already sorted. */
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetTSI(q)->tsi_count == 0)
|
|
|
|
teGetTSI(q)->tsi_count = -1;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
qi = teFreeIterator(qi);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* T10. Mark all packages with their predecessors. */
|
2001-11-02 11:13:35 +08:00
|
|
|
qi = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((q = teNext(qi, TR_ADDED)) != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((tsi = teGetTSI(q)->tsi_next) == NULL)
|
2000-09-27 02:04:12 +08:00
|
|
|
continue;
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(q)->tsi_next = NULL;
|
2000-09-27 02:04:12 +08:00
|
|
|
markLoop(tsi, q);
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(q)->tsi_next = tsi;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
qi = teFreeIterator(qi);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* T11. Print all dependency loops. */
|
2001-11-02 11:13:35 +08:00
|
|
|
ri = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((r = teNext(ri, TR_ADDED)) != NULL)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-11-02 11:13:35 +08:00
|
|
|
{
|
2000-09-27 02:04:12 +08:00
|
|
|
int printed;
|
|
|
|
|
|
|
|
printed = 0;
|
|
|
|
|
|
|
|
/* T12. Mark predecessor chain, looking for start of loop. */
|
2001-11-17 03:26:33 +08:00
|
|
|
for (q = teGetTSI(r)->tsi_chain; q != NULL; q = teGetTSI(q)->tsi_chain) {
|
|
|
|
if (teGetTSI(q)->tsi_reqx)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(q)->tsi_reqx = 1;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* T13. Print predecessor chain from start of loop. */
|
2001-11-17 03:26:33 +08:00
|
|
|
while ((p = q) != NULL && (q = teGetTSI(p)->tsi_chain) != NULL) {
|
2000-09-27 02:04:12 +08:00
|
|
|
const char * dp;
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
/* Unchain predecessor loop. */
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_chain = NULL;
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
if (!printed) {
|
2001-06-20 04:03:13 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("LOOP:\n"));
|
2000-09-27 02:04:12 +08:00
|
|
|
printed = 1;
|
|
|
|
}
|
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/* Find (and destroy if co-requisite) "q <- p" relation. */
|
2001-11-17 08:52:45 +08:00
|
|
|
if ((requires = teGetDS(p, RPMTAG_REQUIRENAME)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
2001-11-03 05:01:25 +08:00
|
|
|
requires = dsiInit(requires);
|
|
|
|
dp = zapRelation(q, p, requires, 1, &nzaps);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* Print next member of loop. */
|
2001-11-01 06:19:42 +08:00
|
|
|
buf[0] = '\0';
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetNEVR(p) != NULL)
|
|
|
|
(void) stpcpy(buf, teGetNEVR(p));
|
2001-06-20 04:03:13 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, " %-40s %s\n", buf,
|
2001-05-04 05:00:18 +08:00
|
|
|
(dp ? dp : "not found!?!"));
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
dp = _free(dp);
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Walk (and erase) linear part of predecessor chain as well. */
|
2001-11-17 03:26:33 +08:00
|
|
|
for (p = r, q = teGetTSI(r)->tsi_chain;
|
2000-09-27 02:04:12 +08:00
|
|
|
q != NULL;
|
2001-11-17 03:26:33 +08:00
|
|
|
p = q, q = teGetTSI(q)->tsi_chain)
|
2000-09-27 02:04:12 +08:00
|
|
|
{
|
|
|
|
/* Unchain linear part of predecessor loop. */
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetTSI(p)->tsi_chain = NULL;
|
|
|
|
teGetTSI(p)->tsi_reqx = 0;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2001-11-02 11:13:35 +08:00
|
|
|
ri = teFreeIterator(ri);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* If a relation was eliminated, then continue sorting. */
|
2001-06-20 04:03:13 +08:00
|
|
|
/* XXX TODO: add control bit. */
|
2000-09-27 02:04:12 +08:00
|
|
|
if (nzaps && nrescans-- > 0) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("========== continuing tsort ...\n"));
|
|
|
|
goto rescan;
|
|
|
|
}
|
2001-11-02 04:15:10 +08:00
|
|
|
|
|
|
|
/* Return no. of packages that could not be ordered. */
|
|
|
|
rpmMessage(RPMMESS_ERROR, _("rpmdepOrder failed, %d elements remain\n"),
|
|
|
|
loopcheck);
|
|
|
|
return loopcheck;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The order ends up as installed packages followed by removed packages,
|
|
|
|
* with removes for upgrades immediately following the installation of
|
|
|
|
* the new package. This would be easier if we could sort the
|
|
|
|
* addedPackages array, but we store indexes into it in various places.
|
|
|
|
*/
|
2001-11-02 04:15:10 +08:00
|
|
|
orderList = xcalloc(numAddedPackages, sizeof(*orderList));
|
2001-11-01 06:19:42 +08:00
|
|
|
j = 0;
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
/* XXX Only added packages are ordered (for now). */
|
|
|
|
while ((p = teNext(pi, TR_ADDED)) != NULL) {
|
2001-11-01 06:19:42 +08:00
|
|
|
|
|
|
|
/* Clean up tsort remnants (if any). */
|
2001-11-17 03:26:33 +08:00
|
|
|
while ((tsi = teGetTSI(p)->tsi_next) != NULL) {
|
|
|
|
teGetTSI(p)->tsi_next = tsi->tsi_next;
|
2001-11-01 06:19:42 +08:00
|
|
|
tsi->tsi_next = NULL;
|
|
|
|
tsi = _free(tsi);
|
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/ /* FIX: transactionElement not opaque */
|
2001-11-07 06:46:26 +08:00
|
|
|
p->tsi = _free(p->tsi);
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
|
2001-11-02 04:15:10 +08:00
|
|
|
/* Prepare added package ordering permutation. */
|
2001-11-17 03:26:33 +08:00
|
|
|
orderList[j].pkgKey = teGetAddedKey(p);
|
|
|
|
orderList[j].orIndex = teiGetOc(pi);
|
2001-11-01 06:19:42 +08:00
|
|
|
j++;
|
1999-04-05 05:26:36 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2001-11-02 04:15:10 +08:00
|
|
|
assert(j <= numAddedPackages);
|
1999-04-14 01:26:43 +08:00
|
|
|
|
2001-11-02 04:15:10 +08:00
|
|
|
qsort(orderList, numAddedPackages, sizeof(*orderList), orderListIndexCmp);
|
1999-04-05 05:26:36 +08:00
|
|
|
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-type@*/
|
2001-09-25 05:53:14 +08:00
|
|
|
newOrder = xcalloc(ts->orderCount, sizeof(*newOrder));
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@=type@*/
|
2001-11-05 06:00:11 +08:00
|
|
|
/*@-branchstate@*/
|
2001-11-02 11:13:35 +08:00
|
|
|
for (i = 0, newOrderCount = 0; i < orderingCount; i++)
|
|
|
|
{
|
2001-10-29 06:17:47 +08:00
|
|
|
struct orderListIndex_s key;
|
|
|
|
orderListIndex needle;
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
key.pkgKey = ordering[i];
|
2001-11-02 04:15:10 +08:00
|
|
|
needle = bsearch(&key, orderList, numAddedPackages,
|
|
|
|
sizeof(key), orderListIndexCmp);
|
1999-04-05 05:26:36 +08:00
|
|
|
/* bsearch should never, ever fail */
|
2001-05-04 05:00:18 +08:00
|
|
|
if (needle == NULL) continue;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2001-11-02 11:13:35 +08:00
|
|
|
j = needle->orIndex;
|
2001-11-17 06:42:19 +08:00
|
|
|
newOrder[newOrderCount++] = q = ts->order[j];
|
|
|
|
ts->order[j] = NULL;
|
2001-01-11 06:19:55 +08:00
|
|
|
for (j = needle->orIndex + 1; j < ts->orderCount; j++) {
|
2001-11-17 06:42:19 +08:00
|
|
|
if ((q = ts->order[j]) == NULL)
|
|
|
|
/*@innerbreak@*/ break;
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetType(q) == TR_REMOVED
|
|
|
|
&& teGetDependsOnKey(q) == needle->pkgKey)
|
|
|
|
{
|
2001-11-17 06:42:19 +08:00
|
|
|
newOrder[newOrderCount++] = q;
|
|
|
|
ts->order[j] = NULL;
|
2001-06-06 03:26:22 +08:00
|
|
|
} else
|
|
|
|
/*@innerbreak@*/ break;
|
1999-04-05 05:26:36 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 06:00:11 +08:00
|
|
|
/*@=branchstate@*/
|
1999-04-05 05:26:36 +08:00
|
|
|
|
2001-11-17 06:42:19 +08:00
|
|
|
for (j = 0; j < ts->orderCount; j++) {
|
|
|
|
if ((p = ts->order[j]) == NULL)
|
|
|
|
continue;
|
|
|
|
assert(teGetType(p) == TR_REMOVED);
|
|
|
|
newOrder[newOrderCount++] = p;
|
|
|
|
ts->order[j] = NULL;
|
1999-04-05 05:26:36 +08:00
|
|
|
}
|
2001-01-11 06:19:55 +08:00
|
|
|
assert(newOrderCount == ts->orderCount);
|
1999-04-14 01:26:43 +08:00
|
|
|
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@+voidabstract@*/
|
2001-04-21 14:02:09 +08:00
|
|
|
ts->order = _free(ts->order);
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@=voidabstract@*/
|
2001-01-11 06:19:55 +08:00
|
|
|
ts->order = newOrder;
|
|
|
|
ts->orderAlloced = ts->orderCount;
|
2001-04-21 14:02:09 +08:00
|
|
|
orderList = _free(orderList);
|
1999-04-05 05:26:36 +08:00
|
|
|
|
2001-11-11 11:15:47 +08:00
|
|
|
/* Clean up after dependency checks */
|
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNextIterator(pi)) != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/ /* FIX: transactionElement not opaque */
|
2001-11-11 11:15:47 +08:00
|
|
|
p->this = dsFree(p->this);
|
|
|
|
p->provides = dsFree(p->provides);
|
|
|
|
p->requires = dsFree(p->requires);
|
|
|
|
p->conflicts = dsFree(p->conflicts);
|
|
|
|
p->obsoletes = dsFree(p->obsoletes);
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
2001-11-11 11:15:47 +08:00
|
|
|
}
|
|
|
|
pi = teFreeIterator(pi);
|
|
|
|
|
|
|
|
ts->addedPackages = alFree(ts->addedPackages);
|
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-09-16 05:21:31 +08:00
|
|
|
/**
|
|
|
|
* Close a single database index.
|
|
|
|
* @param db rpm database
|
|
|
|
* @param rpmtag rpm tag
|
|
|
|
* @return 0 on success
|
|
|
|
*/
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@-mustmod -type@*/ /* FIX: this belongs in rpmdb.c */
|
2001-09-21 23:07:11 +08:00
|
|
|
static int rpmdbCloseDBI(/*@null@*/ rpmdb db, int rpmtag)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies db, fileSystem @*/
|
2001-09-16 05:21:31 +08:00
|
|
|
{
|
|
|
|
int dbix;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (db == NULL || db->_dbi == NULL || dbiTags == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (dbix = 0; dbix < dbiTagsMax; dbix++) {
|
|
|
|
if (dbiTags[dbix] != rpmtag)
|
|
|
|
continue;
|
|
|
|
if (db->_dbi[dbix] != NULL) {
|
|
|
|
int xx;
|
|
|
|
/*@-unqualifiedtrans@*/ /* FIX: double indirection. */
|
|
|
|
xx = dbiClose(db->_dbi[dbix], 0);
|
|
|
|
if (xx && rc == 0) rc = xx;
|
|
|
|
db->_dbi[dbix] = NULL;
|
|
|
|
/*@=unqualifiedtrans@*/
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@=mustmod =type@*/
|
2001-09-16 05:21:31 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
int rpmdepCheck(rpmTransactionSet ts,
|
2001-11-17 03:26:33 +08:00
|
|
|
rpmProblem * dsprobs, int * numProbs)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-09-15 21:49:11 +08:00
|
|
|
rpmdbMatchIterator mi = NULL;
|
2001-11-02 11:13:35 +08:00
|
|
|
teIterator pi = NULL; transactionElement p;
|
2001-10-28 04:09:20 +08:00
|
|
|
int closeatexit = 0;
|
2001-11-11 10:50:31 +08:00
|
|
|
int xx;
|
1999-09-14 13:41:13 +08:00
|
|
|
int rc;
|
1999-04-05 05:26:36 +08:00
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
/* Do lazy, readonly, open of rpm database. */
|
|
|
|
if (ts->rpmdb == NULL) {
|
|
|
|
if ((rc = rpmtsOpenDB(ts, ts->dbmode)) != 0)
|
|
|
|
goto exit;
|
|
|
|
closeatexit = 1;
|
|
|
|
}
|
|
|
|
|
2001-11-09 06:04:35 +08:00
|
|
|
ts->probs = rpmProblemSetCreate();
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
*dsprobs = NULL;
|
|
|
|
*numProbs = 0;
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-10-30 04:12:35 +08:00
|
|
|
alMakeIndex(ts->addedPackages);
|
|
|
|
alMakeIndex(ts->availablePackages);
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
/*
|
|
|
|
* Look at all of the added packages and make sure their dependencies
|
2000-07-08 04:06:41 +08:00
|
|
|
* are satisfied.
|
|
|
|
*/
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNext(pi, TR_ADDED)) != NULL) {
|
2001-10-31 12:00:58 +08:00
|
|
|
rpmDepSet provides;
|
2001-11-17 03:26:33 +08:00
|
|
|
rpmDepSet requires;
|
|
|
|
rpmDepSet conflicts;
|
2001-10-31 12:00:58 +08:00
|
|
|
uint_32 multiLib;
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
multiLib = teGetMultiLib(p);
|
2001-10-31 12:00:58 +08:00
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
provides = teGetDS(p, RPMTAG_PROVIDENAME);
|
|
|
|
requires = teGetDS(p, RPMTAG_REQUIRENAME);
|
|
|
|
conflicts = teGetDS(p, RPMTAG_CONFLICTNAME);
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== +++ %s\n" , teGetNEVR(p));
|
|
|
|
rc = checkPackageDeps(ts, teGetNEVR(p), requires, conflicts,
|
2001-11-11 08:11:33 +08:00
|
|
|
NULL, multiLib);
|
|
|
|
if (rc)
|
1999-09-14 13:41:13 +08:00
|
|
|
goto exit;
|
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
#ifdef DYING /* XXX all packages now have Provides: name = version-release */
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Adding: check name against conflicts matches. */
|
2001-11-17 03:26:33 +08:00
|
|
|
rc = checkDependentConflicts(ts, teGetN(p));
|
2000-07-08 04:06:41 +08:00
|
|
|
if (rc)
|
1999-09-14 13:41:13 +08:00
|
|
|
goto exit;
|
2001-11-17 08:52:45 +08:00
|
|
|
#endif
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
rc = 0;
|
2001-11-03 05:01:25 +08:00
|
|
|
provides = dsiInit(provides);
|
2001-11-03 10:34:15 +08:00
|
|
|
if (provides == NULL || dsiGetN(provides) == NULL)
|
|
|
|
continue;
|
2001-11-03 05:01:25 +08:00
|
|
|
while (dsiNext(provides) >= 0) {
|
2001-11-03 07:17:54 +08:00
|
|
|
const char * Name;
|
|
|
|
|
2001-11-03 10:34:15 +08:00
|
|
|
if ((Name = dsiGetN(provides)) == NULL)
|
|
|
|
/*@innercontinue@*/ continue; /* XXX can't happen */
|
2001-11-03 07:17:54 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Adding: check provides key against conflicts matches. */
|
2001-11-09 06:04:35 +08:00
|
|
|
if (!checkDependentConflicts(ts, Name))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-02-05 06:15:30 +08:00
|
|
|
rc = 1;
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
2000-07-08 04:06:41 +08:00
|
|
|
if (rc)
|
|
|
|
goto exit;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
/*
|
|
|
|
* Look at the removed packages and make sure they aren't critical.
|
|
|
|
*/
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-11-11 10:50:31 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNext(pi, TR_REMOVED)) != NULL) {
|
|
|
|
rpmDepSet provides;
|
2001-11-12 06:51:00 +08:00
|
|
|
TFI_t fi;
|
2001-11-11 10:50:31 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== --- %s\n" , teGetNEVR(p));
|
2001-11-11 10:50:31 +08:00
|
|
|
|
2001-11-17 08:52:45 +08:00
|
|
|
#ifdef DYING /* XXX all packages now have Provides: name = version-release */
|
2001-11-11 10:50:31 +08:00
|
|
|
/* Erasing: check name against requiredby matches. */
|
2001-11-17 03:26:33 +08:00
|
|
|
rc = checkDependentPackages(ts, teGetN(p));
|
2001-11-11 10:50:31 +08:00
|
|
|
if (rc)
|
1999-12-01 02:07:08 +08:00
|
|
|
goto exit;
|
2001-11-17 08:52:45 +08:00
|
|
|
#endif
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-11-11 10:50:31 +08:00
|
|
|
rc = 0;
|
2001-11-17 08:52:45 +08:00
|
|
|
provides = teGetDS(p, RPMTAG_PROVIDENAME);
|
2001-11-11 10:50:31 +08:00
|
|
|
provides = dsiInit(provides);
|
|
|
|
if (provides != NULL)
|
|
|
|
while (dsiNext(provides) >= 0) {
|
|
|
|
const char * Name;
|
2001-11-03 07:17:54 +08:00
|
|
|
|
2001-11-11 10:50:31 +08:00
|
|
|
if ((Name = dsiGetN(provides)) == NULL)
|
|
|
|
/*@innercontinue@*/ continue; /* XXX can't happen */
|
2001-11-03 07:17:54 +08:00
|
|
|
|
2001-11-11 10:50:31 +08:00
|
|
|
/* Erasing: check provides against requiredby matches. */
|
|
|
|
if (!checkDependentPackages(ts, Name))
|
|
|
|
/*@innercontinue@*/ continue;
|
|
|
|
rc = 1;
|
|
|
|
/*@innerbreak@*/ break;
|
|
|
|
}
|
|
|
|
if (rc)
|
|
|
|
goto exit;
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-11-11 10:50:31 +08:00
|
|
|
rc = 0;
|
2001-11-17 08:52:45 +08:00
|
|
|
fi = teGetFI(p, RPMTAG_BASENAMES);
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = tfiInit(fi, 0)) != NULL)
|
2001-11-14 03:04:33 +08:00
|
|
|
while (tfiNext(fi) >= 0) {
|
2001-11-14 08:14:01 +08:00
|
|
|
const char * fn = tfiGetFN(fi);
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-11-11 10:50:31 +08:00
|
|
|
/* Erasing: check filename against requiredby matches. */
|
|
|
|
if (!checkDependentPackages(ts, fn))
|
|
|
|
/*@innercontinue@*/ continue;
|
|
|
|
rc = 1;
|
|
|
|
/*@innerbreak@*/ break;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
2001-11-11 10:50:31 +08:00
|
|
|
if (rc)
|
|
|
|
goto exit;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2001-11-11 10:50:31 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@-type@*/ /* FIX: return refcounted rpmProblemSet */
|
2001-11-09 06:04:35 +08:00
|
|
|
if (ts->probs->numProblems) {
|
2001-11-17 03:26:33 +08:00
|
|
|
*dsprobs = ts->probs->probs;
|
2001-11-09 06:04:35 +08:00
|
|
|
ts->probs->probs = NULL;
|
2001-11-17 03:26:33 +08:00
|
|
|
*numProbs = ts->probs->numProblems;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@=type@*/
|
2000-07-08 04:06:41 +08:00
|
|
|
rc = 0;
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
exit:
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2001-11-02 11:13:35 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-10-28 04:09:20 +08:00
|
|
|
if (closeatexit)
|
|
|
|
xx = rpmtsCloseDB(ts);
|
|
|
|
else if (_cacheDependsRC)
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = rpmdbCloseDBI(ts->rpmdb, RPMDBI_DEPENDS);
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2001-11-10 01:22:08 +08:00
|
|
|
ts->probs = rpmProblemSetFree(ts->probs);
|
2000-07-08 04:06:41 +08:00
|
|
|
return rc;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|