1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1998-07-31 06:09:42 +08:00
|
|
|
|
2000-08-28 03:27:03 +08:00
|
|
|
/** \ingroup rpmdep
|
|
|
|
* \file lib/depends.c
|
|
|
|
*/
|
|
|
|
|
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"
|
1996-06-10 10:36:07 +08:00
|
|
|
|
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;
|
1999-08-07 06:52:49 +08:00
|
|
|
if (np && !headerGetEntry(h, RPMTAG_NAME, &type, (void **) np, &count))
|
|
|
|
*np = NULL;
|
|
|
|
if (vp && !headerGetEntry(h, RPMTAG_VERSION, &type, (void **) vp, &count))
|
|
|
|
*vp = NULL;
|
|
|
|
if (rp && !headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) rp, &count))
|
|
|
|
*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) {
|
|
|
|
while(*depend) *t++ = *depend++;
|
|
|
|
*t++ = ' ';
|
|
|
|
}
|
1999-09-19 08:29:44 +08:00
|
|
|
if (key)
|
|
|
|
while(*key) *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++ = ' ';
|
|
|
|
while(*keyEVR) *t++ = *keyEVR++;
|
|
|
|
}
|
|
|
|
*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) {
|
|
|
|
if (al->index.index)
|
|
|
|
free(al->index.index);
|
|
|
|
al->index.index = NULL;
|
|
|
|
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
|
|
|
{
|
1996-07-18 04:02:28 +08:00
|
|
|
al->alloced = 5;
|
|
|
|
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
|
|
|
{
|
1997-05-01 03:28:09 +08:00
|
|
|
int i;
|
1999-05-24 02:34:30 +08:00
|
|
|
rpmRelocation * r;
|
1996-07-18 04:02:28 +08:00
|
|
|
|
1997-05-01 03:28:09 +08:00
|
|
|
for (i = 0; i < al->size; i++) {
|
1996-07-18 04:02:28 +08:00
|
|
|
if (al->list[i].provides)
|
|
|
|
free(al->list[i].provides);
|
1999-09-19 23:27:37 +08:00
|
|
|
if (al->list[i].providesEVR)
|
|
|
|
free(al->list[i].providesEVR);
|
1999-11-27 05:58:42 +08:00
|
|
|
if (al->list[i].baseNames)
|
|
|
|
free(al->list[i].baseNames);
|
1999-01-06 10:29:42 +08:00
|
|
|
headerFree(al->list[i].h);
|
1999-05-24 02:34:30 +08:00
|
|
|
|
|
|
|
if (al->list[i].relocs) {
|
1999-08-07 07:44:25 +08:00
|
|
|
for (r = al->list[i].relocs; (r->oldPath || r->newPath); r++) {
|
1999-08-07 06:52:49 +08:00
|
|
|
if (r->oldPath) xfree(r->oldPath);
|
|
|
|
if (r->newPath) xfree(r->newPath);
|
1999-05-24 02:34:30 +08:00
|
|
|
}
|
|
|
|
free(al->list[i].relocs);
|
|
|
|
}
|
1999-12-08 05:14:51 +08:00
|
|
|
if (al->list[i].fd)
|
|
|
|
al->list[i].fd = fdFree(al->list[i].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++) {
|
2000-08-23 20:39:49 +08:00
|
|
|
xfree(al->dirs[i].dirName);
|
1999-10-07 06:52:12 +08:00
|
|
|
free(al->dirs[i].files);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (al->numDirs)
|
|
|
|
free(al->dirs);
|
1999-12-15 23:51:30 +08:00
|
|
|
al->dirs = NULL;
|
1999-10-07 06:52:12 +08:00
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
if (al->alloced && al->list)
|
|
|
|
free(al->list);
|
|
|
|
al->list = NULL;
|
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) /*@*/
|
|
|
|
{
|
1999-10-07 06:52:12 +08:00
|
|
|
const struct dirInfo * a = one;
|
|
|
|
const struct dirInfo * b = 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
|
|
|
{
|
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;
|
|
|
|
struct dirInfo dirNeedle;
|
|
|
|
struct dirInfo * dirMatch;
|
|
|
|
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) {
|
|
|
|
al->alloced += 5;
|
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 */
|
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.
|
|
|
|
*/
|
|
|
|
if (headerGetEntry(p->h, RPMTAG_MULTILIBS, NULL, (void **) &pp, NULL))
|
|
|
|
multiLibMask = *pp;
|
|
|
|
|
|
|
|
if (multiLibMask) {
|
|
|
|
for (i = 0; i < pkgNum - 1; i++) {
|
|
|
|
if (!strcmp (p->name, al->list[i].name)
|
|
|
|
&& headerGetEntry(al->list[i].h, RPMTAG_MULTILIBS, NULL,
|
|
|
|
(void **) &pp, NULL)
|
|
|
|
&& !rpmVersionCompare(p->h, al->list[i].h)
|
|
|
|
&& *pp && !(*pp & multiLibMask))
|
|
|
|
p->multiLib = multiLibMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-15 00:04:03 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_EPOCH, NULL, (void **) &p->epoch, NULL))
|
|
|
|
p->epoch = NULL;
|
1996-07-18 04:02:28 +08:00
|
|
|
|
1999-07-23 01:48:31 +08:00
|
|
|
if (!headerGetEntry(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 {
|
|
|
|
if (!headerGetEntry(h, RPMTAG_PROVIDEVERSION,
|
|
|
|
NULL, (void **) &p->providesEVR, NULL))
|
|
|
|
p->providesEVR = NULL;
|
|
|
|
if (!headerGetEntry(h, RPMTAG_PROVIDEFLAGS,
|
|
|
|
NULL, (void **) &p->provideFlags, NULL))
|
|
|
|
p->provideFlags = NULL;
|
1996-07-18 04:02:28 +08:00
|
|
|
}
|
|
|
|
|
1999-12-09 03:04:50 +08:00
|
|
|
if (!headerGetEntryMinMemory(h, RPMTAG_BASENAMES, NULL, (void **)
|
1999-11-27 05:58:42 +08:00
|
|
|
&p->baseNames, &p->filesCount)) {
|
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 {
|
1999-12-09 03:04:50 +08:00
|
|
|
headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL, (void **)
|
1999-11-27 05:58:42 +08:00
|
|
|
&dirNames, &numDirs);
|
1999-12-09 03:04:50 +08:00
|
|
|
headerGetEntryMinMemory(h, RPMTAG_DIRINDEXES, NULL, (void **)
|
|
|
|
&dirIndexes, NULL);
|
2000-07-06 04:39:15 +08:00
|
|
|
headerGetEntry(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 */
|
|
|
|
|
|
|
|
dirMapping = alloca(sizeof(*dirMapping) * numDirs);
|
|
|
|
|
|
|
|
/* 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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-27 05:58:42 +08:00
|
|
|
free(dirNames);
|
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;
|
1999-12-08 05:14:51 +08:00
|
|
|
p->fd = (fd ? 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;
|
|
|
|
while (*s && isdigit(*s)) s++; /* s points to epoch terminator */
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
1999-09-14 13:41:13 +08:00
|
|
|
free(aEVR);
|
|
|
|
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"),
|
|
|
|
(result ? "YES" : "NO "), aDepend, bDepend);
|
|
|
|
if (aDepend) xfree(aDepend);
|
|
|
|
if (bDepend) xfree(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
|
|
|
{
|
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.
|
|
|
|
*/
|
|
|
|
if (!headerGetEntry(h, RPMTAG_PROVIDEVERSION, &type,
|
1999-09-12 05:10:02 +08:00
|
|
|
(void **) &providesEVR, &providesCount))
|
1999-07-23 01:48:31 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
headerGetEntry(h, RPMTAG_PROVIDEFLAGS, &type,
|
1999-09-14 13:41:13 +08:00
|
|
|
(void **) &provideFlags, &providesCount);
|
1999-07-23 01:48:31 +08:00
|
|
|
|
|
|
|
if (!headerGetEntry(h, RPMTAG_PROVIDENAME, &type,
|
|
|
|
(void **) &provides, &providesCount)) {
|
1999-09-12 05:10:02 +08:00
|
|
|
if (providesEVR) xfree(providesEVR);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (provides) xfree(provides);
|
1999-09-12 05:10:02 +08:00
|
|
|
if (providesEVR) xfree(providesEVR);
|
1999-07-23 01:48:31 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
/* XXX FIXME: eliminate when obsoletes is correctly implemented */
|
|
|
|
int headerMatchesDepFlags(Header h,
|
|
|
|
const char * reqName, const char * reqEVR, int reqFlags)
|
1999-07-23 01:48:31 +08:00
|
|
|
{
|
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';
|
|
|
|
if (headerGetEntry(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
|
|
|
|
sprintf(p, "%d:", *epoch);
|
2000-04-21 08:21:15 +08:00
|
|
|
while (*p)
|
|
|
|
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
|
|
|
{
|
|
|
|
rpmTransactionSet rpmdep;
|
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
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
rpmdep = xcalloc(1, sizeof(*rpmdep));
|
|
|
|
rpmdep->rpmdb = rpmdb;
|
1999-08-21 05:05:18 +08:00
|
|
|
rpmdep->scriptFd = NULL;
|
|
|
|
rpmdep->numRemovedPackages = 0;
|
|
|
|
rpmdep->allocedRemovedPackages = 5;
|
1999-09-21 11:22:53 +08:00
|
|
|
rpmdep->removedPackages = xcalloc(rpmdep->allocedRemovedPackages,
|
|
|
|
sizeof(*rpmdep->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
|
|
|
}
|
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
rpmdep->rootDir = xstrdup(rootDir);
|
|
|
|
rpmdep->currDir = NULL;
|
1999-08-21 05:05:18 +08:00
|
|
|
|
|
|
|
alCreate(&rpmdep->addedPackages);
|
|
|
|
alCreate(&rpmdep->availablePackages);
|
|
|
|
|
|
|
|
rpmdep->orderAlloced = 5;
|
|
|
|
rpmdep->orderCount = 0;
|
1999-10-30 00:06:01 +08:00
|
|
|
rpmdep->order = xcalloc(rpmdep->orderAlloced, sizeof(*rpmdep->order));
|
1999-08-21 05:05:18 +08:00
|
|
|
|
|
|
|
return rpmdep;
|
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Add removed package instance to ordered transaction set.
|
|
|
|
* @param rpmdep rpm transaction set
|
|
|
|
* @param dboffset rpm database instance
|
|
|
|
* @param depends installed package of pair (or -1 on erase)
|
|
|
|
*/
|
1999-08-21 05:05:18 +08:00
|
|
|
static void removePackage(rpmTransactionSet rpmdep, int dboffset, int depends)
|
2000-08-23 20:39:49 +08:00
|
|
|
/*@modifies rpmdep @*/
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
|
|
|
if (rpmdep->numRemovedPackages == rpmdep->allocedRemovedPackages) {
|
|
|
|
rpmdep->allocedRemovedPackages += 5;
|
1999-09-21 11:22:53 +08:00
|
|
|
rpmdep->removedPackages = xrealloc(rpmdep->removedPackages,
|
1999-08-21 05:05:18 +08:00
|
|
|
sizeof(int *) * rpmdep->allocedRemovedPackages);
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmdep->removedPackages[rpmdep->numRemovedPackages++] = dboffset;
|
|
|
|
|
|
|
|
if (rpmdep->orderCount == rpmdep->orderAlloced) {
|
|
|
|
rpmdep->orderAlloced += 5;
|
1999-09-21 11:22:53 +08:00
|
|
|
rpmdep->order = xrealloc(rpmdep->order,
|
1999-08-21 05:05:18 +08:00
|
|
|
sizeof(*rpmdep->order) * rpmdep->orderAlloced);
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmdep->order[rpmdep->orderCount].type = TR_REMOVED;
|
|
|
|
rpmdep->order[rpmdep->orderCount].u.removed.dboffset = dboffset;
|
|
|
|
rpmdep->order[rpmdep->orderCount++].u.removed.dependsOnIndex = depends;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
|
|
|
|
const void * key, int upgrade, rpmRelocation * relocs)
|
|
|
|
{
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* XXX binary rpms always have RPMTAG_SOURCERPM, source rpms do not */
|
|
|
|
if (headerIsEntry(h, RPMTAG_SOURCEPACKAGE))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* 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. */
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1999-08-21 05:05:18 +08:00
|
|
|
if (rpmdep->orderCount == rpmdep->orderAlloced) {
|
|
|
|
rpmdep->orderAlloced += 5;
|
1999-09-21 11:22:53 +08:00
|
|
|
rpmdep->order = xrealloc(rpmdep->order,
|
1999-08-21 05:05:18 +08:00
|
|
|
sizeof(*rpmdep->order) * rpmdep->orderAlloced);
|
|
|
|
}
|
|
|
|
rpmdep->order[rpmdep->orderCount].type = TR_ADDED;
|
1999-09-18 05:08:32 +08:00
|
|
|
alNum = alAddPackage(&rpmdep->addedPackages, h, key, fd, relocs) -
|
1999-08-21 05:05:18 +08:00
|
|
|
rpmdep->addedPackages.list;
|
|
|
|
rpmdep->order[rpmdep->orderCount++].u.addedIndex = alNum;
|
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
if (!upgrade || rpmdep->rpmdb == NULL) 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;
|
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
mi = rpmdbInitIterator(rpmdep->rpmdb, RPMTAG_NAME, name, 0);
|
2000-04-13 17:07:08 +08:00
|
|
|
while((h2 = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
if (rpmVersionCompare(h, h2))
|
|
|
|
removePackage(rpmdep, rpmdbGetIteratorOffset(mi), alNum);
|
2000-07-06 04:39:15 +08:00
|
|
|
else {
|
|
|
|
uint_32 *p, multiLibMask = 0, oldmultiLibMask = 0;
|
|
|
|
|
|
|
|
if (headerGetEntry(h2, RPMTAG_MULTILIBS, NULL, (void **) &p, NULL))
|
|
|
|
oldmultiLibMask = *p;
|
|
|
|
if (headerGetEntry(h, RPMTAG_MULTILIBS, NULL, (void **) &p, NULL))
|
|
|
|
multiLibMask = *p;
|
|
|
|
if (oldmultiLibMask && multiLibMask
|
|
|
|
&& !(oldmultiLibMask & multiLibMask)) {
|
|
|
|
rpmdep->addedPackages.list[alNum].multiLib = multiLibMask;
|
|
|
|
}
|
|
|
|
}
|
2000-04-13 17:07:08 +08:00
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
|
|
|
|
if (headerGetEntry(h, RPMTAG_OBSOLETENAME, NULL, (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
|
|
|
|
1999-09-12 05:10:02 +08:00
|
|
|
headerGetEntry(h, RPMTAG_OBSOLETEVERSION, NULL, (void **) &obsoletesEVR, NULL);
|
1999-08-25 06:26:55 +08:00
|
|
|
headerGetEntry(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;
|
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
mi = rpmdbInitIterator(rpmdep->rpmdb, RPMTAG_NAME, obsoletes[j], 0);
|
2000-04-13 17:07:08 +08:00
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmdbPruneIterator(mi,
|
|
|
|
rpmdep->removedPackages, rpmdep->numRemovedPackages, 1);
|
|
|
|
|
|
|
|
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]))
|
|
|
|
{
|
|
|
|
removePackage(rpmdep, rpmdbGetIteratorOffset(mi), alNum);
|
2000-04-13 17:07:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
}
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
1999-09-12 05:10:02 +08:00
|
|
|
if (obsoletesEVR) free(obsoletesEVR);
|
1999-08-21 05:05:18 +08:00
|
|
|
free(obsoletes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-12-08 05:14:51 +08:00
|
|
|
void rpmtransAvailablePackage(rpmTransactionSet rpmdep, Header h,
|
|
|
|
const void * key)
|
1999-08-21 05:05:18 +08:00
|
|
|
{
|
1999-09-18 05:08:32 +08:00
|
|
|
struct availablePackage * al;
|
|
|
|
al = alAddPackage(&rpmdep->availablePackages, h, key, NULL, NULL);
|
1999-08-21 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void rpmtransRemovePackage(rpmTransactionSet rpmdep, int dboffset)
|
|
|
|
{
|
|
|
|
removePackage(rpmdep, dboffset, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rpmtransFree(rpmTransactionSet rpmdep)
|
|
|
|
{
|
1999-12-08 05:14:51 +08:00
|
|
|
struct availableList * addedPackages = &rpmdep->addedPackages;
|
|
|
|
struct availableList * availablePackages = &rpmdep->availablePackages;
|
|
|
|
|
|
|
|
alFree(addedPackages);
|
|
|
|
alFree(availablePackages);
|
2000-07-09 23:17:11 +08:00
|
|
|
if (rpmdep->removedPackages)
|
|
|
|
free(rpmdep->removedPackages);
|
|
|
|
if (rpmdep->order)
|
|
|
|
free(rpmdep->order);
|
1999-12-08 05:14:51 +08:00
|
|
|
if (rpmdep->scriptFd)
|
|
|
|
rpmdep->scriptFd = fdFree(rpmdep->scriptFd, "rpmtransSetScriptFd (rpmtransFree");
|
2000-07-09 23:17:11 +08:00
|
|
|
if (rpmdep->rootDir)
|
|
|
|
xfree(rpmdep->rootDir);
|
|
|
|
if (rpmdep->currDir)
|
|
|
|
xfree(rpmdep->currDir);
|
1999-08-21 05:05:18 +08:00
|
|
|
|
|
|
|
free(rpmdep);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
free(conflicts[i].byName);
|
|
|
|
free(conflicts[i].byVersion);
|
|
|
|
free(conflicts[i].byRelease);
|
|
|
|
free(conflicts[i].needsName);
|
|
|
|
free(conflicts[i].needsVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(conflicts);
|
|
|
|
}
|
|
|
|
|
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;
|
1999-10-07 06:52:12 +08:00
|
|
|
struct dirInfo dirNeedle;
|
|
|
|
struct dirInfo * dirMatch;
|
|
|
|
|
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);
|
1999-11-27 05:58:42 +08:00
|
|
|
xfree(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
|
|
|
|
*/
|
1999-09-25 02:03:20 +08:00
|
|
|
static int unsatisfiedDepend(rpmTransactionSet rpmdep,
|
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;
|
2000-07-09 23:17:11 +08:00
|
|
|
dbi = dbiOpen(rpmdep->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);
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s %-3s (cached)\n"),
|
|
|
|
keyType, keyDepend, (rc ? "NO" : "YES"));
|
|
|
|
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-08-23 20:39:49 +08:00
|
|
|
#ifdef 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))) {
|
1999-09-24 22:54:23 +08:00
|
|
|
if (isspace(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.
|
|
|
|
*/
|
|
|
|
if (!strncmp(keyName, "rpmlib(", sizeof("rpmlib(")-1)) {
|
|
|
|
if (rpmCheckRpmlibProvides(keyName, keyEVR, keyFlags)) {
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (rpmlib provides)\n"),
|
|
|
|
keyType, keyDepend+2);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-24 22:54:23 +08:00
|
|
|
if (alSatisfiesDepend(&rpmdep->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. */
|
2000-07-09 23:17:11 +08:00
|
|
|
if (rpmdep->rpmdb != NULL) {
|
1999-09-14 13:41:13 +08:00
|
|
|
if (*keyName == '/') {
|
|
|
|
/* keyFlags better be 0! */
|
1997-05-01 03:28:09 +08:00
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
mi = rpmdbInitIterator(rpmdep->rpmdb, RPMTAG_BASENAMES, keyName, 0);
|
2000-05-07 08:53:11 +08:00
|
|
|
|
|
|
|
rpmdbPruneIterator(mi,
|
|
|
|
rpmdep->removedPackages, rpmdep->numRemovedPackages, 1);
|
|
|
|
|
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
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
mi = rpmdbInitIterator(rpmdep->rpmdb, RPMTAG_PROVIDENAME, keyName, 0);
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmdbPruneIterator(mi,
|
|
|
|
rpmdep->removedPackages, rpmdep->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);
|
1996-06-10 10:36:07 +08:00
|
|
|
}
|
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
if (suggestion)
|
1999-09-24 22:54:23 +08:00
|
|
|
*suggestion = alSatisfiesDepend(&rpmdep->availablePackages, NULL, NULL,
|
|
|
|
keyName, keyEVR, keyFlags);
|
1996-07-18 10:25:13 +08:00
|
|
|
|
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;
|
2000-07-09 23:17:11 +08:00
|
|
|
dbi = dbiOpen(rpmdep->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
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s: (%s, %s) added to Depends cache.\n"), keyType, keyDepend, (rc ? "NO" : "YES"));
|
|
|
|
#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
|
|
|
|
1998-12-17 05:58:53 +08:00
|
|
|
static int checkPackageDeps(rpmTransactionSet rpmdep, 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
|
|
|
{
|
1999-07-23 01:48:31 +08:00
|
|
|
const char * name, * version, * release;
|
1999-09-18 05:08:32 +08:00
|
|
|
const char ** requires, ** requiresEVR = NULL;
|
|
|
|
const char ** conflicts, ** conflictsEVR = NULL;
|
1999-09-19 08:29:44 +08:00
|
|
|
int requiresCount = 0, 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;
|
1999-09-18 05:08:32 +08:00
|
|
|
int_32 * requireFlags = NULL, * conflictFlags = NULL;
|
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);
|
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
if (!headerGetEntry(h, RPMTAG_REQUIRENAME, &type, (void **) &requires,
|
1996-10-21 03:31:21 +08:00
|
|
|
&requiresCount)) {
|
|
|
|
requiresCount = 0;
|
|
|
|
} else {
|
1999-09-18 05:08:32 +08:00
|
|
|
headerGetEntry(h, RPMTAG_REQUIREFLAGS, &type, (void **) &requireFlags,
|
1996-10-21 03:31:21 +08:00
|
|
|
&requiresCount);
|
1999-09-18 05:08:32 +08:00
|
|
|
headerGetEntry(h, RPMTAG_REQUIREVERSION, &type,
|
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++) {
|
1999-09-19 08:29:44 +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
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
rc = unsatisfiedDepend(rpmdep, " 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
|
|
|
}
|
1999-09-19 08:29:44 +08:00
|
|
|
xfree(keyDepend);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (requiresCount) {
|
|
|
|
free(requiresEVR);
|
|
|
|
free(requires);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!headerGetEntry(h, RPMTAG_CONFLICTNAME, &type, (void **) &conflicts,
|
|
|
|
&conflictsCount)) {
|
|
|
|
conflictsCount = 0;
|
|
|
|
} else {
|
|
|
|
headerGetEntry(h, RPMTAG_CONFLICTFLAGS, &type,
|
|
|
|
(void **) &conflictFlags, &conflictsCount);
|
|
|
|
headerGetEntry(h, RPMTAG_CONFLICTVERSION, &type,
|
|
|
|
(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++) {
|
1999-09-19 08:29:44 +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
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
rc = unsatisfiedDepend(rpmdep, "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;
|
1999-09-21 11:22:53 +08:00
|
|
|
psp->problems = xrealloc(psp->problems, sizeof(*psp->problems) *
|
1996-10-21 03:31:21 +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(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
|
|
|
}
|
1999-09-19 08:29:44 +08:00
|
|
|
xfree(keyDepend);
|
1996-10-21 03:31:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (conflictsCount) {
|
1999-09-12 05:10:02 +08:00
|
|
|
free(conflictsEVR);
|
1996-10-21 03:31:21 +08:00
|
|
|
free(conflicts);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ourrc;
|
1996-06-11 01:42:57 +08:00
|
|
|
}
|
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Adding: check name/provides key against each conflict match. */
|
|
|
|
/* Erasing: check name/provides/filename key against each requiredby match. */
|
2000-04-13 18:11:32 +08:00
|
|
|
static int checkPackageSet(rpmTransactionSet rpmdep, struct problemsSet * psp,
|
|
|
|
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
|
|
|
|
2000-05-07 08:53:11 +08:00
|
|
|
rpmdbPruneIterator(mi,
|
|
|
|
rpmdep->removedPackages, rpmdep->numRemovedPackages, 1);
|
2000-04-13 18:11:32 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
2000-07-06 04:39:15 +08:00
|
|
|
if (checkPackageDeps(rpmdep, 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
|
|
|
}
|
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Erasing: check name/provides/filename key against requiredby matches. */
|
1999-09-18 05:08:32 +08:00
|
|
|
static int checkDependentPackages(rpmTransactionSet rpmdep,
|
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;
|
2000-07-09 23:17:11 +08:00
|
|
|
mi = rpmdbInitIterator(rpmdep->rpmdb, RPMTAG_REQUIRENAME, key, 0);
|
2000-04-13 18:11:32 +08:00
|
|
|
return checkPackageSet(rpmdep, psp, key, mi);
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
|
1999-09-19 08:29:44 +08:00
|
|
|
/* Adding: check name/provides key against conflicts matches. */
|
1999-09-18 05:08:32 +08:00
|
|
|
static int checkDependentConflicts(rpmTransactionSet rpmdep,
|
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
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
if (rpmdep->rpmdb) { /* XXX is this necessary? */
|
2000-04-13 18:11:32 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2000-07-09 23:17:11 +08:00
|
|
|
mi = rpmdbInitIterator(rpmdep->rpmdb, RPMTAG_CONFLICTNAME, key, 0);
|
2000-04-13 18:11:32 +08:00
|
|
|
rc = checkPackageSet(rpmdep, psp, key, mi);
|
2000-03-23 23:49:50 +08:00
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
1997-10-04 00:08:45 +08:00
|
|
|
/* selection status is one of:
|
|
|
|
|
|
|
|
-1: selected
|
|
|
|
0: not selected
|
|
|
|
> 0: selection class
|
|
|
|
|
|
|
|
the current selection pass is included as a separate parameter, and is
|
|
|
|
incremented when satisfying a prerequisite */
|
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
static int addOrderedPack(rpmTransactionSet rpmdep,
|
1997-07-02 00:24:08 +08:00
|
|
|
struct availablePackage * package,
|
1999-09-18 05:08:32 +08:00
|
|
|
int * ordering, int * orderNumPtr,
|
1997-10-04 00:08:45 +08:00
|
|
|
int * selected, int selectionClass,
|
1999-07-23 01:48:31 +08:00
|
|
|
int satisfyDepends, const char ** errorStack)
|
1999-07-14 06:00:05 +08:00
|
|
|
{
|
1999-08-25 06:26:55 +08:00
|
|
|
const char ** requires;
|
1999-09-12 05:10:02 +08:00
|
|
|
const char ** requiresEVR;
|
1997-07-02 00:24:08 +08:00
|
|
|
int_32 * requireFlags;
|
|
|
|
int requiresCount;
|
1997-10-04 00:08:45 +08:00
|
|
|
int matchNum;
|
1997-07-02 00:24:08 +08:00
|
|
|
int packageNum = package - rpmdep->addedPackages.list;
|
1999-08-25 06:26:55 +08:00
|
|
|
int i;
|
1997-07-02 00:24:08 +08:00
|
|
|
struct availablePackage * match;
|
1999-08-25 06:26:55 +08:00
|
|
|
int rc = 0;
|
1997-07-18 23:03:35 +08:00
|
|
|
|
|
|
|
*errorStack++ = package->name;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
1997-10-04 00:08:45 +08:00
|
|
|
if (selected[packageNum] > 0) {
|
2000-07-10 07:10:25 +08:00
|
|
|
const char * errorString;
|
|
|
|
const char ** stack;
|
|
|
|
char * t;
|
|
|
|
|
1997-07-18 23:03:35 +08:00
|
|
|
i = 0;
|
|
|
|
stack = errorStack - 1;
|
2000-07-10 07:10:25 +08:00
|
|
|
while (*(--stack))
|
1997-07-18 23:03:35 +08:00
|
|
|
i += strlen(*stack) + 1;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2000-07-10 07:10:25 +08:00
|
|
|
errorString = t = alloca(i + 2);
|
1997-07-18 23:03:35 +08:00
|
|
|
while ((++stack) < errorStack) {
|
2000-07-10 07:10:25 +08:00
|
|
|
t = stpcpy(t, *stack);
|
|
|
|
*t++ = ' ';
|
1997-07-18 23:03:35 +08:00
|
|
|
}
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1998-01-10 03:10:54 +08:00
|
|
|
rpmError(RPMMESS_PREREQLOOP, _("loop in prerequisite chain: %s"),
|
1997-07-18 23:03:35 +08:00
|
|
|
errorString);
|
|
|
|
|
1997-07-02 00:24:08 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1997-10-04 00:08:45 +08:00
|
|
|
selected[packageNum] = selectionClass;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
if (headerGetEntry(package->h, RPMTAG_REQUIRENAME, NULL,
|
1997-07-02 00:24:08 +08:00
|
|
|
(void **) &requires, &requiresCount)) {
|
1999-09-18 05:08:32 +08:00
|
|
|
headerGetEntry(package->h, RPMTAG_REQUIREFLAGS, NULL,
|
1997-07-02 00:24:08 +08:00
|
|
|
(void **) &requireFlags, NULL);
|
1999-09-18 05:08:32 +08:00
|
|
|
headerGetEntry(package->h, RPMTAG_REQUIREVERSION, NULL,
|
1999-09-12 05:10:02 +08:00
|
|
|
(void **) &requiresEVR, NULL);
|
1997-07-02 00:24:08 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
for (i = 0; rc == 0 && i < requiresCount; i++) {
|
|
|
|
if (!(satisfyDepends || (requireFlags[i] & RPMSENSE_PREREQ)))
|
|
|
|
continue;
|
1999-09-24 22:54:23 +08:00
|
|
|
match = alSatisfiesDepend(&rpmdep->addedPackages, NULL, NULL,
|
1999-09-12 05:10:02 +08:00
|
|
|
requires[i], requiresEVR[i], requireFlags[i]);
|
1999-08-25 06:26:55 +08:00
|
|
|
/* broken dependencies don't concern us */
|
|
|
|
if (!match) continue;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
/* let this package satisfy its own predependencies */
|
|
|
|
if (match == package) continue;
|
1997-07-09 02:41:10 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
/* the package has already been selected */
|
|
|
|
matchNum = match - rpmdep->addedPackages.list;
|
|
|
|
if(selected[matchNum] == -1 || selected[matchNum] == selectionClass)
|
|
|
|
continue;
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
if (requireFlags[i] & RPMSENSE_PREREQ)
|
|
|
|
rc = addOrderedPack(rpmdep, match, ordering, orderNumPtr,
|
|
|
|
selected, selectionClass + 1, 1, errorStack);
|
|
|
|
else
|
|
|
|
rc = addOrderedPack(rpmdep, match, ordering, orderNumPtr,
|
|
|
|
selected, selectionClass, 1, errorStack);
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
1998-05-06 07:12:17 +08:00
|
|
|
|
|
|
|
free(requires);
|
1999-09-12 05:10:02 +08:00
|
|
|
free(requiresEVR);
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* whew -- add this package */
|
1999-08-25 06:26:55 +08:00
|
|
|
if (rc == 0) {
|
|
|
|
ordering[(*orderNumPtr)++] = packageNum;
|
|
|
|
selected[packageNum] = -1;
|
|
|
|
}
|
1997-07-02 00:24:08 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
return rc;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|
|
|
|
|
2000-08-23 20:39:49 +08:00
|
|
|
/**
|
|
|
|
* Compare ordered list entries by index (qsort/bsearch).
|
|
|
|
* @param a 1st ordered list entry
|
|
|
|
* @param b 2nd ordered list entry
|
|
|
|
* @return result of comparison
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
|
|
|
int rpmdepOrder(rpmTransactionSet rpmdep)
|
|
|
|
{
|
1999-04-05 05:26:36 +08:00
|
|
|
int i, j;
|
1997-10-04 00:08:45 +08:00
|
|
|
int * selected;
|
1999-04-05 05:26:36 +08:00
|
|
|
int * ordering;
|
|
|
|
int orderingCount;
|
1999-07-23 01:48:31 +08:00
|
|
|
const char ** errorStack;
|
1999-04-05 05:26:36 +08:00
|
|
|
struct transactionElement * newOrder;
|
|
|
|
int newOrderCount = 0;
|
|
|
|
struct orderListIndex * orderList, * needle, key;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
1997-07-16 09:39:54 +08:00
|
|
|
alMakeIndex(&rpmdep->addedPackages);
|
|
|
|
alMakeIndex(&rpmdep->availablePackages);
|
|
|
|
|
1997-07-02 00:24:08 +08:00
|
|
|
selected = alloca(sizeof(*selected) * rpmdep->addedPackages.size);
|
|
|
|
memset(selected, 0, sizeof(*selected) * rpmdep->addedPackages.size);
|
|
|
|
|
1997-07-18 23:03:35 +08:00
|
|
|
errorStack = alloca(sizeof(*errorStack) * (rpmdep->addedPackages.size + 1));
|
|
|
|
*errorStack++ = NULL;
|
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
ordering = alloca(sizeof(*ordering) * (rpmdep->addedPackages.size + 1));
|
|
|
|
orderingCount = 0;
|
1997-07-02 00:24:08 +08:00
|
|
|
|
|
|
|
for (i = 0; i < rpmdep->addedPackages.size; i++) {
|
1997-10-04 00:08:45 +08:00
|
|
|
if (!selected[i]) {
|
1997-07-02 00:24:08 +08:00
|
|
|
if (addOrderedPack(rpmdep, rpmdep->addedPackages.list + i,
|
1999-09-18 05:08:32 +08:00
|
|
|
ordering, &orderingCount, selected, 1, 0,
|
1999-04-05 05:26:36 +08:00
|
|
|
errorStack)) {
|
1997-07-02 00:24:08 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
/* The order ends up as installed packages followed by removed packages,
|
|
|
|
with removes for upgrades immediately follwing the installation of
|
1999-09-18 05:08:32 +08:00
|
|
|
the new package. This would be easier if we could sort the
|
1999-04-05 05:26:36 +08:00
|
|
|
addedPackages array, but we store indexes into it in various places. */
|
1999-09-21 11:22:53 +08:00
|
|
|
orderList = xmalloc(sizeof(*orderList) * rpmdep->addedPackages.size);
|
1999-04-05 05:26:36 +08:00
|
|
|
for (i = 0, j = 0; i < rpmdep->orderCount; i++) {
|
|
|
|
if (rpmdep->order[i].type == TR_ADDED) {
|
|
|
|
orderList[j].alIndex = rpmdep->order[i].u.addedIndex;
|
|
|
|
orderList[j].orIndex = i;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
1999-04-14 01:26:43 +08:00
|
|
|
if (j > rpmdep->addedPackages.size) abort();
|
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
qsort(orderList, rpmdep->addedPackages.size, sizeof(*orderList),
|
1999-04-05 05:26:36 +08:00
|
|
|
orderListIndexCmp);
|
|
|
|
|
1999-10-30 00:06:01 +08:00
|
|
|
newOrder = xmalloc(sizeof(*newOrder) * rpmdep->orderCount);
|
1999-04-05 05:26:36 +08:00
|
|
|
for (i = 0, newOrderCount = 0; i < orderingCount; i++) {
|
|
|
|
key.alIndex = ordering[i];
|
|
|
|
needle = bsearch(&key, orderList, rpmdep->addedPackages.size,
|
|
|
|
sizeof(key), orderListIndexCmp);
|
|
|
|
/* bsearch should never, ever fail */
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
newOrder[newOrderCount++] = rpmdep->order[needle->orIndex];
|
|
|
|
for (j = needle->orIndex + 1; j < rpmdep->orderCount; j++) {
|
|
|
|
if (rpmdep->order[j].type == TR_REMOVED &&
|
|
|
|
rpmdep->order[j].u.removed.dependsOnIndex == needle->alIndex) {
|
|
|
|
newOrder[newOrderCount++] = rpmdep->order[j];
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < rpmdep->orderCount; i++) {
|
1999-09-18 05:08:32 +08:00
|
|
|
if (rpmdep->order[i].type == TR_REMOVED &&
|
1999-04-05 05:26:36 +08:00
|
|
|
rpmdep->order[i].u.removed.dependsOnIndex == -1) {
|
|
|
|
newOrder[newOrderCount++] = rpmdep->order[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-14 01:26:43 +08:00
|
|
|
if (newOrderCount != rpmdep->orderCount) abort();
|
|
|
|
|
1999-04-05 05:26:36 +08:00
|
|
|
free(rpmdep->order);
|
|
|
|
rpmdep->order = newOrder;
|
|
|
|
rpmdep->orderAlloced = rpmdep->orderCount;
|
|
|
|
free(orderList);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
int rpmdepCheck(rpmTransactionSet rpmdep,
|
1999-07-14 06:00:05 +08:00
|
|
|
struct rpmDependencyConflict ** conflicts, int * numConflicts)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
qsort(rpmdep->removedPackages, rpmdep->numRemovedPackages,
|
|
|
|
sizeof(int), intcmp);
|
|
|
|
|
|
|
|
alMakeIndex(&rpmdep->addedPackages);
|
|
|
|
alMakeIndex(&rpmdep->availablePackages);
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2000-07-08 04:06:41 +08:00
|
|
|
/* Look at all of the added packages and make sure their dependencies
|
|
|
|
* are satisfied.
|
|
|
|
*/
|
1999-07-14 06:00:05 +08:00
|
|
|
p = rpmdep->addedPackages.list;
|
|
|
|
for (i = 0; i < rpmdep->addedPackages.size; i++, p++) {
|
1999-09-18 05:08:32 +08:00
|
|
|
|
2000-07-08 04:06:41 +08:00
|
|
|
rc = checkPackageDeps(rpmdep, &ps, p->h, NULL, p->multiLib);
|
|
|
|
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. */
|
2000-07-08 04:06:41 +08:00
|
|
|
rc = checkDependentConflicts(rpmdep, &ps, p->name);
|
|
|
|
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. */
|
|
|
|
if (checkDependentConflicts(rpmdep, &ps, p->provides[j])) {
|
1999-09-14 13:41:13 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* now look at the removed packages and make sure they aren't critical */
|
2000-06-07 04:06:09 +08:00
|
|
|
if (rpmdep->numRemovedPackages > 0) {
|
2000-07-09 23:17:11 +08:00
|
|
|
mi = rpmdbInitIterator(rpmdep->rpmdb, RPMDBI_PACKAGES, NULL, 0);
|
2000-06-07 04:06:09 +08:00
|
|
|
rpmdbAppendIterator(mi, rpmdep->removedPackages,
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmdep->numRemovedPackages);
|
2000-06-07 04:06:09 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
1999-09-18 05:08:32 +08:00
|
|
|
|
1999-12-01 02:07:08 +08:00
|
|
|
{ const char * name;
|
|
|
|
headerNVR(h, &name, NULL, NULL);
|
1999-07-14 06:00:05 +08:00
|
|
|
|
1999-12-01 02:07:08 +08:00
|
|
|
/* Erasing: check name against requiredby matches. */
|
2000-07-08 04:06:41 +08:00
|
|
|
rc = checkDependentPackages(rpmdep, &ps, name);
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (headerGetEntry(h, RPMTAG_PROVIDENAME, NULL, (void **) &provides,
|
|
|
|
&providesCount)) {
|
|
|
|
rc = 0;
|
|
|
|
for (j = 0; j < providesCount; j++) {
|
|
|
|
/* Erasing: check provides against requiredby matches. */
|
|
|
|
if (checkDependentPackages(rpmdep, &ps, provides[j])) {
|
1999-09-14 13:41:13 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
1999-12-01 02:07:08 +08:00
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
1999-12-01 02:07:08 +08:00
|
|
|
xfree(provides);
|
|
|
|
if (rc)
|
|
|
|
goto exit;
|
1999-07-14 06:00:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-01 02:07:08 +08:00
|
|
|
{ const char ** baseNames, ** dirNames;
|
|
|
|
int_32 * dirIndexes;
|
|
|
|
int fileCount;
|
|
|
|
char * fileName = NULL;
|
|
|
|
int fileAlloced = 0;
|
|
|
|
int len;
|
|
|
|
|
1999-12-09 03:04:50 +08:00
|
|
|
if (headerGetEntry(h, RPMTAG_BASENAMES, NULL,
|
1999-11-27 05:58:42 +08:00
|
|
|
(void **) &baseNames, &fileCount)) {
|
1999-12-09 03:04:50 +08:00
|
|
|
headerGetEntry(h, RPMTAG_DIRNAMES, NULL,
|
1999-11-27 05:58:42 +08:00
|
|
|
(void **) &dirNames, NULL);
|
1999-12-09 03:04:50 +08:00
|
|
|
headerGetEntry(h, RPMTAG_DIRINDEXES, NULL,
|
1999-10-09 04:30:49 +08:00
|
|
|
(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. */
|
|
|
|
if (checkDependentPackages(rpmdep, &ps, fileName)) {
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
1999-10-09 04:30:49 +08:00
|
|
|
}
|
1999-07-14 06:00:05 +08:00
|
|
|
|
1999-12-01 02:07:08 +08:00
|
|
|
free(fileName);
|
|
|
|
free(baseNames);
|
|
|
|
free(dirNames);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-09-18 05:08:32 +08:00
|
|
|
if (!ps.num) {
|
1999-07-14 06:00:05 +08:00
|
|
|
free(ps.problems);
|
1999-09-18 05:08:32 +08:00
|
|
|
} else {
|
1999-07-14 06:00:05 +08:00
|
|
|
*conflicts = ps.problems;
|
|
|
|
*numConflicts = ps.num;
|
|
|
|
}
|
1999-09-18 05:08:32 +08:00
|
|
|
ps.problems = NULL;
|
2000-07-08 04:06:41 +08:00
|
|
|
rc = 0;
|
1999-09-14 13:41:13 +08:00
|
|
|
|
|
|
|
exit:
|
2000-04-27 08:10:28 +08:00
|
|
|
if (mi)
|
|
|
|
rpmdbFreeIterator(mi);
|
2000-07-08 04:06:41 +08:00
|
|
|
if (ps.problems)
|
|
|
|
free(ps.problems);
|
|
|
|
return rc;
|
1997-07-02 00:24:08 +08:00
|
|
|
}
|