Remove support for automatic rollback on failure
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 17 Mar 2008 10:04:39 +0000 (12:04 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 17 Mar 2008 10:04:39 +0000 (12:04 +0200)
- doing this reliably from rpm is simply not possible as there's no way
  to undo script actions, might as well not pretend we can
- for a feature that's not generally usable it complicates mainline code
  way too much

lib/Makefile.am
lib/psm.c
lib/rpminstall.c
lib/rpmts.c
lib/rpmts.h
lib/rpmts_internal.h
lib/rpmtsscore.h [deleted file]
lib/transaction.c
macros.in
rpmdb/rpmdb.c

index c9050e9..c98fa09 100644 (file)
@@ -21,7 +21,7 @@ librpm_la_SOURCES = \
        idtx.c manifest.c manifest.h misc.c package.c \
        poptALL.c poptI.c poptQV.c psm.c psm.h query.c \
        rpmal.c rpmchecksig.c rpmds.c rpmfi.c rpmfi_internal.h rpmgi.c \
-       rpminstall.c rpmtsscore.h rpmts_internal.h \
+       rpminstall.c rpmts_internal.h \
        rpmlead.c rpmlead.h rpmps.c rpmrc.c \
        rpmte.c rpmte_internal.h rpmts.c \
        rpmvercmp.c signature.c signature.h transaction.c \
index 7954795..b5379e2 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -20,7 +20,6 @@
 #include "lib/psm.h"
 #include "lib/rpmfi_internal.h" /* XXX replaced/states, fi->hge, fi->te... */
 #include "lib/rpmte_internal.h"        /* XXX te->fd */
-#include "lib/rpmtsscore.h"
 #include "lib/rpmlead.h"               /* writeLead proto */
 #include "lib/signature.h"             /* signature constants */
 #include "lib/misc.h"          /* XXX rpmMkdirPath, doputenv */
 int _psm_debug = _PSM_DEBUG;
 int _psm_threads = 0;
 
-/* Give access to the rpmte global tracking the last instance added
- * to the database.
- */
-extern unsigned int myinstall_instance;
-
 /**
  */
 struct rpmpsm_s {
@@ -1060,7 +1054,6 @@ static rpmRC runTriggers(rpmpsm psm)
 
     if (psm->te)       /* XXX can't happen */
        N = rpmteN(psm->te);
-/* XXX: Might need to adjust instance counts four autorollback. */
     if (N)             /* XXX can't happen */
        numPackage = rpmdbCountPackages(rpmtsGetRdb(ts), N)
                                + psm->countCorrection;
@@ -1317,48 +1310,6 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
            break;
        }
 
-       /* If we have a score then autorollback is enabled.  If autorollback is
-        * enabled, and this is an autorollback transaction, then we may need to
-        * adjust the pkgs installed count.
-        *
-        * If all this is true, this adjustment should only be made if the PSM goal
-        * is an install.  No need to make this adjustment on the erase
-        * component of the upgrade, or even more absurd to do this when doing a
-        * PKGSAVE.
-        */
-       if (rpmtsGetScore(ts) != NULL &&
-           rpmtsGetType(ts) == RPMTRANS_TYPE_AUTOROLLBACK &&
-           (psm->goal & ~(PSM_PKGSAVE|PSM_PKGERASE))) {
-           /* Get the score, if its not NULL, get the appropriate
-            * score entry.
-            */
-           rpmtsScore score = rpmtsGetScore(ts);
-           if (score != NULL) {
-               /* OK, we got a real score so lets get the appropriate
-                * score entry.
-                */
-               rpmtsScoreEntry se;
-               se = rpmtsScoreGetEntry(score, rpmteN(psm->te));
-
-               /* IF the header for the install element has been installed,
-                * but the header for the erase element has not been erased,
-                * then decrement the instance count.  This is because in an
-                * autorollback, if the header was added in the initial transaction
-                * then in the case of an upgrade the instance count will be
-                * 2 instead of one when re-installing the old package, and 3 when
-                * erasing the new package.
-                *
-                * Another wrinkle is we only want to make this adjustement
-                * if the thing we are rollback was an upgrade of package.  A pure
-                * install or erase does not need the adjustment
-                */
-               if (se && se->installed &&
-                   !se->erased &&
-                   (se->te_types & (TR_ADDED|TR_REMOVED)))
-                   psm->npkgs_installed--;
-          }
-       }
-
        if (psm->goal == PSM_PKGINSTALL) {
            int fc = rpmfiFC(fi);
 
@@ -1992,35 +1943,6 @@ assert(psm->mi == NULL);
            rc = rpmdbAdd(rpmtsGetRdb(ts), rpmtsGetTid(ts), fi->h,
                                NULL, NULL);
 
-       /* Set the database instance so consumers (i.e. rpmtsRun())
-        * can add this to a rollback transaction.
-        */
-       rpmteSetDBInstance(psm->te, myinstall_instance);
-
-       /*
-        * If the score exists and this is not a rollback or autorollback
-        * then lets check off installed for this package.
-        */
-       if (rpmtsGetScore(ts) != NULL &&
-           rpmtsGetType(ts) != RPMTRANS_TYPE_ROLLBACK &&
-           rpmtsGetType(ts) != RPMTRANS_TYPE_AUTOROLLBACK)
-       {
-           /* Get the score, if its not NULL, get the appropriate
-            * score entry.
-            */
-           rpmtsScore score = rpmtsGetScore(ts);
-           if (score != NULL) {
-               rpmtsScoreEntry se;
-               /* OK, we got a real score so lets get the appropriate
-                * score entry.
-                */
-               rpmlog(RPMLOG_DEBUG,
-                   "Attempting to mark %s as installed in score board(%p).\n",
-                   rpmteN(psm->te), score);
-               se = rpmtsScoreGetEntry(score, rpmteN(psm->te));
-               if (se != NULL) se->installed = 1;
-           }
-       }
        (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DBADD), 0);
        break;
     case PSM_RPMDB_REMOVE:
@@ -2028,33 +1950,6 @@ assert(psm->mi == NULL);
        (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DBREMOVE), 0);
        rc = rpmdbRemove(rpmtsGetRdb(ts), rpmtsGetTid(ts), fi->record,
                                NULL, NULL);
-
-       /*
-        * If the score exists and this is not a rollback or autorollback
-        * then lets check off erased for this package.
-        */
-       if (rpmtsGetScore(ts) != NULL &&
-          rpmtsGetType(ts) != RPMTRANS_TYPE_ROLLBACK &&
-          rpmtsGetType(ts) != RPMTRANS_TYPE_AUTOROLLBACK)
-       {
-           /* Get the score, if its not NULL, get the appropriate
-            * score entry.
-            */
-           rpmtsScore score = rpmtsGetScore(ts);
-
-           if (score != NULL) { /* XXX: Can't happen */
-               rpmtsScoreEntry se;
-               /* OK, we got a real score so lets get the appropriate
-                * score entry.
-                */
-               rpmlog(RPMLOG_DEBUG,
-                   "Attempting to mark %s as erased in score board(%p).\n",
-                   rpmteN(psm->te), score);
-               se = rpmtsScoreGetEntry(score, rpmteN(psm->te));
-               if (se != NULL) se->erased = 1;
-           }
-       }
-
        (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DBREMOVE), 0);
        break;
 
index df923b4..13ec497 100644 (file)
@@ -856,7 +856,6 @@ int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv)
     int numAdded;
     int numRemoved;
     rpmps ps;
-    int _unsafe_rollbacks = 0;
     rpmtransFlags transFlags = ia->transFlags;
 
     if (argv != NULL && *argv != NULL) {
@@ -864,8 +863,6 @@ int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv)
        goto exit;
     }
 
-    _unsafe_rollbacks = rpmExpandNumeric("%{?_unsafe_rollbacks}");
-
     vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
     if (ia->qva_flags & VERIFY_DIGEST)
        vsflags |= _RPMVSF_NODIGESTS;
@@ -878,11 +875,6 @@ int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv)
 
     (void) rpmtsSetFlags(ts, transFlags);
 
-    /*  Make the transaction a rollback transaction.  In a rollback
-     *  a best effort is what we want 
-     */
-    rpmtsSetType(ts, RPMTRANS_TYPE_ROLLBACK);
-
     itids = IDTXload(ts, RPMTAG_INSTALLTID);
     if (itids != NULL) {
        ip = itids->idt;
@@ -936,10 +928,6 @@ int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv)
        if (thistid == 0 || thistid < ia->rbtid)
            break;
 
-       /* If we've reached the (configured) rollback goal, then we're done. */
-       if (_unsafe_rollbacks && thistid <= _unsafe_rollbacks)
-           break;
-
        rpmtsEmpty(ts);
        (void) rpmtsSetFlags(ts, transFlags);
 
@@ -981,9 +969,6 @@ int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv)
 
            numRemoved++;
 
-           if (_unsafe_rollbacks)
-               rpmcliPackagesTotal++;
-
            if (!(ia->installInterfaceFlags & ifmask)) {
                ia->installInterfaceFlags |= INSTALL_ERASE;
                (void) rpmtsSetFlags(ts, (transFlags | RPMTRANS_FLAG_REVERSE));
index acd9ebc..401c70b 100644 (file)
@@ -902,9 +902,6 @@ rpmts rpmtsFree(rpmts ts)
     if (_rpmts_stats)
        rpmtsPrintStats(ts);
 
-    /* Free up the memory used by the rpmtsScore */
-    ts->score = rpmtsScoreFree(ts->score);
-
     (void) rpmtsUnlink(ts, RPMDBG_M("tsCreate"));
 
     ts = _free(ts);
@@ -930,36 +927,6 @@ rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
     return ovsflags;
 }
 
-/* 
- * This allows us to mark transactions as being of a certain type.
- * The three types are:
- * 
- *     RPM_TRANS_NORMAL        
- *     RPM_TRANS_ROLLBACK
- *     RPM_TRANS_AUTOROLLBACK
- * 
- * ROLLBACK and AUTOROLLBACK transactions should always be ran as
- * a best effort.  In particular this is important to the autorollback 
- * feature to avoid rolling back a rollback (otherwise known as 
- * dueling rollbacks (-;).  AUTOROLLBACK's additionally need instance 
- * counts passed to scriptlets to be altered.
- */
-void rpmtsSetType(rpmts ts, rpmtsType type)
-{
-    if (ts != NULL) {
-       ts->type = type;
-    }   
-}
-
-/* Let them know what type of transaction we are */
-rpmtsType rpmtsGetType(rpmts ts) 
-{
-    if (ts != NULL) 
-       return ts->type;
-    else
-       return 0;
-}
-
 int rpmtsUnorderedSuccessors(rpmts ts, int first)
 {
     int unorderedSuccessors = 0;
@@ -1499,7 +1466,6 @@ rpmts rpmtsCreate(void)
     ts = xcalloc(1, sizeof(*ts));
     memset(&ts->ops, 0, sizeof(ts->ops));
     (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_TOTAL), -1);
-    ts->type = RPMTRANS_TYPE_NORMAL;
     ts->filesystemCount = 0;
     ts->filesystems = NULL;
     ts->dsi = NULL;
@@ -1552,189 +1518,8 @@ rpmts rpmtsCreate(void)
     memset(ts->pksignid, 0, sizeof(ts->pksignid));
     ts->dig = NULL;
 
-    /* 
-     * We only use the score in an autorollback.  So set this to
-     * NULL by default.
-     */
-    ts->score = NULL;
-
     ts->nrefs = 0;
 
     return rpmtsLink(ts, RPMDBG_M("tsCreate"));
 }
 
-/**********************
- * Transaction Scores *
- **********************/
-
-
-rpmRC rpmtsScoreInit(rpmts runningTS, rpmts rollbackTS) 
-{
-    rpmtsScore score;
-    rpmtsi     pi;
-    rpmte      p;
-    int        i;
-    int        tranElements;  /* Number of transaction elements in runningTS */
-    int        found = 0;
-    rpmRC      rc = RPMRC_OK; /* Assume success */
-    rpmtsScoreEntry se;
-
-    rpmlog(RPMLOG_DEBUG, "Creating transaction score board(%p, %p)\n",
-       runningTS, rollbackTS); 
-
-    /* Allocate space for score board */
-    score = xcalloc(1, sizeof(*score));
-    rpmlog(RPMLOG_DEBUG, "\tScore board address:  %p\n", score);
-
-    /* 
-     * Determine the maximum size needed for the entry list.
-     * XXX: Today, I just get the count of rpmts elements, and allocate
-     *      an array that big.  Yes this is guaranteed to waste memory.
-     *      Future updates will hopefully make this more efficient,
-     *      but for now it will work.
-     */
-    tranElements  = rpmtsNElements(runningTS);
-    rpmlog(RPMLOG_DEBUG, "\tAllocating space for %d entries\n", tranElements);
-    score->scores = xcalloc(tranElements, sizeof(score->scores));
-
-    /* Initialize score entry count */
-    score->entries = 0;
-    score->nrefs   = 0;
-
-    /*
-     * Increment through transaction elements and make sure for every 
-     * N there is an rpmtsScoreEntry.
-     */
-    pi = rpmtsiInit(runningTS); 
-    while ((p = rpmtsiNext(pi, TR_ADDED|TR_REMOVED)) != NULL) {
-       found  = 0;
-
-       /* Try to find the entry in the score list */
-       for(i = 0; i < score->entries; i++) {
-           se = score->scores[i]; 
-           if (strcmp(rpmteN(p), se->N) == 0) {
-               found = 1;
-               break;
-           }
-       }
-
-       /* If we did not find the entry then allocate space for it */
-       if (!found) {
-/* XXX p->fi->te undefined. */
-           rpmlog(RPMLOG_DEBUG, "\tAdding entry for %s to score board.\n",
-               rpmteN(p));
-           se = xcalloc(1, sizeof(*(*(score->scores))));
-           rpmlog(RPMLOG_DEBUG, "\t\tEntry address:  %p\n", se);
-           se->N         = xstrdup(rpmteN(p));
-           se->te_types  = rpmteType(p); 
-           se->installed = 0;
-           se->erased    = 0; 
-           score->scores[score->entries] = se;
-           score->entries++;
-       } else {
-           /* We found this one, so just add the element type to the one 
-            * already there.
-            */
-           rpmlog(RPMLOG_DEBUG, "\tUpdating entry for %s in score board.\n",
-               rpmteN(p));
-           score->scores[i]->te_types |= rpmteType(p);
-       }
-        
-    }
-    pi = rpmtsiFree(pi);
-    /* 
-     * Attach the score to the running transaction and the autorollback
-     * transaction.
-     */
-    runningTS->score  = score;
-    score->nrefs++;
-    rollbackTS->score = score;
-    score->nrefs++;
-
-    return rc;
-}
-
-rpmtsScore rpmtsScoreFree(rpmtsScore score) 
-{
-    rpmtsScoreEntry se = NULL;
-    int i;
-
-    rpmlog(RPMLOG_DEBUG, "May free Score board(%p)\n", score);
-
-    /* If score is not initialized, then just return.
-     * This is likely the case if autorollbacks are not enabled.
-     */
-    if (score == NULL) return NULL;
-
-    /* Decrement the reference count */
-    score->nrefs--;
-
-    /* Do we have any more references?  If so
-     * just return.
-     */
-    if (score->nrefs > 0) return NULL;
-
-    rpmlog(RPMLOG_DEBUG, "\tRefcount is zero...will free\n");
-    /* No more references, lets clean up  */
-    /* First deallocate the score entries */
-    for(i = 0; i < score->entries; i++) {
-       /* Get the score for the ith entry */
-       se = score->scores[i]; 
-       
-       /* Deallocate the score entries name */
-       se->N = _free(se->N);
-
-       /* Deallocate the score entry itself */
-       se = _free(se);
-    }
-
-    /* Next deallocate the score entry table */
-    score->scores = _free(score->scores);
-
-    /* Finally deallocate the score itself */
-    score = _free(score);
-
-    return NULL;
-}
-
-/* 
- * XXX: Do not get the score and then store it aside for later use.
- *      we will delete it out from under you.  There is no rpmtsScoreLink()
- *      as this may be a very temporary fix for autorollbacks.
- */
-rpmtsScore rpmtsGetScore(rpmts ts) 
-{
-    if (ts == NULL) return NULL;
-    return ts->score;
-}
-
-/* 
- * XXX: Do not get the score entry and then store it aside for later use.
- *      we will delete it out from under you.  There is no 
- *      rpmtsScoreEntryLink() as this may be a very temporary fix 
- *      for autorollbacks.
- * XXX: The scores are not sorted.  This should be fixed at earliest
- *      opportunity (i.e. when we have the whole autorollback working).
- */
-rpmtsScoreEntry rpmtsScoreGetEntry(rpmtsScore score, const char *N) 
-{
-    int i;
-    rpmtsScoreEntry se;
-    rpmtsScoreEntry ret = NULL; /* Assume we don't find it */
-
-    rpmlog(RPMLOG_DEBUG, "Looking in score board(%p) for %s\n", score, N);
-
-    /* Try to find the entry in the score list */
-    for(i = 0; i < score->entries; i++) {
-       se = score->scores[i]; 
-       if (strcmp(N, se->N) == 0) {
-           rpmlog(RPMLOG_DEBUG, "\tFound entry at address:  %p\n", se);
-           ret = se;
-           break;
-       }
-    }
-       
-/* XXX score->scores undefined. */
-    return ret;        
-}
index e036107..d3895b7 100644 (file)
@@ -98,15 +98,6 @@ typedef enum rpmVSFlags_e {
     /* bit(s) 16-31 unused */
 } rpmVSFlags;
 
-/** \ingroup rpmts
- * Transaction Types
- */
-typedef enum rpmtsType_e {
-       RPMTRANS_TYPE_NORMAL       = 0,
-       RPMTRANS_TYPE_ROLLBACK     = (1 << 0),
-       RPMTRANS_TYPE_AUTOROLLBACK = (1 << 1)
-} rpmtsType;
-
 #define        _RPMVSF_NODIGESTS       \
   ( RPMVSF_NOSHA1HEADER |      \
     RPMVSF_NOMD5HEADER |       \
@@ -348,26 +339,6 @@ int rpmtsSetSolveCallback(rpmts ts,
                const void * solveData);
 
 /** \ingroup rpmts
- * Return the type of a transaction.
- * @param ts           transaction set
- * @return             0 it is not, 1 it is.
- */
-rpmtsType rpmtsGetType(rpmts ts);
-
-/** \ingroup rpmts
- * Set transaction type.   Allowed types are:
- *
- *     RPMTRANS_TYPE_NORMAL
- *     RPMTRANS_TYPE_ROLLBACK
- *     RPMTRANS_TYPE_AUTOROLLBACK
- *
- * @param ts           transaction set
- * @param type         transaction type
- * @return             void
- */
-void rpmtsSetType(rpmts ts, rpmtsType type);
-
-/** \ingroup rpmts
  * Print possible suggestions for current transaction set, assuming
  * solvedb exists etc.
  * @todo               The whole suggests handling needs rework, this
index 206edac..7e0fd45 100644 (file)
@@ -5,7 +5,6 @@
 #include <rpm/rpmal.h> /* XXX availablePackage/relocateFileList ,*/
 
 #include "rpmdb/rpmhash.h"     /* XXX hashTable */
-#include "lib/rpmtsscore.h"    /* for rpmtsScore */
 
 /** \ingroup rpmts
  */
@@ -36,7 +35,6 @@ struct diskspaceInfo_s {
  */
 struct rpmts_s {
     rpmtransFlags transFlags;  /*!< Bit(s) to control operation. */
-    rpmtsType type;             /*!< default, rollback, autorollback */
 
     rpmdb sdb;                 /*!< Solve database handle. */
     int sdbmode;               /*!< Solve database open mode. */
@@ -111,8 +109,6 @@ struct rpmts_s {
 
     rpmSpec spec;              /*!< Spec file control structure. */
 
-    rpmtsScore score;          /*!< Transaction Score (autorollback). */
-
     int nrefs;                 /*!< Reference count. */
 };
 
diff --git a/lib/rpmtsscore.h b/lib/rpmtsscore.h
deleted file mode 100644 (file)
index 696ebde..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef H_RPMTSSCORE
-#define H_RPMTSSCORE
-
-#include <rpm/rpmtypes.h>
-#include <rpm/rpmte.h>
-
-/**********************
- * Transaction Scores *
- **********************
- *
- * In order to allow instance counts to be adjusted properly when an
- * autorollback transaction is ran, we keep a list that is indexed
- * by rpm name of whether the rpm has been installed or erased.  This listed
- * is only updated:
- *
- *     iif autorollbacks are enabled.
- *     iif this is not a rollback or autorollback transaction.
- *
- * When creating an autorollback transaction, its rpmts points to the same
- * rpmtsScore object as the running transaction.  So when the autorollback
- * transaction runs it can see where each package was in the running transaction
- * at the point the running transaction failed, and thus on a per package
- * basis make adjustments to the instance counts.
- *
- */
-
-struct rpmtsScoreEntry_s {
-    char *         N;                   /*!<Name of package                */
-    rpmElementType te_types;            /*!<te types this entry represents */
-    int            installed;           /*!<Was the new header installed   */
-    int            erased;              /*!<Was the old header removed     */
-};
-
-typedef struct rpmtsScoreEntry_s * rpmtsScoreEntry;
-
-struct rpmtsScore_s {
-        int entries;                    /*!< Number of scores       */
-        rpmtsScoreEntry * scores;       /*!< Array of score entries */
-        int nrefs;                      /*!< Reference count.       */
-};
-
-typedef struct rpmtsScore_s * rpmtsScore;
-
-/** \ingroup rpmts
- * initialize rpmtsScore for running transaction and autorollback
- * transaction.
- * @param runningTS    Running Transaction.
- * @param rollbackTS   Rollback Transaction.
- * @return             RPMRC_OK
- */
-rpmRC rpmtsScoreInit(rpmts runningTS, rpmts rollbackTS);
-
-/** \ingroup rpmts
- * Free rpmtsScore provided no more references exist against it.
- * @param score                rpmtsScore to free
- * @return             NULL always
- */
-rpmtsScore rpmtsScoreFree(rpmtsScore score);
-
-/** \ingroup rpmts
- * Get rpmtsScore from transaction.
- * @param ts   RPM Transaction.
- * @return     rpmtsScore or NULL.
- */
-rpmtsScore rpmtsGetScore(rpmts ts);
-
-/** \ingroup rpmts
- * Get rpmtsScoreEntry from rpmtsScore.
- * @param score   RPM Transaction Score.
- * @param N      Score entry name.
- * @return       rpmtsScoreEntry or NULL.
- */
-rpmtsScoreEntry rpmtsScoreGetEntry(rpmtsScore score, const char *N);
-
-#endif /* H_RPMTSSCORE */
index a855a54..cfb4293 100644 (file)
@@ -874,416 +874,6 @@ rpmfi rpmtsiFi(const rpmtsi tsi)
     return fi;
 }
 
-/**
- * This is not a generalized function to be called from outside
- * librpm.  It is called internally by rpmtsRun() to rollback
- * a failed transaction.
- * @param rollbackTransaction          rollback transaction
- * @return                             RPMRC_OK, or RPMRC_FAIL
- */
-static rpmRC _rpmtsRollback(rpmts rollbackTransaction)
-{
-    int    rc         = 0;
-    int    numAdded   = 0;
-    int    numRemoved = 0;
-    rpm_tid_t tid;
-    rpmtsi tsi;
-    rpmte  te;
-    rpmps  ps;
-
-    /*
-     * Gather information about this rollback transaction for reporting.
-     *    1) Get tid
-     */
-    tid = rpmtsGetTid(rollbackTransaction);
-
-    /*
-     *    2) Get number of install elments and erase elements
-     */
-    tsi = rpmtsiInit(rollbackTransaction);
-    while((te = rpmtsiNext(tsi, 0)) != NULL) {
-       switch (rpmteType(te)) {
-       case TR_ADDED:
-          numAdded++;
-          break;
-       case TR_REMOVED:
-          numRemoved++;
-          break;
-       default:
-          break;
-       }       
-    }
-    tsi = rpmtsiFree(tsi);
-
-    rpmlog(RPMLOG_NOTICE, _("Transaction failed...rolling back\n"));
-    rpmlog(RPMLOG_NOTICE,
-       _("Rollback packages (+%d/-%d) to %-24.24s (0x%08x):\n"),
-                        numAdded, numRemoved, ctime((time_t*) &tid), tid);
-
-    /* Check the transaction to see if it is doable */
-    rc = rpmtsCheck(rollbackTransaction);
-    ps = rpmtsProblems(rollbackTransaction);
-    if (rc != 0 && rpmpsNumProblems(ps) > 0) {
-       rpmlog(RPMLOG_ERR, _("Failed dependencies:\n"));
-       rpmpsPrint(NULL, ps);
-       ps = rpmpsFree(ps);
-       return -1;
-    }
-    ps = rpmpsFree(ps);
-
-    /* Order the transaction */
-    rc = rpmtsOrder(rollbackTransaction);
-    if (rc != 0) {
-       rpmlog(RPMLOG_ERR,
-           _("Could not order auto-rollback transaction!\n"));
-       return -1;
-    }
-
-
-
-    /* Run the transaction and print any problems
-     * We want to stay with the original transactions flags except
-     * that we want to add what is essentially a force.
-     * This handles two things in particular:
-     * 
-     * 1.  We we want to upgrade over a newer package.
-     *         2.  If a header for the old package is there we
-     *      we want to replace it.  No questions asked.
-     */
-    rc = rpmtsRun(rollbackTransaction, NULL,
-         RPMPROB_FILTER_REPLACEPKG
-       | RPMPROB_FILTER_REPLACEOLDFILES
-       | RPMPROB_FILTER_REPLACENEWFILES
-       | RPMPROB_FILTER_OLDPACKAGE
-    );
-    ps = rpmtsProblems(rollbackTransaction);
-    if (rc > 0 && rpmpsNumProblems(ps) > 0)
-       rpmpsPrint(stderr, ps);
-    ps = rpmpsFree(ps);
-
-    /*
-     * After we have ran through the transaction we need to
-     * remove any repackaged packages we just installed/upgraded
-     * from the rp repository.
-     */
-    tsi = rpmtsiInit(rollbackTransaction);
-    while((te = rpmtsiNext(tsi, 0)) != NULL) {
-       fnpyKey key = NULL;
-       rpmlog(RPMLOG_NOTICE, _("Cleaning up repackaged packages:\n"));
-       switch (rpmteType(te)) {
-       /* The install elements are repackaged packages */
-       case TR_ADDED:
-           /* Make sure the filename is still there.  XXX: Can't happen */
-           key = rpmteKey(te);
-           if(key) {
-               rpmlog(RPMLOG_NOTICE, _("\tRemoving %s:\n"), (const char*)key);
-               (void) unlink(key); /* XXX: Should check for an error? */
-           }
-           break;
-                                                                                
-       /* Ignore erase elements...nothing to do */
-       default:
-           break;
-       }
-    }
-    tsi = rpmtsiFree(tsi);
-
-    /* Free the rollback transaction */
-    rollbackTransaction = rpmtsFree(rollbackTransaction);
-
-    return rc;
-}
-
-/**
- * Get the repackaged header and filename from the repackage directory.
- * @todo Find a suitable home for this function.
- * @todo This function creates an IDTX everytime it is called.  Needs to
- *       be made more efficient (only create on per running transaction).
- * @param ts           rpm transaction
- * @param te           transaction element
- * @retval hdrp                Repackaged header
- * @retval fnp         Repackaged package's path (transaction key)
- * @return             RPMRC_NOTFOUND or RPMRC_OK
- */
-static rpmRC getRepackageHeaderFromTE(rpmts ts, rpmte te,
-               Header *hdrp,
-               const char **fnp)
-{
-    rpm_tid_t tid;
-    const char * name;
-    const char * rpname = NULL;
-    const char * _repackage_dir = NULL;
-    const char * globStr = "-*.rpm";
-    char * rp = NULL;          /* Rollback package name */
-    IDTX rtids = NULL;
-    IDT rpIDT;
-    int nrids = 0;
-    size_t nb;                 /* Number of bytes */
-    Header h = NULL;
-    int rc   = RPMRC_NOTFOUND; /* Assume we do not find it*/
-    int xx;
-
-    rpmlog(RPMLOG_DEBUG,
-       "Getting repackaged header from transaction element\n");
-
-    /* Set header pointer to null if its not already */
-    if (hdrp)
-       *hdrp = NULL;
-    if (fnp)
-       *fnp = NULL;
-
-    /* Get the TID of the current transaction */
-    tid = rpmtsGetTid(ts);
-    /* Need the repackage dir if the user want to
-     * rollback on a failure.
-     */
-    _repackage_dir = rpmExpand("%{?_repackage_dir}", NULL);
-    if (_repackage_dir == NULL) goto exit;
-
-    /* Build the glob string to find the possible repackaged
-     * packages for this package.
-     */
-    name = rpmteN(te); 
-    nb = strlen(_repackage_dir) + strlen(name) + strlen(globStr) + 2;
-    rp = memset((char *) malloc(nb), 0, nb);
-    xx = snprintf(rp, nb, "%s/%s%s.rpm", _repackage_dir, name, globStr);
-
-    /* Get the index of possible repackaged packages */
-    rpmlog(RPMLOG_DEBUG, "\tLooking for %s...\n", rp);
-    rtids = IDTXglob(ts, rp, RPMTAG_REMOVETID);
-    rp = _free(rp);
-    if (rtids != NULL) {
-       rpmlog(RPMLOG_DEBUG, "\tMatches found.\n");
-       rpIDT = rtids->idt;
-       nrids = rtids->nidt;
-    } else {
-       rpmlog(RPMLOG_DEBUG, "\tNo matches found.\n");
-       goto exit;
-    }
-
-    /* Now walk through index until we find the package (or we have
-     * exhausted the index.
-     */
-    do {
-       /* If index is null we have exhausted the list and need to
-        * get out of here...the repackaged package was not found.
-        */
-       if (rpIDT == NULL) {
-           rpmlog(RPMLOG_DEBUG, "\tRepackaged package not found!.\n");
-           break;
-       }
-
-       /* Is this the same tid.  If not decrement the list and continue */
-       if (rpIDT->val.u32 != tid) {
-           nrids--;
-           if (nrids > 0)
-               rpIDT++;
-           else
-               rpIDT = NULL;
-           continue;
-       }
-
-       /* OK, the tid matches.  Now lets see if the name is the same.
-        * If I could not get the name from the package, I will go onto
-        * the next one.  Perhaps I should return an error at this
-        * point, but if this was not the correct one, at least the correct one
-        * would be found.
-        * XXX:  Should Match NAC!
-        */
-       rpmlog(RPMLOG_DEBUG, "\tREMOVETID matched INSTALLTID.\n");
-       if (headerGetEntry(rpIDT->h, RPMTAG_NAME, NULL, (rpm_data_t *) &rpname, NULL)) {
-           rpmlog(RPMLOG_DEBUG, "\t\tName:  %s.\n", rpname);
-           if (!strcmp(name,rpname)) {
-               /* It matched we have a canidate */
-               h  = headerLink(rpIDT->h);
-               nb = strlen(rpIDT->key) + 1;
-               rp = memset((char *) malloc(nb), 0, nb);
-               rp = strncat(rp, rpIDT->key, nb);
-               rc = RPMRC_OK;
-               break;
-           }
-       }
-
-       /* Decrement list */    
-       nrids--;
-       if (nrids > 0)
-           rpIDT++;
-       else
-           rpIDT = NULL;
-    } while (1);
-
-exit:
-    if (rc != RPMRC_NOTFOUND && h != NULL && hdrp != NULL) {
-       rpmlog(RPMLOG_DEBUG, "\tRepackaged Package was %s...\n", rp);
-       if (hdrp != NULL)
-           *hdrp = headerLink(h);
-       if (fnp != NULL)
-           *fnp = rp;
-       else
-           rp = _free(rp);
-    }
-    if (h != NULL)
-       h = headerFree(h);
-    rtids = IDTXfree(rtids);
-    return rc; 
-}
-
-/**
- * This is not a generalized function to be called from outside
- * librpm.  It is called internally by rpmtsRun() to add elements
- * to its autorollback transaction.
- * @param rollbackTransaction          rollback transaction
- * @param runningTransaction           running transaction (the one you want to rollback)
- * @param te                           Transaction element.
- * @return                             RPMRC_OK, or RPMRC_FAIL
- */
-static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction,
-               rpmts runningTransaction, rpmte te)
-{
-    Header h   = NULL;
-    Header rph = NULL;
-    const char * rpn;  
-    unsigned int db_instance = 0;
-    rpmtsi pi;         
-    rpmte p;
-    int rc  = RPMRC_FAIL;      /* Assume Failure */
-
-    switch(rpmteType(te)) {
-    case TR_ADDED:
-    {   rpmdbMatchIterator mi;
-
-       rpmlog(RPMLOG_DEBUG,
-           "Adding install element to auto-rollback transaction.\n");
-
-       /* Get the header for this package from the database
-        * First get the database instance (the key).
-        */
-       db_instance = rpmteDBInstance(te);
-       if (db_instance == 0) {
-           /* Could not get the db instance: WTD! */
-           rpmlog(RPMLOG_CRIT,
-               _("Could not get install element database instance!\n"));
-           break;
-       }
-
-       /* Now suck the header out of the database */
-       mi = rpmtsInitIterator(rollbackTransaction,
-           RPMDBI_PACKAGES, &db_instance, sizeof(db_instance));
-       h = rpmdbNextIterator(mi);
-       if (h != NULL) h = headerLink(h);
-       mi = rpmdbFreeIterator(mi);
-       if (h == NULL) {
-           /* Header was not there??? */
-           rpmlog(RPMLOG_CRIT,
-               _("Could not get header for auto-rollback transaction!\n"));
-           break;
-       }
-
-       /* Now see if there is a repackaged package for this */
-       rc = getRepackageHeaderFromTE(runningTransaction, te, &rph, &rpn);
-       switch(rc) {
-       case RPMRC_OK:
-           /* Add the install element, as we had a repackaged package */
-           rpmlog(RPMLOG_DEBUG,
-               "\tAdded repackaged package header: %s.\n", rpn);
-           rpmlog(RPMLOG_DEBUG,
-               "\tAdded from install element %s.\n", rpmteNEVRA(te));
-           rc = rpmtsAddInstallElement(rollbackTransaction, headerLink(rph),
-               (fnpyKey) rpn, 1, te->relocs);
-           break;
-
-       case RPMRC_NOTFOUND:
-           /* Add the header as an erase element, we did not
-            * have a repackaged package
-            */
-           rpmlog(RPMLOG_DEBUG, "\tAdded erase element.\n");
-           rpmlog(RPMLOG_DEBUG,
-               _("\tAdded from install element %s.\n"), rpmteNEVRA(te));
-           rc = rpmtsAddEraseElement(rollbackTransaction, h, db_instance);
-           break;
-                       
-       default:
-           /* Not sure what to do on failure...just give up */
-           rpmlog(RPMLOG_CRIT,
-               _("Could not get repackaged header for auto-rollback transaction!\n"));
-           break;
-       }
-    }  break;
-
-   case TR_REMOVED:
-       rpmlog(RPMLOG_DEBUG,
-           "Add erase element to auto-rollback transaction.\n");
-       /* See if this element has already been added.
-        * If so we want to do nothing.  Compare N's for match.
-        * XXX:  Really should compare NAC's.
-        */
-       pi = rpmtsiInit(rollbackTransaction);
-       while ((p = rpmtsiNext(pi, 0)) != NULL) {
-           if (!strcmp(rpmteN(p), rpmteN(te))) {
-               rpmlog(RPMLOG_DEBUG, "\tFound existing upgrade element.\n");
-               rpmlog(RPMLOG_DEBUG, "\tNot adding erase element for %s.\n",
-                       rpmteN(te));
-               rc = RPMRC_OK;  
-               pi = rpmtsiFree(pi);
-               goto cleanup;
-           }
-       }
-       pi = rpmtsiFree(pi);
-
-       /* Get the repackage header from the current transaction
-       * element.
-       */
-       rc = getRepackageHeaderFromTE(runningTransaction, te, &rph, &rpn);
-       switch(rc) {
-       case RPMRC_OK:
-           /* Add the install element */
-           rpmlog(RPMLOG_DEBUG,
-               "\tAdded repackaged package %s.\n", rpn);
-           rpmlog(RPMLOG_DEBUG,
-               "\tAdded from erase element %s.\n", rpmteNEVRA(te));
-           rc = rpmtsAddInstallElement(rollbackTransaction, rph,
-               (fnpyKey) rpn, 1, te->relocs);
-           if (rc != RPMRC_OK)
-               rpmlog(RPMLOG_CRIT,
-                   _("Could not add erase element to auto-rollback transaction.\n"));
-           break;
-
-       case RPMRC_NOTFOUND:
-           /* Just did not have a repackaged package */
-           rpmlog(RPMLOG_DEBUG,
-               "\tNo repackaged package...nothing to do.\n");
-           rc = RPMRC_OK;
-           break;
-
-       default:
-           rpmlog(RPMLOG_CRIT,
-               _("Failure reading repackaged package!\n"));
-           break;
-       }
-       break;
-
-    default:
-       break;
-    }
-
-/* XXX:  I want to free this, but if I do then the consumers of
- *       are hosed.  Just leaving you a little note Jeff, so you
- *       know that this does introduce a memory leak.  I wanted
- *       keep the patch as simple as possible so I am not fixxing
- *       the leak.
- *   if (rpn != NULL)
- *     free(rpn);
- */
-
-cleanup:
-    /* Clean up */
-    if (h != NULL)
-       h = headerFree(h);
-    if (rph != NULL)
-       rph = headerFree(rph);
-    return rc;
-}
-
 #define        NOTIFY(_ts, _al) if ((_ts)->notify) (void) (_ts)->notify _al
 
 int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
@@ -1304,8 +894,6 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
     rpmtsi qi; rpmte q;
     int numAdded;
     int numRemoved;
-    rpmts rollbackTransaction = NULL;
-    int rollbackOnFailure = 0;
     void * lock = NULL;
     int xx;
 
@@ -1313,20 +901,8 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
     if (rpmtsNElements(ts) <= 0)
        return -1;
 
-    /* See if we need to rollback on failure */
-    rollbackOnFailure = rpmExpandNumeric(
-       "%{?_rollback_transaction_on_failure}");
-    if (rpmtsGetType(ts) & (RPMTRANS_TYPE_ROLLBACK
-       | RPMTRANS_TYPE_AUTOROLLBACK)) {
-       rollbackOnFailure = 0;
-    }
-    /* If we are in test mode, there is no need to rollback on
-     * failure, nor acquire the transaction lock.
-     */
     /* If we are in test mode, then there's no need for transaction lock. */
-    if (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST) {
-       rollbackOnFailure = 0;
-    } else {
+    if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
        lock = rpmtsAcquireLock(ts);
        if (lock == NULL)
            return -1;  /* XXX W2DO? */
@@ -1797,56 +1373,6 @@ assert(psm != NULL);
     }
 
     /* ===============================================
-     * If we were requested to rollback this transaction
-     * if an error occurs, then we need to create a
-     * a rollback transaction.
-     */
-     if (rollbackOnFailure) {
-       rpmtransFlags tsFlags;
-       rpmVSFlags ovsflags;
-       rpmVSFlags vsflags;
-
-       rpmlog(RPMLOG_DEBUG,
-           "Creating auto-rollback transaction\n");
-
-       rollbackTransaction = rpmtsCreate();
-
-       /* Set the verify signature flags:
-        *      - can't verify digests on repackaged packages.  Other than
-        *        they are wrong, this will cause segfaults down stream.
-        *      - signatures are out too.
-        *      - header check are out.
-        */     
-       vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
-       vsflags |= _RPMVSF_NODIGESTS;
-       vsflags |= _RPMVSF_NOSIGNATURES;
-       vsflags |= RPMVSF_NOHDRCHK;
-       vsflags |= RPMVSF_NEEDPAYLOAD;      /* XXX no legacy signatures */
-       ovsflags = rpmtsSetVSFlags(ts, vsflags);
-
-       /*
-        *  If we run this thing its imperitive that it be known that it
-        *  is an autorollback transaction.  This will affect the instance
-        *  counts passed to the scriptlets in the psm.
-        */
-       rpmtsSetType(rollbackTransaction, RPMTRANS_TYPE_AUTOROLLBACK);
-
-       /* Set transaction flags to be the same as the running transaction */
-       tsFlags = rpmtsSetFlags(rollbackTransaction, rpmtsFlags(ts));
-
-       /* Set root dir to be the same as the running transaction */
-       rpmtsSetRootDir(rollbackTransaction, rpmtsRootDir(ts));
-
-       /* Setup the notify of the call back to be the same as the running
-        * transaction
-        */
-       xx = rpmtsSetNotifyCallback(rollbackTransaction, ts->notify, ts->notifyData);
-
-       /* Create rpmtsScore for running transaction and rollback transaction */
-       xx = rpmtsScoreInit(ts, rollbackTransaction);
-     }
-
-    /* ===============================================
      * Save removed files before erasing.
      */
     if (rpmtsFlags(ts) & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
@@ -1949,23 +1475,6 @@ assert(psm != NULL);
                                        rpmteKey(p), ts->notifyData);
                        p->fd = NULL;
                        ourrc++;
-
-                       /* If we should rollback this transaction
-                          on failure, lets do it.                 */
-                       if (rollbackOnFailure) {
-                           rpmlog(RPMLOG_ERR,
-                               _("Add failed.  Could not read package header.\n"));
-                           /* Clean up the current transaction */
-                           p->h = headerFree(p->h);
-                           xx = rpmdbSync(rpmtsGetRdb(ts));
-                           psm = rpmpsmFree(psm);
-                           p->fi = rpmfiFree(p->fi);
-                           pi = rpmtsiFree(pi);
-
-                           /* Run the rollback transaction */
-                           xx = _rpmtsRollback(rollbackTransaction);
-                           return -1;
-                       }
                        break;
                    case RPMRC_NOTTRUSTED:
                    case RPMRC_NOKEY:
@@ -2031,66 +1540,11 @@ assert(psm != NULL);
                if (rpmpsmStage(psm, PSM_PKGINSTALL)) {
                    ourrc++;
                    lastFailKey = pkgKey;
-
-                   /* If we should rollback this transaction
-                      on failure, lets do it.                 */
-                   if (rollbackOnFailure) {
-                       rpmlog(RPMLOG_ERR,
-                           _("Add failed in rpmpsmStage().\n"));
-                       /* Clean up the current transaction */
-                       p->h = headerFree(p->h);
-                       xx = rpmdbSync(rpmtsGetRdb(ts));
-                       psm = rpmpsmFree(psm);
-                       p->fi = rpmfiFree(p->fi);
-                       pi = rpmtsiFree(pi);
-
-                       /* Run the rollback transaction */
-                       xx = _rpmtsRollback(rollbackTransaction);
-                       return -1;
-                   }
                }
                
-               /* If we should rollback on failure lets add
-                * this element to the rollback transaction
-                * as an erase element as it has installed succesfully.
-                */
-               if (rollbackOnFailure) {
-                   int rc;
-
-                   rc = _rpmtsAddRollbackElement(rollbackTransaction, ts, p);
-                   if (rc != RPMRC_OK) {
-                       /* Clean up the current transaction */
-                       p->h = headerFree(p->h);
-                       xx = rpmdbSync(rpmtsGetRdb(ts));
-                       psm = rpmpsmFree(psm);
-                       p->fi = rpmfiFree(p->fi);
-                       pi = rpmtsiFree(pi);
-                       
-                       /* Clean up rollback transaction */
-                       rollbackTransaction = rpmtsFree(rollbackTransaction);
-                       return -1;
-                   }
-               }
            } else {
                ourrc++;
                lastFailKey = pkgKey;
-               
-               /* If we should rollback this transaction
-                * on failure, lets do it.
-                */
-               if (rollbackOnFailure) {
-                   rpmlog(RPMLOG_ERR, _("Add failed.  Could not get file list.\n"));
-                   /* Clean up the current transaction */
-                   p->h = headerFree(p->h);
-                   xx = rpmdbSync(rpmtsGetRdb(ts));
-                   psm = rpmpsmFree(psm);
-                   p->fi = rpmfiFree(p->fi);
-                   pi = rpmtsiFree(pi);
-
-                   /* Run the rollback transaction */
-                   xx = _rpmtsRollback(rollbackTransaction);
-                   return -1;
-               }
            }
 
            if (gotfd) {
@@ -2119,45 +1573,6 @@ assert(psm != NULL);
            if (rpmteDependsOnKey(p) != lastFailKey) {
                if (rpmpsmStage(psm, PSM_PKGERASE)) {
                    ourrc++;
-
-                   /* If we should rollback this transaction
-                    * on failure, lets do it.
-                    */
-                   if (rollbackOnFailure) {
-                       rpmlog(RPMLOG_ERR,
-                           _("Erase failed failed in rpmpsmStage().\n"));
-                       /* Clean up the current transaction */
-                       xx = rpmdbSync(rpmtsGetRdb(ts));
-                       psm = rpmpsmFree(psm);
-                       p->fi = rpmfiFree(p->fi);
-                       pi = rpmtsiFree(pi);
-
-                       /* Run the rollback transaction */
-                       xx = _rpmtsRollback(rollbackTransaction);
-                       return -1;
-                   }
-               }
-
-               /* If we should rollback on failure lets add
-                * this element to the rollback transaction
-                * as an install element as it has erased succesfully.
-                */
-               if (rollbackOnFailure) {
-                   int rc;
-
-                   rc = _rpmtsAddRollbackElement(rollbackTransaction, ts, p);
-
-                   if (rc != RPMRC_OK) {
-                       /* Clean up the current transaction */
-                       xx = rpmdbSync(rpmtsGetRdb(ts));
-                       psm = rpmpsmFree(psm);
-                       p->fi = rpmfiFree(p->fi);
-                       pi = rpmtsiFree(pi);
-               
-                       /* Clean up rollback transaction */
-                       rollbackTransaction = rpmtsFree(rollbackTransaction);
-                       return -1;
-                   }
                }
            }
 
@@ -2178,10 +1593,6 @@ assert(psm != NULL);
     }
     pi = rpmtsiFree(pi);
 
-    /* If we created a rollback transaction lets get rid of it */
-    if (rollbackOnFailure && rollbackTransaction != NULL)
-       rollbackTransaction = rpmtsFree(rollbackTransaction);
-
     if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
        rpmlog(RPMLOG_DEBUG, "running post-transaction scripts\n");
        pi = rpmtsiInit(ts);
index 725178c..baf9cc6 100644 (file)
--- a/macros.in
+++ b/macros.in
@@ -729,10 +729,6 @@ print (t)\
 #      If non-zero, all erasures will be automagically repackaged.
 %_repackage_all_erasures       0
 
-# If non-zero, a failed transaction will be automagically rolled 
-# back (sans, the failing transaction element).
-%_rollback_transaction_on_failure      0
-
 #      Verify digest/signature flags for various rpm modes:
 #      0x30300 (_RPMVSF_NODIGESTS)    --nohdrchk      if set, don't check digest(s)
 #      0xc0c00 (_RPMVSF_NOSIGNATURES) --nosignature   if set, don't check signature(s)
index f31a97f..c3cd056 100644 (file)
@@ -49,11 +49,6 @@ struct dbiTags_s {
 /* XXX should dbitags be per-db instead? */
 static struct dbiTags_s dbiTags = { NULL, 0, 0 };
 
-/* We use this to comunicate back to the the rpm transaction
- *  what their install instance was on a rpmdbAdd().
- */ 
-unsigned int myinstall_instance = 0;
-
 /* Bit mask macros. */
 typedef        unsigned int __pbm_bits;
 #define        __PBM_NBITS             (8 * sizeof (__pbm_bits))
@@ -2732,12 +2727,6 @@ DBT * data = alloca(sizeof(*data));
     int rc;
     int xx;
 
-    /* Reinitialize to zero, so in the event the add fails
-     * we won't have bogus information (i.e. the last succesful
-     * add).
-     */
-    myinstall_instance = 0;
-
     if (db == NULL)
        return 0;
 
@@ -2835,9 +2824,6 @@ memset(data, 0, sizeof(*data));
     {  
        dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
 
-       /* Save the header number for the current transaction. */
-       myinstall_instance = hdrNum;
-       
        if (dbiTags.tags != NULL)
        for (dbix = 0; dbix < dbiTags.max; dbix++) {
            const char *av[1];