Kill FSM: Make FSM_PKGBUILD a function

This commit is contained in:
Florian Festi 2012-03-29 15:49:11 +02:00
parent c5282fc60d
commit d951812386
3 changed files with 58 additions and 40 deletions

View File

@ -63,7 +63,7 @@ static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, const char * fmodeMacro)
rpmfsSetAction(fs, i, FA_COPYOUT);
}
fsmrc = rpmfsmRun(FSM_PKGBUILD, ts, te, fi, cfd, NULL,
fsmrc = rpmPackageFilesArchive(ts, te, fi, cfd,
&csa->cpioArchiveSize, &failedFile);
if (fsmrc) {

View File

@ -1800,45 +1800,6 @@ static int fsmStage(FSM_t fsm, fileStage stage)
switch (stage) {
case FSM_UNKNOWN:
break;
case FSM_PKGBUILD:
while (1) {
rc = fsmInit(fsm);
/* Exit on end-of-payload. */
if (rc == CPIOERR_HDR_TRAILER) {
rc = 0;
break;
}
/* Exit on error. */
if (rc) {
fsm->postpone = 1;
break;
}
if (fsm->postpone || fsm->fflags & RPMFILE_GHOST) /* XXX Don't if %ghost file. */
continue;
/* Hardlinks are handled later */
if (!(S_ISREG(st->st_mode) && st->st_nlink > 1)) {
/* Copy file into archive. */
rc = writeFile(fsm, 1);
}
if (rc) {
if (!fsm->postpone) {
if (fsm->failedFile && *fsm->failedFile == NULL)
*fsm->failedFile = xstrdup(fsm->path);
}
break;
}
}
/* Flush partial sets of hard linked files. */
rc = writeLinks(fsm);
break;
case FSM_POST:
break;
@ -2177,3 +2138,57 @@ int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfi fi,
}
int rpmPackageFilesArchive(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
rpm_loff_t * archiveSize, char ** failedFile)
{
struct fsm_s fsm_;
FSM_t fsm = &fsm_;
int rc = 0;
int ec = 0;
memset(fsm, 0, sizeof(*fsm));
rc = fsmSetup(fsm, FSM_PKGBUILD, ts, te, fi, cfd, NULL, archiveSize, failedFile);
while (!rc) {
rc = fsmInit(fsm);
/* Exit on end-of-payload. */
if (rc == CPIOERR_HDR_TRAILER) {
rc = 0;
break;
}
/* Exit on error. */
if (rc) {
fsm->postpone = 1;
break;
}
if (fsm->postpone || fsm->fflags & RPMFILE_GHOST) /* XXX Don't if %ghost file. */
continue;
/* Hardlinks are handled later */
if (!(S_ISREG(fsm->sb.st_mode) && fsm->sb.st_nlink > 1)) {
/* Copy file into archive. */
rc = writeFile(fsm, 1);
}
if (rc) {
if (!fsm->postpone) {
if (fsm->failedFile && *fsm->failedFile == NULL)
*fsm->failedFile = xstrdup(fsm->path);
}
break;
}
}
/* Flush partial sets of hard linked files. */
if (!rc)
rc = writeLinks(fsm);
ec = fsmTeardown(fsm);
/* Return the relevant code: if setup failed, teardown doesn't matter */
return (rc ? rc : ec);
}

View File

@ -125,6 +125,9 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfi fi,
rpmpsm psm, char ** failedFile);
int rpmPackageFilesArchive(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
rpm_loff_t * archiveSize, char ** failedFile);
RPM_GNUC_INTERNAL
void rpmpsmNotify(rpmpsm psm, int what, rpm_loff_t amount);
#ifdef __cplusplus