goto exit;
/* Do lazy (readonly?) open of rpm database. */
- if (ts->rpmdb == NULL) {
+ if (rpmtsGetRdb(ts) == NULL) {
if ((ec = rpmtsOpenDB(ts, ts->dbmode)) != 0)
goto exit;
}
*/
if (_cacheDependsRC) {
dbiIndex dbi;
- dbi = dbiOpen(ts->rpmdb, RPMDBI_DEPENDS, 0);
+ dbi = dbiOpen(rpmtsGetRdb(ts), RPMDBI_DEPENDS, 0);
if (dbi == NULL)
_cacheDependsRC = 0;
else {
goto exit;
/* XXX only the installer does not have the database open here. */
- if (ts->rpmdb != NULL) {
+ if (rpmtsGetRdb(ts) != NULL) {
if (Name[0] == '/') {
/* depFlags better be 0! */
/*
* Search for an unsatisfied dependency.
*/
- if (!(ts->transFlags & RPMTRANS_FLAG_NOSUGGESTS) && ts->solve != NULL)
+ if (!(rpmtsGetFlags(ts) & RPMTRANS_FLAG_NOSUGGESTS) && ts->solve != NULL)
xx = (*ts->solve) (ts, dep);
unsatisfied:
*/
if (_cacheDependsRC) {
dbiIndex dbi;
- dbi = dbiOpen(ts->rpmdb, RPMDBI_DEPENDS, 0);
+ dbi = dbiOpen(rpmtsGetRdb(ts), RPMDBI_DEPENDS, 0);
if (dbi == NULL) {
_cacheDependsRC = 0;
} else {
{
int rc = 0;
- if (ts->rpmdb != NULL) { /* XXX is this necessary? */
+ if (rpmtsGetRdb(ts) != NULL) { /* XXX is this necessary? */
rpmdbMatchIterator mi;
mi = rpmtsInitIterator(ts, RPMTAG_CONFLICTNAME, dep, 0);
rc = checkPackageSet(ts, dep, mi);
int_32 Flags;
#ifdef DYING
- int chainsaw = ts->transFlags & RPMTRANS_FLAG_CHAINSAW;
+ int chainsaw = rpmtsGetFlags(ts) & RPMTRANS_FLAG_CHAINSAW;
#else
int chainsaw = 1;
#endif
int rc;
/* Do lazy, readonly, open of rpm database. */
- if (ts->rpmdb == NULL) {
+ if (rpmtsGetRdb(ts) == NULL) {
if ((rc = rpmtsOpenDB(ts, ts->dbmode)) != 0)
goto exit;
closeatexit = 1;
if (closeatexit)
xx = rpmtsCloseDB(ts);
else if (_cacheDependsRC)
- xx = rpmdbCloseDBI(ts->rpmdb, RPMDBI_DEPENDS);
+ xx = rpmdbCloseDBI(rpmtsGetRdb(ts), RPMDBI_DEPENDS);
/*@=branchstate@*/
return rc;
}
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
/*@unchecked@*/
-int _fsm_debug = 1;
+int _fsm_debug = 0;
/* XXX Failure to remove is not (yet) cause for failure. */
/*@-exportlocal -exportheadervar@*/
memset(fsm->sufbuf, 0, sizeof(fsm->sufbuf));
if (fsm->goal == FSM_PKGINSTALL) {
- if (ts && ts->id > 0)
- sprintf(fsm->sufbuf, ";%08x", (unsigned)ts->id);
+ if (ts && rpmtsGetTid(ts) > 0)
+ sprintf(fsm->sufbuf, ";%08x", (unsigned)rpmtsGetTid(ts));
}
ec = fsm->rc = 0;
fprintf(stderr, "--> ps %p -- %d %s at %s:%u\n", ps, ps->nrefs, msg, fn, ln);
/*@=modfilesystem@*/
ps->nrefs--;
- return NULL;
+/*@-refcounttrans@*/
+ return ps;
+/*@=refcounttrans@*/
}
rpmProblemSet XrpmpsLink(rpmProblemSet ps, const char * msg,
if (_ps_debug > 0 && msg != NULL)
fprintf(stderr, "--> ps %p ++ %d %s at %s:%u\n", ps, ps->nrefs, msg, fn, ln);
/*@=modfilesystem@*/
- /*@-refcounttrans@*/ return ps; /*@=refcounttrans@*/
+/*@-refcounttrans@*/
+ return ps;
+/*@=refcounttrans@*/
}
rpmProblemSet rpmProblemSetCreate(void)
{
- rpmProblemSet ps;
-
- ps = xcalloc(1, sizeof(*ps));
- ps->numProblems = ps->numProblemsAlloced = 0;
- ps->probs = NULL;
- ps->nrefs = 0;
-
+ rpmProblemSet ps = xcalloc(1, sizeof(*ps));
return rpmpsLink(ps, "create");
}
rpmProblemSet rpmProblemSetFree(rpmProblemSet ps)
{
if (ps == NULL) return NULL;
- if (ps->nrefs > 1)
- return rpmpsUnlink(ps, "dereference");
+ ps = rpmpsUnlink(ps, "dereference");
+ if (ps->nrefs > 0)
+ return NULL;
if (ps->probs) {
int i;
}
ps->probs = _free(ps->probs);
}
-/*@-nullstate@*/ /* FIX: ps->probs may be NULL */
- (void) rpmpsUnlink(ps, "destroy");
-/*@=nullstate@*/
- /*@-refcounttrans -usereleased@*/
ps = _free(ps);
- /*@=refcounttrans =usereleased@*/
return NULL;
}
/*@access TFI_t@*/
/*@access transactionElement@*/ /* XXX rpmInstallSourcePackage */
-/*@access rpmTransactionSet@*/
/*@access alKey@*/
/*@access rpmDepSet@*/
goto exit;
}
-/*@-assignexpose@*/
+/*@-assignexpose -type@*/
fi->te = ts->order[0];
-/*@=assignexpose@*/
+/*@=assignexpose =type@*/
fi->te->fd = fdLink(fd, "installSourcePackage");
hge = fi->hge;
hfd = fi->hfd;
FD_t fd;
/*@-branchstate@*/
- if (makeTempFile((!ts->chrootDone ? rootDir : "/"), &fn, &fd)) {
+ if (makeTempFile((!rpmtsGetChrootDone(ts) ? rootDir : "/"), &fn, &fd)) {
if (freePrefixes) free(prefixes);
return 1;
}
xx = Fclose(fd);
{ const char * sn = fn;
- if (!ts->chrootDone && rootDir != NULL &&
+ if (!rpmtsGetChrootDone(ts) && rootDir != NULL &&
!(rootDir[0] == '/' && rootDir[1] == '\0'))
{
sn += strlen(rootDir)-1;
rootDir = strchr(rootDir, '/');
/*@fallthrough@*/
case URL_IS_UNKNOWN:
- if (!ts->chrootDone && !(rootDir[0] == '/' && rootDir[1] == '\0')) {
+ if (!rpmtsGetChrootDone(ts) && !(rootDir[0] == '/' && rootDir[1] == '\0')) {
/*@-superuser -noeffect @*/
xx = chroot(rootDir);
/*@=superuser =noeffect @*/
* @param triggersAlreadyRun
* @return
*/
-static int handleOneTrigger(PSM_t psm, Header sourceH, Header triggeredH,
+static int handleOneTrigger(const PSM_t psm, Header sourceH, Header triggeredH,
int arg2, unsigned char * triggersAlreadyRun)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState@*/
- /*@modifies psm, triggeredH, *triggersAlreadyRun, rpmGlobalMacroContext,
+ /*@modifies triggeredH, *triggersAlreadyRun, rpmGlobalMacroContext,
fileSystem, internalState @*/
{
int scareMem = 1;
{ int arg1;
int index;
- arg1 = rpmdbCountPackages(ts->rpmdb, Name);
+ arg1 = rpmdbCountPackages(rpmtsGetRdb(ts), Name);
if (arg1 < 0) {
/* XXX W2DO? fails as "execution of script failed" */
rc = RPMRC_FAIL;
int numPackage;
rpmRC rc = RPMRC_OK;
- numPackage = rpmdbCountPackages(ts->rpmdb, teGetN(psm->te)) + psm->countCorrection;
+ numPackage = rpmdbCountPackages(rpmtsGetRdb(ts), teGetN(psm->te)) + psm->countCorrection;
if (numPackage < 0)
return 1;
* versions of this package that will be installed when we are
* finished.
*/
- psm->npkgs_installed = rpmdbCountPackages(ts->rpmdb, teGetN(psm->te));
+ psm->npkgs_installed = rpmdbCountPackages(rpmtsGetRdb(ts), teGetN(psm->te));
if (psm->npkgs_installed < 0) {
rc = RPMRC_FAIL;
break;
/* Add remove transaction id to header. */
if (psm->oh)
- { int_32 tid = ts->id;
+ { int_32 tid = rpmtsGetTid(ts);
xx = headerAddEntry(psm->oh, RPMTAG_REMOVETID,
RPM_INT32_TYPE, &tid, 1);
}
case PSM_CREATE:
break;
case PSM_NOTIFY:
+/*@-type@*/
if (ts && ts->notify) {
/*@-noeffectuncon @*/ /* FIX: check rc */
(void) ts->notify(fi->h, psm->what, psm->amount, psm->total,
teGetKey(psm->te), ts->notifyData);
/*@=noeffectuncon @*/
}
+/*@=type@*/
break;
case PSM_DESTROY:
break;
case PSM_CHROOT_IN:
{ const char * rootDir = rpmtsGetRootDir(ts);
/* Change root directory if requested and not already done. */
- if (rootDir != NULL && !ts->chrootDone && !psm->chrootDone) {
+ if (rootDir != NULL && !rpmtsGetChrootDone(ts) && !psm->chrootDone) {
static int _loaded = 0;
/*
/*@-superuser@*/
rc = chroot(rootDir);
/*@=superuser@*/
- psm->chrootDone = ts->chrootDone = 1;
- if (ts->rpmdb != NULL) ts->rpmdb->db_chrootDone = 1;
+ psm->chrootDone = 1;
+ (void) rpmtsSetChrootDone(ts, 1);
}
} break;
case PSM_CHROOT_OUT:
/* Restore root directory if changed. */
if (psm->chrootDone) {
+ const char * currDir = rpmtsGetCurrDir(ts);
/*@-superuser@*/
rc = chroot(".");
/*@=superuser@*/
- psm->chrootDone = ts->chrootDone = 0;
- if (ts->rpmdb != NULL)
- ts->rpmdb->db_chrootDone = 0;
- if (ts->currDir != NULL) /* XXX can't happen */
- xx = chdir(ts->currDir);
+ psm->chrootDone = 0;
+ (void) rpmtsSetChrootDone(ts, 0);
+ if (currDir != NULL) /* XXX can't happen */
+ xx = chdir(currDir);
}
break;
case PSM_SCRIPT: /* Run current package scriptlets. */
case PSM_RPMDB_ADD:
if (rpmtsGetFlags(ts) & RPMTRANS_FLAG_TEST) break;
if (fi->h != NULL) /* XXX can't happen */
- rc = rpmdbAdd(ts->rpmdb, ts->id, fi->h);
+ rc = rpmdbAdd(rpmtsGetRdb(ts), rpmtsGetTid(ts), fi->h);
break;
case PSM_RPMDB_REMOVE:
if (rpmtsGetFlags(ts) & RPMTRANS_FLAG_TEST) break;
- rc = rpmdbRemove(ts->rpmdb, ts->id, fi->record);
+ rc = rpmdbRemove(rpmtsGetRdb(ts), rpmtsGetTid(ts), fi->record);
break;
default:
#include "misc.h" /* XXX for makeTempFile() */
#include "debug.h"
-/*@access rpmTransactionSet @*/ /* ts->rpmdb, ts->id, ts->dig et al */
+/*@access rpmTransactionSet @*/ /* ts->dig et al */
/*?access Header @*/ /* XXX compared with NULL */
/*@access FD_t @*/ /* XXX stealing digests */
/*@access pgpDig @*/
* @param argv array of pubkey file names (NULL terminated)
* @return 0 on success
*/
-static int rpmImportPubkey(rpmTransactionSet ts,
+static int rpmImportPubkey(const rpmTransactionSet ts,
/*@unused@*/ QVA_t qva,
/*@null@*/ const char ** argv)
/*@globals RPMVERSION, fileSystem, internalState @*/
- /*@modifies ts, fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/
{
const char * fn;
int res = 0;
/* XXX W2DO: tag value inheirited from parent? */
xx = headerAddEntry(h, RPMTAG_BUILDHOST, RPM_STRING_TYPE, buildhost, 1);
-
- xx = headerAddEntry(h, RPMTAG_INSTALLTIME, RPM_INT32_TYPE, &ts->id, 1);
-
- /* XXX W2DO: tag value inheirited from parent? */
- xx = headerAddEntry(h, RPMTAG_BUILDTIME, RPM_INT32_TYPE, &ts->id, 1);
+ { int_32 tid = rpmtsGetTid(ts);
+ xx = headerAddEntry(h, RPMTAG_INSTALLTIME, RPM_INT32_TYPE, &tid, 1);
+ /* XXX W2DO: tag value inheirited from parent? */
+ xx = headerAddEntry(h, RPMTAG_BUILDTIME, RPM_INT32_TYPE, &tid, 1);
+ }
#ifdef NOTYET
/* XXX W2DO: tag value inheirited from parent? */
#endif
/* Add header to database. */
- xx = rpmdbAdd(ts->rpmdb, ts->id, h);
+ xx = rpmdbAdd(rpmtsGetRdb(ts), rpmtsGetTid(ts), h);
bottom:
/* Clean up. */
/*@access TFI_t @*/
/*@access transactionElement @*/
-/*@access rpmTransactionSet @*/ /* XXX for ts->ignoreSet and ts->probs */
+/*@access rpmTransactionSet @*/ /* XXX for ts->ignoreSet */
/*@unchecked@*/
static int _fi_debug = 0;
/* XXX actions check prevents problem from being appended twice. */
if (j == numValid && !allowBadRelocate && actions) {
- rpmProblemSetAppend(ts->probs, RPMPROB_BADRELOCATE,
+ rpmProblemSet ps = rpmtsGetProblems(ts);
+ rpmProblemSetAppend(ps, RPMPROB_BADRELOCATE,
p->NEVR, p->key,
relocations[i].oldPath, NULL, NULL, 0);
+ ps = rpmProblemSetFree(ps);
}
del =
strlen(relocations[i].newPath) - strlen(relocations[i].oldPath);
#include <rpmcli.h>
#include "rpmdb.h"
-#include "rpmts.h" /* XXX ts->rpmdb */
+#include "rpmts.h"
#include "manifest.h"
#include "misc.h" /* XXX for rpmGlob() */
#include "debug.h"
-/*@access rpmTransactionSet @*/ /* XXX compared with NULL, ts->rpmdb */
+/*@access rpmTransactionSet @*/ /* XXX ts->goal, ts->dbmode */
/*@access rpmProblemSet @*/ /* XXX compared with NULL */
/*@access Header @*/ /* XXX compared with NULL */
/*@access rpmdb @*/ /* XXX compared with NULL */
fprintf(stdout, _("Retrieving %s\n"), fileURL);
{ char tfnbuf[64];
- const char * rootDir;
- rootDir = (ts->rootDir && *ts->rootDir) ? ts->rootDir : "";
+ const char * rootDir = rpmtsGetRootDir(ts);
+ if (!(rootDir && * rootDir))
+ rootDir = "";
strcpy(tfnbuf, "rpm-xfer.XXXXXX");
(void) mktemp(tfnbuf);
tfn = rpmGenPath(rootDir, "%{_tmppath}/", tfnbuf);
if (eiu->rpmrc == RPMRC_OK || eiu->rpmrc == RPMRC_BADSIZE) {
/* Open database RDWR for binary packages. */
- /*@-nullstate@*/ /* FIX: ts->rootDir may be NULL? */
if (rpmtsOpenDB(ts, ts->dbmode)) {
eiu->numFailed++;
goto exit;
}
- /*@=nullstate@*/ /* FIX: ts->rootDir may be NULL? */
if (eiu->relocations) {
const char ** paths;
int c;
if (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft,
- (void **) &paths, &c) && (c == 1)) {
+ (void **) &paths, &c) && (c == 1))
+ {
eiu->relocations->oldPath = xstrdup(paths[0]);
paths = headerFreeData(paths, pft);
} else {
int count;
xx = headerNVR(eiu->h, &name, NULL, NULL);
- /*@-nullstate@*/ /* FIX: ts->rootDir may be NULL? */
mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
- /*@=nullstate@*/ /* FIX: ts->rootDir may be NULL? */
count = rpmdbGetIteratorCount(mi);
while ((oldH = rpmdbNextIterator(mi)) != NULL) {
if (rpmVersionCompare(oldH, eiu->h) < 0)
/* Package is newer than those currently installed. */
}
- /*@-nullstate@*/ /* FIX: ts->rootDir may be NULL? */
/*@-abstract@*/
rc = rpmtsAddPackage(ts, eiu->h, (fnpyKey)fileName,
(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
relocations);
/*@=abstract@*/
- /*@=nullstate@*/
/* XXX reference held by transaction set */
eiu->h = headerFree(eiu->h, "Install added");
if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NODEPS)) {
- /*@-nullstate@*/ /* FIX: ts->rootDir may be NULL? */
if (rpmtsCheck(ts)) {
eiu->numFailed = eiu->numPkgs;
stopInstall = 1;
}
- /*@=nullstate@*/
ps = rpmtsGetProblems(ts);
if (!stopInstall && ps) {
}
if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NOORDER)) {
- /*@-nullstate@*/ /* FIX: ts->rootDir may be NULL? */
if (rpmtsOrder(ts)) {
eiu->numFailed = eiu->numPkgs;
stopInstall = 1;
}
- /*@=nullstate@*/
}
if (eiu->numRPMS && !stopInstall) {
rpmMessage(RPMMESS_DEBUG, _("installing binary packages\n"));
- /*@-nullstate@*/ /* FIX: ts->rootDir may be NULL? */
rc = rpmtsRun(ts, NULL, probFilter);
- /*@=nullstate@*/
ps = rpmtsGetProblems(ts);
if (rc < 0) {
* Unreference a problem set instance.
* @param ps problem set
* @param msg
- * @return NULL always
+ * @return problem set
*/
-/*@unused@*/ /*@null@*/
-rpmProblemSet rpmpsUnlink (/*@killref@*/ /*@only@*/ rpmProblemSet ps,
+/*@unused@*/
+rpmProblemSet rpmpsUnlink (/*@killref@*/ /*@returned@*/ rpmProblemSet ps,
const char * msg)
/*@modifies ps @*/;
/** @todo Remove debugging entry from the ABI. */
/*@null@*/
-rpmProblemSet XrpmpsUnlink (/*@killref@*/ /*@only@*/ rpmProblemSet ps,
+rpmProblemSet XrpmpsUnlink (/*@killref@*/ /*@returned@*/ rpmProblemSet ps,
const char * msg, const char * fn, unsigned ln)
/*@modifies ps @*/;
#define rpmpsUnlink(_ps, _msg) XrpmpsUnlink(_ps, _msg, __FILE__, __LINE__)
#include "debug.h"
+/*@access rpmdb @*/ /* XXX db->db_chrootDone, NULL */
+
/*@access FD_t @*/ /* XXX compared with NULL */
/*@access rpmProblemSet @*/
/*@access rpmTransactionSet @*/
{
int rc = 0;
- if (ts->rpmdb != NULL) {
- rc = rpmdbClose(ts->rpmdb);
- ts->rpmdb = NULL;
+ if (ts->rdb != NULL) {
+ rc = rpmdbClose(ts->rdb);
+ ts->rdb = NULL;
}
return rc;
}
{
int rc = 0;
- if (ts->rpmdb != NULL && ts->dbmode == dbmode)
+ if (ts->rdb != NULL && ts->dbmode == dbmode)
return 0;
(void) rpmtsCloseDB(ts);
/* XXX there's a potential db lock race here. */
ts->dbmode = dbmode;
- rc = rpmdbOpen(ts->rootDir, &ts->rpmdb, ts->dbmode, 0644);
+ rc = rpmdbOpen(ts->rootDir, &ts->rdb, ts->dbmode, 0644);
if (rc) {
const char * dn;
/*@-globs -mods@*/ /* FIX: rpmGlobalMacroContext for an error? shrug */
rpmdbMatchIterator rpmtsInitIterator(const rpmTransactionSet ts, int rpmtag,
const void * keyp, size_t keylen)
{
- return rpmdbInitIterator(ts->rpmdb, rpmtag, keyp, keylen);
+ return rpmdbInitIterator(ts->rdb, rpmtag, keyp, keylen);
}
static int rpmtsCloseSDB(rpmTransactionSet ts)
if (ts->probs) {
if (ts->probs->numProblems > 0)
ps = rpmpsLink(ts->probs, NULL);
- ts->probs = rpmpsUnlink(ts->probs, NULL);
}
}
return ps;
}
}
+const char * rpmtsGetCurrDir(rpmTransactionSet ts)
+{
+ const char * currDir = NULL;
+ if (ts != NULL) {
+ currDir = ts->currDir;
+ }
+ return currDir;
+}
+
+void rpmtsSetCurrDir(rpmTransactionSet ts, const char * currDir)
+{
+ if (ts != NULL) {
+ ts->currDir = _free(ts->currDir);
+ if (currDir)
+ ts->currDir = xstrdup(currDir);
+ }
+}
+
FD_t rpmtsGetScriptFd(rpmTransactionSet ts)
{
FD_t scriptFd = NULL;
}
}
+int rpmtsGetChrootDone(rpmTransactionSet ts)
+{
+ int chrootDone = 0;
+ if (ts != NULL) {
+ chrootDone = ts->chrootDone;
+ }
+ return chrootDone;
+}
+
+int rpmtsSetChrootDone(rpmTransactionSet ts, int chrootDone)
+{
+ int ochrootDone = 0;
+ if (ts != NULL) {
+ ochrootDone = ts->chrootDone;
+ if (ts->rdb != NULL)
+ ts->rdb->db_chrootDone = chrootDone;
+ ts->chrootDone = chrootDone;
+ }
+ return ochrootDone;
+}
+
+int_32 rpmtsGetTid(rpmTransactionSet ts)
+{
+ int_32 tid = 0;
+ if (ts != NULL) {
+ tid = ts->tid;
+ }
+ return tid;
+}
+
+int_32 rpmtsSetTid(rpmTransactionSet ts, int_32 tid)
+{
+ int_32 otid = 0;
+ if (ts != NULL) {
+ otid = ts->tid;
+ ts->tid = tid;
+ }
+ return otid;
+}
+
+rpmdb rpmtsGetRdb(rpmTransactionSet ts)
+{
+ rpmdb rdb = NULL;
+ if (ts != NULL) {
+ rdb = ts->rdb;
+ }
+/*@-compdef -refcounttrans -usereleased @*/
+ return rdb;
+/*@=compdef =refcounttrans =usereleased @*/
+}
+
rpmtsFlags rpmtsGetFlags(rpmTransactionSet ts)
{
rpmtsFlags otransFlags = 0;
return otransFlags;
}
-rpmtsFlags rpmtsSetFlags(rpmTransactionSet ts, rpmtsFlags ntransFlags)
+rpmtsFlags rpmtsSetFlags(rpmTransactionSet ts, rpmtsFlags transFlags)
{
rpmtsFlags otransFlags = 0;
if (ts != NULL) {
otransFlags = ts->transFlags;
- ts->transFlags = ntransFlags;
+ ts->transFlags = transFlags;
}
return otransFlags;
}
ts->filesystems = NULL;
ts->di = NULL;
- ts->rpmdb = NULL;
+ ts->rdb = NULL;
ts->dbmode = O_RDONLY;
ts->scriptFd = NULL;
- ts->id = (int_32) time(NULL);
+ ts->tid = (int_32) time(NULL);
ts->delta = 5;
ts->numRemovedPackages = 0;
/*@only@*/ /*@null@*/
const void ** suggests; /*!< Possible depCheck suggestions. */
/*@refcounted@*/ /*@null@*/
- rpmdb sdb; /*!< Available universe database handle. */
+ rpmdb sdb; /*!< Solve database handle. */
/*@observer@*/ /*@null@*/
rpmCallbackFunction notify; /*!< Callback function. */
int dbmode; /*!< Database open mode. */
/*@refcounted@*/ /*@null@*/
- rpmdb rpmdb; /*!< Database handle. */
+ rpmdb rdb; /*!< Install database handle. */
/*@only@*/
hashTable ht; /*!< Fingerprint hash table. */
/*@null@*/
FD_t scriptFd; /*!< Scriptlet stdout/stderr. */
int delta; /*!< Delta for reallocation. */
- int_32 id; /*!< Transaction id. */
+ int_32 tid; /*!< Transaction id. */
int verify_legacy; /*!< Verify legacy signatures? */
int nodigests; /*!< Verify digests? */
* @param ts transaction set
* @param rootDir new transaction rootDir (or NULL)
*/
-void rpmtsSetRootDir(rpmTransactionSet ts,
- /*@null@*/ const char * rootDir)
+void rpmtsSetRootDir(rpmTransactionSet ts, /*@null@*/ const char * rootDir)
+ /*@modifies ts @*/;
+
+/** \ingroup rpmts
+ * Get transaction currDir, i.e. current directory before chroot(2).
+ * @param ts transaction set
+ * @return transaction currDir
+ */
+/*@observer@*/ /*@null@*/
+const char * rpmtsGetCurrDir(rpmTransactionSet ts)
+ /*@*/;
+
+/** \ingroup rpmts
+ * Set transaction currDir, i.e. current directory before chroot(2).
+ * @param ts transaction set
+ * @param currDir new transaction currDir (or NULL)
+ */
+void rpmtsSetCurrDir(rpmTransactionSet ts, /*@null@*/ const char * currDir)
/*@modifies ts @*/;
/** \ingroup rpmts
/*@modifies ts, scriptFd @*/;
/** \ingroup rpmts
+ * Get chrootDone flag, i.e. has chroot(2) been performed?
+ * @param ts transaction set
+ * @return chrootDone flag
+ */
+int rpmtsGetChrootDone(rpmTransactionSet ts)
+ /*@*/;
+
+/** \ingroup rpmts
+ * Set chrootDone flag, i.e. has chroot(2) been performed?
+ * @param ts transaction set
+ * @param chrootDone new chrootDone flag
+ * @return previous chrootDone flag
+ */
+int rpmtsSetChrootDone(rpmTransactionSet ts, int chrootDone)
+ /*@modifies ts @*/;
+
+/** \ingroup rpmts
+ * Get transaction id, i.e. transaction time stamp.
+ * @param ts transaction set
+ * @return chrootDone flag
+ */
+int_32 rpmtsGetTid(rpmTransactionSet ts)
+ /*@*/;
+
+/** \ingroup rpmts
+ * Set transaction id, i.e. transaction time stamp.
+ * @param ts transaction set
+ * @param tid new transaction id
+ * @return previous transaction id
+ */
+int_32 rpmtsSetTid(rpmTransactionSet ts, int_32 tid)
+ /*@modifies ts @*/;
+
+/** \ingroup rpmts
+ * Get transaction database handle.
+ * @param ts transaction set
+ * @return transaction database handle
+ */
+/*@null@*/
+rpmdb rpmtsGetRdb(rpmTransactionSet ts)
+ /*@*/;
+
+/** \ingroup rpmts
* Get transaction flags, i.e. bits to control rpmtsRun().
* @param ts transaction set
* @return transaction flags
/** \ingroup rpmts
* Set transaction flags, i.e. bits to control rpmtsRun().
* @param ts transaction set
- * @param ntransFlags new transaction flags
+ * @param transFlags new transaction flags
* @return previous transaction flags
*/
-rpmtsFlags rpmtsSetFlags(rpmTransactionSet ts, rpmtsFlags ntransFlags)
+rpmtsFlags rpmtsSetFlags(rpmTransactionSet ts, rpmtsFlags transFlags)
/*@modifies ts @*/;
/** \ingroup rpmts
probably right :-( */
#define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
-#ifdef DYING
-void rpmtsSetScriptFd(rpmTransactionSet ts, FD_t fd)
-{
- ts->scriptFd = (fd ? fdLink(fd, "rpmtsSetScriptFd") : NULL);
-}
-
-int rpmtsGetKeys(const rpmTransactionSet ts, fnpyKey ** ep, int * nep)
-{
- int rc = 0;
-
- if (nep) *nep = ts->orderCount;
- if (ep) {
- teIterator pi; transactionElement p;
- fnpyKey * e;
-
- *ep = e = xmalloc(ts->orderCount * sizeof(*e));
- pi = teInitIterator(ts);
- while ((p = teNextIterator(pi)) != NULL) {
- switch (teGetType(p)) {
- case TR_ADDED:
- /*@-dependenttrans@*/
- *e = teGetKey(p);
- /*@=dependenttrans@*/
- /*@switchbreak@*/ break;
- case TR_REMOVED:
- default:
- *e = NULL;
- /*@switchbreak@*/ break;
- }
- e++;
- }
- pi = teFreeIterator(pi);
- }
- return rc;
-}
-#endif
-
/**
*/
static int archOkay(/*@null@*/ const char * pkgArch)
* The file doesn't exist on the disk. Create it unless the new
* package has marked it as missingok, or allfiles is requested.
*/
- if (!(ts->transFlags & RPMTRANS_FLAG_ALLFILES)
+ if (!(rpmtsGetFlags(ts) & RPMTRANS_FLAG_ALLFILES)
&& (newFlags & RPMFILE_MISSINGOK))
{
rpmMessage(RPMMESS_DEBUG, _("%s skipped due to missingok flag\n"),
const char * altNEVR = NULL;
TFI_t otherFi = NULL;
int numReplaced = 0;
+ rpmProblemSet ps;
int i;
{ rpmdbMatchIterator mi;
fi->replaced = xcalloc(sharedCount, sizeof(*fi->replaced));
+ ps = rpmtsGetProblems(ts);
for (i = 0; i < sharedCount; i++, shared++) {
int otherFileNum, fileNum;
if (filecmp(otherFi, fi)) {
if (reportConflicts) {
- rpmProblemSetAppend(ts->probs, RPMPROB_FILE_CONFLICT,
+ rpmProblemSetAppend(ps, RPMPROB_FILE_CONFLICT,
teGetNEVR(p), teGetKey(p),
tfiGetDN(fi), tfiGetBN(fi),
altNEVR,
fi->replacedSizes[fileNum] = otherFi->fsizes[otherFi->i];
}
+ ps = rpmProblemSetFree(ps);
altNEVR = _free(altNEVR);
otherFi = fiFree(otherFi, 1);
{
struct diskspaceInfo * ds = NULL;
uint_32 fixupSize = 0;
+ rpmProblemSet ps;
const char * fn;
int i, j;
+ ps = rpmtsGetProblems(ts);
fi = tfiInit(fi, 0);
if (fi != NULL) /* XXX lclint */
while ((i = tfiNext(fi)) >= 0) {
if ((ts->ignoreSet & RPMPROB_FILTER_REPLACENEWFILES)
&& filecmp(otherFi, fi))
{
- rpmProblemSetAppend(ts->probs, RPMPROB_NEW_FILE_CONFLICT,
+ rpmProblemSetAppend(ps, RPMPROB_NEW_FILE_CONFLICT,
teGetNEVR(p), teGetKey(p),
fn, NULL,
teGetNEVR(otherFi->te),
ds->bneeded -= BLOCK_ROUND(fixupSize, ds->bsize);
}
}
+ ps = rpmProblemSetFree(ps);
}
/**
req = dsFree(req);
if (rc == 0) {
+ rpmProblemSet ps = rpmtsGetProblems(ts);
const char * altNEVR = hGetNEVR(h, NULL);
- rpmProblemSetAppend(ts->probs, RPMPROB_OLDPACKAGE,
+ rpmProblemSetAppend(ps, RPMPROB_OLDPACKAGE,
teGetNEVR(p), teGetKey(p),
NULL, NULL,
altNEVR,
0);
altNEVR = _free(altNEVR);
+ ps = rpmProblemSetFree(ps);
rc = 1;
} else
rc = 0;
/*@globals rpmGlobalMacroContext @*/
/*@modifies fi, rpmGlobalMacroContext @*/
{
- int noDocs = (ts->transFlags & RPMTRANS_FLAG_NODOCS);
+ int noDocs = (rpmtsGetFlags(ts) & RPMTRANS_FLAG_NODOCS);
char ** netsharedPaths = NULL;
const char ** languages;
const char * dn, * bn;
int nexti;
alKey lastKey;
fingerPrintCache fpc;
+ rpmProblemSet ps;
PSM_t psm = memset(alloca(sizeof(*psm)), 0, sizeof(*psm));
teIterator pi; transactionElement p;
teIterator qi; transactionElement q;
/* FIXME: what if the same package is included in ts twice? */
- if (ts->transFlags & RPMTRANS_FLAG_NOSCRIPTS)
- ts->transFlags |= (_noTransScripts | _noTransTriggers);
- if (ts->transFlags & RPMTRANS_FLAG_NOTRIGGERS)
- ts->transFlags |= _noTransTriggers;
+ if (rpmtsGetFlags(ts) & RPMTRANS_FLAG_NOSCRIPTS)
+ (void) rpmtsSetFlags(ts, (rpmtsGetFlags(ts) | _noTransScripts | _noTransTriggers));
+ if (rpmtsGetFlags(ts) & RPMTRANS_FLAG_NOTRIGGERS)
+ (void) rpmtsSetFlags(ts, (rpmtsGetFlags(ts) | _noTransTriggers));
/* XXX MULTILIB is broken, as packages can and do execute /sbin/ldconfig. */
- if (ts->transFlags & (RPMTRANS_FLAG_JUSTDB | RPMTRANS_FLAG_MULTILIB))
- ts->transFlags |= (_noTransScripts | _noTransTriggers);
+ if (rpmtsGetFlags(ts) & (RPMTRANS_FLAG_JUSTDB | RPMTRANS_FLAG_MULTILIB))
+ (void) rpmtsSetFlags(ts, (rpmtsGetFlags(ts) | _noTransScripts | _noTransTriggers));
ts->probs = rpmProblemSetFree(ts->probs);
ts->probs = rpmProblemSetCreate();
+
ts->ignoreSet = ignoreSet;
- ts->currDir = _free(ts->currDir);
- ts->currDir = currentDirectory();
- ts->chrootDone = 0;
- if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0;
- ts->id = (int_32) time(NULL);
+ { const char * currDir = currentDirectory();
+ rpmtsSetCurrDir(ts, currDir);
+ currDir = _free(currDir);
+ }
+
+ (void) rpmtsSetChrootDone(ts, 0);
+
+ { int_32 tid = (int_32) time(NULL);
+ (void) rpmtsSetTid(ts, tid);
+ }
memset(psm, 0, sizeof(*psm));
psm->ts = rpmtsLink(ts, "tsRun");
* For packages being removed:
* - count files.
*/
+ ps = rpmtsGetProblems(ts);
/* The ordering doesn't matter here */
pi = teInitIterator(ts);
while ((p = teNext(pi, TR_ADDED)) != NULL) {
if (!(ts->ignoreSet & RPMPROB_FILTER_IGNOREARCH))
if (!archOkay(teGetA(p)))
- rpmProblemSetAppend(ts->probs, RPMPROB_BADARCH,
+ rpmProblemSetAppend(ps, RPMPROB_BADARCH,
teGetNEVR(p), teGetKey(p),
teGetA(p), NULL,
NULL, 0);
if (!(ts->ignoreSet & RPMPROB_FILTER_IGNOREOS))
if (!osOkay(teGetO(p)))
- rpmProblemSetAppend(ts->probs, RPMPROB_BADOS,
+ rpmProblemSetAppend(ps, RPMPROB_BADOS,
teGetNEVR(p), teGetKey(p),
teGetO(p), NULL,
NULL, 0);
teGetR(p));
while (rpmdbNextIterator(mi) != NULL) {
- rpmProblemSetAppend(ts->probs, RPMPROB_PKG_INSTALLED,
+ rpmProblemSetAppend(ps, RPMPROB_PKG_INSTALLED,
teGetNEVR(p), teGetKey(p),
NULL, NULL,
NULL, 0);
}
pi = teFreeIterator(pi);
+ ps = rpmProblemSetFree(ps);
/* The ordering doesn't matter here */
pi = teInitIterator(ts);
}
pi = teFreeIterator(pi);
- if (!ts->chrootDone) {
+ if (!rpmtsGetChrootDone(ts)) {
+ const char * rootDir = rpmtsGetRootDir(ts);
xx = chdir("/");
/*@-superuser -noeffect @*/
- xx = chroot(ts->rootDir);
+ if (rootDir != NULL)
+ xx = chroot(rootDir);
/*@=superuser =noeffect @*/
- ts->chrootDone = 1;
- if (ts->rpmdb) ts->rpmdb->db_chrootDone = 1;
+ (void) rpmtsSetChrootDone(ts, 1);
}
ts->ht = htCreate(totalFileCount * 2, 0, 0, fpHashFunction, fpEqual);
/* ===============================================
* Compute file disposition for each package in transaction set.
*/
+ ps = rpmtsGetProblems(ts);
pi = teInitIterator(ts);
while ((p = teNextIterator(pi)) != NULL) {
dbiIndexSet * matches;
/* Extract file info for all files in this package from the database. */
matches = xcalloc(fc, sizeof(*matches));
- if (rpmdbFindFpList(ts->rpmdb, fi->fps, matches, fc)) {
+ if (rpmdbFindFpList(rpmtsGetRdb(ts), fi->fps, matches, fc)) {
psm->ts = rpmtsUnlink(ts, "tsRun (rpmFindFpList fail)");
+ ps = rpmProblemSetFree(ps);
return 1; /* XXX WTFO? */
}
/*@innercontinue@*/ continue;
if (adj_fs_blocks(dip->bneeded) > dip->bavail) {
- rpmProblemSetAppend(ts->probs, RPMPROB_DISKSPACE,
+ rpmProblemSetAppend(ps, RPMPROB_DISKSPACE,
teGetNEVR(p), teGetKey(p),
ts->filesystems[i], NULL, NULL,
(adj_fs_blocks(dip->bneeded) - dip->bavail) * dip->bsize);
}
if (adj_fs_blocks(dip->ineeded) > dip->iavail) {
- rpmProblemSetAppend(ts->probs, RPMPROB_DISKNODES,
+ rpmProblemSetAppend(ps, RPMPROB_DISKNODES,
teGetNEVR(p), teGetKey(p),
ts->filesystems[i], NULL, NULL,
(adj_fs_blocks(dip->ineeded) - dip->iavail));
}
}
pi = teFreeIterator(pi);
+ ps = rpmProblemSetFree(ps);
- if (ts->chrootDone) {
+ if (rpmtsGetChrootDone(ts)) {
+ const char * currDir = rpmtsGetCurrDir(ts);
/*@-superuser -noeffect @*/
xx = chroot(".");
/*@=superuser =noeffect @*/
- ts->chrootDone = 0;
- if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0;
- xx = chdir(ts->currDir);
+ (void) rpmtsSetChrootDone(ts, 0);
+ if (currDir != NULL)
+ xx = chdir(currDir);
}
/*@-noeffectuncon @*/ /* FIX: check rc */
}
pi = teFreeIterator(pi);
- fpCacheFree(fpc);
- htFree(ts->ht);
- ts->ht = NULL;
+ fpc = fpCacheFree(fpc);
+ ts->ht = htFree(ts->ht);
/* ===============================================
* If unfiltered problems exist, free memory and return.
*/
- if ((ts->transFlags & RPMTRANS_FLAG_BUILD_PROBS)
+ if ((rpmtsGetFlags(ts) & RPMTRANS_FLAG_BUILD_PROBS)
|| (ts->probs->numProblems &&
(okProbs != NULL || rpmProblemSetTrim(ts->probs, okProbs)))
)
/* ===============================================
* Save removed files before erasing.
*/
- if (ts->transFlags & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
+ if (rpmtsGetFlags(ts) & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
pi = teInitIterator(ts);
while ((p = teNextIterator(pi)) != NULL) {
fi = teiGetFi(pi);
case TR_ADDED:
/*@switchbreak@*/ break;
case TR_REMOVED:
- if (!(ts->transFlags & RPMTRANS_FLAG_REPACKAGE))
+ if (!(rpmtsGetFlags(ts) & RPMTRANS_FLAG_REPACKAGE))
/*@switchbreak@*/ break;
psm->te = p;
psm->fi = rpmfiLink(fi, "tsRepackage");
}
if (teGetMultiLib(p))
- ts->transFlags |= RPMTRANS_FLAG_MULTILIB;
+ (void) rpmtsSetFlags(ts, (rpmtsGetFlags(ts) | RPMTRANS_FLAG_MULTILIB));
else
- ts->transFlags &= ~RPMTRANS_FLAG_MULTILIB;
+ (void) rpmtsSetFlags(ts, (rpmtsGetFlags(ts) & ~RPMTRANS_FLAG_MULTILIB));
if (psmStage(psm, PSM_PKGINSTALL)) {
ourrc++;
}
/*@switchbreak@*/ break;
}
- xx = rpmdbSync(ts->rpmdb);
+ xx = rpmdbSync(rpmtsGetRdb(ts));
(void) rpmfiUnlink(psm->fi, "tsInstall");
psm->fi = NULL;
psm->te = NULL;
static void py_rpmtsDealloc(PyObject * o) {
rpmtsObject * trans = (void *) o;
- trans->ts->rpmdb = NULL; /* XXX HACK: avoid rpmdb close/free */
+ trans->ts->rdb = NULL; /* XXX HACK: avoid rpmdb close/free */
rpmtsFree(trans->ts);
if (trans->dbo) {
Py_DECREF(trans->dbo);
o->ts = rpmtsCreate();
(void) rpmtsSetRootDir(o->ts, rootDir);
/* XXX this will be fun to fix */
- o->ts->rpmdb = (db ? dbFromDb(db) : NULL);
+ o->ts->rdb = (db ? dbFromDb(db) : NULL);
o->keyList = PyList_New(0);
return (void *) o;
return fpc;
}
-void fpCacheFree(fingerPrintCache cache)
+fingerPrintCache fpCacheFree(fingerPrintCache cache)
{
- htFree(cache->ht);
+ cache->ht = htFree(cache->ht);
free(cache);
+ return NULL;
}
/**
strcpy(dn, (*buf != '\0' ? buf : "/"));
newEntry->ino = sb.st_ino;
newEntry->dev = sb.st_dev;
- newEntry->isFake = 0;
newEntry->dirName = dn;
fp.entry = newEntry;
fp.baseName = baseName;
if (!scareMemory && fp.subDir != NULL)
fp.subDir = xstrdup(fp.subDir);
- /*@-compdef@*/ /* FIX: fp.entry.{dirName,dev,ino,isFake} undef @*/
+ /*@-compdef@*/ /* FIX: fp.entry.{dirName,dev,ino} undef @*/
return fp;
/*@=compdef@*/
}
/*@notreached@*/
- /*@-compdef@*/ /* FIX: fp.entry.{dirName,dev,ino,isFake} undef @*/
+ /*@-compdef@*/ /* FIX: fp.entry.{dirName,dev,ino} undef @*/
/*@-nullret@*/ return fp; /*@=nullret@*/ /* LCL: can't happen. */
/*@=compdef@*/
}
}
}
+#ifdef UNUSED
+/**
+ * Return finger prints of all file names in header.
+ * @warning: scareMemory is assumed!
+ * @param cache pointer to fingerprint cache
+ * @param h package header
+ * @retval fpList pointer to array of finger prints
+ */
+static
void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList)
+ /*@modifies h, cache, *fpList @*/;
{
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
dirNames = hfd(dirNames, dnt);
baseNames = hfd(baseNames, bnt);
}
+#endif
const char * dirName; /*!< path to existing directory */
dev_t dev; /*!< stat(2) device number */
ino_t ino; /*!< stat(2) inode number */
- int isFake; /*!< (currently unused) */
};
/**
/*@dependent@*/ const char * baseName; /*!< file base name */
};
-/* only if !scarceMemory */
-/** */
-#define fpFree(a) free((void *)(a).baseName)
-
/** */
#define FP_ENTRY_EQUAL(a, b) (((a)->dev == (b)->dev) && ((a)->ino == (b)->ino))
/**
* Destroy finger print cache.
* @param cache pointer to fingerprint cache
+ * @return NULL always
*/
-void fpCacheFree(/*@only@*/ fingerPrintCache cache)
+/*@null@*/
+fingerPrintCache fpCacheFree(/*@only@*/ fingerPrintCache cache)
/*@modifies cache @*/;
/**
int fileCount, fingerPrint * fpList)
/*@modifies cache, *fpList @*/;
-/**
- * Return finger prints of all file names in header.
- * @warning: scareMemory is assumed!
- * @param cache pointer to fingerprint cache
- * @param h package header
- * @retval fpList pointer to array of finger prints
- */
-/*@unused@*/
-void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList)
- /*@modifies h, cache, *fpList @*/;
-
#ifdef __cplusplus
}
#endif
if (rc) {
allMatches = dbiFreeIndexSet(allMatches);
- fpCacheFree(fpc);
+ fpc = fpCacheFree(fpc);
return rc;
}
rec = _free(rec);
allMatches = dbiFreeIndexSet(allMatches);
- fpCacheFree(fpc);
+ fpc = fpCacheFree(fpc);
if ((*matches)->count == 0) {
*matches = dbiFreeIndexSet(*matches);
mi = rpmdbFreeIterator(mi);
- fpCacheFree(fpc);
+ fpc = fpCacheFree(fpc);
return 0;
b->data[b->dataCount++] = data;
}
-void htFree(hashTable ht)
+hashTable htFree(hashTable ht)
{
hashBucket b, n;
int i;
ht->buckets = _free(ht->buckets);
ht = _free(ht);
+ return NULL;
}
int htHasEntry(hashTable ht, const void * key)
/**
* Destroy hash table.
* @param ht pointer to hash table
+ * @return NULL always
*/
-void htFree( /*@only@*/ hashTable ht)
+/*@null@*/
+hashTable htFree( /*@only@*/ hashTable ht)
/*@modifies ht @*/;
/**