Move header INSTALLTID manipulation out of rpmdbAdd()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 7 Apr 2010 05:35:14 +0000 (08:35 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 7 Apr 2010 05:35:14 +0000 (08:35 +0300)
lib/psm.c
lib/rpmdb.c
lib/rpmdb.h
lib/rpmts.c

index 6a36258..06afe8d 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -1068,14 +1068,20 @@ static rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
     case PSM_RPMDB_ADD: {
        Header h;
        if (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)        break;
+
        h = rpmteHeader(psm->te);
+
+       if (!headerIsEntry(h, RPMTAG_INSTALLTID)) {
+           rpm_tid_t tid = rpmtsGetTid(ts);
+           if (tid != 0 && tid != (rpm_tid_t)-1)
+               headerPutUint32(h, RPMTAG_INSTALLTID, &tid, 1);
+       }
+       
        (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DBADD), 0);
        if (!(rpmtsVSFlags(ts) & RPMVSF_NOHDRCHK))
-           rc = rpmdbAdd(rpmtsGetRdb(ts), rpmtsGetTid(ts), h,
-                               ts, headerCheck);
+           rc = rpmdbAdd(rpmtsGetRdb(ts), 0, h, ts, headerCheck);
        else
-           rc = rpmdbAdd(rpmtsGetRdb(ts), rpmtsGetTid(ts), h,
-                               NULL, NULL);
+           rc = rpmdbAdd(rpmtsGetRdb(ts), 0, h, NULL, NULL);
        (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DBADD), 0);
 
        if (rc == RPMRC_OK)
index c13d1e4..f2f3d59 100644 (file)
@@ -2405,15 +2405,6 @@ int rpmdbAdd(rpmdb db, int iid, Header h,
     memset(&key, 0, sizeof(key));
     memset(&data, 0, sizeof(data));
 
-#ifdef NOTYET  /* XXX headerDel() broken on dribbles. */
-    xx = headerDel(h, RPMTAG_REMOVETID);
-#endif
-    if (iid != 0 && iid != -1) {
-       rpm_tid_t tid = iid;
-       if (!headerIsEntry(h, RPMTAG_INSTALLTID)) 
-           headerPutUint32(h, RPMTAG_INSTALLTID, &tid, 1);
-    }
-
     (void) blockSignals(&signalMask);
 
     dbi = rpmdbOpenIndex(db, RPMDBI_PACKAGES, 0);
index bb574cb..b8d1214 100644 (file)
@@ -236,7 +236,7 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
 /** \ingroup rpmdb
  * Add package header to rpm database and indices.
  * @param db           rpm database
- * @param iid          install transaction id (iid = 0 or -1 to skip)
+ * @param iid          (unused)
  * @param h            header
  * @param ts           (unused) transaction set (or NULL)
  * @param (*hdrchk)    (unused) headerCheck() vector (or NULL)
@@ -248,7 +248,7 @@ int rpmdbAdd(rpmdb db, int iid, Header h, rpmts ts,
 /** \ingroup rpmdb
  * Remove package header from rpm database and indices.
  * @param db           rpm database
- * @param rid          (unused) remove transaction id (rid = 0 or -1 to skip)
+ * @param rid          (unused)
  * @param hdrNum       package instance number in database
  * @param ts           (unused) transaction set (or NULL)
  * @param (*hdrchk)    (unused) headerCheck() vector (or NULL)
index d7d7e35..4e08353 100644 (file)
@@ -395,6 +395,7 @@ static int makePubkeyHeader(rpmts ts, rpmPubkey key, Header h)
 
     {   rpm_tid_t tid = rpmtsGetTid(ts);
        headerPutUint32(h, RPMTAG_INSTALLTIME, &tid, 1);
+       headerPutUint32(h, RPMTAG_INSTALLTID, &tid, 1);
        headerPutUint32(h, RPMTAG_BUILDTIME, &tid, 1);
     }
     rc = 0;
@@ -429,7 +430,7 @@ rpmRC rpmtsImportPubkey(const rpmts ts, const unsigned char * pkt, size_t pktlen
     /* Add header to database. */
     if (rpmtsOpenDB(ts, (O_RDWR|O_CREAT)))
        goto exit;
-    if (rpmdbAdd(rpmtsGetRdb(ts), rpmtsGetTid(ts), h, NULL, NULL) != 0)
+    if (rpmdbAdd(rpmtsGetRdb(ts), 0, h, NULL, NULL) != 0)
        goto exit;
     rc = RPMRC_OK;