From d307d0ae97306db489fb01f949ae0a5e0db095f5 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 14 Nov 2013 09:55:59 +0200 Subject: [PATCH] Let install and erase create their own file iterators - Package install and erase ultimately need different types of file iterators, grab and pass the actual file set handle instead of an iterator from psm and use a local iterator in fsm. Passing the rpmfiles handle isn't strictly needed, fsm could grab it from the element by itself... This also eliminates the last use of rpmteFI() in librpm. - No functional changes here, both install and erase still use a plain old forward rpmfi iterator which is plain wrong for both of them. --- lib/fsm.c | 8 ++++++-- lib/fsm.h | 4 ++-- lib/psm.c | 12 ++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/fsm.c b/lib/fsm.c index 603bef293..db65d9e2b 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -1216,10 +1216,11 @@ static void setFileState(rpmfs fs, int i, rpmFileAction action) } } -int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd, +int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files, FD_t cfd, rpmpsm psm, char ** failedFile) { rpmfs fs = rpmteGetFileStates(te); + rpmfi fi = rpmfilesIter(files, RPMFI_ITER_FWD); FSM_t fsm = fsmNew(FSM_PKGINSTALL, fs, fi, failedFile); struct stat * st = &fsm->sb; int saveerrno = errno; @@ -1380,15 +1381,17 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd, rpmfiArchiveClose(fi); _free(found); fsmFree(fsm); + rpmfiFree(fi); return rc; } -int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfi fi, +int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfiles files, rpmpsm psm, char ** failedFile) { rpmfs fs = rpmteGetFileStates(te); + rpmfi fi = rpmfilesIter(files, RPMFI_ITER_FWD); FSM_t fsm = fsmNew(FSM_PKGERASE, fs, fi, failedFile); int rc = 0; @@ -1474,6 +1477,7 @@ int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfi fi, } fsmFree(fsm); + rpmfiFree(fi); return rc; } diff --git a/lib/fsm.h b/lib/fsm.h index 0965ef317..c0effccbf 100644 --- a/lib/fsm.h +++ b/lib/fsm.h @@ -25,10 +25,10 @@ typedef struct rpmpsm_s * rpmpsm; * @return 0 on success */ -int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd, +int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files, FD_t cfd, rpmpsm psm, char ** failedFile); -int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfi fi, +int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfiles files, rpmpsm psm, char ** failedFile); RPM_GNUC_INTERNAL diff --git a/lib/psm.c b/lib/psm.c index 33eb4a0b8..5247380ef 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -54,7 +54,7 @@ typedef enum pkgStage_e { struct rpmpsm_s { rpmts ts; /*!< transaction set */ rpmte te; /*!< current transaction element */ - rpmfi fi; /*!< transaction element file info */ + rpmfiles files; /*!< transaction element file info */ const char * goalName; char * failedFile; rpmTagVal scriptTag; /*!< Scriptlet data tag. */ @@ -654,7 +654,7 @@ exit: static rpmpsm rpmpsmFree(rpmpsm psm) { if (psm) { - rpmfiFree(psm->fi); + rpmfilesFree(psm->files); rpmtsFree(psm->ts), /* XXX rpmte not refcounted yet */ memset(psm, 0, sizeof(*psm)); /* XXX trash and burn */ @@ -667,7 +667,7 @@ static rpmpsm rpmpsmNew(rpmts ts, rpmte te) { rpmpsm psm = xcalloc(1, sizeof(*psm)); psm->ts = rpmtsLink(ts); - psm->fi = rpmfiLink(rpmteFI(te)); + psm->files = rpmteFiles(te); psm->te = te; /* XXX rpmte not refcounted yet */ return psm; } @@ -724,7 +724,7 @@ static rpmRC rpmpsmNext(rpmpsm psm, pkgStage nstage) static rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) { const rpmts ts = psm->ts; - int fc = rpmfiFC(psm->fi); + int fc = rpmfilesFC(psm->files); rpmRC rc = RPMRC_OK; switch (stage) { @@ -825,7 +825,7 @@ static rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) break; } - fsmrc = rpmPackageFilesInstall(psm->ts, psm->te, psm->fi, + fsmrc = rpmPackageFilesInstall(psm->ts, psm->te, psm->files, payload, psm, &psm->failedFile); saved_errno = errno; @@ -867,7 +867,7 @@ static rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) /* XXX should't we log errors from here? */ if (fc > 0 && !(rpmtsFlags(ts) & RPMTRANS_FLAG_JUSTDB)) { - rc = rpmPackageFilesRemove(psm->ts, psm->te, psm->fi, + rc = rpmPackageFilesRemove(psm->ts, psm->te, psm->files, psm, &psm->failedFile); }