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.
This commit is contained in:
parent
a30acf9d01
commit
d307d0ae97
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
12
lib/psm.c
12
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue