Yank rpmfi state update out of rpmtsRun()
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 14 Nov 2008 15:16:42 +0000 (17:16 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 14 Nov 2008 15:16:42 +0000 (17:16 +0200)
- stuff it into internal rpmfiUpdateState() function to get it out of
  sight for now, the mechanism needs some...

lib/rpmfi.c
lib/rpmfi_internal.h
lib/transaction.c

index 4b9d26f..7096973 100644 (file)
@@ -1405,3 +1405,46 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0));
     /* FIX: rpmfi null annotations */
     return rpmfiLink(fi, (fi ? fi->Type : NULL));
 }
+
+rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p)
+{
+    char * fstates = fi->fstates;
+    rpmFileAction * actions = fi->actions;
+    sharedFileInfo replaced = fi->replaced;
+    rpmte savep;
+    int numShared = 0;
+
+    if (replaced != NULL) {
+       for (; replaced->otherPkg; replaced++) {
+           numShared++;
+       }
+       if (numShared > 0) {
+           replaced = xcalloc(numShared + 1, sizeof(*fi->replaced));
+           memcpy(replaced, fi->replaced, 
+                  sizeof(*fi->replaced) * (numShared + 1));
+       }
+    }
+
+    fi->fstates = NULL;
+    fi->actions = NULL;
+    fi->replaced = NULL;
+    /* FIX: fi->actions is NULL */
+    fi = rpmfiFree(fi);
+
+    savep = rpmtsSetRelocateElement(ts, p);
+    fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
+    (void) rpmtsSetRelocateElement(ts, savep);
+
+    if (fi != NULL) {  /* XXX can't happen */
+       fi->te = p;
+       free(fi->fstates);
+       fi->fstates = fstates;
+       free(fi->actions);
+       fi->actions = actions;
+       if (replaced != NULL)
+           fi->replaced = replaced;
+       p->fi = fi;
+    }
+    return fi;
+}
+
index 7404623..93f5bfb 100644 (file)
@@ -113,5 +113,8 @@ struct rpmfi_s {
 int nrefs;             /*!< Reference count. */
 };
 
+RPM_GNUC_INTERNAL
+rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p);
+
 #endif /* _RPMFI_INTERNAL_H */
 
index d904ccc..67c0d58 100644 (file)
@@ -1270,46 +1270,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
                 * XXX around a recreated file info set.
                 */
                rpmpsmSetFI(psm, NULL);
-               {
-                   char * fstates = fi->fstates;
-                   rpmFileAction * actions = fi->actions;
-                   sharedFileInfo replaced = fi->replaced;
-                   rpmte savep;
-                   int numShared = 0;
-
-                   if (replaced != NULL) {
-                        for (; replaced->otherPkg; replaced++) {
-                            numShared++;
-                        }
-                        if (numShared > 0) {
-                            replaced = xcalloc(numShared + 1, 
-                                               sizeof(*fi->replaced));
-                            memcpy(replaced, fi->replaced, 
-                                   sizeof(*fi->replaced) * (numShared + 1));
-                        }
-                    }
-
-                   fi->fstates = NULL;
-                   fi->actions = NULL;
-                   fi->replaced = NULL;
-/* FIX: fi->actions is NULL */
-                   fi = rpmfiFree(fi);
-
-                   savep = rpmtsSetRelocateElement(ts, p);
-                   fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
-                   (void) rpmtsSetRelocateElement(ts, savep);
-
-                   if (fi != NULL) {   /* XXX can't happen */
-                       fi->te = p;
-                       fi->fstates = _free(fi->fstates);
-                       fi->fstates = fstates;
-                       fi->actions = _free(fi->actions);
-                       fi->actions = actions;
-                        if (replaced != NULL)
-                            fi->replaced = replaced;
-                       p->fi = fi;
-                   }
-               }
+               fi = rpmfiUpdateState(fi, ts, p);
                rpmpsmSetFI(psm, p->fi);
 
 /* FIX: psm->fi may be NULL */