2000-08-28 03:27:03 +08:00
|
|
|
/** \ingroup rpmdep
|
|
|
|
* \file lib/depends.c
|
|
|
|
*/
|
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
int _depends_debug = 0;
|
|
|
|
|
|
|
|
#include "system.h"
|
|
|
|
|
1999-07-14 05:37:57 +08:00
|
|
|
#include <rpmlib.h>
|
1997-01-18 00:20:18 +08:00
|
|
|
|
1998-03-28 00:46:39 +08:00
|
|
|
#include "depends.h"
|
2000-04-26 03:41:37 +08:00
|
|
|
#include "rpmdb.h"
|
1996-07-11 00:29:24 +08:00
|
|
|
#include "misc.h"
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1996-06-10 10:36:07 +08:00
|
|
|
|
2000-10-29 01:16:25 +08:00
|
|
|
/*@access dbiIndex@*/ /* XXX compared with NULL */
|
|
|
|
/*@access dbiIndexSet@*/ /* XXX compared with NULL */
|
|
|
|
/*@access Header@*/ /* XXX compared with NULL */
|
2001-04-29 09:05:43 +08:00
|
|
|
/*@access FD_t@*/ /* XXX compared with NULL */
|
2000-10-29 01:16:25 +08:00
|
|
|
/*@access rpmdb@*/ /* XXX compared with NULL */
|
2001-04-29 09:05:43 +08:00
|
|
|
/*@access rpmdbMatchIterator@*/ /* XXX compared with NULL */
|
1999-09-18 05:08:32 +08:00
|
|
|
/*@access rpmTransactionSet@*/
|
|
|
|
|
1999-08-07 06:52:49 +08:00
|
|
|
int headerNVR(Header h, const char **np, const char **vp, const char **rp)
|
1999-07-23 01:48:31 +08:00
|
|
|
{
|
|
|
|
int type, count;
|
2000-12-13 04:03:45 +08:00
|
|
|
if (np) {
|
|
|
|
if (!(headerGetEntry(h, RPMTAG_NAME, &type, (void **) np, &count)
|
|
|
|
&& type == RPM_STRING_TYPE && count == 1))
|
|
|
|
*np = NULL;
|
|
|
|
}
|
|
|
|
if (vp) {
|
|
|
|
if (!(headerGetEntry(h, RPMTAG_VERSION, &type, (void **) vp, &count)
|
|
|
|
&& type == RPM_STRING_TYPE && count == 1))
|
|
|
|
*vp = NULL;
|
|
|
|
}
|
|
|
|
if (rp) {
|
|
|
|
if (!(headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) rp, &count)
|
|
|
|
&& type == RPM_STRING_TYPE && count == 1))
|
|
|
|
*rp = NULL;
|
|
|
|
}
|
1999-07-23 01:48:31 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Return formatted dependency string.
|
|
|
|
* @param depend type of dependency ("R" == Requires, "C" == Conflcts)
|
|
|
|
* @param key dependency name string
|
|
|
|
* @param keyEVR dependency [epoch:]version[-release] string
|
|
|
|
* @param keyFlags dependency logical range qualifiers
|
|
|
|
* @return formatted dependency (malloc'ed)
|
|
|
|
*/
|
|
|
|
static /*@only@*/ char *printDepend(const char * depend, const char * key,
|
|
|
|
const char * keyEVR, int keyFlags) /*@*/
|
1999-09-19 08:29:44 +08:00
|
|
|
{
|
|
|
|
char *tbuf, *t;
|
|
|
|
size_t nb;
|
|
|
|
|
|
|
|
nb = 0;
|
2000-04-26 03:41:37 +08:00
|
|
|
if (depend) nb += strlen(depend) + 1;
|
1999-09-19 08:29:44 +08:00
|
|
|
if (key) nb += strlen(key);
|
2000-04-26 03:41:37 +08:00
|
|
|
if (keyFlags & RPMSENSE_SENSEMASK) {
|
1999-09-19 08:29:44 +08:00
|
|
|
if (nb) nb++;
|
|
|
|
if (keyFlags & RPMSENSE_LESS) nb++;
|
|
|
|
if (keyFlags & RPMSENSE_GREATER) nb++;
|
|
|
|
if (keyFlags & RPMSENSE_EQUAL) nb++;
|
|
|
|
}
|
2000-04-26 03:41:37 +08:00
|
|
|
if (keyEVR && *keyEVR) {
|
1999-09-19 08:29:44 +08:00
|
|
|
if (nb) nb++;
|
|
|
|
nb += strlen(keyEVR);
|
|
|
|
}
|
|
|
|
|
1999-09-21 11:22:53 +08:00
|
|
|
t = tbuf = xmalloc(nb + 1);
|
2000-04-26 03:41:37 +08:00
|
|
|
if (depend) {
|
2001-04-29 09:05:43 +08:00
|
|
|
while(*depend != '\0') *t++ = *depend++;
|
2000-04-26 03:41:37 +08:00
|
|
|
*t++ = ' ';
|
|
|
|
}
|
1999-09-19 08:29:44 +08:00
|
|
|
if (key)
|
2001-04-29 09:05:43 +08:00
|
|
|
while(*key != '\0') *t++ = *key++;
|
2000-04-26 03:41:37 +08:00
|
|
|
if (keyFlags & RPMSENSE_SENSEMASK) {
|
1999-09-19 08:29:44 +08:00
|
|
|
if (t != tbuf) *t++ = ' ';
|
|
|
|
if (keyFlags & RPMSENSE_LESS) *t++ = '<';
|
|
|
|
if (keyFlags & RPMSENSE_GREATER) *t++ = '>';
|
|
|
|
if (keyFlags & RPMSENSE_EQUAL) *t++ = '=';
|
|
|
|
}
|
2000-04-26 03:41:37 +08:00
|
|
|
if (keyEVR && *keyEVR) {
|
1999-09-19 08:29:44 +08:00
|
|
|
if (t != tbuf) *t++ = ' ';
|
2001-04-29 09:05:43 +08:00
|
|
|
while(*keyEVR != '\0') *t++ = *keyEVR++;
|
1999-09-19 08:29:44 +08:00
|
|
|
}
|
|
|
|
*t = '\0';
|
|
|
|
return tbuf;
|
|
|
|
}
|
|
|
|
|
2000-07-15 22:53:54 +08:00
|
|
|
#ifdef UNUSED
|
2000-04-14 00:00:34 +08:00
|
|
|
static /*@only@*/ const char *buildEVR(int_32 *e, const char *v, const char *r)
|
1999-09-19 08:29:44 +08:00
|
|
|
{
|
2000-04-14 00:00:34 +08:00
|
|
|
const char *pEVR;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
pEVR = p = xmalloc(21 + strlen(v) + 1 + strlen(r) + 1);
|
|
|
|
*p = '\0';
|
|
|
|
if (e) {
|
|
|
|
sprintf(p, "%d:", *e);
|
2000-04-21 08:21:15 +08:00
|
|
|
while (*p)
|
|
|
|
p++;
|
2000-04-14 00:00:34 +08:00
|
|
|
}
|
|
|
|
(void) stpcpy( stpcpy( stpcpy(p, v) , "-") , r);
|
1999-09-19 08:29:44 +08:00
|
|
|
return pEVR;
|
|
|
|
}
|
2000-04-14 00:00:34 +08:00
|
|
|
#endif
|
1999-09-19 08:29:44 +08:00
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
struct orderListIndex {
|
|
|
|
int alIndex;
|
|
|
|
int orIndex;
|
|
|
|
};
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Destroy available item index.
|
|
|
|
* @param al available list
|
|
|
|
*/
|
1999-07-14 06:00:05 +08:00
|
|
|
static void alFreeIndex(struct availableList * al)
|
2000-08-23 20:39:49 +08:00
|
|
|
/*@modifies al->index @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
|
|
|
if (al->index.size) {
|
2001-02-05 06:15:30 +08:00
|
|
|
al->index.index = _free(al->index.index);
|
1999-07-14 06:00:05 +08:00
|
|
|
al->index.size = 0;
|
|
|
|
}
|
|
|
|
}
|
1996-07-18 04:02:28 +08:00
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Initialize available packckages, items, and directories list.
|
|
|
|
* @param al available list
|
|
|
|
*/
|
|
|
|
static void alCreate(struct availableList * al)
|
|
|
|
/*@modifies *al @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-01-16 07:09:42 +08:00
|
|
|
al->alloced = al->delta;
|
1996-07-18 04:02:28 +08:00
|
|
|
al->size = 0;
|
1999-09-21 11:22:53 +08:00
|
|
|
al->list = xcalloc(al->alloced, sizeof(*al->list));
|
1996-07-18 04:02:28 +08:00
|
|
|
|
|
|
|
al->index.index = NULL;
|
1999-09-19 08:29:44 +08:00
|
|
|
al->index.size = 0;
|
1999-10-07 06:52:12 +08:00
|
|
|
|
|
|
|
al->numDirs = 0;
|
|
|
|
al->dirs = NULL;
|
1998-03-05 00:52:59 +08:00
|
|
|
}
|
1996-07-18 04:02:28 +08:00
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Free available packages, items, and directories members.
|
|
|
|
* @param al available list
|
|
|
|
*/
|
1999-12-08 05:14:51 +08:00
|
|
|
static void alFree(struct availableList * al)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HFD_t hfd = headerFreeData;
|
2000-09-27 02:04:12 +08:00
|
|
|
struct availablePackage * p;
|
1999-05-24 02:34:30 +08:00
|
|
|
rpmRelocation * r;
|
2000-09-27 02:04:12 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0, p = al->list; i < al->size; i++, p++) {
|
|
|
|
|
|
|
|
{ struct tsortInfo * tsi;
|
|
|
|
while ((tsi = p->tsi.tsi_next) != NULL) {
|
|
|
|
p->tsi.tsi_next = tsi->tsi_next;
|
|
|
|
tsi->tsi_next = NULL;
|
2001-02-05 06:15:30 +08:00
|
|
|
tsi = _free(tsi);
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
}
|
1996-07-18 04:02:28 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
p->provides = hfd(p->provides, -1);
|
|
|
|
p->providesEVR = hfd(p->providesEVR, -1);
|
|
|
|
p->requires = hfd(p->requires, -1);
|
|
|
|
p->requiresEVR = hfd(p->requiresEVR, -1);
|
|
|
|
p->baseNames = hfd(p->baseNames, -1);
|
2000-09-27 02:04:12 +08:00
|
|
|
if (p->h) headerFree(p->h);
|
|
|
|
|
|
|
|
if (p->relocs) {
|
|
|
|
for (r = p->relocs; (r->oldPath || r->newPath); r++) {
|
2001-02-05 06:15:30 +08:00
|
|
|
r->oldPath = _free(r->oldPath);
|
|
|
|
r->newPath = _free(r->newPath);
|
1999-05-24 02:34:30 +08:00
|
|
|
}
|
2001-02-05 06:15:30 +08:00
|
|
|
p->relocs = _free(p->relocs);
|
1999-05-24 02:34:30 +08:00
|
|
|
}
|
2001-04-29 09:05:43 +08:00
|
|
|
if (p->fd != NULL)
|
2000-09-27 02:04:12 +08:00
|
|
|
p->fd = fdFree(p->fd, "alAddPackage (alFree)");
|
1997-05-01 03:28:09 +08:00
|
|
|
}
|
1996-07-18 04:02:28 +08:00
|
|
|
|
1999-10-07 06:52:12 +08:00
|
|
|
for (i = 0; i < al->numDirs; i++) {
|
2001-02-05 06:15:30 +08:00
|
|
|
al->dirs[i].dirName = _free(al->dirs[i].dirName);
|
|
|
|
al->dirs[i].files = _free(al->dirs[i].files);
|
1999-10-07 06:52:12 +08:00
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (al->numDirs && al->dirs)
|
|
|
|
al->dirs = _free(al->dirs);
|
1999-09-19 08:29:44 +08:00
|
|
|
if (al->alloced && al->list)
|
2001-02-05 06:15:30 +08:00
|
|
|
al->list = _free(al->list);
|
1996-07-18 04:02:28 +08:00
|
|
|
alFreeIndex(al);
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Compare two directory info entries by name (qsort/bsearch).
|
|
|
|
* @param one 1st directory info
|
|
|
|
* @param two 2nd directory info
|
|
|
|
* @return result of comparison
|
|
|
|
*/
|
|
|
|
static int dirInfoCompare(const void * one, const void * two) /*@*/
|
|
|
|
{
|
2001-04-29 09:05:43 +08:00
|
|
|
const dirInfo a = (const dirInfo) one;
|
|
|
|
const dirInfo b = (const dirInfo) two;
|
1999-12-15 23:51:30 +08:00
|
|
|
int lenchk = a->dirNameLen - b->dirNameLen;
|
1999-10-07 06:52:12 +08:00
|
|
|
|
1999-12-15 23:51:30 +08:00
|
|
|
if (lenchk)
|
|
|
|
return lenchk;
|
2000-04-14 00:00:34 +08:00
|
|
|
|
1999-12-15 23:51:30 +08:00
|
|
|
/* XXX FIXME: this might do "backward" strcmp for speed */
|
1999-10-07 06:52:12 +08:00
|
|
|
return strcmp(a->dirName, b->dirName);
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Add package to available list.
|
|
|
|
* @param al available list
|
|
|
|
* @param h package header
|
|
|
|
* @param key package private data
|
|
|
|
* @param fd package file handle
|
|
|
|
* @param relocs package file relocations
|
|
|
|
* @return available package pointer
|
|
|
|
*/
|
1999-09-19 08:29:44 +08:00
|
|
|
static /*@exposed@*/ struct availablePackage * alAddPackage(struct availableList * al,
|
1999-12-08 05:14:51 +08:00
|
|
|
Header h, /*@dependent@*/ const void * key,
|
|
|
|
FD_t fd, rpmRelocation * relocs)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
|
|
|
HFD_t hfd = headerFreeData;
|
|
|
|
int dnt, bnt;
|
1996-07-18 04:02:28 +08:00
|
|
|
struct availablePackage * p;
|
1999-05-24 02:34:30 +08:00
|
|
|
rpmRelocation * r;
|
|
|
|
int i;
|
1999-12-09 03:04:50 +08:00
|
|
|
int_32 * dirIndexes;
|
1999-11-27 05:58:42 +08:00
|
|
|
const char ** dirNames;
|
1999-10-07 06:52:12 +08:00
|
|
|
int numDirs, dirNum;
|
|
|
|
int * dirMapping;
|
2001-04-29 09:05:43 +08:00
|
|
|
struct dirInfo_s dirNeedle;
|
|
|
|
dirInfo dirMatch;
|
1999-10-07 06:52:12 +08:00
|
|
|
int first, last, fileNum;
|
|
|
|
int origNumDirs;
|
1999-12-09 00:32:25 +08:00
|
|
|
int pkgNum;
|
2000-07-06 04:39:15 +08:00
|
|
|
uint_32 multiLibMask = 0;
|
|
|
|
uint_32 * fileFlags = NULL;
|
|
|
|
uint_32 * pp = NULL;
|
1996-07-18 04:02:28 +08:00
|
|
|
|
|
|
|
if (al->size == al->alloced) {
|
2001-01-16 07:09:42 +08:00
|
|
|
al->alloced += al->delta;
|
1999-09-21 11:22:53 +08:00
|
|
|
al->list = xrealloc(al->list, sizeof(*al->list) * al->alloced);
|
1996-07-18 04:02:28 +08:00
|
|
|
}
|
|
|
|
|
1999-12-09 00:32:25 +08:00
|
|
|
pkgNum = al->size++;
|
|
|
|
p = al->list + pkgNum;
|
1999-09-21 11:22:53 +08:00
|
|
|
p->h = headerLink(h); /* XXX reference held by transaction set */
|
2001-04-21 14:02:09 +08:00
|
|
|
p->depth = p->npreds = 0;
|
2000-09-27 02:04:12 +08:00
|
|
|
memset(&p->tsi, 0, sizeof(p->tsi));
|
2000-07-06 04:39:15 +08:00
|
|
|
p->multiLib = 0; /* MULTILIB */
|
1996-07-18 04:02:28 +08:00
|
|
|
|
1999-07-23 01:48:31 +08:00
|
|
|
headerNVR(p->h, &p->name, &p->version, &p->release);
|
|
|
|
|
2000-07-06 04:39:15 +08:00
|
|
|
/* 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.
|
|
|
|
*/
|
2001-02-05 06:15:30 +08:00
|
|
|
if (hge(p->h, RPMTAG_MULTILIBS, NULL, (void **) &pp, NULL))
|
2000-07-06 04:39:15 +08:00
|
|
|
multiLibMask = *pp;
|
|
|
|
|
|
|
|
if (multiLibMask) {
|
|
|
|
for (i = 0; i < pkgNum - 1; i++) {
|
|
|
|
if (!strcmp (p->name, al->list[i].name)
|
2001-02-05 06:15:30 +08:00
|
|
|
&& hge(al->list[i].h, RPMTAG_MULTILIBS, NULL,
|
2000-07-06 04:39:15 +08:00
|
|
|
(void **) &pp, NULL)
|
|
|
|
&& !rpmVersionCompare(p->h, al->list[i].h)
|
|
|
|
&& *pp && !(*pp & multiLibMask))
|
|
|
|
p->multiLib = multiLibMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_EPOCH, NULL, (void **) &p->epoch, NULL))
|
1999-09-15 00:04:03 +08:00
|
|
|
p->epoch = NULL;
|
1996-07-18 04:02:28 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_PROVIDENAME, NULL, (void **) &p->provides,
|
1996-07-18 04:02:28 +08:00
|
|
|
&p->providesCount)) {
|
|
|
|
p->providesCount = 0;
|
|
|
|
p->provides = NULL;
|
1999-09-19 08:29:44 +08:00
|
|
|
p->providesEVR = NULL;
|
|
|
|
p->provideFlags = NULL;
|
|
|
|
} else {
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_PROVIDEVERSION,
|
1999-09-19 08:29:44 +08:00
|
|
|
NULL, (void **) &p->providesEVR, NULL))
|
|
|
|
p->providesEVR = NULL;
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_PROVIDEFLAGS,
|
1999-09-19 08:29:44 +08:00
|
|
|
NULL, (void **) &p->provideFlags, NULL))
|
|
|
|
p->provideFlags = NULL;
|
1996-07-18 04:02:28 +08:00
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_REQUIRENAME, NULL, (void **) &p->requires,
|
2000-09-27 02:04:12 +08:00
|
|
|
&p->requiresCount)) {
|
|
|
|
p->requiresCount = 0;
|
|
|
|
p->requires = NULL;
|
|
|
|
p->requiresEVR = NULL;
|
|
|
|
p->requireFlags = NULL;
|
|
|
|
} else {
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_REQUIREVERSION,
|
2000-09-27 02:04:12 +08:00
|
|
|
NULL, (void **) &p->requiresEVR, NULL))
|
|
|
|
p->requiresEVR = NULL;
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_REQUIREFLAGS,
|
2000-09-27 02:04:12 +08:00
|
|
|
NULL, (void **) &p->requireFlags, NULL))
|
|
|
|
p->requireFlags = NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_BASENAMES, &bnt, (void **) &p->baseNames, &p->filesCount))
|
2000-12-03 05:53:44 +08:00
|
|
|
{
|
1997-05-01 03:28:09 +08:00
|
|
|
p->filesCount = 0;
|
1999-11-27 05:58:42 +08:00
|
|
|
p->baseNames = NULL;
|
1999-10-07 06:52:12 +08:00
|
|
|
} else {
|
2001-02-05 06:15:30 +08:00
|
|
|
hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, &numDirs);
|
|
|
|
hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL);
|
|
|
|
hge(h, RPMTAG_FILEFLAGS, NULL, (void **) &fileFlags, NULL);
|
1999-10-07 06:52:12 +08:00
|
|
|
|
|
|
|
/* XXX FIXME: We ought to relocate the directory list here */
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
dirMapping = alloca(sizeof(*dirMapping) * numDirs);
|
1999-10-07 06:52:12 +08:00
|
|
|
|
|
|
|
/* allocated enough space for all the directories we could possible
|
|
|
|
need to add */
|
|
|
|
al->dirs = xrealloc(al->dirs,
|
|
|
|
sizeof(*al->dirs) * (al->numDirs + numDirs));
|
|
|
|
origNumDirs = al->numDirs;
|
|
|
|
|
|
|
|
for (dirNum = 0; dirNum < numDirs; dirNum++) {
|
1999-11-27 05:58:42 +08:00
|
|
|
dirNeedle.dirName = (char *) dirNames[dirNum];
|
1999-12-15 23:51:30 +08:00
|
|
|
dirNeedle.dirNameLen = strlen(dirNames[dirNum]);
|
1999-10-07 06:52:12 +08:00
|
|
|
dirMatch = bsearch(&dirNeedle, al->dirs, origNumDirs,
|
|
|
|
sizeof(dirNeedle), dirInfoCompare);
|
|
|
|
if (dirMatch) {
|
|
|
|
dirMapping[dirNum] = dirMatch - al->dirs;
|
|
|
|
} else {
|
1999-12-15 23:51:30 +08:00
|
|
|
dirMapping[dirNum] = al->numDirs;
|
1999-11-27 05:58:42 +08:00
|
|
|
al->dirs[al->numDirs].dirName = xstrdup(dirNames[dirNum]);
|
1999-12-15 23:51:30 +08:00
|
|
|
al->dirs[al->numDirs].dirNameLen = strlen(dirNames[dirNum]);
|
1999-10-07 06:52:12 +08:00
|
|
|
al->dirs[al->numDirs].files = NULL;
|
|
|
|
al->dirs[al->numDirs].numFiles = 0;
|
|
|
|
al->numDirs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
dirNames = hfd(dirNames, dnt);
|
1999-10-07 06:52:12 +08:00
|
|
|
|
|
|
|
first = 0;
|
|
|
|
while (first < p->filesCount) {
|
|
|
|
last = first;
|
|
|
|
while ((last + 1) < p->filesCount) {
|
1999-12-09 03:04:50 +08:00
|
|
|
if (dirIndexes[first] != dirIndexes[last + 1]) break;
|
1999-10-07 06:52:12 +08:00
|
|
|
last++;
|
|
|
|
}
|
|
|
|
|
1999-12-09 03:04:50 +08:00
|
|
|
dirMatch = al->dirs + dirMapping[dirIndexes[first]];
|
1999-10-07 06:52:12 +08:00
|
|
|
dirMatch->files = xrealloc(dirMatch->files,
|
|
|
|
sizeof(*dirMatch->files) *
|
|
|
|
(dirMatch->numFiles + last - first + 1));
|
|
|
|
for (fileNum = first; fileNum <= last; fileNum++) {
|
1999-11-27 05:58:42 +08:00
|
|
|
dirMatch->files[dirMatch->numFiles].baseName =
|
|
|
|
p->baseNames[fileNum];
|
1999-12-09 00:32:25 +08:00
|
|
|
dirMatch->files[dirMatch->numFiles].pkgNum = pkgNum;
|
2000-07-06 04:39:15 +08:00
|
|
|
dirMatch->files[dirMatch->numFiles].fileFlags =
|
|
|
|
fileFlags[fileNum];
|
1999-10-07 06:52:12 +08:00
|
|
|
dirMatch->numFiles++;
|
|
|
|
}
|
|
|
|
|
|
|
|
first = last + 1;
|
|
|
|
}
|
1999-12-15 23:51:30 +08:00
|
|
|
|
|
|
|
if (origNumDirs + al->numDirs)
|
|
|
|
qsort(al->dirs, al->numDirs, sizeof(dirNeedle), dirInfoCompare);
|
|
|
|
|
1999-10-07 06:52:12 +08:00
|
|
|
}
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1996-07-18 10:25:13 +08:00
|
|
|
p->key = key;
|
2001-04-29 09:05:43 +08:00
|
|
|
p->fd = (fd != NULL ? fdLink(fd, "alAddPackage") : NULL);
|
1996-07-18 10:25:13 +08:00
|
|
|
|
1999-05-24 02:34:30 +08:00
|
|
|
if (relocs) {
|
|
|
|
for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++);
|
1999-09-21 11:22:53 +08:00
|
|
|
p->relocs = xmalloc(sizeof(*p->relocs) * (i + 1));
|
1999-05-24 02:34:30 +08:00
|
|
|
|
|
|
|
for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) {
|
1999-09-21 11:22:53 +08:00
|
|
|
p->relocs[i].oldPath = r->oldPath ? xstrdup(r->oldPath) : NULL;
|
|
|
|
p->relocs[i].newPath = r->newPath ? xstrdup(r->newPath) : NULL;
|
1999-05-24 02:34:30 +08:00
|
|
|
}
|
|
|
|
p->relocs[i].oldPath = NULL;
|
|
|
|
p->relocs[i].newPath = NULL;
|
|
|
|
} else {
|
|
|
|
p->relocs = NULL;
|
|
|
|
}
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1996-07-18 04:02:28 +08:00
|
|
|
alFreeIndex(al);
|
1999-04-05 05:26:36 +08:00
|
|
|
|
|
|
|
return p;
|
1996-07-18 04:02:28 +08:00
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Compare two available index entries by name (qsort/bsearch).
|
|
|
|
* @param one 1st available index entry
|
|
|
|
* @param two 2nd available index entry
|
|
|
|
* @return result of comparison
|
|
|
|
*/
|
2000-04-14 00:00:34 +08:00
|
|
|
static int indexcmp(const void * one, const void * two)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-04-14 00:00:34 +08:00
|
|
|
const struct availableIndexEntry * a = one;
|
|
|
|
const struct availableIndexEntry * b = two;
|
|
|
|
int lenchk = a->entryLen - b->entryLen;
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2000-04-14 00:00:34 +08:00
|
|
|
if (lenchk)
|
|
|
|
return lenchk;
|
|
|
|
|
|
|
|
return strcmp(a->entry, b->entry);
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Generate index for available list.
|
|
|
|
* @param al available list
|
|
|
|
*/
|
1999-07-14 06:00:05 +08:00
|
|
|
static void alMakeIndex(struct availableList * al)
|
2000-08-23 20:39:49 +08:00
|
|
|
/*@modifies al->index @*/
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
1996-07-18 04:02:28 +08:00
|
|
|
struct availableIndex * ai = &al->index;
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
if (ai->size) return;
|
|
|
|
|
1999-10-07 06:52:12 +08:00
|
|
|
for (i = 0; i < al->size; i++)
|
1996-07-18 04:02:28 +08:00
|
|
|
ai->size += al->list[i].providesCount;
|
|
|
|
|
|
|
|
if (ai->size) {
|
1999-09-21 11:22:53 +08:00
|
|
|
ai->index = xcalloc(ai->size, sizeof(*ai->index));
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1996-07-18 04:02:28 +08:00
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < al->size; i++) {
|
|
|
|
for (j = 0; j < al->list[i].providesCount; j++) {
|
2000-07-06 04:39:15 +08:00
|
|
|
|
|
|
|
/* If multilib install, skip non-multilib provides. */
|
|
|
|
if (al->list[i].multiLib &&
|
|
|
|
!isDependsMULTILIB(al->list[i].provideFlags[j])) {
|
|
|
|
ai->size--;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1996-07-18 04:02:28 +08:00
|
|
|
ai->index[k].package = al->list + i;
|
|
|
|
ai->index[k].entry = al->list[i].provides[j];
|
2000-04-14 00:00:34 +08:00
|
|
|
ai->index[k].entryLen = strlen(al->list[i].provides[j]);
|
1997-05-01 03:28:09 +08:00
|
|
|
ai->index[k].type = IET_PROVIDES;
|
|
|
|
k++;
|
|
|
|
}
|
1996-07-18 04:02:28 +08:00
|
|
|
}
|
|
|
|
|
1998-03-05 00:52:59 +08:00
|
|
|
qsort(ai->index, ai->size, sizeof(*ai->index), indexcmp);
|
1996-07-18 04:02:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Compare removed package instances (qsort/bsearch).
|
|
|
|
* @param a 1st instance address
|
|
|
|
* @param b 2nd instance address
|
|
|
|
* @return result of comparison
|
|
|
|
*/
|
1999-07-14 06:00:05 +08:00
|
|
|
static int intcmp(const void * a, const void *b)
|
|
|
|
{
|
1996-06-10 10:36:07 +08:00
|
|
|
const int * aptr = a;
|
|
|
|
const int * bptr = b;
|
2000-05-07 08:53:11 +08:00
|
|
|
int rc = (*aptr - *bptr);
|
|
|
|
return rc;
|
1996-06-10 10:36:07 +08:00
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Split EVR into epoch, version, and release components.
|
|
|
|
* @param evr [epoch:]version[-release] string
|
|
|
|
* @retval *ep pointer to epoch
|
|
|
|
* @retval *vp pointer to version
|
|
|
|
* @retval *rp pointer to release
|
|
|
|
*/
|
1999-12-08 05:14:51 +08:00
|
|
|
static void parseEVR(char *evr,
|
|
|
|
/*@exposed@*/ /*@out@*/ const char **ep,
|
|
|
|
/*@exposed@*/ /*@out@*/ const char **vp,
|
|
|
|
/*@exposed@*/ /*@out@*/const char **rp) /*@modifies evr,*ep,*vp,*rp @*/
|
1999-07-23 01:48:31 +08:00
|
|
|
{
|
1999-09-14 13:41:13 +08:00
|
|
|
const char *epoch;
|
|
|
|
const char *version; /* assume only version is present */
|
|
|
|
const char *release;
|
1999-07-23 01:48:31 +08:00
|
|
|
char *s, *se;
|
|
|
|
|
|
|
|
s = evr;
|
2001-04-29 09:05:43 +08:00
|
|
|
while (*s && xisdigit(*s)) s++; /* s points to epoch terminator */
|
1999-07-23 01:48:31 +08:00
|
|
|
se = strrchr(s, '-'); /* se points to version terminator */
|
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
if (*s == ':') {
|
|
|
|
epoch = evr;
|
|
|
|
*s++ = '\0';
|
|
|
|
version = s;
|
|
|
|
if (*epoch == '\0') epoch = "0";
|
|
|
|
} else {
|
1999-09-15 00:04:03 +08:00
|
|
|
epoch = NULL; /* XXX disable epoch compare if missing */
|
1999-09-14 13:41:13 +08:00
|
|
|
version = evr;
|
1999-07-23 01:48:31 +08:00
|
|
|
}
|
1999-09-14 13:41:13 +08:00
|
|
|
if (se) {
|
|
|
|
*se++ = '\0';
|
|
|
|
release = se;
|
|
|
|
} else {
|
|
|
|
release = NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-23 01:48:31 +08:00
|
|
|
if (ep) *ep = epoch;
|
|
|
|
if (vp) *vp = version;
|
|
|
|
if (rp) *rp = release;
|
|
|
|
}
|
|
|
|
|
1999-09-26 23:04:03 +08:00
|
|
|
const char *rpmNAME = PACKAGE;
|
|
|
|
const char *rpmEVR = VERSION;
|
|
|
|
int rpmFLAGS = RPMSENSE_EQUAL;
|
1999-07-23 01:48:31 +08:00
|
|
|
|
2000-07-11 10:12:49 +08:00
|
|
|
int rpmRangesOverlap(const char *AName, const char *AEVR, int AFlags,
|
1999-09-14 13:41:13 +08:00
|
|
|
const char *BName, const char *BEVR, int BFlags)
|
1999-08-25 06:26:55 +08:00
|
|
|
{
|
2000-04-26 03:41:37 +08:00
|
|
|
const char *aDepend = printDepend(NULL, AName, AEVR, AFlags);
|
|
|
|
const char *bDepend = printDepend(NULL, BName, BEVR, BFlags);
|
1999-09-14 13:41:13 +08:00
|
|
|
char *aEVR, *bEVR;
|
|
|
|
const char *aE, *aV, *aR, *bE, *bV, *bR;
|
1999-08-25 06:26:55 +08:00
|
|
|
int result;
|
|
|
|
int sense;
|
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
/* Different names don't overlap. */
|
1999-09-19 08:29:44 +08:00
|
|
|
if (strcmp(AName, BName)) {
|
|
|
|
result = 0;
|
|
|
|
goto exit;
|
|
|
|
}
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
/* Same name. If either A or B is an existence test, always overlap. */
|
1999-09-19 08:29:44 +08:00
|
|
|
if (!((AFlags & RPMSENSE_SENSEMASK) && (BFlags & RPMSENSE_SENSEMASK))) {
|
|
|
|
result = 1;
|
|
|
|
goto exit;
|
|
|
|
}
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
/* If either EVR is non-existent or empty, always overlap. */
|
1999-09-19 08:29:44 +08:00
|
|
|
if (!(AEVR && *AEVR && BEVR && *BEVR)) {
|
|
|
|
result = 1;
|
|
|
|
goto exit;
|
|
|
|
}
|
1999-08-25 06:26:55 +08:00
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
/* Both AEVR and BEVR exist. */
|
1999-09-21 11:22:53 +08:00
|
|
|
aEVR = xstrdup(AEVR);
|
1999-09-14 13:41:13 +08:00
|
|
|
parseEVR(aEVR, &aE, &aV, &aR);
|
1999-09-21 11:22:53 +08:00
|
|
|
bEVR = xstrdup(BEVR);
|
1999-09-14 13:41:13 +08:00
|
|
|
parseEVR(bEVR, &bE, &bV, &bR);
|
1999-08-25 06:26:55 +08:00
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
/* Compare {A,B} [epoch:]version[-release] */
|
1999-09-20 21:23:46 +08:00
|
|
|
sense = 0;
|
1999-09-19 23:27:37 +08:00
|
|
|
if (aE && *aE && bE && *bE)
|
|
|
|
sense = rpmvercmp(aE, bE);
|
1999-09-25 00:02:14 +08:00
|
|
|
else if (aE && *aE && atol(aE) > 0) {
|
|
|
|
/* XXX legacy epoch-less requires/conflicts compatibility */
|
1999-09-25 07:36:52 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("the \"B\" dependency needs an epoch (assuming same as \"A\")\n\tA %s\tB %s\n"),
|
1999-09-25 00:02:14 +08:00
|
|
|
aDepend, bDepend);
|
|
|
|
sense = 0;
|
|
|
|
} else if (bE && *bE && atol(bE) > 0)
|
1999-09-19 23:27:37 +08:00
|
|
|
sense = -1;
|
1999-09-24 22:54:23 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
if (sense == 0) {
|
1999-09-14 13:41:13 +08:00
|
|
|
sense = rpmvercmp(aV, bV);
|
|
|
|
if (sense == 0 && aR && *aR && bR && *bR) {
|
|
|
|
sense = rpmvercmp(aR, bR);
|
1999-08-25 06:26:55 +08:00
|
|
|
}
|
|
|
|
}
|
2001-04-21 14:02:09 +08:00
|
|
|
aEVR = _free(aEVR);
|
|
|
|
bEVR = _free(bEVR);
|
1999-08-25 06:26:55 +08:00
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
/* Detect overlap of {A,B} range. */
|
1999-08-25 06:26:55 +08:00
|
|
|
result = 0;
|
1999-09-14 13:41:13 +08:00
|
|
|
if (sense < 0 && ((AFlags & RPMSENSE_GREATER) || (BFlags & RPMSENSE_LESS))) {
|
1999-08-25 06:26:55 +08:00
|
|
|
result = 1;
|
1999-09-14 13:41:13 +08:00
|
|
|
} else if (sense > 0 && ((AFlags & RPMSENSE_LESS) || (BFlags & RPMSENSE_GREATER))) {
|
1999-08-25 06:26:55 +08:00
|
|
|
result = 1;
|
1999-09-14 13:41:13 +08:00
|
|
|
} else if (sense == 0 &&
|
|
|
|
(((AFlags & RPMSENSE_EQUAL) && (BFlags & RPMSENSE_EQUAL)) ||
|
|
|
|
((AFlags & RPMSENSE_LESS) && (BFlags & RPMSENSE_LESS)) ||
|
|
|
|
((AFlags & RPMSENSE_GREATER) && (BFlags & RPMSENSE_GREATER)))) {
|
1999-08-25 06:26:55 +08:00
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
exit:
|
1999-09-24 22:54:23 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _(" %s A %s\tB %s\n"),
|
2001-04-21 14:02:09 +08:00
|
|
|
(result ? _("YES") : _("NO ")), aDepend, bDepend);
|
|
|
|
aDepend = _free(aDepend);
|
|
|
|
bDepend = _free(bDepend);
|
1999-08-25 06:26:55 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
typedef int (*dbrecMatch_t) (Header h, const char *reqName, const char * reqEVR, int reqFlags);
|
|
|
|
|
1999-09-12 05:10:02 +08:00
|
|
|
static int rangeMatchesDepFlags (Header h, const char *reqName, const char * reqEVR, int reqFlags)
|
1999-07-23 01:48:31 +08:00
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
|
|
|
HFD_t hfd = headerFreeData;
|
|
|
|
int pnt, pvt;
|
1999-09-12 05:10:02 +08:00
|
|
|
const char ** provides;
|
|
|
|
const char ** providesEVR;
|
1999-09-14 13:41:13 +08:00
|
|
|
int_32 * provideFlags;
|
1999-07-23 01:48:31 +08:00
|
|
|
int providesCount;
|
|
|
|
int result;
|
|
|
|
int type;
|
|
|
|
int i;
|
|
|
|
|
1999-09-12 05:10:02 +08:00
|
|
|
if (!(reqFlags & RPMSENSE_SENSEMASK) || !reqEVR || !strlen(reqEVR))
|
1999-07-23 01:48:31 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Get provides information from header */
|
|
|
|
/*
|
|
|
|
* Rpm prior to 3.0.3 does not have versioned provides.
|
|
|
|
* If no provides version info is available, match any requires.
|
|
|
|
*/
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_PROVIDEVERSION, &pvt,
|
1999-09-12 05:10:02 +08:00
|
|
|
(void **) &providesEVR, &providesCount))
|
1999-07-23 01:48:31 +08:00
|
|
|
return 1;
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
hge(h, RPMTAG_PROVIDEFLAGS, &type, (void **) &provideFlags, &providesCount);
|
1999-07-23 01:48:31 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_PROVIDENAME, &pnt, (void **) &provides, &providesCount))
|
|
|
|
{
|
|
|
|
providesEVR = hfd(providesEVR, pvt);
|
1999-07-23 01:48:31 +08:00
|
|
|
return 0; /* XXX should never happen */
|
|
|
|
}
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
for (i = 0; i < providesCount; i++) {
|
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
/* Filter out provides that came along for the ride. */
|
|
|
|
if (strcmp(provides[i], reqName))
|
|
|
|
continue;
|
|
|
|
|
2000-07-11 10:12:49 +08:00
|
|
|
result = rpmRangesOverlap(provides[i], providesEVR[i], provideFlags[i],
|
2000-05-07 08:53:11 +08:00
|
|
|
reqName, reqEVR, reqFlags);
|
1999-07-23 01:48:31 +08:00
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
/* If this provide matches the require, we're done. */
|
1999-07-23 01:48:31 +08:00
|
|
|
if (result)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
provides = hfd(provides, pnt);
|
|
|
|
providesEVR = hfd(providesEVR, pvt);
|
1999-07-23 01:48:31 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
int headerMatchesDepFlags(Header h,
|
|
|
|
const char * reqName, const char * reqEVR, int reqFlags)
|
1999-07-23 01:48:31 +08:00
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
1999-09-14 13:41:13 +08:00
|
|
|
const char *name, *version, *release;
|
1999-09-15 00:04:03 +08:00
|
|
|
int_32 * epoch;
|
2000-04-14 00:00:34 +08:00
|
|
|
const char *pkgEVR;
|
|
|
|
char *p;
|
1999-09-14 13:41:13 +08:00
|
|
|
int pkgFlags = RPMSENSE_EQUAL;
|
1999-07-23 01:48:31 +08:00
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
if (!((reqFlags & RPMSENSE_SENSEMASK) && reqEVR && *reqEVR))
|
1999-07-23 01:48:31 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Get package information from header */
|
1999-09-14 13:41:13 +08:00
|
|
|
headerNVR(h, &name, &version, &release);
|
1999-07-23 01:48:31 +08:00
|
|
|
|
2000-04-14 00:00:34 +08:00
|
|
|
pkgEVR = p = alloca(21 + strlen(version) + 1 + strlen(release) + 1);
|
|
|
|
*p = '\0';
|
2001-02-05 06:15:30 +08:00
|
|
|
if (hge(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
|
2000-04-14 00:00:34 +08:00
|
|
|
sprintf(p, "%d:", *epoch);
|
2001-04-29 09:05:43 +08:00
|
|
|
while (*p != '\0')
|
2000-04-21 08:21:15 +08:00
|
|
|
p++;
|
1996-06-11 01:42:57 +08:00
|
|
|
}
|
2000-04-14 00:00:34 +08:00
|
|
|
(void) stpcpy( stpcpy( stpcpy(p, version) , "-") , release);
|
1996-06-11 01:42:57 +08:00
|
|
|
|
2000-07-11 10:12:49 +08:00
|
|
|
return rpmRangesOverlap(name, pkgEVR, pkgFlags, reqName, reqEVR, reqFlags);
|
1996-06-10 10:36:07 +08:00
|
|
|
}
|
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
rpmTransactionSet rpmtransCreateSet(rpmdb rpmdb, 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
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
if (!rootDir) rootDir = "";
|
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-01-16 07:09:42 +08:00
|
|
|
ts->rpmdb = rpmdb;
|
|
|
|
ts->scriptFd = NULL;
|
|
|
|
ts->id = 0;
|
|
|
|
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-01-16 07:09:42 +08:00
|
|
|
ts->rootDir = xstrdup(rootDir);
|
|
|
|
ts->currDir = NULL;
|
|
|
|
ts->chrootDone = 0;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->addedPackages.delta = ts->delta;
|
|
|
|
alCreate(&ts->addedPackages);
|
|
|
|
ts->availablePackages.delta = ts->delta;
|
|
|
|
alCreate(&ts->availablePackages);
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->orderAlloced = ts->delta;
|
|
|
|
ts->orderCount = 0;
|
|
|
|
ts->order = xcalloc(ts->orderAlloced, sizeof(*ts->order));
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
return ts;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
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
|
2000-08-23 20:39:49 +08:00
|
|
|
* @param dboffset rpm database instance
|
|
|
|
* @param depends installed package of pair (or -1 on erase)
|
|
|
|
*/
|
2001-01-16 07:09:42 +08:00
|
|
|
static void removePackage(rpmTransactionSet ts, int dboffset, int depends)
|
|
|
|
/*@modifies ts @*/
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-01-16 07:09:42 +08:00
|
|
|
if (ts->numRemovedPackages == ts->allocedRemovedPackages) {
|
|
|
|
ts->allocedRemovedPackages += ts->delta;
|
|
|
|
ts->removedPackages = xrealloc(ts->removedPackages,
|
|
|
|
sizeof(int *) * ts->allocedRemovedPackages);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->removedPackages[ts->numRemovedPackages++] = dboffset;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
if (ts->orderCount == ts->orderAlloced) {
|
|
|
|
ts->orderAlloced += ts->delta;
|
|
|
|
ts->order = xrealloc(ts->order, sizeof(*ts->order) * ts->orderAlloced);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->order[ts->orderCount].type = TR_REMOVED;
|
|
|
|
ts->order[ts->orderCount].u.removed.dboffset = dboffset;
|
|
|
|
ts->order[ts->orderCount++].u.removed.dependsOnIndex = depends;
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd,
|
1999-08-21 05:05:18 +08:00
|
|
|
const void * key, int upgrade, rpmRelocation * relocs)
|
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
|
|
|
HFD_t hfd = headerFreeData;
|
|
|
|
int ont, ovt;
|
1999-08-21 05:05:18 +08:00
|
|
|
/* this is an install followed by uninstalls */
|
2000-04-13 20:43:49 +08:00
|
|
|
const char * name;
|
|
|
|
int count;
|
1999-08-21 05:05:18 +08:00
|
|
|
const char ** obsoletes;
|
|
|
|
int alNum;
|
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
/*
|
|
|
|
* FIXME: handling upgrades like this is *almost* okay. It doesn't
|
|
|
|
* check to make sure we're upgrading to a newer version, and it
|
|
|
|
* makes it difficult to generate a return code based on the number of
|
|
|
|
* packages which failed.
|
|
|
|
*/
|
2001-01-16 07:09:42 +08:00
|
|
|
if (ts->orderCount == ts->orderAlloced) {
|
|
|
|
ts->orderAlloced += ts->delta;
|
|
|
|
ts->order = xrealloc(ts->order, sizeof(*ts->order) * ts->orderAlloced);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->order[ts->orderCount].type = TR_ADDED;
|
|
|
|
alNum = alAddPackage(&ts->addedPackages, h, key, fd, relocs) -
|
|
|
|
ts->addedPackages.list;
|
|
|
|
ts->order[ts->orderCount++].u.addedIndex = alNum;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
if (!upgrade || ts->rpmdb == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* XXX binary rpms always have RPMTAG_SOURCERPM, source rpms do not */
|
|
|
|
if (headerIsEntry(h, RPMTAG_SOURCEPACKAGE))
|
|
|
|
return 0;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2000-04-13 17:07:08 +08:00
|
|
|
headerNVR(h, &name, NULL, NULL);
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2000-04-13 17:07:08 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
|
|
|
Header h2;
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, name, 0);
|
2000-04-13 17:07:08 +08:00
|
|
|
while((h2 = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
if (rpmVersionCompare(h, h2))
|
2001-01-16 07:09:42 +08:00
|
|
|
removePackage(ts, rpmdbGetIteratorOffset(mi), alNum);
|
2000-07-06 04:39:15 +08:00
|
|
|
else {
|
|
|
|
uint_32 *p, multiLibMask = 0, oldmultiLibMask = 0;
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (hge(h2, RPMTAG_MULTILIBS, NULL, (void **) &p, NULL))
|
2000-07-06 04:39:15 +08:00
|
|
|
oldmultiLibMask = *p;
|
2001-02-05 06:15:30 +08:00
|
|
|
if (hge(h, RPMTAG_MULTILIBS, NULL, (void **) &p, NULL))
|
2000-07-06 04:39:15 +08:00
|
|
|
multiLibMask = *p;
|
|
|
|
if (oldmultiLibMask && multiLibMask
|
|
|
|
&& !(oldmultiLibMask & multiLibMask)) {
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->addedPackages.list[alNum].multiLib = multiLibMask;
|
2000-07-06 04:39:15 +08:00
|
|
|
}
|
|
|
|
}
|
2000-04-13 17:07:08 +08:00
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (hge(h, RPMTAG_OBSOLETENAME, &ont, (void **) &obsoletes, &count)) {
|
1999-09-12 05:10:02 +08:00
|
|
|
const char **obsoletesEVR;
|
|
|
|
int_32 *obsoletesFlags;
|
2000-04-13 20:43:49 +08:00
|
|
|
int j;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
hge(h, RPMTAG_OBSOLETEVERSION, &ovt, (void **) &obsoletesEVR, NULL);
|
|
|
|
hge(h, RPMTAG_OBSOLETEFLAGS, NULL, (void **) &obsoletesFlags, NULL);
|
1999-08-21 05:05:18 +08:00
|
|
|
|
|
|
|
for (j = 0; j < count; j++) {
|
1999-09-12 07:57:59 +08:00
|
|
|
|
|
|
|
/* XXX avoid self-obsoleting packages. */
|
|
|
|
if (!strcmp(name, obsoletes[j]))
|
|
|
|
continue;
|
|
|
|
|
2000-04-13 17:07:08 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
|
|
|
Header h2;
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, obsoletes[j], 0);
|
2000-04-13 17:07:08 +08:00
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
if (obsoletesEVR == NULL ||
|
|
|
|
headerMatchesDepFlags(h2,
|
2000-05-07 08:53:11 +08:00
|
|
|
obsoletes[j], obsoletesEVR[j], obsoletesFlags[j]))
|
|
|
|
{
|
2001-01-16 07:09:42 +08:00
|
|
|
removePackage(ts, rpmdbGetIteratorOffset(mi), alNum);
|
2000-04-13 17:07:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
obsoletesEVR = hfd(obsoletesEVR, ovt);
|
|
|
|
obsoletes = hfd(obsoletes, ont);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-27 01:06:09 +08:00
|
|
|
void rpmtransAvailablePackage(rpmTransactionSet ts, Header h, const void * key)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
1999-09-18 05:08:32 +08:00
|
|
|
struct availablePackage * al;
|
2001-01-16 07:09:42 +08:00
|
|
|
al = alAddPackage(&ts->availablePackages, h, key, NULL, NULL);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
void rpmtransRemovePackage(rpmTransactionSet ts, int dboffset)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-01-16 07:09:42 +08:00
|
|
|
removePackage(ts, dboffset, -1);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
void rpmtransFree(rpmTransactionSet ts)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
2001-04-21 14:02:09 +08:00
|
|
|
alFree(&ts->addedPackages);
|
|
|
|
alFree(&ts->availablePackages);
|
|
|
|
ts->di = _free(ts->di);
|
|
|
|
ts->removedPackages = _free(ts->removedPackages);
|
|
|
|
ts->order = _free(ts->order);
|
2001-04-29 09:05:43 +08:00
|
|
|
if (ts->scriptFd != NULL)
|
2001-01-16 07:09:42 +08:00
|
|
|
ts->scriptFd = fdFree(ts->scriptFd, "rpmtransSetScriptFd (rpmtransFree");
|
2001-04-21 14:02:09 +08:00
|
|
|
ts->rootDir = _free(ts->rootDir);
|
|
|
|
ts->currDir = _free(ts->currDir);
|
2001-01-16 07:09:42 +08:00
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
ts = _free(ts);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
1999-11-27 05:58:42 +08:00
|
|
|
void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts,
|
|
|
|
int numConflicts)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < numConflicts; i++) {
|
|
|
|
headerFree(conflicts[i].byHeader);
|
2001-04-21 14:02:09 +08:00
|
|
|
conflicts[i].byName = _free(conflicts[i].byName);
|
|
|
|
conflicts[i].byVersion = _free(conflicts[i].byVersion);
|
|
|
|
conflicts[i].byRelease = _free(conflicts[i].byRelease);
|
|
|
|
conflicts[i].needsName = _free(conflicts[i].needsName);
|
|
|
|
conflicts[i].needsVersion = _free(conflicts[i].needsVersion);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
conflicts = _free(conflicts);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Check added package file lists for a file.
|
|
|
|
* @param al available list
|
|
|
|
* @param keyType type of dependency
|
|
|
|
* @param fileName file name to search for
|
|
|
|
* @return available package pointer
|
|
|
|
*/
|
1999-10-21 05:40:10 +08:00
|
|
|
/*@dependent@*/ /*@null@*/ static struct availablePackage *
|
1999-12-08 05:14:51 +08:00
|
|
|
alFileSatisfiesDepend(struct availableList * al,
|
|
|
|
const char * keyType, const char * fileName)
|
1999-10-21 05:40:10 +08:00
|
|
|
{
|
1999-10-07 06:52:12 +08:00
|
|
|
int i;
|
1999-11-27 05:58:42 +08:00
|
|
|
const char * dirName;
|
|
|
|
const char * baseName;
|
2001-04-29 09:05:43 +08:00
|
|
|
struct dirInfo_s dirNeedle;
|
|
|
|
dirInfo dirMatch;
|
1999-10-07 06:52:12 +08:00
|
|
|
|
2000-04-07 21:10:37 +08:00
|
|
|
if (al->numDirs == 0) /* Solaris 2.6 bsearch sucks down on this. */
|
|
|
|
return NULL;
|
|
|
|
|
1999-11-27 05:58:42 +08:00
|
|
|
{ char * chptr = xstrdup(fileName);
|
|
|
|
dirName = chptr;
|
|
|
|
chptr = strrchr(chptr, '/');
|
|
|
|
chptr++;
|
|
|
|
*chptr = '\0';
|
|
|
|
}
|
1999-10-07 06:52:12 +08:00
|
|
|
|
1999-11-27 05:58:42 +08:00
|
|
|
dirNeedle.dirName = (char *) dirName;
|
1999-12-15 23:51:30 +08:00
|
|
|
dirNeedle.dirNameLen = strlen(dirName);
|
1999-10-07 06:52:12 +08:00
|
|
|
dirMatch = bsearch(&dirNeedle, al->dirs, al->numDirs,
|
|
|
|
sizeof(dirNeedle), dirInfoCompare);
|
2001-04-21 14:02:09 +08:00
|
|
|
dirName = _free(dirName);
|
1999-10-07 06:52:12 +08:00
|
|
|
if (!dirMatch) return NULL;
|
|
|
|
|
1999-11-27 05:58:42 +08:00
|
|
|
baseName = strrchr(fileName, '/') + 1;
|
1999-10-07 06:52:12 +08:00
|
|
|
|
|
|
|
/* XXX FIXME: these file lists should be sorted and bsearched */
|
|
|
|
for (i = 0; i < dirMatch->numFiles; i++) {
|
1999-11-27 05:58:42 +08:00
|
|
|
if (!strcmp(dirMatch->files[i].baseName, baseName)) {
|
2000-07-06 04:39:15 +08:00
|
|
|
|
|
|
|
/* If a file dependency would be satisfied by a file
|
|
|
|
we are not going to install, skip it. */
|
|
|
|
if (al->list[dirMatch->files[i].pkgNum].multiLib &&
|
|
|
|
!isFileMULTILIB(dirMatch->files[i].fileFlags))
|
|
|
|
continue;
|
|
|
|
|
1999-10-07 06:52:12 +08:00
|
|
|
if (keyType)
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added files)\n"),
|
|
|
|
keyType, fileName);
|
1999-12-09 00:32:25 +08:00
|
|
|
return al->list + dirMatch->files[i].pkgNum;
|
1999-10-07 06:52:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Check added package file lists for a provide.
|
|
|
|
* @param al available list
|
|
|
|
* @param keyType type of dependency
|
|
|
|
* @param keyDepend dependency string representation
|
|
|
|
* @param keyName dependency name string
|
|
|
|
* @param keyEVR dependency [epoch:]version[-release] string
|
|
|
|
* @param keyFlags dependency logical range qualifiers
|
|
|
|
* @return available package pointer
|
|
|
|
*/
|
1999-12-08 05:14:51 +08:00
|
|
|
/*@dependent@*/ /*@null@*/ static struct availablePackage * alSatisfiesDepend(
|
1999-10-07 06:52:12 +08:00
|
|
|
struct availableList * al,
|
1999-12-08 05:14:51 +08:00
|
|
|
const char * keyType, const char * keyDepend,
|
1999-09-24 22:54:23 +08:00
|
|
|
const char * keyName, const char * keyEVR, int keyFlags)
|
1999-07-23 01:48:31 +08:00
|
|
|
{
|
|
|
|
struct availableIndexEntry needle, * match;
|
1999-12-08 05:14:51 +08:00
|
|
|
struct availablePackage * p;
|
1999-09-19 08:29:44 +08:00
|
|
|
int i, rc;
|
1999-07-23 01:48:31 +08:00
|
|
|
|
1999-10-07 06:52:12 +08:00
|
|
|
if (*keyName == '/')
|
|
|
|
return alFileSatisfiesDepend(al, keyType, keyName);
|
|
|
|
|
1999-07-23 01:48:31 +08:00
|
|
|
if (!al->index.size) return NULL;
|
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
needle.entry = keyName;
|
2000-04-14 00:00:34 +08:00
|
|
|
needle.entryLen = strlen(keyName);
|
1999-07-23 01:48:31 +08:00
|
|
|
match = bsearch(&needle, al->index.index, al->index.size,
|
|
|
|
sizeof(*al->index.index), indexcmp);
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
if (match == NULL) return NULL;
|
|
|
|
|
|
|
|
p = match->package;
|
|
|
|
rc = 0;
|
|
|
|
switch (match->type) {
|
|
|
|
case IET_PROVIDES:
|
|
|
|
for (i = 0; i < p->providesCount; i++) {
|
1999-09-20 21:23:46 +08:00
|
|
|
const char *proEVR;
|
|
|
|
int proFlags;
|
|
|
|
|
|
|
|
/* Filter out provides that came along for the ride. */
|
2000-05-07 08:53:11 +08:00
|
|
|
if (strcmp(p->provides[i], keyName))
|
|
|
|
continue;
|
1999-09-20 21:23:46 +08:00
|
|
|
|
|
|
|
proEVR = (p->providesEVR ? p->providesEVR[i] : NULL);
|
|
|
|
proFlags = (p->provideFlags ? p->provideFlags[i] : 0);
|
2000-07-11 10:12:49 +08:00
|
|
|
rc = rpmRangesOverlap(p->provides[i], proEVR, proFlags,
|
1999-09-20 21:04:44 +08:00
|
|
|
keyName, keyEVR, keyFlags);
|
1999-09-19 08:29:44 +08:00
|
|
|
if (rc) break;
|
|
|
|
}
|
1999-09-24 22:54:23 +08:00
|
|
|
if (keyType && keyDepend && rc)
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (added provide)\n"),
|
|
|
|
keyType, keyDepend+2);
|
1999-09-19 08:29:44 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-07-23 01:48:31 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
if (rc)
|
|
|
|
return p;
|
1999-07-23 01:48:31 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Check key for an unsatisfied dependency.
|
|
|
|
* @param al available list
|
|
|
|
* @param keyType type of dependency
|
|
|
|
* @param keyDepend dependency string representation
|
|
|
|
* @param keyName dependency name string
|
|
|
|
* @param keyEVR dependency [epoch:]version[-release] string
|
|
|
|
* @param keyFlags dependency logical range qualifiers
|
|
|
|
* @retval suggestion possible package to resolve dependency
|
|
|
|
* @return 0 if satisfied, 1 if not satisfied, 2 if error
|
|
|
|
*/
|
2001-01-16 07:09:42 +08:00
|
|
|
static int unsatisfiedDepend(rpmTransactionSet ts,
|
1999-12-08 05:14:51 +08:00
|
|
|
const char * keyType, const char * keyDepend,
|
1999-09-24 22:54:23 +08:00
|
|
|
const char * keyName, const char * keyEVR, int keyFlags,
|
1999-10-21 05:40:10 +08:00
|
|
|
/*@out@*/ struct availablePackage ** suggestion)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-05-02 16:30:31 +08:00
|
|
|
static int _cacheDependsRC = 1;
|
2000-04-14 00:00:34 +08:00
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
Header h;
|
1999-09-19 08:29:44 +08:00
|
|
|
int rc = 0; /* assume dependency is satisfied */
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1996-07-18 10:25:13 +08:00
|
|
|
if (suggestion) *suggestion = NULL;
|
|
|
|
|
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 {
|
2000-06-13 06:07:13 +08:00
|
|
|
DBC * dbcursor = NULL;
|
2000-05-07 08:53:11 +08:00
|
|
|
size_t keylen = strlen(keyDepend);
|
|
|
|
void * datap = NULL;
|
|
|
|
size_t datalen = 0;
|
|
|
|
int xx;
|
2000-06-13 06:07:13 +08:00
|
|
|
xx = dbiCopen(dbi, &dbcursor, 0);
|
|
|
|
xx = dbiGet(dbi, dbcursor, (void **)&keyDepend, &keylen, &datap, &datalen, 0);
|
2000-05-07 08:53:11 +08:00
|
|
|
if (xx == 0 && datap && datalen == 4) {
|
|
|
|
memcpy(&rc, datap, datalen);
|
2001-04-21 14:02:09 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s %-s (cached)\n"),
|
|
|
|
keyType, keyDepend, (rc ? _("NO ") : _("YES")));
|
2000-05-07 08:53:11 +08:00
|
|
|
xx = dbiCclose(dbi, NULL, 0);
|
|
|
|
return rc;
|
|
|
|
}
|
2000-06-13 06:07:13 +08:00
|
|
|
xx = dbiCclose(dbi, dbcursor, 0);
|
2000-04-26 03:41:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#ifndef DYING
|
1999-09-12 05:10:02 +08:00
|
|
|
{ const char * rcProvidesString;
|
|
|
|
const char * start;
|
2000-08-23 20:39:49 +08:00
|
|
|
int i;
|
2000-04-14 00:00:34 +08:00
|
|
|
|
1999-09-14 13:41:13 +08:00
|
|
|
if (!(keyFlags & RPMSENSE_SENSEMASK) &&
|
1997-07-24 02:32:15 +08:00
|
|
|
(rcProvidesString = rpmGetVar(RPMVAR_PROVIDES))) {
|
1999-09-14 13:41:13 +08:00
|
|
|
i = strlen(keyName);
|
|
|
|
while ((start = strstr(rcProvidesString, keyName))) {
|
2001-04-29 09:05:43 +08:00
|
|
|
if (xisspace(start[i]) || start[i] == '\0' || start[i] == ',') {
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (rpmrc provides)\n"),
|
|
|
|
keyType, keyDepend+2);
|
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-02-05 06:15:30 +08:00
|
|
|
if (!strncmp(keyName, "rpmlib(", sizeof("rpmlib(")-1)) {
|
2000-07-14 07:30:41 +08:00
|
|
|
if (rpmCheckRpmlibProvides(keyName, keyEVR, keyFlags)) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (rpmlib provides)\n"),
|
|
|
|
keyType, keyDepend+2);
|
|
|
|
goto exit;
|
|
|
|
}
|
2000-11-01 02:24:05 +08:00
|
|
|
goto unsatisfied;
|
2000-07-14 07:30:41 +08:00
|
|
|
}
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
if (alSatisfiesDepend(&ts->addedPackages, keyType, keyDepend, keyName, keyEVR, keyFlags)) {
|
1999-09-19 08:29:44 +08:00
|
|
|
goto exit;
|
1999-09-24 22:54:23 +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. */
|
2001-01-16 07:09:42 +08:00
|
|
|
if (ts->rpmdb != NULL) {
|
1999-09-14 13:41:13 +08:00
|
|
|
if (*keyName == '/') {
|
|
|
|
/* keyFlags better be 0! */
|
1997-05-01 03:28:09 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_BASENAMES, keyName, 0);
|
2000-05-07 08:53:11 +08:00
|
|
|
|
|
|
|
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) {
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (db files)\n"),
|
|
|
|
keyType, keyDepend+2);
|
|
|
|
rpmdbFreeIterator(mi);
|
1999-09-24 22:54:23 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmdbFreeIterator(mi);
|
1996-07-18 10:25:13 +08:00
|
|
|
}
|
2000-04-13 18:11:32 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_PROVIDENAME, keyName, 0);
|
2000-05-07 08:53:11 +08:00
|
|
|
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) {
|
2000-05-07 08:53:11 +08:00
|
|
|
if (rangeMatchesDepFlags(h, keyName, keyEVR, keyFlags)) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (db provides)\n"),
|
|
|
|
keyType, keyDepend+2);
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
goto exit;
|
|
|
|
}
|
2000-04-14 00:00:34 +08:00
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
2000-12-13 04:03:45 +08:00
|
|
|
|
|
|
|
#ifndef DYING
|
2001-01-16 07:09:42 +08:00
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_NAME, keyName, 0);
|
2000-12-13 04:03:45 +08:00
|
|
|
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) {
|
|
|
|
if (rangeMatchesDepFlags(h, keyName, keyEVR, keyFlags)) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (db package)\n"),
|
|
|
|
keyType, keyDepend+2);
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
#endif
|
|
|
|
|
1996-06-10 10:36:07 +08:00
|
|
|
}
|
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
if (suggestion)
|
2001-01-16 07:09:42 +08:00
|
|
|
*suggestion = alSatisfiesDepend(&ts->availablePackages, NULL, NULL,
|
1999-09-24 22:54:23 +08:00
|
|
|
keyName, keyEVR, keyFlags);
|
1996-07-18 10:25:13 +08:00
|
|
|
|
2000-11-01 02:24:05 +08:00
|
|
|
unsatisfied:
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s NO\n"), keyType, keyDepend+2);
|
1999-09-19 08:29:44 +08:00
|
|
|
rc = 1; /* dependency is unsatisfied */
|
|
|
|
|
|
|
|
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 {
|
2000-06-13 06:07:13 +08:00
|
|
|
DBC * dbcursor = NULL;
|
2000-04-28 23:14:47 +08:00
|
|
|
int xx;
|
2000-06-13 06:07:13 +08:00
|
|
|
xx = dbiCopen(dbi, &dbcursor, 0);
|
|
|
|
xx = dbiPut(dbi, dbcursor, keyDepend, strlen(keyDepend), &rc, sizeof(rc), 0);
|
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-04-21 14:02:09 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: (%s, %s) added to Depends cache.\n"), keyType, keyDepend, (rc ? _("NO ") : _("YES")));
|
2000-05-07 08:53:11 +08:00
|
|
|
#endif
|
2000-06-13 06:07:13 +08:00
|
|
|
xx = dbiCclose(dbi, dbcursor, 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-01-16 07:09:42 +08:00
|
|
|
static int checkPackageDeps(rpmTransactionSet ts, struct problemsSet * psp,
|
2000-07-06 04:39:15 +08:00
|
|
|
Header h, const char * keyName, uint_32 multiLib)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
|
|
|
HFD_t hfd = headerFreeData;
|
|
|
|
int rnt, rvt;
|
|
|
|
int cnt, cvt;
|
1999-07-23 01:48:31 +08:00
|
|
|
const char * name, * version, * release;
|
2000-09-27 02:04:12 +08:00
|
|
|
const char ** requires;
|
|
|
|
const char ** requiresEVR = NULL;
|
|
|
|
int_32 * requireFlags = NULL;
|
|
|
|
int requiresCount = 0;
|
|
|
|
const char ** conflicts;
|
|
|
|
const char ** conflictsEVR = NULL;
|
|
|
|
int_32 * conflictFlags = NULL;
|
|
|
|
int conflictsCount = 0;
|
1999-07-23 01:48:31 +08:00
|
|
|
int type;
|
1996-06-11 01:42:57 +08:00
|
|
|
int i, rc;
|
1996-10-21 03:31:21 +08:00
|
|
|
int ourrc = 0;
|
1996-07-18 10:25:13 +08:00
|
|
|
struct availablePackage * suggestion;
|
1996-06-11 01:42:57 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
headerNVR(h, &name, &version, &release);
|
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
if (!hge(h, RPMTAG_REQUIRENAME, &rnt, (void **) &requires, &requiresCount))
|
|
|
|
{
|
1996-10-21 03:31:21 +08:00
|
|
|
requiresCount = 0;
|
2001-04-29 09:05:43 +08:00
|
|
|
rvt = RPM_STRING_ARRAY_TYPE;
|
1996-10-21 03:31:21 +08:00
|
|
|
} else {
|
2001-02-05 06:15:30 +08:00
|
|
|
hge(h, RPMTAG_REQUIREFLAGS, &type, (void **) &requireFlags,
|
1996-10-21 03:31:21 +08:00
|
|
|
&requiresCount);
|
2001-02-05 06:15:30 +08:00
|
|
|
hge(h, RPMTAG_REQUIREVERSION, &rvt,
|
1999-09-12 05:10:02 +08:00
|
|
|
(void **) &requiresEVR, &requiresCount);
|
1996-10-21 03:31:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < requiresCount && !ourrc; i++) {
|
2001-04-21 14:02:09 +08:00
|
|
|
const char * keyDepend;
|
1999-09-14 13:41:13 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Filter out requires that came along for the ride. */
|
|
|
|
if (keyName && strcmp(keyName, requires[i]))
|
|
|
|
continue;
|
|
|
|
|
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. */
|
|
|
|
if (multiLib && !isDependsMULTILIB(requireFlags[i]))
|
|
|
|
continue;
|
|
|
|
|
2000-04-26 03:41:37 +08:00
|
|
|
keyDepend = printDepend("R", requires[i], requiresEVR[i], requireFlags[i]);
|
1996-06-11 01:42:57 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
rc = unsatisfiedDepend(ts, " Requires", keyDepend,
|
1999-09-25 02:03:20 +08:00
|
|
|
requires[i], requiresEVR[i], requireFlags[i], &suggestion);
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
switch (rc) {
|
1999-09-19 08:29:44 +08:00
|
|
|
case 0: /* requirements are satisfied. */
|
1999-09-14 13:41:13 +08:00
|
|
|
break;
|
1999-09-19 08:29:44 +08:00
|
|
|
case 1: /* requirements are not satisfied. */
|
2000-07-10 07:10:25 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("package %s-%s-%s require not satisfied: %s\n"),
|
|
|
|
name, version, release, keyDepend+2);
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1996-06-11 01:42:57 +08:00
|
|
|
if (psp->num == psp->alloced) {
|
|
|
|
psp->alloced += 5;
|
1999-09-21 11:22:53 +08:00
|
|
|
psp->problems = xrealloc(psp->problems, sizeof(*psp->problems) *
|
1996-06-11 01:42:57 +08:00
|
|
|
psp->alloced);
|
|
|
|
}
|
1998-12-17 05:58:53 +08:00
|
|
|
psp->problems[psp->num].byHeader = headerLink(h);
|
1999-09-21 11:22:53 +08:00
|
|
|
psp->problems[psp->num].byName = xstrdup(name);
|
|
|
|
psp->problems[psp->num].byVersion = xstrdup(version);
|
|
|
|
psp->problems[psp->num].byRelease = xstrdup(release);
|
|
|
|
psp->problems[psp->num].needsName = xstrdup(requires[i]);
|
|
|
|
psp->problems[psp->num].needsVersion = xstrdup(requiresEVR[i]);
|
1996-07-11 00:29:24 +08:00
|
|
|
psp->problems[psp->num].needsFlags = requireFlags[i];
|
|
|
|
psp->problems[psp->num].sense = RPMDEP_SENSE_REQUIRES;
|
1996-07-20 06:26:00 +08:00
|
|
|
|
|
|
|
if (suggestion)
|
|
|
|
psp->problems[psp->num].suggestedPackage = suggestion->key;
|
|
|
|
else
|
|
|
|
psp->problems[psp->num].suggestedPackage = NULL;
|
1996-07-11 00:29:24 +08:00
|
|
|
|
1996-06-11 01:42:57 +08:00
|
|
|
psp->num++;
|
1999-09-14 13:41:13 +08:00
|
|
|
break;
|
|
|
|
case 2: /* something went wrong! */
|
|
|
|
default:
|
1996-10-21 03:31:21 +08:00
|
|
|
ourrc = 1;
|
1999-09-14 13:41:13 +08:00
|
|
|
break;
|
1996-06-11 01:42:57 +08:00
|
|
|
}
|
2001-04-21 14:02:09 +08:00
|
|
|
keyDepend = _free(keyDepend);
|
1999-09-19 08:29:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (requiresCount) {
|
2001-02-05 06:15:30 +08:00
|
|
|
requiresEVR = hfd(requiresEVR, rvt);
|
|
|
|
requires = hfd(requires, rnt);
|
1999-09-19 08:29:44 +08:00
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!hge(h, RPMTAG_CONFLICTNAME, &cnt, (void **)&conflicts, &conflictsCount))
|
|
|
|
{
|
1999-09-19 08:29:44 +08:00
|
|
|
conflictsCount = 0;
|
2001-04-29 09:05:43 +08:00
|
|
|
cvt = RPM_STRING_ARRAY_TYPE;
|
1999-09-19 08:29:44 +08:00
|
|
|
} else {
|
2001-02-05 06:15:30 +08:00
|
|
|
hge(h, RPMTAG_CONFLICTFLAGS, &type,
|
1999-09-19 08:29:44 +08:00
|
|
|
(void **) &conflictFlags, &conflictsCount);
|
2001-02-05 06:15:30 +08:00
|
|
|
hge(h, RPMTAG_CONFLICTVERSION, &cvt,
|
1999-09-19 08:29:44 +08:00
|
|
|
(void **) &conflictsEVR, &conflictsCount);
|
1996-06-11 01:42:57 +08:00
|
|
|
}
|
|
|
|
|
1996-10-21 03:31:21 +08:00
|
|
|
for (i = 0; i < conflictsCount && !ourrc; i++) {
|
2001-04-21 14:02:09 +08:00
|
|
|
const char * keyDepend;
|
1999-09-14 13:41:13 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Filter out conflicts that came along for the ride. */
|
|
|
|
if (keyName && strcmp(keyName, conflicts[i]))
|
|
|
|
continue;
|
|
|
|
|
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. */
|
|
|
|
if (multiLib && !isDependsMULTILIB(conflictFlags[i]))
|
|
|
|
continue;
|
|
|
|
|
2000-04-26 03:41:37 +08:00
|
|
|
keyDepend = printDepend("C", conflicts[i], conflictsEVR[i], conflictFlags[i]);
|
1996-06-11 01:42:57 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
rc = unsatisfiedDepend(ts, "Conflicts", keyDepend,
|
1999-09-25 02:03:20 +08:00
|
|
|
conflicts[i], conflictsEVR[i], conflictFlags[i], NULL);
|
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. */
|
1998-09-28 06:03:52 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("package %s conflicts: %s\n"),
|
2000-05-07 08:53:11 +08:00
|
|
|
name, keyDepend+2);
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1996-10-21 03:31:21 +08:00
|
|
|
if (psp->num == psp->alloced) {
|
|
|
|
psp->alloced += 5;
|
2001-02-05 06:15:30 +08:00
|
|
|
psp->problems = xrealloc(psp->problems,
|
|
|
|
sizeof(*psp->problems) * psp->alloced);
|
1996-10-21 03:31:21 +08:00
|
|
|
}
|
1998-12-17 05:58:53 +08:00
|
|
|
psp->problems[psp->num].byHeader = headerLink(h);
|
1999-09-21 11:22:53 +08:00
|
|
|
psp->problems[psp->num].byName = xstrdup(name);
|
|
|
|
psp->problems[psp->num].byVersion = xstrdup(version);
|
|
|
|
psp->problems[psp->num].byRelease = xstrdup(release);
|
|
|
|
psp->problems[psp->num].needsName = xstrdup(conflicts[i]);
|
|
|
|
psp->problems[psp->num].needsVersion = xstrdup(conflictsEVR[i]);
|
1999-09-14 13:41:13 +08:00
|
|
|
psp->problems[psp->num].needsFlags = conflictFlags[i];
|
1996-10-21 03:31:21 +08:00
|
|
|
psp->problems[psp->num].sense = RPMDEP_SENSE_CONFLICTS;
|
|
|
|
psp->problems[psp->num].suggestedPackage = NULL;
|
|
|
|
|
|
|
|
psp->num++;
|
1999-09-14 13:41:13 +08:00
|
|
|
break;
|
1999-09-19 08:29:44 +08:00
|
|
|
case 1: /* conflicts don't exist. */
|
1999-09-14 13:41:13 +08:00
|
|
|
break;
|
|
|
|
case 2: /* something went wrong! */
|
|
|
|
default:
|
1996-10-21 03:31:21 +08:00
|
|
|
ourrc = 1;
|
1999-09-14 13:41:13 +08:00
|
|
|
break;
|
1996-10-21 03:31:21 +08:00
|
|
|
}
|
2001-04-21 14:02:09 +08:00
|
|
|
keyDepend = _free(keyDepend);
|
1996-10-21 03:31:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (conflictsCount) {
|
2001-02-05 06:15:30 +08:00
|
|
|
conflictsEVR = hfd(conflictsEVR, cvt);
|
|
|
|
conflicts = hfd(conflicts, cnt);
|
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
|
|
|
/**
|
|
|
|
* Adding: check name/provides key against each conflict match,
|
|
|
|
* Erasing: check name/provides/filename key against each requiredby match.
|
|
|
|
*/
|
2001-01-16 07:09:42 +08:00
|
|
|
static int checkPackageSet(rpmTransactionSet ts, struct problemsSet * psp,
|
2000-04-13 18:11:32 +08:00
|
|
|
const char * key, /*@only@*/ rpmdbMatchIterator mi)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
|
|
|
Header h;
|
2000-04-13 18:11:32 +08:00
|
|
|
int rc = 0;
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
rpmdbPruneIterator(mi, ts->removedPackages, ts->numRemovedPackages, 1);
|
2000-04-13 18:11:32 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
2001-01-16 07:09:42 +08:00
|
|
|
if (checkPackageDeps(ts, psp, h, key, 0)) {
|
2000-04-13 18:11:32 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
|
|
|
|
return rc;
|
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-01-16 07:09:42 +08:00
|
|
|
static int checkDependentPackages(rpmTransactionSet ts,
|
1999-09-19 08:29:44 +08:00
|
|
|
struct problemsSet * psp, const char * key)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-04-13 18:11:32 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2001-01-16 07:09:42 +08:00
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_REQUIRENAME, key, 0);
|
|
|
|
return checkPackageSet(ts, psp, 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-01-16 07:09:42 +08:00
|
|
|
static int checkDependentConflicts(rpmTransactionSet ts,
|
1999-09-19 08:29:44 +08:00
|
|
|
struct problemsSet * psp, const char * key)
|
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-01-16 07:09:42 +08:00
|
|
|
if (ts->rpmdb) { /* XXX is this necessary? */
|
2000-04-13 18:11:32 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2001-01-16 07:09:42 +08:00
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMTAG_CONFLICTNAME, key, 0);
|
|
|
|
rc = checkPackageSet(ts, psp, 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)
|
2000-09-27 02:04:12 +08:00
|
|
|
static struct badDeps_s {
|
|
|
|
const char * pname;
|
|
|
|
const char * qname;
|
|
|
|
} badDeps[] = {
|
|
|
|
{ "libtermcap", "bash" },
|
|
|
|
{ "modutils", "vixie-cron" },
|
|
|
|
{ "ypbind", "yp-tools" },
|
|
|
|
{ "ghostscript-fonts", "ghostscript" },
|
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 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ignoreDep(struct availablePackage * p, struct availablePackage * q)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2000-09-27 02:04:12 +08:00
|
|
|
struct badDeps_s *bdp;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
for (bdp = badDeps; bdp->pname != NULL; bdp++) {
|
2000-12-21 05:08:18 +08:00
|
|
|
if (!strcmp(p->name, bdp->pname) && !strcmp(q->name, 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;
|
|
|
|
}
|
|
|
|
#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
|
|
|
|
*/
|
|
|
|
static void markLoop(struct tsortInfo * tsi, struct availablePackage * q)
|
|
|
|
{
|
|
|
|
struct availablePackage * p;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
while (tsi != NULL) {
|
|
|
|
p = tsi->tsi_suc;
|
|
|
|
tsi = tsi->tsi_next;
|
|
|
|
if (p->tsi.tsi_pkg != NULL)
|
|
|
|
continue;
|
|
|
|
p->tsi.tsi_pkg = q;
|
|
|
|
markLoop(p->tsi.tsi_next, p);
|
|
|
|
}
|
|
|
|
}
|
1997-07-09 02:41:10 +08:00
|
|
|
|
2001-01-27 01:06:09 +08:00
|
|
|
static inline /*@observer@*/ const char * const identifyDepend(int_32 f) {
|
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)
|
|
|
|
*/
|
|
|
|
static /*@owned@*/ /*@null@*/ const char *
|
|
|
|
zapRelation(struct availablePackage * q, struct availablePackage * p,
|
|
|
|
int zap, int * nzaps)
|
|
|
|
{
|
|
|
|
struct tsortInfo * tsi_prev;
|
|
|
|
struct tsortInfo * tsi;
|
|
|
|
const char *dp = NULL;
|
|
|
|
|
|
|
|
if (q == NULL)
|
|
|
|
return dp;
|
|
|
|
for (tsi_prev = &q->tsi, tsi = q->tsi.tsi_next;
|
|
|
|
tsi != NULL;
|
|
|
|
tsi_prev = tsi, tsi = tsi->tsi_next)
|
|
|
|
{
|
|
|
|
int j;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
if (tsi->tsi_suc != p)
|
|
|
|
continue;
|
|
|
|
j = tsi->tsi_reqx;
|
2000-11-12 19:11:49 +08:00
|
|
|
dp = printDepend( identifyDepend(p->requireFlags[j]),
|
2000-09-27 02:04:12 +08:00
|
|
|
p->requires[j], p->requiresEVR[j], p->requireFlags[j]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Attempt to unravel a dependency loop by eliminating PreReq's.
|
|
|
|
* This hack "works" for the (relatively) more important autogenerated
|
|
|
|
* Requires: lib*.so.*
|
|
|
|
* but may cause package %pre/%post scriptlets with, for example,
|
|
|
|
* PreReq: /bin/sh
|
|
|
|
* to fail.
|
|
|
|
*/
|
2000-11-12 19:11:49 +08:00
|
|
|
if (zap && !(p->requireFlags[j] & RPMSENSE_PREREQ)) {
|
2000-09-27 02:04:12 +08:00
|
|
|
rpmMessage(RPMMESS_WARNING,
|
|
|
|
_("removing %s-%s-%s \"%s\" from tsort relations.\n"),
|
|
|
|
p->name, p->version, p->release, dp);
|
|
|
|
p->tsi.tsi_count--;
|
|
|
|
tsi_prev->tsi_next = tsi->tsi_next;
|
|
|
|
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
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
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-01-16 07:09:42 +08:00
|
|
|
static inline int addRelation( const rpmTransactionSet ts,
|
2000-11-12 19:11:49 +08:00
|
|
|
struct availablePackage * p, unsigned char * selected, int j)
|
|
|
|
{
|
|
|
|
struct availablePackage * q;
|
|
|
|
struct tsortInfo * tsi;
|
|
|
|
int matchNum;
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
q = alSatisfiesDepend(&ts->addedPackages, NULL, NULL,
|
2000-11-12 19:11:49 +08:00
|
|
|
p->requires[j], p->requiresEVR[j], p->requireFlags[j]);
|
|
|
|
|
|
|
|
/* Ordering depends only on added package relations. */
|
|
|
|
if (q == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Avoid rpmlib feature dependencies. */
|
|
|
|
if (!strncmp(p->requires[j], "rpmlib(", sizeof("rpmlib(")-1))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if defined(DEPENDENCY_WHITEOUT)
|
|
|
|
/* Avoid certain dependency relations. */
|
|
|
|
if (ignoreDep(p, q))
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Avoid redundant relations. */
|
|
|
|
/* XXX FIXME: add control bit. */
|
2001-01-16 07:09:42 +08:00
|
|
|
matchNum = q - ts->addedPackages.list;
|
2001-04-29 09:05:43 +08:00
|
|
|
if (selected[matchNum] != 0)
|
2000-11-12 19:11:49 +08:00
|
|
|
return 0;
|
|
|
|
selected[matchNum] = 1;
|
|
|
|
|
|
|
|
/* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */
|
2001-01-09 12:07:49 +08:00
|
|
|
p->tsi.tsi_count++; /* bump p predecessor count */
|
2001-04-21 14:02:09 +08:00
|
|
|
if (p->depth <= q->depth) /* Save max. depth in dependency tree */
|
|
|
|
p->depth = q->depth + 1;
|
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
tsi = xmalloc(sizeof(*tsi));
|
|
|
|
tsi->tsi_suc = p;
|
|
|
|
tsi->tsi_reqx = j;
|
|
|
|
tsi->tsi_next = q->tsi.tsi_next;
|
|
|
|
q->tsi.tsi_next = tsi;
|
2001-01-09 12:07:49 +08:00
|
|
|
q->tsi.tsi_qcnt++; /* bump q successor count */
|
2000-11-12 19:11:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
1999-07-14 06:00:05 +08:00
|
|
|
static int orderListIndexCmp(const void * one, const void * two)
|
|
|
|
{
|
2000-07-10 07:10:25 +08:00
|
|
|
int a = ((const struct orderListIndex *)one)->alIndex;
|
|
|
|
int b = ((const struct orderListIndex *)two)->alIndex;
|
|
|
|
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-01-27 01:06:09 +08:00
|
|
|
static void addQ(/*@kept@*/ struct availablePackage * p,
|
2001-04-29 09:05:43 +08:00
|
|
|
struct availablePackage ** qp,
|
|
|
|
struct availablePackage ** rp)
|
2001-01-09 12:07:49 +08:00
|
|
|
{
|
|
|
|
struct availablePackage *q, *qprev;
|
|
|
|
|
|
|
|
if ((*rp) == NULL) { /* 1st element */
|
|
|
|
(*rp) = (*qp) = p;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (qprev = NULL, q = (*qp); q != NULL; qprev = q, q = q->tsi.tsi_suc) {
|
2001-01-13 05:47:49 +08:00
|
|
|
if (q->tsi.tsi_qcnt <= p->tsi.tsi_qcnt)
|
2001-01-09 12:07:49 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (qprev == NULL) { /* insert at beginning of list */
|
|
|
|
p->tsi.tsi_suc = q;
|
|
|
|
(*qp) = p; /* new head */
|
|
|
|
} else if (q == NULL) { /* insert at end of list */
|
|
|
|
qprev->tsi.tsi_suc = p;
|
|
|
|
(*rp) = p; /* new tail */
|
|
|
|
} else { /* insert between qprev and q */
|
|
|
|
p->tsi.tsi_suc = q;
|
|
|
|
qprev->tsi.tsi_suc = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-11 06:19:55 +08:00
|
|
|
int rpmdepOrder(rpmTransactionSet ts)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
2001-01-11 06:19:55 +08:00
|
|
|
int npkgs = ts->addedPackages.size;
|
2001-04-21 14:02:09 +08:00
|
|
|
int chainsaw = ts->transFlags & RPMTRANS_FLAG_CHAINSAW;
|
2000-09-27 02:04:12 +08:00
|
|
|
struct availablePackage * p;
|
|
|
|
struct availablePackage * q;
|
|
|
|
struct availablePackage * r;
|
|
|
|
struct tsortInfo * tsi;
|
|
|
|
struct tsortInfo * tsi_next;
|
|
|
|
int * ordering = alloca(sizeof(*ordering) * (npkgs + 1));
|
|
|
|
int orderingCount = 0;
|
|
|
|
unsigned char * selected = alloca(sizeof(*selected) * (npkgs + 1));
|
|
|
|
int loopcheck;
|
1999-04-05 05:26:36 +08:00
|
|
|
struct transactionElement * newOrder;
|
|
|
|
int newOrderCount = 0;
|
2000-09-27 02:04:12 +08:00
|
|
|
struct orderListIndex * orderList;
|
|
|
|
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-01-11 06:19:55 +08:00
|
|
|
alMakeIndex(&ts->addedPackages);
|
|
|
|
alMakeIndex(&ts->availablePackages);
|
1997-07-16 09:39:54 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
/* T1. Initialize. */
|
|
|
|
loopcheck = npkgs;
|
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-01-11 06:19:55 +08:00
|
|
|
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
|
2000-09-27 02:04:12 +08:00
|
|
|
int matchNum;
|
1997-07-18 23:03:35 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
if (p->requiresCount <= 0)
|
|
|
|
continue;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
memset(selected, 0, sizeof(*selected) * npkgs);
|
|
|
|
|
|
|
|
/* Avoid narcisstic relations. */
|
2001-01-11 06:19:55 +08:00
|
|
|
matchNum = p - ts->addedPackages.list;
|
2000-09-27 02:04:12 +08:00
|
|
|
selected[matchNum] = 1;
|
|
|
|
|
|
|
|
/* T2. Next "q <- p" relation. */
|
2000-11-12 19:11:49 +08:00
|
|
|
|
|
|
|
/* First, do pre-requisites. */
|
2000-09-27 02:04:12 +08:00
|
|
|
for (j = 0; j < p->requiresCount; j++) {
|
|
|
|
|
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
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
if (isErasePreReq(p->requireFlags[j]) ||
|
|
|
|
!( isInstallPreReq(p->requireFlags[j]) ||
|
|
|
|
isLegacyPreReq(p->requireFlags[j]) ))
|
2000-09-27 02:04:12 +08:00
|
|
|
continue;
|
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
/* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */
|
2001-01-11 06:19:55 +08:00
|
|
|
(void) addRelation(ts, p, selected, j);
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Then do co-requisites. */
|
|
|
|
for (j = 0; j < p->requiresCount; j++) {
|
|
|
|
|
|
|
|
/* Skip if %pre/%post requires or legacy prereq. */
|
2000-09-27 02:04:12 +08:00
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
if (isErasePreReq(p->requireFlags[j]) ||
|
|
|
|
( isInstallPreReq(p->requireFlags[j]) ||
|
|
|
|
isLegacyPreReq(p->requireFlags[j]) ))
|
|
|
|
continue;
|
2000-09-27 02:04:12 +08:00
|
|
|
|
|
|
|
/* T3. Record next "q <- p" relation (i.e. "p" requires "q"). */
|
2001-01-11 06:19:55 +08:00
|
|
|
(void) addRelation(ts, p, selected, j);
|
2000-11-12 19:11:49 +08:00
|
|
|
|
2000-09-27 02:04:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
/* Save predecessor count. */
|
|
|
|
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
|
|
|
|
p->npreds = p->tsi.tsi_count;
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
q = r = NULL;
|
2001-01-11 06:19:55 +08:00
|
|
|
qlen = 0;
|
|
|
|
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++) {
|
2001-01-17 01:33:59 +08:00
|
|
|
|
|
|
|
/* Prefer packages in presentation order. */
|
2001-04-21 14:02:09 +08:00
|
|
|
if (!chainsaw)
|
|
|
|
p->tsi.tsi_qcnt = (npkgs - i);
|
2001-01-17 01:33:59 +08:00
|
|
|
|
2001-01-11 04:42:32 +08:00
|
|
|
if (p->tsi.tsi_count != 0)
|
|
|
|
continue;
|
|
|
|
p->tsi.tsi_suc = NULL;
|
|
|
|
addQ(p, &q, &r);
|
|
|
|
qlen++;
|
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.) */
|
2000-09-27 02:04:12 +08:00
|
|
|
for (; q != NULL; q = q->tsi.tsi_suc) {
|
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "%4d%4d%4d%4d %*s %s-%s-%s\n",
|
|
|
|
orderingCount, q->npreds, q->tsi.tsi_qcnt, q->depth,
|
|
|
|
2*q->depth, "",
|
2001-01-13 05:47:49 +08:00
|
|
|
q->name, q->version, q->release);
|
2001-01-11 06:19:55 +08:00
|
|
|
ordering[orderingCount++] = q - ts->addedPackages.list;
|
2001-01-11 04:42:32 +08:00
|
|
|
qlen--;
|
2000-09-27 02:04:12 +08:00
|
|
|
loopcheck--;
|
|
|
|
|
|
|
|
/* T6. Erase relations. */
|
|
|
|
tsi_next = q->tsi.tsi_next;
|
|
|
|
q->tsi.tsi_next = NULL;
|
|
|
|
while ((tsi = tsi_next) != NULL) {
|
|
|
|
tsi_next = tsi->tsi_next;
|
|
|
|
tsi->tsi_next = NULL;
|
|
|
|
p = tsi->tsi_suc;
|
|
|
|
if ((--p->tsi.tsi_count) <= 0) {
|
|
|
|
/* XXX FIXME: add control bit. */
|
|
|
|
p->tsi.tsi_suc = NULL;
|
2001-01-09 12:07:49 +08:00
|
|
|
addQ(p, &q->tsi.tsi_suc, &r);
|
|
|
|
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
|
|
|
}
|
2001-01-21 23:43:32 +08:00
|
|
|
if (!_printed && loopcheck == qlen && q->tsi.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
|
|
|
}
|
|
|
|
|
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-01-11 06:19:55 +08:00
|
|
|
for (i = 0, q = ts->addedPackages.list; i < npkgs; i++, q++) {
|
2000-09-27 02:04:12 +08:00
|
|
|
q->tsi.tsi_pkg = NULL;
|
|
|
|
q->tsi.tsi_reqx = 0;
|
|
|
|
/* Mark packages already sorted. */
|
|
|
|
if (q->tsi.tsi_count == 0)
|
|
|
|
q->tsi.tsi_count = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* T10. Mark all packages with their predecessors. */
|
2001-01-11 06:19:55 +08:00
|
|
|
for (i = 0, q = ts->addedPackages.list; i < npkgs; i++, q++) {
|
2000-09-27 02:04:12 +08:00
|
|
|
if ((tsi = q->tsi.tsi_next) == NULL)
|
|
|
|
continue;
|
|
|
|
q->tsi.tsi_next = NULL;
|
|
|
|
markLoop(tsi, q);
|
|
|
|
q->tsi.tsi_next = tsi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* T11. Print all dependency loops. */
|
2001-01-11 06:19:55 +08:00
|
|
|
for (i = 0, r = ts->addedPackages.list; i < npkgs; i++, r++) {
|
2000-09-27 02:04:12 +08:00
|
|
|
int printed;
|
|
|
|
|
|
|
|
printed = 0;
|
|
|
|
|
|
|
|
/* T12. Mark predecessor chain, looking for start of loop. */
|
|
|
|
for (q = r->tsi.tsi_pkg; q != NULL; q = q->tsi.tsi_pkg) {
|
|
|
|
if (q->tsi.tsi_reqx)
|
|
|
|
break;
|
|
|
|
q->tsi.tsi_reqx = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* T13. Print predecessor chain from start of loop. */
|
|
|
|
while ((p = q) != NULL && (q = p->tsi.tsi_pkg) != NULL) {
|
|
|
|
const char * dp;
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
/* Unchain predecessor loop. */
|
|
|
|
p->tsi.tsi_pkg = NULL;
|
|
|
|
|
|
|
|
if (!printed) {
|
2000-12-14 06:00:33 +08:00
|
|
|
rpmMessage(RPMMESS_WARNING, _("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. */
|
2000-09-27 02:04:12 +08:00
|
|
|
dp = zapRelation(q, p, 1, &nzaps);
|
|
|
|
|
|
|
|
/* Print next member of loop. */
|
|
|
|
sprintf(buf, "%s-%s-%s", p->name, p->version, p->release);
|
2000-12-14 06:00:33 +08:00
|
|
|
rpmMessage(RPMMESS_WARNING, " %-40s %s\n", buf, dp);
|
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. */
|
|
|
|
for (p = r, q = r->tsi.tsi_pkg;
|
|
|
|
q != NULL;
|
|
|
|
p = q, q = q->tsi.tsi_pkg)
|
|
|
|
{
|
|
|
|
/* Unchain linear part of predecessor loop. */
|
|
|
|
p->tsi.tsi_pkg = NULL;
|
|
|
|
p->tsi.tsi_reqx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If a relation was eliminated, then continue sorting. */
|
|
|
|
/* XXX FIXME: add control bit. */
|
|
|
|
if (nzaps && nrescans-- > 0) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("========== continuing tsort ...\n"));
|
|
|
|
goto rescan;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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-01-11 06:19:55 +08:00
|
|
|
orderList = xmalloc(sizeof(*orderList) * npkgs);
|
|
|
|
for (i = 0, j = 0; i < ts->orderCount; i++) {
|
|
|
|
if (ts->order[i].type == TR_ADDED) {
|
|
|
|
orderList[j].alIndex = ts->order[i].u.addedIndex;
|
1999-04-05 05:26:36 +08:00
|
|
|
orderList[j].orIndex = i;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2001-01-11 06:19:55 +08:00
|
|
|
assert(j <= npkgs);
|
1999-04-14 01:26:43 +08:00
|
|
|
|
2001-01-11 06:19:55 +08:00
|
|
|
qsort(orderList, npkgs, sizeof(*orderList), orderListIndexCmp);
|
1999-04-05 05:26:36 +08:00
|
|
|
|
2001-01-11 06:19:55 +08:00
|
|
|
newOrder = xmalloc(sizeof(*newOrder) * ts->orderCount);
|
1999-04-05 05:26:36 +08:00
|
|
|
for (i = 0, newOrderCount = 0; i < orderingCount; i++) {
|
2000-09-27 02:04:12 +08:00
|
|
|
struct orderListIndex * needle, key;
|
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
key.alIndex = ordering[i];
|
2001-01-11 06:19:55 +08:00
|
|
|
needle = bsearch(&key, orderList, npkgs, sizeof(key),orderListIndexCmp);
|
1999-04-05 05:26:36 +08:00
|
|
|
/* bsearch should never, ever fail */
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2001-01-11 06:19:55 +08:00
|
|
|
newOrder[newOrderCount++] = ts->order[needle->orIndex];
|
|
|
|
for (j = needle->orIndex + 1; j < ts->orderCount; j++) {
|
|
|
|
if (ts->order[j].type == TR_REMOVED &&
|
|
|
|
ts->order[j].u.removed.dependsOnIndex == needle->alIndex) {
|
|
|
|
newOrder[newOrderCount++] = ts->order[j];
|
1999-04-05 05:26:36 +08:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-11 06:19:55 +08:00
|
|
|
for (i = 0; i < ts->orderCount; i++) {
|
|
|
|
if (ts->order[i].type == TR_REMOVED &&
|
|
|
|
ts->order[i].u.removed.dependsOnIndex == -1) {
|
|
|
|
newOrder[newOrderCount++] = ts->order[i];
|
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-04-21 14:02:09 +08:00
|
|
|
ts->order = _free(ts->order);
|
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
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
int rpmdepCheck(rpmTransactionSet ts,
|
1999-07-14 06:00:05 +08:00
|
|
|
struct rpmDependencyConflict ** conflicts, int * numConflicts)
|
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
|
|
|
HFD_t hfd = headerFreeData;
|
2001-01-16 07:09:42 +08:00
|
|
|
int npkgs = ts->addedPackages.size;
|
1999-07-14 06:00:05 +08:00
|
|
|
struct availablePackage * p;
|
|
|
|
int i, j;
|
1999-09-14 13:41:13 +08:00
|
|
|
int rc;
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmdbMatchIterator mi = NULL;
|
1999-09-14 13:41:13 +08:00
|
|
|
Header h = NULL;
|
1999-07-14 06:00:05 +08:00
|
|
|
struct problemsSet ps;
|
1999-04-05 05:26:36 +08:00
|
|
|
|
1999-07-14 06:00:05 +08:00
|
|
|
ps.alloced = 5;
|
|
|
|
ps.num = 0;
|
1999-09-21 11:22:53 +08:00
|
|
|
ps.problems = xcalloc(ps.alloced, sizeof(struct rpmDependencyConflict));
|
1999-07-14 06:00:05 +08:00
|
|
|
|
|
|
|
*conflicts = NULL;
|
|
|
|
*numConflicts = 0;
|
|
|
|
|
2001-01-16 07:09:42 +08:00
|
|
|
qsort(ts->removedPackages, ts->numRemovedPackages, sizeof(int), intcmp);
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-01-16 07:09:42 +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-01-16 07:09:42 +08:00
|
|
|
for (i = 0, p = ts->addedPackages.list; i < npkgs; i++, p++)
|
2000-09-27 02:04:12 +08:00
|
|
|
{
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2001-04-24 04:56:59 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, ("========== +++ %s-%s-%s\n"),
|
|
|
|
p->name, p->version, p->release);
|
2001-01-16 07:09:42 +08:00
|
|
|
rc = checkPackageDeps(ts, &ps, p->h, NULL, p->multiLib);
|
2000-07-08 04:06:41 +08:00
|
|
|
if (rc)
|
1999-09-14 13:41:13 +08:00
|
|
|
goto exit;
|
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Adding: check name against conflicts matches. */
|
2001-01-16 07:09:42 +08:00
|
|
|
rc = checkDependentConflicts(ts, &ps, p->name);
|
2000-07-08 04:06:41 +08:00
|
|
|
if (rc)
|
1999-09-14 13:41:13 +08:00
|
|
|
goto exit;
|
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
if (p->providesCount == 0 || p->provides == NULL)
|
|
|
|
continue;
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
rc = 0;
|
1999-09-19 08:29:44 +08:00
|
|
|
for (j = 0; j < p->providesCount; j++) {
|
|
|
|
/* Adding: check provides key against conflicts matches. */
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!checkDependentConflicts(ts, &ps, p->provides[j]))
|
|
|
|
continue;
|
|
|
|
rc = 1;
|
|
|
|
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-02-05 06:15:30 +08:00
|
|
|
/*
|
|
|
|
* Look at the removed packages and make sure they aren't critical.
|
|
|
|
*/
|
2001-01-16 07:09:42 +08:00
|
|
|
if (ts->numRemovedPackages > 0) {
|
|
|
|
mi = rpmdbInitIterator(ts->rpmdb, RPMDBI_PACKAGES, NULL, 0);
|
|
|
|
rpmdbAppendIterator(mi, ts->removedPackages, ts->numRemovedPackages);
|
2000-06-07 04:06:09 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2001-04-24 04:56:59 +08:00
|
|
|
{ const char * name, * version, * release;
|
|
|
|
headerNVR(h, &name, &version, &release);
|
|
|
|
rpmMessage(RPMMESS_DEBUG, ("========== --- %s-%s-%s\n"),
|
|
|
|
name, version, release);
|
1999-07-14 06:00:05 +08:00
|
|
|
|
1999-12-01 02:07:08 +08:00
|
|
|
/* Erasing: check name against requiredby matches. */
|
2001-01-16 07:09:42 +08:00
|
|
|
rc = checkDependentPackages(ts, &ps, name);
|
2000-07-08 04:06:41 +08:00
|
|
|
if (rc)
|
1999-12-01 02:07:08 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
|
1999-12-01 02:07:08 +08:00
|
|
|
{ const char ** provides;
|
|
|
|
int providesCount;
|
2001-02-05 06:15:30 +08:00
|
|
|
int pnt;
|
1999-12-01 02:07:08 +08:00
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (hge(h, RPMTAG_PROVIDENAME, &pnt, (void **) &provides,
|
|
|
|
&providesCount))
|
|
|
|
{
|
1999-12-01 02:07:08 +08:00
|
|
|
rc = 0;
|
|
|
|
for (j = 0; j < providesCount; j++) {
|
|
|
|
/* Erasing: check provides against requiredby matches. */
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!checkDependentPackages(ts, &ps, provides[j]))
|
|
|
|
continue;
|
1999-09-14 13:41:13 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
2001-02-05 06:15:30 +08:00
|
|
|
provides = hfd(provides, pnt);
|
1999-12-01 02:07:08 +08:00
|
|
|
if (rc)
|
|
|
|
goto exit;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-01 02:07:08 +08:00
|
|
|
{ const char ** baseNames, ** dirNames;
|
2001-02-05 06:15:30 +08:00
|
|
|
int_32 * dirIndexes, dnt, bnt;
|
1999-12-01 02:07:08 +08:00
|
|
|
int fileCount;
|
|
|
|
char * fileName = NULL;
|
|
|
|
int fileAlloced = 0;
|
|
|
|
int len;
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
if (hge(h, RPMTAG_BASENAMES, &bnt, (void **) &baseNames, &fileCount))
|
|
|
|
{
|
|
|
|
hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL);
|
|
|
|
hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL);
|
1999-12-01 02:07:08 +08:00
|
|
|
rc = 0;
|
|
|
|
for (j = 0; j < fileCount; j++) {
|
|
|
|
len = strlen(baseNames[j]) + 1 +
|
|
|
|
strlen(dirNames[dirIndexes[j]]);
|
|
|
|
if (len > fileAlloced) {
|
|
|
|
fileAlloced = len * 2;
|
|
|
|
fileName = xrealloc(fileName, fileAlloced);
|
|
|
|
}
|
2000-04-14 00:00:34 +08:00
|
|
|
*fileName = '\0';
|
2000-07-08 04:06:41 +08:00
|
|
|
(void) stpcpy( stpcpy(fileName, dirNames[dirIndexes[j]]) , baseNames[j]);
|
1999-12-01 02:07:08 +08:00
|
|
|
/* Erasing: check filename against requiredby matches. */
|
2001-02-05 06:15:30 +08:00
|
|
|
if (!checkDependentPackages(ts, &ps, fileName))
|
|
|
|
continue;
|
|
|
|
rc = 1;
|
|
|
|
break;
|
1999-10-09 04:30:49 +08:00
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
fileName = _free(fileName);
|
2001-02-05 06:15:30 +08:00
|
|
|
baseNames = hfd(baseNames, bnt);
|
|
|
|
dirNames = hfd(dirNames, dnt);
|
1999-12-01 02:07:08 +08:00
|
|
|
if (rc)
|
|
|
|
goto exit;
|
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
2000-06-07 04:06:09 +08:00
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
2000-07-08 04:06:41 +08:00
|
|
|
mi = NULL;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
2001-04-21 14:02:09 +08:00
|
|
|
if (ps.num) {
|
1999-07-14 06:00:05 +08:00
|
|
|
*conflicts = ps.problems;
|
2001-04-21 14:02:09 +08:00
|
|
|
ps.problems = NULL;
|
1999-07-14 06:00:05 +08:00
|
|
|
*numConflicts = ps.num;
|
|
|
|
}
|
2000-07-08 04:06:41 +08:00
|
|
|
rc = 0;
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
exit:
|
2001-04-29 09:05:43 +08:00
|
|
|
if (mi != NULL)
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmdbFreeIterator(mi);
|
2001-04-21 14:02:09 +08:00
|
|
|
ps.problems = _free(ps.problems);
|
2000-07-08 04:06:41 +08:00
|
|
|
return rc;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|