2002-05-17 00:55:21 +08:00
|
|
|
/** \ingroup rpmts
|
2000-08-28 03:27:03 +08:00
|
|
|
* \file lib/depends.c
|
|
|
|
*/
|
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "system.h"
|
|
|
|
|
2002-08-14 00:36:44 +08:00
|
|
|
#include <rpmcli.h> /* XXX rpmcliPackagesTotal */
|
2002-03-14 01:59:49 +08:00
|
|
|
|
|
|
|
#include <rpmmacro.h> /* XXX rpmExpand("%{_dependency_whiteout}" */
|
1997-01-18 00:20:18 +08:00
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
#include "rpmdb.h" /* XXX response cache needs dbiOpen et al. */
|
|
|
|
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmds.h"
|
|
|
|
#include "rpmfi.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMTE_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmte.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMTS_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmts.h"
|
2001-11-04 23:43:26 +08:00
|
|
|
|
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 @*/
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@access rpmts @*/
|
2001-10-29 06:17:47 +08:00
|
|
|
|
2002-05-03 06:16:30 +08:00
|
|
|
/*@access dbiIndex @*/ /* XXX for dbi->dbi_txnid */
|
|
|
|
|
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-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-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
|
|
|
|
*/
|
2002-07-03 07:54:35 +08:00
|
|
|
static int intcmp(const void * a, const void * b)
|
|
|
|
/*@requires maxRead(a) == 0 /\ maxRead(b) == 0 @*/
|
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
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int removePackage(rpmts ts, Header h, int dboffset,
|
2001-11-17 16:02:17 +08:00
|
|
|
/*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey depends)
|
2002-08-20 06:27:44 +08:00
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies ts, h, fileSystem @*/
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmte 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) {
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-05-17 04:02:08 +08:00
|
|
|
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;
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
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. */
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-02 04:15:10 +08:00
|
|
|
ts->removedPackages[ts->numRemovedPackages] = dboffset;
|
|
|
|
ts->numRemovedPackages++;
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2002-04-15 05:48:44 +08:00
|
|
|
if (ts->numRemovedPackages > 1)
|
|
|
|
qsort(ts->removedPackages, ts->numRemovedPackages,
|
2001-10-16 22:58:57 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
p = rpmteNew(ts, h, TR_REMOVED, NULL, NULL, dboffset, depends);
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-17 08:52:45 +08:00
|
|
|
ts->order[ts->orderCount] = p;
|
2001-11-10 09:39:50 +08:00
|
|
|
ts->orderCount++;
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2001-11-10 09:39:50 +08:00
|
|
|
|
2001-07-07 04:37:42 +08:00
|
|
|
return 0;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
int rpmtsAddInstallElement(rpmts 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
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
|
|
|
uint_32 dscolor;
|
2001-11-10 09:39:50 +08:00
|
|
|
int isSource;
|
2001-11-02 07:18:15 +08:00
|
|
|
int duplicate = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmtsi pi; rpmte p;
|
2003-01-18 01:43:04 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
|
|
|
const char * arch;
|
|
|
|
const char * os;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds add;
|
|
|
|
rpmds obsoletes;
|
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
|
|
|
/*
|
2003-01-18 01:43:04 +08:00
|
|
|
* Check for previously added versions with the same name and arch/os.
|
2001-11-11 08:11:33 +08:00
|
|
|
* FIXME: only catches previously added, older packages.
|
2001-01-25 20:58:03 +08:00
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
add = rpmdsThis(h, RPMTAG_REQUIRENAME, (RPMSENSE_EQUAL|RPMSENSE_LESS));
|
2003-01-18 01:43:04 +08:00
|
|
|
arch = NULL;
|
|
|
|
xx = hge(h, RPMTAG_ARCH, NULL, (void **)&arch, NULL);
|
|
|
|
os = NULL;
|
|
|
|
xx = hge(h, RPMTAG_OS, NULL, (void **)&os, NULL);
|
2001-11-11 08:11:33 +08:00
|
|
|
pkgKey = RPMAL_NOMATCH;
|
2002-05-28 05:40:08 +08:00
|
|
|
for (pi = rpmtsiInit(ts), oc = 0; (p = rpmtsiNext(pi, 0)) != NULL; oc++) {
|
2003-01-18 01:43:04 +08:00
|
|
|
const char * parch;
|
|
|
|
const char * pos;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds this;
|
2001-11-17 06:42:19 +08:00
|
|
|
|
|
|
|
/* XXX Only added packages need be checked for dupes. */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteType(p) == TR_REMOVED)
|
2001-11-17 06:42:19 +08:00
|
|
|
continue;
|
|
|
|
|
2003-01-18 01:43:04 +08:00
|
|
|
if (tscolor) {
|
|
|
|
if (arch == NULL || (parch = rpmteA(p)) == NULL)
|
|
|
|
continue;
|
|
|
|
if (os == NULL || (pos = rpmteO(p)) == NULL)
|
|
|
|
continue;
|
|
|
|
if (strcmp(arch, parch) || strcmp(os, pos))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((this = rpmteDS(p, RPMTAG_NAME)) == NULL)
|
2001-11-17 08:52:45 +08:00
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
rc = rpmdsCompare(add, this);
|
2001-11-11 08:11:33 +08:00
|
|
|
if (rc != 0) {
|
2002-05-20 02:42:25 +08:00
|
|
|
const char * pkgNEVR = rpmdsDNEVR(this);
|
|
|
|
const char * addNEVR = rpmdsDNEVR(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;
|
2002-05-20 02:42:25 +08:00
|
|
|
pkgKey = rpmteAddedKey(p);
|
2001-11-11 08:11:33 +08:00
|
|
|
break;
|
2001-10-28 04:09:20 +08:00
|
|
|
}
|
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2002-05-20 02:42:25 +08:00
|
|
|
add = rpmdsFree(add);
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2001-11-10 09:39:50 +08:00
|
|
|
isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
|
|
|
|
|
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
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
p = rpmteNew(ts, h, TR_ADDED, key, relocs, -1, pkgKey);
|
2002-07-07 02:48:09 +08:00
|
|
|
|
|
|
|
if (duplicate && oc < ts->orderCount) {
|
|
|
|
/*@-type -unqualifiedtrans@*/
|
|
|
|
/*@-boundswrite@*/
|
|
|
|
ts->order[oc] = rpmteFree(ts->order[oc]);
|
|
|
|
/*@=boundswrite@*/
|
|
|
|
/*@=type =unqualifiedtrans@*/
|
|
|
|
}
|
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-17 08:52:45 +08:00
|
|
|
ts->order[oc] = p;
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2002-08-14 00:36:44 +08:00
|
|
|
if (!duplicate) {
|
2001-11-17 07:22:24 +08:00
|
|
|
ts->orderCount++;
|
2002-08-14 00:36:44 +08:00
|
|
|
rpmcliPackagesTotal++;
|
|
|
|
}
|
2001-11-11 03:24:19 +08:00
|
|
|
|
2002-05-28 02:12:12 +08:00
|
|
|
pkgKey = rpmalAdd(&ts->addedPackages, pkgKey, rpmteKey(p),
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteDS(p, RPMTAG_PROVIDENAME),
|
2002-12-31 09:23:03 +08:00
|
|
|
rpmteFI(p, RPMTAG_BASENAMES), tscolor);
|
2001-11-05 06:00:11 +08:00
|
|
|
if (pkgKey == RPMAL_NOMATCH) {
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
ts->order[oc] = rpmteFree(ts->order[oc]);
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2001-11-02 07:18:15 +08:00
|
|
|
ec = 1;
|
|
|
|
goto exit;
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmteSetAddedKey(p, pkgKey);
|
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. */
|
2002-07-15 05:23:29 +08:00
|
|
|
if (rpmtsGetRdb(ts) == NULL && ts->dbmode != -1) {
|
2001-10-28 04:09:20 +08:00
|
|
|
if ((ec = rpmtsOpenDB(ts, ts->dbmode)) != 0)
|
|
|
|
goto exit;
|
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2003-01-02 00:54:04 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
|
|
|
Header oh;
|
|
|
|
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, rpmteN(p), 0);
|
|
|
|
while((oh = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
if (rpmVersionCompare(h, oh))
|
|
|
|
xx = removePackage(ts, oh, rpmdbGetIteratorOffset(mi), pkgKey);
|
|
|
|
}
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
obsoletes = rpmdsLink(rpmteDS(p, RPMTAG_OBSOLETENAME), "Obsoletes");
|
|
|
|
obsoletes = rpmdsInit(obsoletes);
|
2001-11-02 13:36:48 +08:00
|
|
|
if (obsoletes != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
while (rpmdsNext(obsoletes) >= 0) {
|
2001-11-03 07:17:54 +08:00
|
|
|
const char * Name;
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((Name = rpmdsN(obsoletes)) == NULL)
|
2001-11-03 10:34:15 +08:00
|
|
|
continue; /* XXX can't happen */
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2002-12-31 09:23:03 +08:00
|
|
|
/* Ignore colored obsoletes not in our rainbow. */
|
|
|
|
dscolor = rpmdsColor(obsoletes);
|
|
|
|
if (tscolor && dscolor && !(tscolor & dscolor))
|
|
|
|
continue;
|
|
|
|
|
2001-11-02 13:36:48 +08:00
|
|
|
/* XXX avoid self-obsoleting packages. */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (!strcmp(rpmteN(p), Name))
|
1999-09-12 07:57:59 +08:00
|
|
|
continue;
|
|
|
|
|
2001-11-02 13:36:48 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
2002-10-16 02:44:16 +08:00
|
|
|
Header oh;
|
2000-04-13 17:07:08 +08:00
|
|
|
|
2001-11-17 16:02:17 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, 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
|
|
|
|
2002-10-16 02:44:16 +08:00
|
|
|
while((oh = 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.
|
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmdsEVR(obsoletes) == NULL
|
2002-10-16 02:44:16 +08:00
|
|
|
|| rpmdsAnyMatchesDep(oh, obsoletes, _rpmds_nopromote))
|
|
|
|
xx = removePackage(ts, oh, rpmdbGetIteratorOffset(mi), pkgKey);
|
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
|
|
|
}
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
obsoletes = rpmdsFree(obsoletes);
|
2001-11-02 13:36:48 +08:00
|
|
|
|
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:
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2001-10-28 04:09:20 +08:00
|
|
|
return ec;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
int rpmtsAddEraseElement(rpmts 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
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
2002-05-02 06:13:00 +08:00
|
|
|
* Check dep for an unsatisfied dependency.
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param ts transaction set
|
2002-05-02 06:13:00 +08:00
|
|
|
* @param dep dependency
|
2002-07-30 07:06:06 +08:00
|
|
|
* @param adding dependency is from added package set?
|
2000-08-23 20:39:49 +08:00
|
|
|
* @return 0 if satisfied, 1 if not satisfied, 2 if error
|
|
|
|
*/
|
2002-07-30 07:06:06 +08:00
|
|
|
static int unsatisfiedDepend(rpmts ts, rpmds dep, int adding)
|
2002-07-22 06:06:19 +08:00
|
|
|
/*@globals _cacheDependsRC, rpmGlobalMacroContext,
|
|
|
|
fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, _cacheDependsRC, rpmGlobalMacroContext,
|
|
|
|
fileSystem, internalState @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2002-05-02 06:13:00 +08:00
|
|
|
DBT * key = alloca(sizeof(*key));
|
|
|
|
DBT * data = alloca(sizeof(*data));
|
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;
|
2002-07-30 07:06:06 +08:00
|
|
|
int _cacheThisRC = 1;
|
2001-11-03 07:17:54 +08:00
|
|
|
int rc;
|
2002-04-13 09:28:20 +08:00
|
|
|
int xx;
|
2002-08-14 00:36:44 +08:00
|
|
|
int retrying = 0;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((Name = rpmdsN(dep)) == NULL)
|
2001-11-03 10:34:15 +08:00
|
|
|
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;
|
2002-05-18 05:08:39 +08:00
|
|
|
dbi = dbiOpen(rpmtsGetRdb(ts), 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;
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@-branchstate@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((DNEVR = rpmdsDNEVR(dep)) != NULL) {
|
2001-11-03 10:34:15 +08:00
|
|
|
DBC * dbcursor = NULL;
|
|
|
|
void * datap = NULL;
|
|
|
|
size_t datalen = 0;
|
|
|
|
size_t DNEVRlen = strlen(DNEVR);
|
|
|
|
|
2002-05-02 06:13:00 +08:00
|
|
|
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, 0);
|
|
|
|
|
|
|
|
memset(key, 0, sizeof(*key));
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@i@*/ key->data = (void *) DNEVR;
|
2002-05-02 06:13:00 +08:00
|
|
|
key->size = DNEVRlen;
|
|
|
|
memset(data, 0, sizeof(*data));
|
|
|
|
data->data = datap;
|
|
|
|
data->size = datalen;
|
2002-05-05 00:41:01 +08:00
|
|
|
xx = dbiGet(dbi, dbcursor, key, data, DB_SET);
|
2002-05-02 06:13:00 +08:00
|
|
|
DNEVR = key->data;
|
|
|
|
DNEVRlen = key->size;
|
|
|
|
datap = data->data;
|
|
|
|
datalen = data->size;
|
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-03 10:34:15 +08:00
|
|
|
if (xx == 0 && datap && datalen == 4)
|
|
|
|
memcpy(&rc, datap, datalen);
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2001-11-03 10:34:15 +08:00
|
|
|
xx = dbiCclose(dbi, dbcursor, 0);
|
|
|
|
}
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@=branchstate@*/
|
2001-11-03 07:17:54 +08:00
|
|
|
|
|
|
|
if (rc >= 0) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmdsNotify(dep, _("(cached)"), rc);
|
2000-05-07 08:53:11 +08:00
|
|
|
return rc;
|
|
|
|
}
|
2000-04-26 03:41:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-14 00:36:44 +08:00
|
|
|
retry:
|
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;
|
2002-05-20 02:42:25 +08:00
|
|
|
int_32 Flags = rpmdsFlags(dep);
|
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@*/
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
2001-04-29 09:05:43 +08:00
|
|
|
if (xisspace(start[i]) || start[i] == '\0' || start[i] == ',') {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmdsNotify(dep, _("(rpmrc provides)"), rc);
|
1999-09-19 08:29:44 +08:00
|
|
|
goto exit;
|
1999-09-24 22:54:23 +08:00
|
|
|
}
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
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)) {
|
2002-05-02 06:13:00 +08:00
|
|
|
if (rpmCheckRpmlibProvides(dep)) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmdsNotify(dep, _("(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. */
|
2002-07-30 07:06:06 +08:00
|
|
|
if (rpmalSatisfiesDepend(ts->addedPackages, dep, NULL) != NULL) {
|
|
|
|
/*
|
|
|
|
* XXX Ick, context sensitive answers from dependency cache.
|
|
|
|
* XXX Always resolve added dependencies within context to disambiguate.
|
|
|
|
*/
|
|
|
|
if (_rpmds_nopromote)
|
|
|
|
_cacheThisRC = 0;
|
1999-09-19 08:29:44 +08:00
|
|
|
goto exit;
|
2002-07-30 07:06:06 +08:00
|
|
|
}
|
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. */
|
2002-05-18 05:08:39 +08:00
|
|
|
if (rpmtsGetRdb(ts) != NULL) {
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
2001-11-03 07:17:54 +08:00
|
|
|
if (Name[0] == '/') {
|
2002-05-02 06:13:00 +08:00
|
|
|
/* depFlags 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) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmdsNotify(dep, _("(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
|
|
|
}
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
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) {
|
2002-07-30 07:06:06 +08:00
|
|
|
if (rpmdsAnyMatchesDep(h, dep, _rpmds_nopromote)) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmdsNotify(dep, _("(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) {
|
2002-07-30 07:06:06 +08:00
|
|
|
if (rpmdsAnyMatchesDep(h, dep, _rpmds_nopromote)) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmdsNotify(dep, _("(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
|
|
|
}
|
|
|
|
|
2002-04-13 09:28:20 +08:00
|
|
|
/*
|
2002-04-15 05:48:44 +08:00
|
|
|
* Search for an unsatisfied dependency.
|
2002-04-13 09:28:20 +08:00
|
|
|
*/
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
2002-08-14 00:36:44 +08:00
|
|
|
if (adding && !retrying && !(rpmtsFlags(ts) & RPMTRANS_FLAG_NOSUGGEST)) {
|
|
|
|
if (ts->solve != NULL) {
|
2002-08-10 06:25:04 +08:00
|
|
|
xx = (*ts->solve) (ts, dep, ts->solveData);
|
2002-08-14 00:36:44 +08:00
|
|
|
if (xx == 0)
|
|
|
|
goto exit;
|
|
|
|
if (xx == -1) {
|
|
|
|
retrying = 1;
|
|
|
|
rpmalMakeIndex(ts->addedPackages);
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
}
|
2002-07-30 07:06:06 +08:00
|
|
|
}
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
2002-04-13 09:28:20 +08:00
|
|
|
|
2000-11-01 02:24:05 +08:00
|
|
|
unsatisfied:
|
1999-09-19 08:29:44 +08:00
|
|
|
rc = 1; /* dependency is unsatisfied */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmdsNotify(dep, 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.
|
|
|
|
*/
|
2002-07-30 07:06:06 +08:00
|
|
|
if (_cacheDependsRC && _cacheThisRC) {
|
2000-05-02 16:30:31 +08:00
|
|
|
dbiIndex dbi;
|
2002-05-18 05:08:39 +08:00
|
|
|
dbi = dbiOpen(rpmtsGetRdb(ts), 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;
|
2002-04-13 09:28:20 +08:00
|
|
|
xx = 0;
|
2002-05-03 06:16:30 +08:00
|
|
|
/*@-branchstate@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((DNEVR = rpmdsDNEVR(dep)) != 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);
|
2002-05-02 06:13:00 +08:00
|
|
|
|
2002-05-03 06:16:30 +08:00
|
|
|
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
|
2002-05-02 06:13:00 +08:00
|
|
|
|
|
|
|
memset(key, 0, sizeof(*key));
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@i@*/ key->data = (void *) DNEVR;
|
2002-05-02 06:13:00 +08:00
|
|
|
key->size = DNEVRlen;
|
|
|
|
memset(data, 0, sizeof(*data));
|
|
|
|
data->data = &rc;
|
|
|
|
data->size = sizeof(rc);
|
|
|
|
|
2002-05-03 06:16:30 +08:00
|
|
|
/*@-compmempass@*/
|
|
|
|
xx = dbiPut(dbi, dbcursor, key, data, 0);
|
|
|
|
/*@=compmempass@*/
|
|
|
|
xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
|
2001-11-03 05:01:25 +08:00
|
|
|
}
|
2002-05-03 06:16:30 +08:00
|
|
|
/*@=branchstate@*/
|
2000-05-07 08:53:11 +08:00
|
|
|
if (xx)
|
2000-05-02 16:30:31 +08:00
|
|
|
_cacheDependsRC = 0;
|
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
|
|
|
/**
|
2002-06-29 05:54:24 +08:00
|
|
|
* Check added requires/conflicts against against installed+added packages.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @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)
|
2002-05-02 06:13:00 +08:00
|
|
|
* @param depName dependency name to filter (or NULL)
|
2002-12-31 09:23:03 +08:00
|
|
|
* @param tscolor color bits for transaction set (0 disables)
|
2002-06-29 05:54:24 +08:00
|
|
|
* @param adding dependency is from added package set?
|
2001-06-01 06:31:14 +08:00
|
|
|
* @return 0 no problems found
|
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int checkPackageDeps(rpmts ts, const char * pkgNEVR,
|
|
|
|
/*@null@*/ rpmds requires, /*@null@*/ rpmds conflicts,
|
2002-12-31 09:23:03 +08:00
|
|
|
/*@null@*/ const char * depName, uint_32 tscolor, int adding)
|
2002-07-22 06:06:19 +08:00
|
|
|
/*@globals rpmGlobalMacroContext,
|
|
|
|
fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, requires, conflicts, rpmGlobalMacroContext,
|
|
|
|
fileSystem, internalState */
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
uint_32 dscolor;
|
2001-11-03 07:17:54 +08:00
|
|
|
const char * Name;
|
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
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
requires = rpmdsInit(requires);
|
2001-11-02 13:36:48 +08:00
|
|
|
if (requires != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
while (!ourrc && rpmdsNext(requires) >= 0) {
|
1999-09-14 13:41:13 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((Name = rpmdsN(requires)) == NULL)
|
2001-11-03 10:34:15 +08:00
|
|
|
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. */
|
2002-05-02 06:13:00 +08:00
|
|
|
if (depName != NULL && strcmp(depName, Name))
|
1999-09-19 08:29:44 +08:00
|
|
|
continue;
|
|
|
|
|
2002-12-31 09:23:03 +08:00
|
|
|
/* Ignore colored requires not in our rainbow. */
|
|
|
|
dscolor = rpmdsColor(requires);
|
|
|
|
if (tscolor && dscolor && !(tscolor & dscolor))
|
2000-07-06 04:39:15 +08:00
|
|
|
continue;
|
|
|
|
|
2002-07-30 07:06:06 +08:00
|
|
|
rc = unsatisfiedDepend(ts, requires, adding);
|
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) {
|
2002-05-28 02:12:12 +08:00
|
|
|
suggestedKeys = rpmalAllSatisfiesDepend(ts->availablePackages,
|
2001-11-08 08:12:49 +08:00
|
|
|
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
|
|
|
|
2002-06-29 05:54:24 +08:00
|
|
|
rpmdsProblem(ts->probs, pkgNEVR, requires, suggestedKeys, adding);
|
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
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
conflicts = rpmdsInit(conflicts);
|
2001-11-02 13:36:48 +08:00
|
|
|
if (conflicts != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
while (!ourrc && rpmdsNext(conflicts) >= 0) {
|
1999-09-14 13:41:13 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((Name = rpmdsN(conflicts)) == NULL)
|
2001-11-03 10:34:15 +08:00
|
|
|
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. */
|
2002-05-02 06:13:00 +08:00
|
|
|
if (depName != NULL && strcmp(depName, Name))
|
1999-09-19 08:29:44 +08:00
|
|
|
continue;
|
|
|
|
|
2002-12-31 09:23:03 +08:00
|
|
|
/* Ignore colored conflicts not in our rainbow. */
|
|
|
|
dscolor = rpmdsColor(conflicts);
|
|
|
|
if (tscolor && dscolor && !(tscolor & dscolor))
|
2000-07-06 04:39:15 +08:00
|
|
|
continue;
|
|
|
|
|
2002-07-30 07:06:06 +08:00
|
|
|
rc = unsatisfiedDepend(ts, conflicts, adding);
|
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. */
|
2002-06-29 05:54:24 +08:00
|
|
|
rpmdsProblem(ts->probs, pkgNEVR, conflicts, NULL, adding);
|
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.
|
2002-05-02 06:13:00 +08:00
|
|
|
* Adding: check name/provides dep against each conflict match,
|
|
|
|
* Erasing: check name/provides/filename dep against each requiredby match.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param ts transaction set
|
2002-05-02 06:13:00 +08:00
|
|
|
* @param dep dependency name
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param mi rpm database iterator
|
2002-06-29 05:54:24 +08:00
|
|
|
* @param adding dependency is from added package set?
|
2001-06-01 06:31:14 +08:00
|
|
|
* @return 0 no problems found
|
2000-09-27 02:04:12 +08:00
|
|
|
*/
|
2002-06-29 05:54:24 +08:00
|
|
|
static int checkPackageSet(rpmts ts, const char * dep,
|
|
|
|
/*@only@*/ /*@null@*/ rpmdbMatchIterator mi, int adding)
|
2002-07-22 06:06:19 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, mi, rpmGlobalMacroContext, fileSystem, internalState @*/
|
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;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds requires, conflicts;
|
2001-11-11 08:11:33 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
pkgNEVR = hGetNEVR(h, NULL);
|
2002-05-20 02:42:25 +08:00
|
|
|
requires = rpmdsNew(h, RPMTAG_REQUIRENAME, scareMem);
|
2002-07-30 07:06:06 +08:00
|
|
|
(void) rpmdsSetNoPromote(requires, _rpmds_nopromote);
|
2002-05-20 02:42:25 +08:00
|
|
|
conflicts = rpmdsNew(h, RPMTAG_CONFLICTNAME, scareMem);
|
2002-07-30 07:06:06 +08:00
|
|
|
(void) rpmdsSetNoPromote(requires, _rpmds_nopromote);
|
2002-06-29 05:54:24 +08:00
|
|
|
rc = checkPackageDeps(ts, pkgNEVR, requires, conflicts, dep, 0, adding);
|
2002-05-20 02:42:25 +08:00
|
|
|
conflicts = rpmdsFree(conflicts);
|
|
|
|
requires = rpmdsFree(requires);
|
2001-11-11 08:11:33 +08:00
|
|
|
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
|
|
|
/**
|
2002-06-29 05:54:24 +08:00
|
|
|
* Check to-be-erased dependencies against installed requires.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param ts transaction set
|
2002-05-02 06:13:00 +08:00
|
|
|
* @param dep requires name
|
2001-06-01 06:31:14 +08:00
|
|
|
* @return 0 no problems found
|
2000-09-27 02:04:12 +08:00
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int checkDependentPackages(rpmts ts, const char * dep)
|
2002-07-22 06:06:19 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-04-13 18:11:32 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2002-05-02 06:13:00 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_REQUIRENAME, dep, 0);
|
2002-06-29 05:54:24 +08:00
|
|
|
return checkPackageSet(ts, dep, mi, 0);
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/**
|
2002-06-29 05:54:24 +08:00
|
|
|
* Check to-be-added dependencies against installed conflicts.
|
2001-06-01 06:31:14 +08:00
|
|
|
* @param ts transaction set
|
2002-05-02 06:13:00 +08:00
|
|
|
* @param dep conflicts name
|
2001-06-01 06:31:14 +08:00
|
|
|
* @return 0 no problems found
|
2000-09-27 02:04:12 +08:00
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int checkDependentConflicts(rpmts ts, const char * dep)
|
2002-07-22 06:06:19 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/
|
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
|
|
|
|
2002-05-18 05:08:39 +08:00
|
|
|
if (rpmtsGetRdb(ts) != NULL) { /* XXX is this necessary? */
|
2000-04-13 18:11:32 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2002-05-02 06:13:00 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_CONFLICTNAME, dep, 0);
|
2002-06-29 05:54:24 +08:00
|
|
|
rc = checkPackageSet(ts, dep, mi, 1);
|
2000-03-23 23:49:50 +08:00
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-01-31 06:19:56 +08:00
|
|
|
struct badDeps_s {
|
2002-03-14 01:59:49 +08:00
|
|
|
/*@observer@*/ /*@owned@*/ /*@null@*/
|
|
|
|
const char * pname;
|
|
|
|
/*@observer@*/ /*@dependent@*/ /*@null@*/
|
|
|
|
const char * qname;
|
2002-01-31 06:19:56 +08:00
|
|
|
};
|
2000-11-12 19:11:49 +08:00
|
|
|
|
2002-05-02 06:13:00 +08:00
|
|
|
#ifdef REFERENCE
|
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 }
|
|
|
|
};
|
2002-01-31 06:19:56 +08:00
|
|
|
#else
|
2002-05-07 09:07:41 +08:00
|
|
|
/*@unchecked@*/
|
|
|
|
static int badDepsInitialized = 0;
|
|
|
|
|
2002-02-10 06:39:29 +08:00
|
|
|
/*@unchecked@*/ /*@only@*/ /*@null@*/
|
2002-01-31 06:19:56 +08:00
|
|
|
static struct badDeps_s * badDeps = NULL;
|
|
|
|
#endif
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2002-05-07 09:07:41 +08:00
|
|
|
/**
|
|
|
|
*/
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@-modobserver -observertrans @*/
|
2002-05-07 09:07:41 +08:00
|
|
|
static void freeBadDeps(void)
|
|
|
|
/*@globals badDeps, badDepsInitialized @*/
|
|
|
|
/*@modifies badDeps, badDepsInitialized @*/
|
|
|
|
{
|
|
|
|
if (badDeps) {
|
|
|
|
struct badDeps_s * bdp;
|
|
|
|
for (bdp = badDeps; bdp->pname != NULL && bdp->qname != NULL; bdp++)
|
|
|
|
bdp->pname = _free(bdp->pname);
|
|
|
|
badDeps = _free(badDeps);
|
|
|
|
}
|
|
|
|
badDepsInitialized = 0;
|
|
|
|
}
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@=modobserver =observertrans @*/
|
2002-05-07 09:07:41 +08:00
|
|
|
|
2002-01-31 06:19:56 +08:00
|
|
|
/**
|
|
|
|
* Check for dependency relations to be ignored.
|
|
|
|
*
|
|
|
|
* @param p successor element (i.e. with Requires: )
|
|
|
|
* @param q predecessor element (i.e. with Provides: )
|
|
|
|
* @return 1 if dependency is to be ignored.
|
|
|
|
*/
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int ignoreDep(const rpmte p, const rpmte q)
|
2002-05-07 09:07:41 +08:00
|
|
|
/*@globals badDeps, badDepsInitialized @*/
|
|
|
|
/*@modifies badDeps, badDepsInitialized @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2002-01-31 06:19:56 +08:00
|
|
|
struct badDeps_s * bdp;
|
|
|
|
|
2002-02-10 06:39:29 +08:00
|
|
|
/*@-globs -mods@*/
|
2002-05-07 09:07:41 +08:00
|
|
|
if (!badDepsInitialized) {
|
2002-01-31 06:19:56 +08:00
|
|
|
char * s = rpmExpand("%{?_dependency_whiteout}", NULL);
|
2002-02-10 06:39:29 +08:00
|
|
|
const char ** av = NULL;
|
|
|
|
int ac = 0;
|
2002-01-31 06:19:56 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (s != NULL && *s != '\0'
|
|
|
|
&& !(i = poptParseArgvString(s, &ac, (const char ***)&av))
|
|
|
|
&& ac > 0 && av != NULL)
|
|
|
|
{
|
|
|
|
bdp = badDeps = xcalloc(ac+1, sizeof(*badDeps));
|
|
|
|
for (i = 0; i < ac; i++, bdp++) {
|
2002-02-10 06:39:29 +08:00
|
|
|
char * pname, * qname;
|
2002-01-31 06:19:56 +08:00
|
|
|
|
|
|
|
if (av[i] == NULL)
|
|
|
|
break;
|
2002-02-10 06:39:29 +08:00
|
|
|
pname = xstrdup(av[i]);
|
|
|
|
if ((qname = strchr(pname, '>')) != NULL)
|
|
|
|
*qname++ = '\0';
|
|
|
|
bdp->pname = pname;
|
|
|
|
/*@-usereleased@*/
|
|
|
|
bdp->qname = qname;
|
|
|
|
/*@=usereleased@*/
|
2002-01-31 06:19:56 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
|
|
|
_("ignore package name relation(s) [%d]\t%s -> %s\n"),
|
2002-02-10 06:39:29 +08:00
|
|
|
i, bdp->pname, (bdp->qname ? bdp->qname : "???"));
|
2002-01-31 06:19:56 +08:00
|
|
|
}
|
2002-02-10 06:39:29 +08:00
|
|
|
bdp->pname = NULL;
|
|
|
|
bdp->qname = NULL;
|
2002-01-31 06:19:56 +08:00
|
|
|
}
|
|
|
|
av = _free(av);
|
|
|
|
s = _free(s);
|
2002-05-07 09:07:41 +08:00
|
|
|
badDepsInitialized++;
|
2002-01-31 06:19:56 +08:00
|
|
|
}
|
2002-02-10 06:39:29 +08:00
|
|
|
/*@=globs =mods@*/
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2002-02-10 06:39:29 +08:00
|
|
|
/*@-compdef@*/
|
2002-01-31 06:19:56 +08:00
|
|
|
if (badDeps != NULL)
|
|
|
|
for (bdp = badDeps; bdp->pname != NULL && bdp->qname != NULL; bdp++) {
|
2002-05-20 02:42:25 +08:00
|
|
|
if (!strcmp(rpmteN(p), bdp->pname) && !strcmp(rpmteN(q), bdp->qname))
|
2000-09-27 02:04:12 +08:00
|
|
|
return 1;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
2000-09-27 02:04:12 +08:00
|
|
|
return 0;
|
2002-02-10 06:39:29 +08:00
|
|
|
/*@=compdef@*/
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
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
|
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static void markLoop(/*@special@*/ tsortInfo tsi, rpmte 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
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmte 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;
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteTSI(p)->tsi_chain != NULL)
|
2000-09-27 02:04:12 +08:00
|
|
|
continue;
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@-assignexpose -temptrans@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_chain = q;
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@=assignexpose =temptrans@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteTSI(p)->tsi_next != NULL)
|
|
|
|
markLoop(rpmteTSI(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")
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param requires relation
|
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)
|
|
|
|
*/
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
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 *
|
2002-05-20 02:42:25 +08:00
|
|
|
zapRelation(rpmte q, rpmte p,
|
|
|
|
/*@null@*/ rpmds 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;
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
for (tsi_prev = rpmteTSI(q), tsi = rpmteTSI(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;
|
|
|
|
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@-abstractcompare@*/
|
2000-09-27 02:04:12 +08:00
|
|
|
if (tsi->tsi_suc != p)
|
|
|
|
continue;
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@=abstractcompare@*/
|
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
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmdsSetIx(requires, tsi->tsi_reqx);
|
2001-11-03 07:17:54 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
Flags = rpmdsFlags(requires);
|
2001-11-03 07:17:54 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
dp = rpmdsNewDNEVR( 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"),
|
2002-05-20 02:42:25 +08:00
|
|
|
(rpmteNEVR(p) ? rpmteNEVR(p) : "???"), dp);
|
|
|
|
rpmteTSI(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@*/
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
1997-07-02 00:24:08 +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
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param requires relation
|
2000-11-12 19:11:49 +08:00
|
|
|
* @return 0 always
|
|
|
|
*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-mustmod@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static inline int addRelation(rpmts ts,
|
|
|
|
/*@dependent@*/ rpmte p,
|
2001-11-13 04:51:05 +08:00
|
|
|
unsigned char * selected,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds requires)
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies ts, p, *selected, fileSystem @*/
|
2000-11-12 19:11:49 +08:00
|
|
|
{
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmtsi qi; rpmte 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
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((Name = rpmdsN(requires)) == NULL)
|
2003-01-26 04:59:52 +08:00
|
|
|
return 0;
|
2001-11-05 11:44:05 +08:00
|
|
|
|
|
|
|
/* Avoid rpmlib feature dependencies. */
|
|
|
|
if (!strncmp(Name, "rpmlib(", sizeof("rpmlib(")-1))
|
|
|
|
return 0;
|
|
|
|
|
2003-01-26 04:59:52 +08:00
|
|
|
/* Avoid package config dependencies. */
|
|
|
|
if (!strncmp(Name, "config(", sizeof("config(")-1))
|
|
|
|
return 0;
|
|
|
|
|
2001-11-08 08:12:49 +08:00
|
|
|
pkgKey = RPMAL_NOMATCH;
|
2002-05-28 02:12:12 +08:00
|
|
|
key = rpmalSatisfiesDepend(ts->addedPackages, requires, &pkgKey);
|
2001-11-05 11:44:05 +08:00
|
|
|
|
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 */
|
2002-05-28 05:40:08 +08:00
|
|
|
for (qi = rpmtsiInit(ts), i = 0; (q = rpmtsiNext(qi, 0)) != NULL; i++) {
|
2002-05-20 02:42:25 +08:00
|
|
|
|
2001-11-17 06:42:19 +08:00
|
|
|
/* XXX Only added packages need be checked for matches. */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteType(q) == TR_REMOVED)
|
2001-11-17 06:42:19 +08:00
|
|
|
continue;
|
2002-05-20 02:42:25 +08:00
|
|
|
|
|
|
|
if (pkgKey == rpmteAddedKey(q))
|
2001-11-01 06:19:42 +08:00
|
|
|
break;
|
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
qi = rpmtsiFree(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
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* Avoid redundant relations. */
|
2001-06-20 04:03:13 +08:00
|
|
|
/* XXX TODO: add control bit. */
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
if (selected[i] != 0)
|
2000-11-12 19:11:49 +08:00
|
|
|
return 0;
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-01 06:19:42 +08:00
|
|
|
selected[i] = 1;
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2000-11-12 19:11:49 +08:00
|
|
|
|
|
|
|
/* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_count++; /* bump p predecessor count */
|
2001-11-17 16:02:17 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteDepth(p) <= rpmteDepth(q)) /* Save max. depth in dependency tree */
|
|
|
|
(void) rpmteSetDepth(p, (rpmteDepth(q) + 1));
|
2001-11-17 16:02:17 +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
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
tsi->tsi_reqx = rpmdsIx(requires);
|
2001-11-03 10:34:15 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
tsi->tsi_next = rpmteTSI(q)->tsi_next;
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@-mods@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(q)->tsi_next = tsi;
|
|
|
|
rpmteTSI(q)->tsi_qcnt++; /* bump q successor count */
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@=mods@*/
|
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).
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param one 1st ordered list entry
|
|
|
|
* @param two 2nd ordered list entry
|
2000-08-23 20:39:49 +08:00
|
|
|
* @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
|
|
|
/**
|
2001-11-18 19:46:22 +08:00
|
|
|
* Add element to list sorting by tsi_qcnt.
|
2001-01-09 12:07:49 +08:00
|
|
|
* @param p new element
|
|
|
|
* @retval qp address of first element
|
|
|
|
* @retval rp address of last element
|
|
|
|
*/
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-mustmod@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static void addQ(/*@dependent@*/ rpmte p,
|
|
|
|
/*@in@*/ /*@out@*/ rpmte * qp,
|
|
|
|
/*@in@*/ /*@out@*/ rpmte * rp)
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@modifies p, *qp, *rp @*/
|
2001-01-09 12:07:49 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmte q, qprev;
|
2001-01-09 12:07:49 +08:00
|
|
|
|
2001-11-18 19:46:22 +08:00
|
|
|
/* Mark the package as queued. */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_reqx = 1;
|
2001-11-18 19:46:22 +08:00
|
|
|
|
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-18 19:46:22 +08:00
|
|
|
|
|
|
|
/* Find location in queue using metric tsi_qcnt. */
|
|
|
|
for (qprev = NULL, q = (*qp);
|
|
|
|
q != NULL;
|
2002-05-20 02:42:25 +08:00
|
|
|
qprev = q, q = rpmteTSI(q)->tsi_suc)
|
2001-11-18 19:46:22 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteTSI(q)->tsi_qcnt <= rpmteTSI(p)->tsi_qcnt)
|
2001-01-09 12:07:49 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-11-18 04:44:16 +08:00
|
|
|
|
2001-01-09 12:07:49 +08:00
|
|
|
if (qprev == NULL) { /* insert at beginning of list */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_suc = q;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-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 */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(qprev)->tsi_suc = p;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-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 */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_suc = q;
|
|
|
|
rpmteTSI(qprev)->tsi_suc = p;
|
2001-01-09 12:07:49 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=mustmod@*/
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2001-01-09 12:07:49 +08:00
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-bounds@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
int rpmtsOrder(rpmts ts)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds requires;
|
2002-01-05 02:34:04 +08:00
|
|
|
int_32 Flags;
|
2003-01-26 04:59:52 +08:00
|
|
|
int anaconda = rpmtsFlags(ts) & RPMTRANS_FLAG_ANACONDA;
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmtsi pi; rpmte p;
|
|
|
|
rpmtsi qi; rpmte q;
|
|
|
|
rpmtsi ri; rpmte r;
|
2001-10-30 04:12:35 +08:00
|
|
|
tsortInfo tsi;
|
|
|
|
tsortInfo tsi_next;
|
2001-11-18 04:44:16 +08:00
|
|
|
alKey * ordering;
|
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;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmte * newOrder;
|
1999-04-05 05:26:36 +08:00
|
|
|
int newOrderCount = 0;
|
2001-10-29 06:17:47 +08:00
|
|
|
orderListIndex orderList;
|
2001-11-18 04:44:16 +08:00
|
|
|
int numOrderList;
|
2000-09-27 02:04:12 +08:00
|
|
|
int nrescans = 10;
|
2001-01-17 05:54:59 +08:00
|
|
|
int _printed = 0;
|
2001-11-18 19:46:22 +08:00
|
|
|
char deptypechar;
|
2003-01-26 04:59:52 +08:00
|
|
|
size_t tsbytes;
|
2001-11-18 04:44:16 +08:00
|
|
|
int oType = 0;
|
2002-01-05 11:23:42 +08:00
|
|
|
int treex;
|
|
|
|
int depth;
|
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
|
|
|
|
2002-08-14 00:36:44 +08:00
|
|
|
#ifdef DYING
|
2002-05-28 02:12:12 +08:00
|
|
|
rpmalMakeIndex(ts->addedPackages);
|
2002-08-14 00:36:44 +08:00
|
|
|
#endif
|
2001-11-01 06:19:42 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/* T1. Initialize. */
|
2001-11-18 04:44:16 +08:00
|
|
|
if (oType == 0)
|
|
|
|
numOrderList = ts->orderCount;
|
|
|
|
else {
|
|
|
|
numOrderList = 0;
|
|
|
|
if (oType & TR_ADDED)
|
|
|
|
numOrderList += ts->numAddedPackages;
|
|
|
|
if (oType & TR_REMOVED)
|
|
|
|
numOrderList += ts->numRemovedPackages;
|
|
|
|
}
|
|
|
|
ordering = alloca(sizeof(*ordering) * (numOrderList + 1));
|
|
|
|
loopcheck = numOrderList;
|
2003-01-26 04:59:52 +08:00
|
|
|
tsbytes = 0;
|
2001-11-18 04:44:16 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, oType)) != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteNewTSI(p);
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(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"));
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
1997-07-18 23:03:35 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((requires = rpmteDS(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. */
|
2002-05-28 05:40:08 +08:00
|
|
|
selected[rpmtsiOc(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. */
|
2002-05-20 02:42:25 +08:00
|
|
|
requires = rpmdsInit(requires);
|
2001-11-03 05:01:25 +08:00
|
|
|
if (requires != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
while (rpmdsNext(requires) >= 0) {
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
Flags = rpmdsFlags(requires);
|
2001-11-03 07:17:54 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
2001-11-18 04:44:16 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
/* Skip if not %preun/%postun requires or legacy prereq. */
|
|
|
|
if (isInstallPreReq(Flags)
|
2003-01-26 04:59:52 +08:00
|
|
|
|| !( isErasePreReq(Flags) || isLegacyPreReq(Flags) ) )
|
2001-11-18 04:44:16 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-11-18 04:44:16 +08:00
|
|
|
case TR_ADDED:
|
|
|
|
/* Skip if not %pre/%post requires or legacy prereq. */
|
|
|
|
if (isErasePreReq(Flags)
|
2003-01-26 04:59:52 +08:00
|
|
|
|| !( isInstallPreReq(Flags) || isLegacyPreReq(Flags) ) )
|
2001-11-18 04:44:16 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-11-18 04:44:16 +08:00
|
|
|
}
|
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. */
|
2002-05-20 02:42:25 +08:00
|
|
|
requires = rpmdsInit(requires);
|
2001-11-03 05:01:25 +08:00
|
|
|
if (requires != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
while (rpmdsNext(requires) >= 0) {
|
2000-11-12 19:11:49 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
Flags = rpmdsFlags(requires);
|
2001-11-03 07:17:54 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
2001-11-18 04:44:16 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
/* Skip if %preun/%postun requires or legacy prereq. */
|
|
|
|
if (isInstallPreReq(Flags)
|
2003-01-26 04:59:52 +08:00
|
|
|
|| ( isErasePreReq(Flags) || isLegacyPreReq(Flags) ) )
|
2001-11-18 04:44:16 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-11-18 04:44:16 +08:00
|
|
|
case TR_ADDED:
|
|
|
|
/* Skip if %pre/%post requires or legacy prereq. */
|
|
|
|
if (isErasePreReq(Flags)
|
2003-01-26 04:59:52 +08:00
|
|
|
|| ( isInstallPreReq(Flags) || isLegacyPreReq(Flags) ) )
|
2001-11-18 04:44:16 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-11-18 04:44:16 +08:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2002-01-05 11:23:42 +08:00
|
|
|
/* Save predecessor count and mark tree roots. */
|
|
|
|
treex = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
2002-01-05 11:23:42 +08:00
|
|
|
int npreds;
|
2001-10-30 07:39:51 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
npreds = rpmteTSI(p)->tsi_count;
|
2002-01-05 11:23:42 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmteSetNpreds(p, npreds);
|
2002-01-05 11:23:42 +08:00
|
|
|
|
|
|
|
if (npreds == 0)
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmteSetTree(p, treex++);
|
2002-01-05 11:23:42 +08:00
|
|
|
else
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmteSetTree(p, -1);
|
2002-01-05 11:23:42 +08:00
|
|
|
#ifdef UNNECESSARY
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmteSetParent(p, NULL);
|
2002-01-05 11:23:42 +08:00
|
|
|
#endif
|
2001-11-17 03:26:33 +08:00
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2001-04-21 14:02:09 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/* T4. Scan for zeroes. */
|
2002-01-05 11:23:42 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("========== tsorting packages (order, #predecessors, #succesors, tree, depth)\n"));
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
rescan:
|
2002-05-28 05:40:08 +08:00
|
|
|
if (pi != NULL) pi = rpmtsiFree(pi);
|
2000-09-27 02:04:12 +08:00
|
|
|
q = r = NULL;
|
2001-01-11 06:19:55 +08:00
|
|
|
qlen = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
2001-01-17 01:33:59 +08:00
|
|
|
|
2003-01-26 04:59:52 +08:00
|
|
|
/* Prefer packages in chainsaw or anaconda presentation order. */
|
|
|
|
if (anaconda)
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmteTSI(p)->tsi_qcnt = (ts->orderCount - rpmtsiOc(pi));
|
2001-01-17 01:33:59 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteTSI(p)->tsi_count != 0)
|
2001-01-11 04:42:32 +08:00
|
|
|
continue;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_suc = NULL;
|
2001-01-11 04:42:32 +08:00
|
|
|
addQ(p, &q, &r);
|
|
|
|
qlen++;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(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.) */
|
2002-05-20 02:42:25 +08:00
|
|
|
for (; q != NULL; q = rpmteTSI(q)->tsi_suc) {
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2001-11-18 04:44:16 +08:00
|
|
|
/* Mark the package as unqueued. */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(q)->tsi_reqx = 0;
|
2001-11-18 04:44:16 +08:00
|
|
|
|
|
|
|
if (oType != 0)
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(q)) {
|
2001-11-01 06:19:42 +08:00
|
|
|
case TR_ADDED:
|
2001-11-18 04:44:16 +08:00
|
|
|
if (!(oType & TR_ADDED))
|
|
|
|
continue;
|
2001-11-01 06:19:42 +08:00
|
|
|
/*@switchbreak@*/ break;
|
|
|
|
case TR_REMOVED:
|
2001-11-18 04:44:16 +08:00
|
|
|
if (!(oType & TR_REMOVED))
|
|
|
|
continue;
|
|
|
|
/*@switchbreak@*/ break;
|
2001-11-01 06:19:42 +08:00
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
/*@notreached@*/ /*@switchbreak@*/ break;
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
deptypechar = (rpmteType(q) == TR_REMOVED ? '-' : '+');
|
2001-11-01 06:19:42 +08:00
|
|
|
|
2002-01-05 11:23:42 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "%5d%5d%5d%5d%5d %*s%c%s\n",
|
2002-05-20 02:42:25 +08:00
|
|
|
orderingCount, rpmteNpreds(q),
|
|
|
|
rpmteTSI(q)->tsi_qcnt, rpmteTree(q), rpmteDepth(q),
|
|
|
|
(2 * rpmteDepth(q)), "",
|
2001-11-18 04:44:16 +08:00
|
|
|
deptypechar,
|
2002-05-20 02:42:25 +08:00
|
|
|
(rpmteNEVR(q) ? rpmteNEVR(q) : "???"));
|
2001-11-17 16:02:17 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
treex = rpmteTree(q);
|
|
|
|
depth = rpmteDepth(q);
|
|
|
|
(void) rpmteSetDegree(q, 0);
|
2003-01-26 04:59:52 +08:00
|
|
|
tsbytes += rpmtePkgFileSize(q);
|
2002-01-05 11:23:42 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
ordering[orderingCount] = rpmteAddedKey(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. */
|
2002-05-20 02:42:25 +08:00
|
|
|
tsi_next = rpmteTSI(q)->tsi_next;
|
|
|
|
rpmteTSI(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;
|
2002-05-20 02:42:25 +08:00
|
|
|
if (p && (--rpmteTSI(p)->tsi_count) <= 0) {
|
2002-01-05 11:23:42 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmteSetTree(p, treex);
|
|
|
|
(void) rpmteSetDepth(p, depth+1);
|
|
|
|
(void) rpmteSetParent(p, q);
|
|
|
|
(void) rpmteSetDegree(q, rpmteDegree(q)+1);
|
2002-01-05 11:23:42 +08:00
|
|
|
|
2001-06-20 04:03:13 +08:00
|
|
|
/* XXX TODO: add control bit. */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_suc = NULL;
|
|
|
|
addQ(p, &rpmteTSI(q)->tsi_suc, &r);
|
2001-01-09 12:07:49 +08:00
|
|
|
qlen++;
|
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
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
if (!_printed && loopcheck == qlen && rpmteTSI(q)->tsi_suc != NULL) {
|
2001-01-17 05:54:59 +08:00
|
|
|
_printed++;
|
2002-08-20 06:27:44 +08:00
|
|
|
(void) rpmtsUnorderedSuccessors(ts, orderingCount);
|
2001-01-17 05:54:59 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
2003-01-26 04:59:52 +08:00
|
|
|
_("========== successors only (%d bytes)\n"), (int)tsbytes);
|
2001-11-18 04:44:16 +08:00
|
|
|
|
|
|
|
/* Relink the queue in presentation order. */
|
2002-05-20 02:42:25 +08:00
|
|
|
tsi = rpmteTSI(q);
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
2001-11-18 04:44:16 +08:00
|
|
|
/* Is this element in the queue? */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteTSI(p)->tsi_reqx == 0)
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-11-18 04:44:16 +08:00
|
|
|
tsi->tsi_suc = p;
|
2002-05-20 02:42:25 +08:00
|
|
|
tsi = rpmteTSI(p);
|
2001-11-18 04:44:16 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2001-11-18 04:44:16 +08:00
|
|
|
tsi->tsi_suc = NULL;
|
2001-01-17 05:54:59 +08:00
|
|
|
}
|
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;
|
2002-05-28 05:40:08 +08:00
|
|
|
qi = rpmtsiInit(ts);
|
|
|
|
while ((q = rpmtsiNext(qi, oType)) != NULL) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(q)->tsi_chain = NULL;
|
|
|
|
rpmteTSI(q)->tsi_reqx = 0;
|
2000-09-27 02:04:12 +08:00
|
|
|
/* Mark packages already sorted. */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteTSI(q)->tsi_count == 0)
|
|
|
|
rpmteTSI(q)->tsi_count = -1;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
qi = rpmtsiFree(qi);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* T10. Mark all packages with their predecessors. */
|
2002-05-28 05:40:08 +08:00
|
|
|
qi = rpmtsiInit(ts);
|
|
|
|
while ((q = rpmtsiNext(qi, oType)) != NULL) {
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((tsi = rpmteTSI(q)->tsi_next) == NULL)
|
2000-09-27 02:04:12 +08:00
|
|
|
continue;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(q)->tsi_next = NULL;
|
2000-09-27 02:04:12 +08:00
|
|
|
markLoop(tsi, q);
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(q)->tsi_next = tsi;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
qi = rpmtsiFree(qi);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* T11. Print all dependency loops. */
|
2002-05-28 05:40:08 +08:00
|
|
|
ri = rpmtsiInit(ts);
|
|
|
|
while ((r = rpmtsiNext(ri, oType)) != NULL)
|
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. */
|
2002-05-20 02:42:25 +08:00
|
|
|
for (q = rpmteTSI(r)->tsi_chain; q != NULL;
|
|
|
|
q = rpmteTSI(q)->tsi_chain)
|
2001-11-17 16:02:17 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteTSI(q)->tsi_reqx)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(q)->tsi_reqx = 1;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* T13. Print predecessor chain from start of loop. */
|
2002-05-20 02:42:25 +08:00
|
|
|
while ((p = q) != NULL && (q = rpmteTSI(p)->tsi_chain) != NULL) {
|
2000-09-27 02:04:12 +08:00
|
|
|
const char * dp;
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
/* Unchain predecessor loop. */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(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. */
|
2002-05-20 02:42:25 +08:00
|
|
|
requires = rpmteDS(p, RPMTAG_REQUIRENAME);
|
|
|
|
requires = rpmdsInit(requires);
|
2001-11-17 16:02:17 +08:00
|
|
|
if (requires == NULL)
|
|
|
|
/*@innercontinue@*/ continue; /* XXX can't happen */
|
2001-11-03 05:01:25 +08:00
|
|
|
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';
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteNEVR(p) != NULL)
|
|
|
|
(void) stpcpy(buf, rpmteNEVR(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. */
|
2002-05-20 02:42:25 +08:00
|
|
|
for (p = r, q = rpmteTSI(r)->tsi_chain; q != NULL;
|
|
|
|
p = q, q = rpmteTSI(q)->tsi_chain)
|
2000-09-27 02:04:12 +08:00
|
|
|
{
|
|
|
|
/* Unchain linear part of predecessor loop. */
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteTSI(p)->tsi_chain = NULL;
|
|
|
|
rpmteTSI(p)->tsi_reqx = 0;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
ri = rpmtsiFree(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. */
|
2002-05-17 00:55:21 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("rpmtsOrder failed, %d elements remain\n"),
|
2001-11-02 04:15:10 +08:00
|
|
|
loopcheck);
|
|
|
|
return loopcheck;
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
|
2001-11-18 04:44:16 +08:00
|
|
|
/* Clean up tsort remnants (if any). */
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteFreeTSI(p);
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2001-11-18 04:44:16 +08:00
|
|
|
|
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-18 04:44:16 +08:00
|
|
|
orderList = xcalloc(numOrderList, sizeof(*orderList));
|
2001-11-01 06:19:42 +08:00
|
|
|
j = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, oType)) != NULL) {
|
2001-11-02 04:15:10 +08:00
|
|
|
/* Prepare added package ordering permutation. */
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
2001-11-18 04:44:16 +08:00
|
|
|
case TR_ADDED:
|
2002-05-20 02:42:25 +08:00
|
|
|
orderList[j].pkgKey = rpmteAddedKey(p);
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-11-18 04:44:16 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
orderList[j].pkgKey = RPMAL_NOMATCH;
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-11-18 04:44:16 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
orderList[j].orIndex = rpmtsiOc(pi);
|
2001-11-01 06:19:42 +08:00
|
|
|
j++;
|
1999-04-05 05:26:36 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-04-14 01:26:43 +08:00
|
|
|
|
2001-11-18 04:44:16 +08:00
|
|
|
qsort(orderList, numOrderList, 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-18 04:44:16 +08:00
|
|
|
needle = bsearch(&key, orderList, numOrderList,
|
2001-11-02 04:15:10 +08:00
|
|
|
sizeof(key), orderListIndexCmp);
|
1999-04-05 05:26:36 +08:00
|
|
|
/* bsearch should never, ever fail */
|
2001-11-18 04:44:16 +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-18 04:44:16 +08:00
|
|
|
if ((q = ts->order[j]) == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
newOrder[newOrderCount++] = q;
|
2001-11-17 06:42:19 +08:00
|
|
|
ts->order[j] = NULL;
|
2003-01-26 04:59:52 +08:00
|
|
|
if (anaconda)
|
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;
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteType(q) == TR_REMOVED
|
|
|
|
&& rpmteDependsOnKey(q) == needle->pkgKey)
|
2001-11-17 03:26:33 +08:00
|
|
|
{
|
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;
|
|
|
|
newOrder[newOrderCount++] = p;
|
|
|
|
ts->order[j] = NULL;
|
1999-04-05 05:26:36 +08:00
|
|
|
}
|
2001-11-18 04:44:16 +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
|
|
|
|
2002-07-15 05:23:29 +08:00
|
|
|
#ifdef DYING /* XXX now done at the CLI level just before rpmtsRun(). */
|
2002-05-17 00:55:21 +08:00
|
|
|
rpmtsClean(ts);
|
2002-04-12 00:55:19 +08:00
|
|
|
#endif
|
2002-05-07 09:07:41 +08:00
|
|
|
freeBadDeps();
|
2001-11-11 11:15:47 +08:00
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=bounds@*/
|
1999-04-05 05:26:36 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
int rpmtsCheck(rpmts ts)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
2001-09-15 21:49:11 +08:00
|
|
|
rpmdbMatchIterator mi = NULL;
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmtsi pi = NULL; rpmte 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. */
|
2002-07-15 05:23:29 +08:00
|
|
|
if (rpmtsGetRdb(ts) == NULL && ts->dbmode != -1) {
|
2001-10-28 04:09:20 +08:00
|
|
|
if ((rc = rpmtsOpenDB(ts, ts->dbmode)) != 0)
|
|
|
|
goto exit;
|
|
|
|
closeatexit = 1;
|
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
ts->probs = rpmpsFree(ts->probs);
|
|
|
|
ts->probs = rpmpsCreate();
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2002-05-28 02:12:12 +08:00
|
|
|
rpmalMakeIndex(ts->addedPackages);
|
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.
|
|
|
|
*/
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds provides;
|
|
|
|
|
2002-12-31 10:12:02 +08:00
|
|
|
/*@-nullpass@*/ /* FIX: rpmts{A,O} can return null. */
|
2002-12-31 09:23:03 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== +++ %s %s/%s 0x%x\n",
|
|
|
|
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
|
2002-12-31 10:12:02 +08:00
|
|
|
/*@=nullpass@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
rc = checkPackageDeps(ts, rpmteNEVR(p),
|
|
|
|
rpmteDS(p, RPMTAG_REQUIRENAME),
|
|
|
|
rpmteDS(p, RPMTAG_CONFLICTNAME),
|
2001-11-17 16:02:17 +08:00
|
|
|
NULL,
|
2002-12-31 09:23:03 +08:00
|
|
|
tscolor, 1);
|
2001-11-11 08:11:33 +08:00
|
|
|
if (rc)
|
1999-09-14 13:41:13 +08:00
|
|
|
goto exit;
|
|
|
|
|
2001-11-17 16:02:17 +08:00
|
|
|
#if defined(DYING) || defined(__LCLINT__)
|
|
|
|
/* XXX all packages now have Provides: name = version-release */
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Adding: check name against conflicts matches. */
|
2002-05-20 02:42:25 +08:00
|
|
|
rc = checkDependentConflicts(ts, rpmteN(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;
|
2002-05-20 02:42:25 +08:00
|
|
|
provides = rpmteDS(p, RPMTAG_PROVIDENAME);
|
|
|
|
provides = rpmdsInit(provides);
|
|
|
|
if (provides == NULL || rpmdsN(provides) == NULL)
|
2001-11-03 10:34:15 +08:00
|
|
|
continue;
|
2002-05-20 02:42:25 +08:00
|
|
|
while (rpmdsNext(provides) >= 0) {
|
2001-11-03 07:17:54 +08:00
|
|
|
const char * Name;
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((Name = rpmdsN(provides)) == NULL)
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@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
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(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.
|
|
|
|
*/
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds provides;
|
|
|
|
rpmfi fi;
|
2001-11-11 10:50:31 +08:00
|
|
|
|
2002-12-31 10:12:02 +08:00
|
|
|
/*@-nullpass@*/ /* FIX: rpmts{A,O} can return null. */
|
2002-12-31 09:23:03 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== --- %s %s/%s 0x%x\n",
|
|
|
|
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
|
2002-12-31 10:12:02 +08:00
|
|
|
/*@=nullpass@*/
|
2001-11-11 10:50:31 +08:00
|
|
|
|
2001-11-17 16:02:17 +08:00
|
|
|
#if defined(DYING) || defined(__LCLINT__)
|
|
|
|
/* XXX all packages now have Provides: name = version-release */
|
2001-11-11 10:50:31 +08:00
|
|
|
/* Erasing: check name against requiredby matches. */
|
2002-05-20 02:42:25 +08:00
|
|
|
rc = checkDependentPackages(ts, rpmteN(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;
|
2002-05-20 02:42:25 +08:00
|
|
|
provides = rpmteDS(p, RPMTAG_PROVIDENAME);
|
|
|
|
provides = rpmdsInit(provides);
|
2001-11-11 10:50:31 +08:00
|
|
|
if (provides != NULL)
|
2002-05-20 02:42:25 +08:00
|
|
|
while (rpmdsNext(provides) >= 0) {
|
2001-11-11 10:50:31 +08:00
|
|
|
const char * Name;
|
2001-11-03 07:17:54 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((Name = rpmdsN(provides)) == NULL)
|
2001-11-11 10:50:31 +08:00
|
|
|
/*@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;
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmteFI(p, RPMTAG_BASENAMES);
|
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while (rpmfiNext(fi) >= 0) {
|
|
|
|
const char * fn = rpmfiFN(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
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-07-14 06:00:05 +08:00
|
|
|
|
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);
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(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)
|
2002-05-18 05:08:39 +08:00
|
|
|
xx = rpmdbCloseDBI(rpmtsGetRdb(ts), RPMDBI_DEPENDS);
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2000-07-08 04:06:41 +08:00
|
|
|
return rc;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|