Bury build filestate setting inside fsm remains
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 24 Apr 2012 09:36:26 +0000 (12:36 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 24 Apr 2012 09:43:54 +0000 (12:43 +0300)
- This whole thing probably isn't needed anymore, but for now just
  lift the FA_SKIP/FA_COPYOUT setting to rpmPackageFilesArchive(),
  allowing rpmfsSetAction() to become properly internal-only function.
- Trim out unnecessary now unnecessary librpm internal includes
  from librpmbuild code

build/pack.c
lib/fsm.c
lib/rpmfs.h

index ebfee57..ef79eb6 100644 (file)
 #include <rpm/rpmlog.h>
 
 #include "rpmio/rpmio_internal.h"      /* fdInitDigest, fdFiniDigest */
-#include "lib/cpio.h"
 #include "lib/fsm.h"
-#include "lib/rpmfi_internal.h"                /* rpmfiFSM() */
-#include "lib/rpmte_internal.h"                /* rpmfs */
 #include "lib/signature.h"
 #include "lib/rpmlead.h"
 #include "build/rpmbuild_internal.h"
@@ -39,10 +36,9 @@ static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, const char * fmodeMacro)
     rpmts ts = NULL;
     rpmfi fi = csa->cpioList;
     rpmte te = NULL;
-    rpmfs fs = NULL;
     char *failedFile = NULL;
     FD_t cfd;
-    int i, fsmrc;
+    int fsmrc;
 
     (void) Fflush(fdo);
     cfd = Fdopen(fdDup(Fileno(fdo)), fmodeMacro);
@@ -53,15 +49,6 @@ static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, const char * fmodeMacro)
     ts = rpmtsCreate();
     rpmtsAddInstallElement(ts, h, NULL, 0, NULL);
     te = rpmtsElement(ts, 0);
-    fs = rpmteGetFileStates(te);
-
-    fi = rpmfiInit(fi, 0);
-    while ((i = rpmfiNext(fi)) >= 0) {
-       if (rpmfiFFlags(fi) & RPMFILE_GHOST)
-           rpmfsSetAction(fs, i, FA_SKIP);
-       else
-           rpmfsSetAction(fs, i, FA_COPYOUT);
-    }
 
     fsmrc = rpmPackageFilesArchive(ts, te, fi, cfd,
                      &csa->cpioArchiveSize, &failedFile);
index b0e2e90..981c33b 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1947,9 +1947,19 @@ int rpmPackageFilesArchive(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
     rpmcpio_t archive = rpmcpioOpen(cfd, O_WRONLY);
     int rc = 0;
 
-    if (archive == NULL)
+    if (archive == NULL) {
        rc = CPIOERR_INTERNAL;
+    } else {
+       rpmfs fs = rpmteGetFileStates(te);
+       int ghost, i, fc = rpmfiFC(fi);
 
+       /* XXX Is this actually still needed? */
+       for (i = 0; i < fc; i++) {
+           ghost = (rpmfiFFlagsIndex(fi, i) & RPMFILE_GHOST);
+           rpmfsSetAction(fs, i, ghost ? FA_SKIP : FA_COPYOUT);
+       }
+    }
+           
     while (!rc) {
        fsmReset(fsm);
 
index ef478ad..4253dd2 100644 (file)
@@ -55,7 +55,7 @@ rpm_fstate_t * rpmfsGetStates(rpmfs fs);
 RPM_GNUC_INTERNAL
 rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix);
 
-/* XXX this should be internal too but build code needs for now */
+RPM_GNUC_INTERNAL
 void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action);
 
 #ifdef __cplusplus