* \file lib/depends.c
*/
-#define _DS_SCAREMEM 0
+#define _DS_SCAREMEM 1
#include "system.h"
/*@=mods =onlytrans =type@*/
}
+char * hGetNEVR(Header h, const char ** np)
+{
+ const char * n, * v, * r;
+ char * NVR, * t;
+
+ (void) headerNVR(h, &n, &v, &r);
+ NVR = t = xcalloc(1, strlen(n) + strlen(v) + strlen(r) + sizeof("--"));
+ t = stpcpy(t, n);
+ t = stpcpy(t, "-");
+ t = stpcpy(t, v);
+ t = stpcpy(t, "-");
+ t = stpcpy(t, r);
+ if (np)
+ *np = n;
+ return NVR;
+}
+
+static void delTE(transactionElement p)
+ /*@modifies p @*/
+{
+ rpmRelocation * r;
+
+ if (p->relocs) {
+ for (r = p->relocs; (r->oldPath || r->newPath); r++) {
+ r->oldPath = _free(r->oldPath);
+ r->newPath = _free(r->newPath);
+ }
+ p->relocs = _free(p->relocs);
+ }
+
+ p->provides = dsFree(p->provides);
+ p->requires = dsFree(p->requires);
+ p->conflicts = dsFree(p->conflicts);
+ p->obsoletes = dsFree(p->obsoletes);
+ p->fns = fnsFree(p->fns);
+
+ /*@-type@*/ /* FIX: cast? */
+ if (p->fd != NULL)
+ p->fd = fdFree(p->fd, "alAddPackage (rpmtransFree)");
+ /*@=type@*/
+
+ p->os = _free(p->os);
+ p->arch = _free(p->arch);
+ p->epoch = _free(p->epoch);
+ p->NEVR = _free(p->NEVR);
+ p->name = _free(p->name);
+ memset(p, 0, sizeof(*p)); /* XXX trash and burn */
+ /*@-nullstate@*/ /* FIX: p->{NEVR,name} annotations */
+ return;
+ /*@=nullstate@*/
+}
+
+static void addTE(transactionElement p, Header h,
+ /*@null@*/ FD_t fd,
+ /*@null@*/ fnpyKey key,
+ /*@null@*/ rpmRelocation * relocs)
+ /*@modifies p, h @*/
+{
+ int scareMem = _DS_SCAREMEM;
+ HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ const char * arch, * os;
+ int_32 * ep;
+ int xx;
+
+ p->NEVR = hGetNEVR(h, NULL);
+ p->name = xstrdup(p->NEVR);
+ if ((p->release = strrchr(p->name, '-')) != NULL)
+ *p->release++ = '\0';
+ if ((p->version = strrchr(p->name, '-')) != NULL)
+ *p->version++ = '\0';
+
+ arch = NULL;
+ xx = hge(h, RPMTAG_ARCH, NULL, (void **)&arch, NULL);
+ p->arch = (arch != NULL ? xstrdup(arch) : NULL);
+ os = NULL;
+ xx = hge(h, RPMTAG_OS, NULL, (void **)&os, NULL);
+ p->os = (os != NULL ? xstrdup(os) : NULL);
+
+ ep = NULL;
+ xx = hge(h, RPMTAG_EPOCH, NULL, (void **)&ep, NULL);
+ /*@-branchstate@*/
+ if (ep) {
+ p->epoch = xmalloc(20);
+ sprintf(p->epoch, "%d", *ep);
+ } else
+ p->epoch = NULL;
+ /*@=branchstate@*/
+
+ p->provides = dsNew(h, RPMTAG_PROVIDENAME, scareMem);
+ p->fns = fnsNew(h, RPMTAG_BASENAMES, scareMem);
+ p->requires = dsNew(h, RPMTAG_REQUIRENAME, scareMem);
+ p->conflicts = dsNew(h, RPMTAG_CONFLICTNAME, scareMem);
+ p->obsoletes = dsNew(h, RPMTAG_OBSOLETENAME, scareMem);
+
+ /*@-assignexpose -ownedtrans @*/
+ p->key = key;
+ /*@=assignexpose =ownedtrans @*/
+
+ /*@-type@*/ /* FIX: cast? */
+ p->fd = (fd != NULL ? fdLink(fd, "rpmtransAddPackage") : NULL);
+ /*@=type@*/
+
+ if (relocs != NULL) {
+ rpmRelocation * r;
+ int i;
+
+ for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++)
+ {};
+ p->relocs = xmalloc((i + 1) * sizeof(*p->relocs));
+
+ for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) {
+ p->relocs[i].oldPath = r->oldPath ? xstrdup(r->oldPath) : NULL;
+ p->relocs[i].newPath = r->newPath ? xstrdup(r->newPath) : NULL;
+ }
+ p->relocs[i].oldPath = NULL;
+ p->relocs[i].newPath = NULL;
+ } else {
+ p->relocs = NULL;
+ }
+}
+
rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * rootDir)
{
rpmTransactionSet ts;
alKey depends)
/*@modifies ts, h @*/
{
- int scareMem = _DS_SCAREMEM;
transactionElement p;
/* Filter out duplicate erasures. */
memset(p, 0, sizeof(*p));
- p->NEVR = hGetNEVR(h, NULL);
- p->name = xstrdup(p->NEVR);
- if ((p->release = strrchr(p->name, '-')) != NULL)
- *p->release++ = '\0';
- if ((p->version = strrchr(p->name, '-')) != NULL)
- *p->version++ = '\0';
-
- p->provides = dsNew(h, RPMTAG_PROVIDENAME, scareMem);
- p->fns = fnsNew(h, RPMTAG_BASENAMES, scareMem);
- p->requires = dsNew(h, RPMTAG_REQUIRENAME, scareMem);
- p->conflicts = dsNew(h, RPMTAG_CONFLICTNAME, scareMem);
- p->obsoletes = dsNew(h, RPMTAG_CONFLICTNAME, scareMem);
+ addTE(p, h, NULL, NULL, NULL);
p->type = TR_REMOVED;
p->u.removed.dboffset = dboffset;
return 0;
}
-char * hGetNEVR(Header h, const char ** np)
-{
- const char * n, * v, * r;
- char * NVR, * t;
-
- (void) headerNVR(h, &n, &v, &r);
- NVR = t = xcalloc(1, strlen(n) + strlen(v) + strlen(r) + sizeof("--"));
- t = stpcpy(t, n);
- t = stpcpy(t, "-");
- t = stpcpy(t, v);
- t = stpcpy(t, "-");
- t = stpcpy(t, r);
- if (np)
- *np = n;
- return NVR;
-}
-
int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd,
fnpyKey key, int upgrade, rpmRelocation * relocs)
{
- int scareMem = _DS_SCAREMEM;
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
const char * name = NULL;
char * addNEVR = hGetNEVR(h, &name);
char * pkgNEVR = NULL;
int isSource;
int duplicate = 0;
- transactionElement p;
- rpmDepSet provides;
- rpmDepSet requires;
- rpmDepSet conflicts;
+ teIterator pi; transactionElement p;
rpmDepSet obsoletes;
- rpmFNSet fns;
alKey pkgKey; /* addedPackages key */
int apx; /* addedPackages index */
int xx;
int ec = 0;
int rc;
- int i;
+ int oc;
/*
* Check for previously added versions with the same name.
*/
- i = ts->orderCount;
apx = 0;
- if ((p = ts->order) != NULL)
- for (i = 0; i < ts->orderCount; i++, p++) {
+ pi = teInitIterator(ts);
+ /* XXX Only added packages need be checked for dupes. */
+ while ((p = teNext(pi, TR_ADDED)) != NULL) {
const char * pname;
Header ph;
- /* XXX Only added packages are checked for dupes (for now). */
- switch (p->type) {
- case TR_ADDED:
- /*@switchbreak@*/ break;
- case TR_REMOVED:
- default:
- continue;
- /*@notreached@*/ /*@switchbreak@*/ break;
- }
-
apx++;
ph = alGetHeader(ts->addedPackages, p->u.addedKey, 0);
}
break;
}
+ pi = teFreeIterator(pi);
+ oc = (p == NULL ? ts->orderCount : (p - ts->order));
isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
- /*@-branchstate@*/
- if (duplicate) {
- p = ts->order + i;
- provides = rpmdsLink(p->provides, "xfer");
- p->provides = rpmdsUnlink(p->provides, "xfer");
- fns = rpmfnsLink(p->fns, "xfer");
- p->fns = rpmfnsUnlink(p->fns, "xfer");
- } else {
- provides = dsNew(h, RPMTAG_PROVIDENAME, scareMem);
- fns = fnsNew(h, RPMTAG_BASENAMES, scareMem);
+ if (p != NULL && duplicate && oc < ts->orderCount)
+ delTE(p);
+
+ if (oc == ts->orderAlloced) {
+ ts->orderAlloced += ts->delta;
+ ts->order = xrealloc(ts->order, ts->orderAlloced * sizeof(*ts->order));
}
- /*@=branchstate@*/
- requires = dsNew(h, RPMTAG_REQUIRENAME, scareMem);
- conflicts = dsNew(h, RPMTAG_CONFLICTNAME, scareMem);
- obsoletes = dsNew(h, RPMTAG_CONFLICTNAME, scareMem);
+ p = ts->order + oc;
+ memset(p, 0, sizeof(*p));
+
+ addTE(p, h, fd, key, relocs);
+ p->type = TR_ADDED;
/* XXX cast assumes that available keys are indices, not pointers */
- pkgKey = alAddPackage(ts->addedPackages, (alKey)apx, key, h, provides, fns);
+ pkgKey = alAddPackage(ts->addedPackages, (alKey)apx, p->key, h,
+ p->provides, p->fns);
if (pkgKey == RPMAL_NOMATCH) {
ec = 1;
goto exit;
}
-
- /* XXX Note: i == ts->orderCount here almost always. */
- if (i == ts->orderAlloced) {
- ts->orderAlloced += ts->delta;
- ts->order = xrealloc(ts->order, ts->orderAlloced * sizeof(*ts->order));
- }
-
- p = ts->order + i;
- memset(p, 0, sizeof(*p));
-
p->u.addedKey = pkgKey;
- p->type = TR_ADDED;
p->multiLib = 0;
#ifdef NOYET
}
#endif
- p->NEVR = xstrdup(addNEVR);
- p->name = xstrdup(addNEVR);
- if ((p->release = strrchr(p->name, '-')) != NULL)
- *p->release++ = '\0';
- if ((p->version = strrchr(p->name, '-')) != NULL)
- *p->version++ = '\0';
-
- p->provides = rpmdsUnlink(p->provides, "xfer");
- p->provides = rpmdsLink(provides, "xfer");
- provides = rpmdsUnlink(provides, "xfer");
-
- p->requires = rpmdsUnlink(p->requires, "xfer");
- p->requires = rpmdsLink(requires, "xfer");
- requires = rpmdsUnlink(requires, "xfer");
-
- p->conflicts = rpmdsUnlink(p->conflicts, "xfer");
- p->conflicts = rpmdsLink(conflicts, "xfer");
- conflicts = rpmdsUnlink(conflicts, "xfer");
-
- p->obsoletes = rpmdsUnlink(p->obsoletes, "xfer");
- p->obsoletes = rpmdsLink(obsoletes, "xfer");
- obsoletes = rpmdsUnlink(obsoletes, "xfer");
-
- p->fns = rpmfnsUnlink(p->fns, "xfer");
- p->fns = rpmfnsLink(fns, "xfer");
- fns = rpmfnsUnlink(fns, "xfer");
-
- /*@-assignexpose -ownedtrans @*/
- p->key = key;
- /*@=assignexpose =ownedtrans @*/
-
- /*@-type@*/ /* FIX: cast? */
- p->fd = (fd != NULL ? fdLink(fd, "rpmtransAddPackage") : NULL);
- /*@=type@*/
-
- if (relocs) {
- rpmRelocation * r;
-
- for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++)
- {};
- p->relocs = xmalloc((i + 1) * sizeof(*p->relocs));
-
- for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) {
- p->relocs[i].oldPath = r->oldPath ? xstrdup(r->oldPath) : NULL;
- p->relocs[i].newPath = r->newPath ? xstrdup(r->newPath) : NULL;
- }
- p->relocs[i].oldPath = NULL;
- p->relocs[i].newPath = NULL;
- } else {
- p->relocs = NULL;
- }
-
if (!duplicate) {
assert(apx == ts->numAddedPackages);
ts->numAddedPackages++;
mi = rpmdbFreeIterator(mi);
}
- obsoletes = dsiInit(rpmdsLink(p->obsoletes, "obsoletes"));
+ obsoletes = dsiInit(rpmdsLink(p->obsoletes, "Obsoletes"));
if (obsoletes != NULL)
while (dsiNext(obsoletes) >= 0) {
const char * Name;
exit:
pkgNEVR = _free(pkgNEVR);
addNEVR = _free(addNEVR);
+ pi = teFreeIterator(pi);
return ec;
}
pi = teInitIterator(ts);
while ((p = teNextIterator(pi)) != NULL) {
+#ifdef DYING
rpmRelocation * r;
+
if (p->relocs) {
for (r = p->relocs; (r->oldPath || r->newPath); r++) {
r->oldPath = _free(r->oldPath);
p->fd = fdFree(p->fd, "alAddPackage (rpmtransFree)");
/*@=type@*/
+ p->os = _free(p->os);
+ p->arch = _free(p->arch);
+ p->epoch = _free(p->epoch);
p->NEVR = _free(p->NEVR);
p->name = _free(p->name);
+#else
+ delTE(p);
+#endif
}
pi = teFreeIterator(pi);
int rpmdepOrder(rpmTransactionSet ts)
{
- int numAddedPackages = alGetSize(ts->addedPackages);
+ int numAddedPackages = ts->numAddedPackages;
int chainsaw = ts->transFlags & RPMTRANS_FLAG_CHAINSAW;
teIterator pi; transactionElement p;
teIterator qi; transactionElement q;
int qlen;
int i, j;
-assert(ts->numAddedPackages == alGetSize(ts->addedPackages));
-
alMakeIndex(ts->addedPackages);
/*@-modfilesystem -nullpass@*/
pi = teInitIterator(ts);
/* XXX Only added packages are ordered (for now). */
while ((p = teNext(pi, TR_ADDED)) != NULL) {
-
p->tsi = xcalloc(1, sizeof(*p->tsi));
-
-#ifdef DYING
- /* Retrieve info from addedPackages. */
- p->NEVR = alGetNVR(ts->addedPackages, p->u.addedKey);
- p->name = alGetNVR(ts->addedPackages, p->u.addedKey);
- if ((p->release = strrchr(p->name, '-')) != NULL)
- *p->release++ = '\0';
- if ((p->version = strrchr(p->name, '-')) != NULL)
- *p->version++ = '\0';
-/*@-modfilesystem@*/
-prtTSI(p->NEVR, p->tsi);
-/*@=modfilesystem@*/
-#endif
}
pi = teFreeIterator(pi);
tsi = _free(tsi);
}
p->tsi = _free(p->tsi);
-#ifdef DYING
- p->NEVR = _free(p->NEVR);
- p->name = _free(p->name);
-#endif
/* Prepare added package ordering permutation. */
orderList[j].pkgKey = p->u.addedKey;
rpmDepSet provides;
uint_32 multiLib;
- /* XXX Only added packages are checked (for now). */
- switch (p->type) {
- case TR_ADDED:
- /*@switchbreak@*/ break;
- case TR_REMOVED:
- default:
- continue;
- /*@notreached@*/ /*@switchbreak@*/ break;
- }
-
h = alGetHeader(ts->addedPackages, p->u.addedKey, 0);
if (h == NULL) /* XXX can't happen */
break;
if (rc)
goto exit;
-
rc = 0;
provides = p->provides;
provides = dsiInit(provides);
* A single package instance to be installed/removed atomically.
*/
struct transactionElement_s {
+ enum rpmTransactionType {
+ TR_ADDED, /*!< Package will be installed. */
+ TR_REMOVED /*!< Package will be removed. */
+ } type; /*!< Package disposition (installed/removed). */
+
+/*@only@*/
+ const char * NEVR; /*!< Package name-version-release. */
+/*@owned@*/
+ const char * name; /*!< Name: */
/*@only@*/ /*@null@*/
- char * NEVR;
-/*@owned@*/ /*@null@*/
- char * name;
+ char * epoch;
/*@dependent@*/ /*@null@*/
- char * version;
+ char * version; /*!< Version: */
/*@dependent@*/ /*@null@*/
- char * release;
+ char * release; /*!< Release: */
+/*@only@*/ /*@null@*/
+ const char * arch; /*!< Architecture hint. */
+/*@only@*/ /*@null@*/
+ const char * os; /*!< Operating system hint. */
- int npreds; /*!< No. of predecessors. */
- int depth; /*!< Max. depth in dependency tree. */
+ int npreds; /*!< No. of predecessors. */
+ int depth; /*!< Max. depth in dependency tree. */
/*@owned@*/
- tsortInfo tsi; /*!< Ordering info. */
-
- enum rpmTransactionType {
- TR_ADDED, /*!< Package will be installed. */
- TR_REMOVED /*!< Package will be removed. */
- } type; /*!< Package disposition (installed/removed). */
+ tsortInfo tsi; /*!< Dependency ordering chains. */
/*@refcounted@*/ /*@null@*/
rpmDepSet provides; /*!< Provides: dependencies. */
/*@refcounted@*/ /*@null@*/
rpmDepSet obsoletes; /*!< Obsoletes: dependencies. */
/*@refcounted@*/ /*@null@*/
- rpmFNSet fns; /*!< File info set. */
+ rpmFNSet fns; /*!< File information. */
- uint_32 multiLib; /* (TR_ADDED) MULTILIB */
- int_32 filesCount; /* (TR_ADDED) No. files in package. */
+ uint_32 multiLib; /*!< (TR_ADDED) MULTILIB */
/*@kept@*//*@null@*/
- fnpyKey key;
- /*!< (TR_ADDED) Retrieval key (CLI uses file name, e.g.). */
+ fnpyKey key; /*!< (TR_ADDED) Retrieval key. */
/*@owned@*/ /*@null@*/
- rpmRelocation * relocs;
- /*!< (TR_ADDED) Payload file relocations. */
-/*@refcounted@*/ /*@null@*/
- FD_t fd; /*!< (TR_ADDED) Payload file descriptor (usually NULL). */
+ rpmRelocation * relocs; /*!< (TR_ADDED) Payload file relocations. */
+/*@refcounted@*/ /*@null@*/
+ FD_t fd; /*!< (TR_ADDED) Payload file descriptor. */
/*@-fielduse@*/ /* LCL: confused by union? */
union {
/*@access rpmProblemSet@*/
/*@unchecked@*/
-static int _ps_debug = 1;
+static int _ps_debug = 0;
rpmProblemSet XrpmpsUnlink(rpmProblemSet ps, const char * msg,
const char * fn, unsigned ln)
}
}
-int alGetSize(const availableList al)
+/**
+ * Return number of packages in list.
+ * @param al available list
+ * @return no. of packages in list
+ */
+static int alGetSize(/*@null@*/ const availableList al)
+ /*@*/
{
- return al->size;
+ return (al != NULL ? al->size : 0);
}
static inline alNum alKey2Num(/*@unused@*/ /*@null@*/ const availableList al,
/*@=nullret =temptrans =retalias @*/
}
-availablePackage alGetPkg(const availableList al, alKey pkgKey)
+/**
+ * Return available package.
+ * @param al available list
+ * @param pkgKey available package key
+ * @return available package pointer
+ */
+/*@dependent@*/ /*@null@*/
+static availablePackage alGetPkg(/*@null@*/ const availableList al,
+ /*@null@*/ alKey pkgKey)
+ /*@*/
{
availablePackage alp = NULL;
alNum pkgNum = alKey2Num(al, pkgKey);
- if (al != NULL && pkgNum >= 0 && pkgNum < al->size) {
+ if (al != NULL && pkgNum >= 0 && pkgNum < alGetSize(al)) {
if (al->list != NULL)
alp = al->list + pkgNum;
}
return h;
}
-#ifdef DYING
-char * alGetNVR(const availableList al, alKey pkgKey)
-{
- availablePackage alp = alGetPkg(al, pkgKey);
- char * pkgNVR = NULL;
-
- if (alp != NULL) {
- char * t;
- t = xcalloc(1, strlen(alp->name) +
- strlen(alp->version) +
- strlen(alp->release) + sizeof("--"));
- pkgNVR = t;
- t = stpcpy(t, alp->name);
- t = stpcpy(t, "-");
- t = stpcpy(t, alp->version);
- t = stpcpy(t, "-");
- t = stpcpy(t, alp->release);
- }
- return pkgNVR;
-}
-#endif
-
availableList alCreate(int delta)
{
availableList al = xcalloc(1, sizeof(*al));
/*@=modfilesys@*/
/*@-assignexpose -temptrans@*/
- alp->provides = rpmdsLink(provides, "alAddPackage");
- alp->fns = rpmfnsLink(fns, "alAddPackage");
+ alp->provides = rpmdsLink(provides, "Provides (alAddPackage)");
+ alp->fns = rpmfnsLink(fns, "Files (alAddPackage)");
/*@=assignexpose =temptrans@*/
if (alp->fns && alp->fns->fc > 0) {
typedef /*@abstract@*/ struct availablePackage_s * availablePackage;
/**
- * Return number of packages in list.
- * @param al available list
- * @return no. of packages in list
- */
-int alGetSize(const availableList al)
- /*@*/;
-
-/**
* Return available package header.
* @param al available list
* @param pkgKey available package key
/*@modifies al @*/;
/**
- * Return available package.
- * @param al available list
- * @param pkgKey available package key
- * @return available package pointer
- */
-/*@-exportlocal@*/
-/*@dependent@*/ /*@null@*/
-availablePackage alGetPkg(/*@null@*/ availableList al, /*@null@*/ alKey pkgKey)
- /*@*/;
-/*@=exportlocal@*/
-
-#ifdef DYING
-/**
- * Return (malloc'd) available package name-version-release string.
- * @param al available list
- * @param pkgKey available package key
- * @return name-version-release string
- */
-/*@only@*/ /*@null@*/
-char * alGetNVR(/*@null@*/const availableList al, /*@null@*/ alKey pkgKey)
- /*@*/;
-#endif
-
-/**
* Initialize available packckages, items, and directory list.
* @param delta no. of entries to add on each realloc
* @return al new available list
/*@access rpmFNSet @*/
/*@unchecked@*/
-static int _fns_debug = 1;
+static int _fns_debug = 0;
/*@-shadow@*/ /* XXX copy from depends.c for now. */
static char * hGetNEVR(Header h, /*@out@*/ const char ** np)
{
if (fns == NULL) return NULL;
/*@-modfilesystem@*/
-if (_fns_debug)
-fprintf(stderr, "--> fns %p -- %d %s at %s:%u\n", fns, fns->nrefs, msg, fn, ln);
+if (_fns_debug && msg != NULL)
+fprintf(stderr, "--> fi %p -- %d %s at %s:%u\n", fns, fns->nrefs, msg, fn, ln);
/*@=modfilesystem@*/
fns->nrefs--;
return NULL;
if (fns == NULL) return NULL;
fns->nrefs++;
/*@-modfilesystem@*/
-if (_fns_debug)
-fprintf(stderr, "--> fns %p ++ %d %s at %s:%u\n", fns, fns->nrefs, msg, fn, ln);
+if (_fns_debug && msg != NULL)
+fprintf(stderr, "--> fi %p ++ %d %s at %s:%u\n", fns, fns->nrefs, msg, fn, ln);
/*@=modfilesystem@*/
/*@-refcounttrans@*/ return fns; /*@=refcounttrans@*/
}
if (fns == NULL) return NULL;
if (fns->nrefs > 1)
- return rpmfnsUnlink(fns, "dereference");
+ return rpmfnsUnlink(fns, fns->Type);
/*@-modfilesystem@*/
if (_fns_debug < 0)
-fprintf(stderr, "*** fns %p -- %s[%d]\n", fns, fns->Type, fns->fc);
+fprintf(stderr, "*** fi %p\t%s[%d]\n", fns, fns->Type, fns->fc);
/*@=modfilesystem@*/
/*@-branchstate@*/
}
/*@=branchstate@*/
- (void) rpmfnsUnlink(fns, "destroy");
/*@-refcounttrans -usereleased@*/
+ (void) rpmfnsUnlink(fns, fns->Type);
memset(fns, 0, sizeof(*fns)); /* XXX trash and burn */
fns = _free(fns);
/*@=refcounttrans =usereleased@*/
/*@-modfilesystem@*/
if (_fns_debug < 0)
-fprintf(stderr, "*** fns %p ++ %s[%d]\n", fns, fns->Type, fns->fc);
+fprintf(stderr, "*** fi %p\t%s[%d]\n", fns, fns->Type, fns->fc);
/*@=modfilesystem@*/
}
/*@=branchstate@*/
exit:
- return rpmfnsLink(fns, "create");
+ return rpmfnsLink(fns, (fns ? fns->Type : NULL));
}
/*@access rpmDepSet @*/
/*@unchecked@*/
-static int _ds_debug = 1;
+static int _ds_debug = 0;
rpmDepSet XrpmdsUnlink(rpmDepSet ds, const char * msg, const char * fn, unsigned ln)
{
if (ds == NULL) return NULL;
/*@-modfilesystem@*/
-if (_ds_debug)
+if (_ds_debug && msg != NULL)
fprintf(stderr, "--> ds %p -- %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln);
/*@=modfilesystem@*/
ds->nrefs--;
if (ds == NULL) return NULL;
ds->nrefs++;
/*@-modfilesystem@*/
-if (_ds_debug)
+if (_ds_debug && msg != NULL)
fprintf(stderr, "--> ds %p ++ %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln);
/*@=modfilesystem@*/
/*@-refcounttrans@*/ return ds; /*@=refcounttrans@*/
return NULL;
if (ds->nrefs > 1)
- return rpmdsUnlink(ds, "dereference");
+ return rpmdsUnlink(ds, ds->Type);
/*@-modfilesystem@*/
if (_ds_debug < 0)
-fprintf(stderr, "*** ds %p --\t%s[%d]\n", ds, ds->Type, ds->Count);
+fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);
/*@=modfilesystem@*/
ds->DNEVR = _free(ds->DNEVR);
- (void) rpmdsUnlink(ds, "destroy");
+ (void) rpmdsUnlink(ds, ds->Type);
/*@-refcounttrans -usereleased@*/
memset(ds, 0, sizeof(*ds)); /* XXX trash and burn */
ds = _free(ds);
/*@-modfilesystem@*/
if (_ds_debug < 0)
-fprintf(stderr, "*** ds %p ++\t%s[%d]\n", ds, ds->Type, ds->Count);
+fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);
/*@=modfilesystem@*/
}
exit:
/*@-nullstate@*/ /* FIX: ds->Flags may be NULL */
- return rpmdsLink(ds, "create");
+ return rpmdsLink(ds, (ds ? ds->Type : NULL));
/*@=nullstate@*/
}
} else
ds->i = -1;
- }
-/*@-modfilesystem -nullderef -nullpass @*/
-if (_ds_debug < 0&& i != -1)
-fprintf(stderr, "*** ds %p\t%s[%d]: %s\n", ds, (ds && ds->Type ? ds->Type : "?Type?"), i, (ds->DNEVR ? ds->DNEVR : "?DNEVR?"));
-/*@=modfilesystem =nullderef =nullpass @*/
+/*@-modfilesystem @*/
+if (_ds_debug < 0 && i != -1)
+fprintf(stderr, "*** ds %p\t%s[%d]: %s\n", ds, (ds->Type ? ds->Type : "?Type?"), i, (ds->DNEVR ? ds->DNEVR : "?DNEVR?"));
+/*@=modfilesystem @*/
+
+ }
return i;
}
*/
/*@unused@*/ /*@null@*/
rpmFNSet rpmfnsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fns,
- const char * msg)
+ /*@null@*/ const char * msg)
/*@modifies fns @*/;
/** @todo Remove debugging entry from the ABI. */
/*@-exportlocal@*/
/*@null@*/
rpmFNSet XrpmfnsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fns,
- const char * msg, const char * fn, unsigned ln)
+ /*@null@*/ const char * msg, const char * fn, unsigned ln)
/*@modifies fns @*/;
/*@=exportlocal@*/
#define rpmfnsUnlink(_fns, _msg) XrpmfnsUnlink(_fns, _msg, __FILE__, __LINE__)
* @return new file info set reference
*/
/*@unused@*/
-rpmFNSet rpmfnsLink (/*@null@*/ rpmFNSet fns, const char * msg)
+rpmFNSet rpmfnsLink (/*@null@*/ rpmFNSet fns, /*@null@*/ const char * msg)
/*@modifies fns @*/;
/** @todo Remove debugging entry from the ABI. */
-rpmFNSet XrpmfnsLink (/*@null@*/ rpmFNSet fns, const char * msg,
+rpmFNSet XrpmfnsLink (/*@null@*/ rpmFNSet fns, /*@null@*/ const char * msg,
const char * fn, unsigned ln)
/*@modifies fns @*/;
#define rpmfnsLink(_fns, _msg) XrpmfnsLink(_fns, _msg, __FILE__, __LINE__)
*/
/*@unused@*/ /*@null@*/
rpmDepSet rpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
- const char * msg)
+ /*@null@*/ const char * msg)
/*@modifies ds @*/;
/** @todo Remove debugging entry from the ABI. */
/*@-exportlocal@*/
/*@null@*/
rpmDepSet XrpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
- const char * msg, const char * fn, unsigned ln)
+ /*@null@*/ const char * msg, const char * fn, unsigned ln)
/*@modifies ds @*/;
/*@=exportlocal@*/
#define rpmdsUnlink(_ds, _msg) XrpmdsUnlink(_ds, _msg, __FILE__, __LINE__)
* @return new dependency set reference
*/
/*@unused@*/
-rpmDepSet rpmdsLink (/*@null@*/ rpmDepSet ds, const char * msg)
+rpmDepSet rpmdsLink (/*@null@*/ rpmDepSet ds, /*@null@*/ const char * msg)
/*@modifies ds @*/;
/** @todo Remove debugging entry from the ABI. */
-rpmDepSet XrpmdsLink (/*@null@*/ rpmDepSet ds, const char * msg,
+rpmDepSet XrpmdsLink (/*@null@*/ rpmDepSet ds, /*@null@*/ const char * msg,
const char * fn, unsigned ln)
/*@modifies ds @*/;
#define rpmdsLink(_ds, _msg) XrpmdsLink(_ds, _msg, __FILE__, __LINE__)
void rpmProblemSetAppend(/*@null@*/ rpmProblemSet ps, rpmProblemType type,
/*@null@*/ const char * pkgNEVR,
/*@exposed@*/ /*@null@*/ fnpyKey key,
- const char * dn, const char * bn,
+ /*@null@*/ const char * dn, /*@null@*/ const char * bn,
/*@null@*/ const char * altNEVR,
unsigned long ulong1)
/*@modifies ps @*/;
/*@access alKey @*/
/*@access fnpyKey @*/
+/*@access rpmDepSet @*/
/*@access rpmFNSet @*/
/*@access TFI_t @*/
/**
*/
struct diskspaceInfo {
- dev_t dev; /*!< file system device number. */
- signed long bneeded; /*!< no. of blocks needed. */
- signed long ineeded; /*!< no. of inodes needed. */
- int bsize; /*!< file system block size. */
- signed long bavail; /*!< no. of blocks available. */
- signed long iavail; /*!< no. of inodes available. */
+ dev_t dev; /*!< File system device number. */
+ signed long bneeded; /*!< No. of blocks needed. */
+ signed long ineeded; /*!< No. of inodes needed. */
+ int bsize; /*!< File system block size. */
+ signed long bavail; /*!< No. of blocks available. */
+ signed long iavail; /*!< No. of inodes available. */
};
/**
/**
*/
-static int archOkay(Header h, /*@out@*/ const char ** pkgArchPtr)
- /*@modifies *pkgArchPtr @*/
+static int archOkay(/*@null@*/ const char * pkgArch)
+ /*@*/
{
- const char * pkgArch;
- int type, count;
- int rc = 1; /* assume AOK */
-
- if (pkgArchPtr != NULL) *pkgArchPtr = pkgArch = NULL;
-
- /* make sure we're trying to install this on the proper architecture */
- (void) headerGetEntry(h, RPMTAG_ARCH, &type, (void **) &pkgArch, &count);
-
-#ifdef DYING
- if (type == RPM_INT8_TYPE) {
- int_8 * pkgArchNum;
- int archNum;
-
- /* old arch handling */
- rpmGetArchInfo(NULL, &archNum);
- pkgArchNum = pkgArch;
- if (archNum != *pkgArchNum)
- rc = 0;
- } else
-#endif
-
- if (!rpmMachineScore(RPM_MACHTABLE_INSTARCH, pkgArch)) {
- rc = 0;
- if (pkgArchPtr != NULL) *pkgArchPtr = pkgArch;
- }
-
- return rc;
+ if (pkgArch == NULL) return 0;
+ return (rpmMachineScore(RPM_MACHTABLE_INSTARCH, pkgArch) ? 1 : 0);
}
/**
*/
-static int osOkay(Header h, /*@out@*/ const char ** pkgOsPtr)
- /*@modifies *pkgOsPtr @*/
+static int osOkay(/*@null@*/ const char * pkgOs)
+ /*@*/
{
- const char * pkgOs;
- int type, count;
- int rc = 1; /* assume AOK */
-
- if (pkgOsPtr != NULL) *pkgOsPtr = pkgOs = NULL;
-
- /* make sure we're trying to install this on the proper os */
- (void) headerGetEntry(h, RPMTAG_OS, &type, (void **) &pkgOs, &count);
-
-#ifdef DYING
- if (type == RPM_INT8_TYPE) {
- /* v1 packages and v2 packages both used improper OS numbers, so just
- deal with it hope things work */
- return 1;
- } else
-#endif
-
- if (!rpmMachineScore(RPM_MACHTABLE_INSTOS, pkgOs)) {
- rc = 0;
- if (pkgOsPtr != NULL) *pkgOsPtr = pkgOs;
- }
-
- return rc;
+ if (pkgOs == NULL) return 0;
+ return (rpmMachineScore(RPM_MACHTABLE_INSTOS, pkgOs) ? 1 : 0);
}
/**
}
/**
+ * Ensure that current package is newer than installed package.
+ * @param ts transaction set
+ * @param p current transaction element
+ * @param h installed header
+ * @return 0 if not newer, 1 if okay
*/
+#ifdef DYING
static int ensureOlder(rpmTransactionSet ts,
const Header h, /*@null@*/ const Header old,
/*@dependent@*/ /*@null@*/ const void * key)
return rc;
}
+#else
+static int ensureOlder(rpmTransactionSet ts, transactionElement p, Header h)
+ /*@modifies ts @*/
+{
+ rpmDepSet req = memset(alloca(sizeof(*req)), 0, sizeof(*req));
+ const char * reqEVR;
+ int_32 reqFlags = (RPMSENSE_LESS | RPMSENSE_EQUAL);
+ char * t;
+ int rc;
+
+ if (p == NULL || h == NULL)
+ return 1;
+
+ t = alloca(strlen(p->NEVR) + (p->epoch != NULL ? strlen(p->epoch) : 0) + 1);
+ *t = '\0';
+ reqEVR = t;
+ if (p->epoch != NULL) t = stpcpy( stpcpy(t, p->epoch), ":");
+ if (p->version != NULL) t = stpcpy(t, p->version);
+ *t++ = '-';
+ if (p->release != NULL) t = stpcpy(t, p->release);
+
+ /*@-compmempass@*/
+ req->i = -1;
+ req->Type = "Requires";
+ req->tagN = RPMTAG_REQUIRENAME;
+ req->DNEVR = NULL;
+ /*@-immediatetrans@*/
+ /*@-assignexpose@*/
+ req->N = (const char **) &p->name;
+ /*@=assignexpose@*/
+ req->EVR = &reqEVR;
+ req->Flags = &reqFlags;
+ /*@=immediatetrans@*/
+ req->Count = 1;
+ (void) dsiNext(dsiInit(req));
+
+ rc = headerMatchesDepFlags(h, req);
+
+ req->DNEVR = _free(req->DNEVR);
+ /*@=compmempass@*/
+
+ /*@-branchstate@*/ /* FIX: p->key ??? */
+ if (rc == 0) {
+ const char * altNEVR = hGetNEVR(h, NULL);
+ rpmProblemSetAppend(ts->probs, RPMPROB_OLDPACKAGE,
+ p->NEVR, p->key,
+ NULL, NULL,
+ altNEVR,
+ 0);
+ altNEVR = _free(altNEVR);
+ rc = 1;
+ } else
+ rc = 0;
+ /*@=branchstate@*/
+
+ return rc;
+}
+#endif
/**
*/
/* The ordering doesn't matter here */
tei = teInitIterator(ts);
while ((p = teNext(tei, TR_ADDED)) != NULL) {
- const char * n, * v, * r;
- fnpyKey key;
rpmdbMatchIterator mi;
- const char * str1;
- Header h;
pkgKey = p->u.addedKey;
- h = alGetHeader(ts->addedPackages, pkgKey, 0);
- if (h == NULL) /* XXX can't happen */
- continue;
-
- (void) headerNVR(h, &n, &v, &r);
- key = p->key;
-
- str1 = NULL;
- if (!archOkay(h, &str1) && !(ts->ignoreSet & RPMPROB_FILTER_IGNOREARCH)) {
- const char * pkgNEVR = hGetNEVR(h, NULL);
+ /*@-branchstate@*/ /* FIX: p->key ??? */
+ if (!archOkay(p->arch) && !(ts->ignoreSet & RPMPROB_FILTER_IGNOREARCH))
rpmProblemSetAppend(ts->probs, RPMPROB_BADARCH,
- pkgNEVR, key,
- str1, NULL,
+ p->NEVR, p->key,
+ p->arch, NULL,
NULL, 0);
- pkgNEVR = _free(pkgNEVR);
- }
- str1 = NULL;
- if (!osOkay(h, &str1) && !(ts->ignoreSet & RPMPROB_FILTER_IGNOREOS)) {
- const char * pkgNEVR = hGetNEVR(h, NULL);
+ if (!osOkay(p->os) && !(ts->ignoreSet & RPMPROB_FILTER_IGNOREOS))
rpmProblemSetAppend(ts->probs, RPMPROB_BADOS,
- pkgNEVR, key,
- str1, NULL,
+ p->NEVR, p->key,
+ p->os, NULL,
NULL, 0);
- pkgNEVR = _free(pkgNEVR);
- }
+ /*@=branchstate@*/
if (!(ts->ignoreSet & RPMPROB_FILTER_OLDPACKAGE)) {
- Header oldH;
- mi = rpmtsInitIterator(ts, RPMTAG_NAME, n, 0);
- while ((oldH = rpmdbNextIterator(mi)) != NULL)
- xx = ensureOlder(ts, h, oldH, key);
+ Header h;
+ mi = rpmtsInitIterator(ts, RPMTAG_NAME, p->name, 0);
+ while ((h = rpmdbNextIterator(mi)) != NULL)
+ xx = ensureOlder(ts, p, h);
mi = rpmdbFreeIterator(mi);
}
&& !alGetMultiLib(ts->addedPackages, i)
#endif
) {
- mi = rpmtsInitIterator(ts, RPMTAG_NAME, n, 0);
- xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT, v);
- xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT, r);
+ mi = rpmtsInitIterator(ts, RPMTAG_NAME, p->name, 0);
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT,
+ p->version);
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT,
+ p->release);
while (rpmdbNextIterator(mi) != NULL) {
- const char * pkgNEVR = hGetNEVR(h, NULL);
rpmProblemSetAppend(ts->probs, RPMPROB_PKG_INSTALLED,
- pkgNEVR, key,
+ p->NEVR, p->key,
NULL, NULL,
NULL, 0);
- pkgNEVR = _free(pkgNEVR);
/*@innerbreak@*/ break;
}
mi = rpmdbFreeIterator(mi);
if (p->fns != NULL)
totalFileCount += p->fns->fc;
- h = headerFree(h, "alGetHeader (rpmtsRun sanity)");
-
}
tei = teFreeIterator(tei);
/* ===============================================
* Initialize transaction element file info for package:
*/
- ts->flEntries = alGetSize(ts->addedPackages) + ts->numRemovedPackages;
+ ts->flEntries = ts->numAddedPackages + ts->numRemovedPackages;
ts->flList = xcalloc(ts->flEntries, sizeof(*ts->flList));
/*
te = t = alloca(nb);
*te = '\0';
pkgNEVR = (conflicts->pkgNEVR ? conflicts->pkgNEVR : "?pkgNEVR?");
- sprintf(te, _("Unsatisifed dependencies for %s:"), pkgNEVR);
+ sprintf(te, _("Unsatisifed dependencies for %s: "), pkgNEVR);
te += strlen(te);
for (i = 0; i < numConflicts; i++) {
c = conflicts + i;
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2001-11-09 20:32-0500\n"
+"POT-Creation-Date: 2001-11-10 14:13-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "cannot open Packages database in %s\n"
msgstr ""
-#: lib/depends.c:354
+#: lib/depends.c:431
#, c-format
msgid "newer package %s already added, skipping %s\n"
msgstr ""
-#: lib/depends.c:359
+#: lib/depends.c:436
#, c-format
msgid "package %s already added, ignoring\n"
msgstr ""
-#: lib/depends.c:364
+#: lib/depends.c:441
#, c-format
msgid "older package %s already added, replacing with %s\n"
msgstr ""
-#: lib/depends.c:716
+#: lib/depends.c:739
msgid "(cached)"
msgstr ""
-#: lib/depends.c:741
+#: lib/depends.c:764
msgid "(rpmrc provides)"
msgstr ""
-#: lib/depends.c:757
+#: lib/depends.c:780
msgid "(rpmlib provides)"
msgstr ""
-#: lib/depends.c:778
+#: lib/depends.c:801
msgid "(db files)"
msgstr ""
-#: lib/depends.c:790
+#: lib/depends.c:813
msgid "(db provides)"
msgstr ""
-#: lib/depends.c:803
+#: lib/depends.c:826
msgid "(db package)"
msgstr ""
-#: lib/depends.c:842
+#: lib/depends.c:865
#, c-format
msgid "%9s: (%s, %s) added to Depends cache.\n"
msgstr ""
-#: lib/depends.c:844 lib/rpmds.c:468 lib/rpmds.c:625
+#: lib/depends.c:867 lib/rpmds.c:468 lib/rpmds.c:626
msgid "NO "
msgstr ""
-#: lib/depends.c:844 lib/rpmds.c:468 lib/rpmds.c:625
+#: lib/depends.c:867 lib/rpmds.c:468 lib/rpmds.c:626
msgid "YES"
msgstr ""
-#: lib/depends.c:1178
+#: lib/depends.c:1201
#, c-format
msgid "removing %s \"%s\" from tsort relations.\n"
msgstr ""
#. Record all relations.
-#: lib/depends.c:1424
+#: lib/depends.c:1431
msgid "========== recording tsort relations\n"
msgstr ""
#. T4. Scan for zeroes.
-#: lib/depends.c:1497
+#: lib/depends.c:1504
msgid ""
"========== tsorting packages (order, #predecessors, #succesors, depth)\n"
msgstr ""
-#: lib/depends.c:1572
+#: lib/depends.c:1579
msgid "========== successors only (presentation order)\n"
msgstr ""
-#: lib/depends.c:1633
+#: lib/depends.c:1640
msgid "LOOP:\n"
msgstr ""
-#: lib/depends.c:1668
+#: lib/depends.c:1675
msgid "========== continuing tsort ...\n"
msgstr ""
#. Return no. of packages that could not be ordered.
-#: lib/depends.c:1673
+#: lib/depends.c:1680
#, c-format
msgid "rpmdepOrder failed, %d elements remain\n"
msgstr ""
msgid "package %s is not installed\n"
msgstr ""
-#: lib/rpmal.c:695
+#: lib/rpmal.c:688
msgid "(added files)"
msgstr ""
-#: lib/rpmal.c:794
+#: lib/rpmal.c:787
msgid "(added provide)"
msgstr ""
msgstr ""
#. XXX legacy epoch-less requires/conflicts compatibility
-#: lib/rpmds.c:595
+#: lib/rpmds.c:596
#, c-format
msgid ""
"the \"B\" dependency needs an epoch (assuming same as \"A\")\n"
"\tA %s\tB %s\n"
msgstr ""
-#: lib/rpmds.c:624
+#: lib/rpmds.c:625
#, c-format
msgid " %s A %s\tB %s\n"
msgstr ""
#. @=branchstate@
-#: lib/rpmds.c:649
+#: lib/rpmds.c:650
#, c-format
msgid "package %s has unsatisfied %s: %s\n"
msgstr ""
msgid "Signature: UNKNOWN (%d)\n"
msgstr ""
-#: lib/transaction.c:252
+#: lib/transaction.c:206
#, c-format
msgid "%s skipped due to missingok flag\n"
msgstr ""
#. @innercontinue@
-#: lib/transaction.c:905
+#: lib/transaction.c:923
#, c-format
msgid "excluding directory %s\n"
msgstr ""
#: lib/verify.c:518
#, c-format
-msgid "Unsatisifed dependencies for %s:"
+msgid "Unsatisifed dependencies for %s: "
msgstr ""
#: lib/verify.c:556