From d69ac19b05107c991fb63deacd3d7a56c23d6847 Mon Sep 17 00:00:00 2001 From: jbj Date: Thu, 1 Mar 2001 17:04:27 +0000 Subject: [PATCH] Move more functionality into psmStage. CVS patchset: 4590 CVS date: 2001/03/01 17:04:27 --- lib/psm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------- po/rpm.pot | 30 +++++++++++------------ 2 files changed, 86 insertions(+), 26 deletions(-) diff --git a/lib/psm.c b/lib/psm.c index a2c5b2c..f475240 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -553,8 +553,7 @@ static int markReplacedFiles(const rpmTransactionSet ts, const TFI_t fi) * * @todo Add endian tag so that srpm MD5 sums can be verified when installed. * - * @param ts transaction set - * @param fi transaction element file info (NULL means all files) + * @param psm package state machine data * @param allFiles install all files? * @return 0 on success */ @@ -574,6 +573,7 @@ static int installArchive(PSM_t psm, int allFiles) } /* Retrieve type of payload compression. */ +#ifndef DYING { const char * payload_compressor = NULL; char * t; @@ -587,9 +587,12 @@ static int installArchive(PSM_t psm, int allFiles) if (!strcmp(payload_compressor, "bzip2")) t = stpcpy(t, ".bzdio"); } +#else + rc = psmStage(psm, PSM_RPMIO_FLAGS); +#endif +#ifdef DYING { - psm->cfd = Fdopen(fdDup(Fileno(alp->fd)), psm->rpmio_flags); rc = fsmSetup(fi->fsm, FSM_PKGINSTALL, ts, fi, @@ -605,6 +608,15 @@ static int installArchive(PSM_t psm, int allFiles) (void) fsmTeardown(fi->fsm); } } +#else + psm->cfd = Fdopen(fdDup(Fileno(alp->fd)), psm->rpmio_flags); + rc = psmStage(psm, PSM_PKGINSTALL); + saveerrno = errno; /* XXX FIXME: Fclose with libio destroys errno */ + Fclose(psm->cfd); + psm->cfd = NULL; + if (!rc) + rc = psmStage(psm, PSM_PKGCOMMIT); +#endif if (rc) { /* @@ -1660,8 +1672,14 @@ psm->stepName = " install"; goto exit; } +#ifdef DYING if (rpmdbAdd(ts->rpmdb, ts->id, fi->h)) goto exit; +#else + rc = psmStage(psm, PSM_RPMDB_ADD); + if (rc) + goto exit; +#endif psm->scriptTag = RPMTAG_POSTIN; psm->progTag = RPMTAG_POSTINPROG; @@ -1716,6 +1734,7 @@ assert(fi->type == TR_REMOVED); goto exit; } +#ifndef DYING { rpmdbMatchIterator mi = NULL; Header h; @@ -1731,6 +1750,13 @@ assert(fi->type == TR_REMOVED); fi->h = headerLink(h); rpmdbFreeIterator(mi); } +#else + rc = psmStage(psm, PSM_RPMDB_LOAD); + if (rc) { + rc = 2; + goto exit; + } +#endif psm->scriptTag = RPMTAG_PREUN; psm->progTag = RPMTAG_PREUNPROG; @@ -1757,6 +1783,7 @@ assert(fi->type == TR_REMOVED); goto exit; } +#ifndef DYING if (fi->fc > 0 && !(ts->transFlags & RPMTRANS_FLAG_JUSTDB)) { const void * pkgKey = NULL; @@ -1772,6 +1799,9 @@ assert(fi->type == TR_REMOVED); (void)ts->notify(fi->h, RPMCALLBACK_UNINST_STOP, 0, fi->fc, pkgKey, ts->notifyData); } +#else + rc = psmStage(psm, PSM_PKGERASE); +#endif /* XXX WTFO? erase failures are not cause for stopping. */ psm->scriptTag = RPMTAG_POSTUN; @@ -1793,8 +1823,13 @@ exit: /* Restore root directory if changed. */ (void) psmStage(psm, PSM_CHROOT_OUT); +#ifndef DYING if (!rc && !(ts->transFlags & RPMTRANS_FLAG_TEST)) rpmdbRemove(ts->rpmdb, ts->id, fi->record); +#else + if (!rc) + (void) psmStage(psm, PSM_RPMDB_REMOVE); +#endif if (fi->h) { headerFree(fi->h); @@ -1813,7 +1848,6 @@ int repackage(PSM_t psm) FD_t fd = NULL; const char * pkgURL = NULL; const char * pkgfn = NULL; - Header h = NULL; Header oh = NULL; int saveerrno; int rc = 0; @@ -1823,7 +1857,9 @@ psm->stepName = " save"; assert(fi->type == TR_REMOVED); /* Retrieve installed header. */ +#ifdef DYING { rpmdbMatchIterator mi = NULL; + Header h; mi = rpmdbInitIterator(ts->rpmdb, RPMDBI_PACKAGES, &fi->record, sizeof(fi->record)); @@ -1834,27 +1870,34 @@ assert(fi->type == TR_REMOVED); rc = 2; goto exit; } - h = headerLink(h); + fi->h = headerLink(h); rpmdbFreeIterator(mi); } +#else + rc = psmStage(psm, PSM_RPMDB_LOAD); + if (rc) { + rc = 2; + goto exit; + } +#endif /* Regenerate original header. */ { void * uh = NULL; int_32 uht, uhc; HFD_t hfd = fi->hfd; - if (headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, &uh, &uhc)) { + if (headerGetEntry(fi->h, RPMTAG_HEADERIMMUTABLE, &uht, &uh, &uhc)) { oh = headerCopyLoad(uh); uh = hfd(uh, uht); } else { - oh = headerLink(h); + oh = headerLink(fi->h); } } /* Open output package for writing. */ { const char * bfmt = rpmGetPath("%{_repackage_name_fmt}", NULL); const char * pkgbn = - headerSprintf(h, bfmt, rpmTagTable, rpmHeaderFormats, NULL); + headerSprintf(fi->h, bfmt, rpmTagTable, rpmHeaderFormats, NULL); bfmt = _free(bfmt); pkgURL = rpmGenPath( "%{?_repackage_root:%{_repackage_root}}", @@ -1870,10 +1913,11 @@ assert(fi->type == TR_REMOVED); } /* Retrieve type of payload compression. */ +#ifndef DYING { const char * payload_compressor = NULL; char * t; - if (!hge(h, RPMTAG_PAYLOADCOMPRESSOR, NULL, + if (!hge(fi->h, RPMTAG_PAYLOADCOMPRESSOR, NULL, (void **) &payload_compressor, NULL)) payload_compressor = "gzip"; psm->rpmio_flags = t = xmalloc(sizeof("w9.gzdio")); @@ -1883,6 +1927,9 @@ assert(fi->type == TR_REMOVED); if (!strcmp(payload_compressor, "bzip2")) t = stpcpy(t, ".bzdio"); } +#else + rc = psmStage(psm, PSM_RPMIO_FLAGS); +#endif /* Write the lead section into the package. */ { int archnum = -1; @@ -1918,7 +1965,7 @@ assert(fi->type == TR_REMOVED); } /* Write the signature section into the package. */ - { Header sig = headerRegenSigHeader(h); + { Header sig = headerRegenSigHeader(fi->h); rc = rpmWriteSignature(fd, sig); headerFree(sig); if (rc) goto exit; @@ -1932,6 +1979,7 @@ assert(fi->type == TR_REMOVED); (void) psmStage(psm, PSM_CHROOT_IN); /* Write the payload into the package. */ +#ifdef DYING { fileAction * actions = fi->actions; fileAction action = fi->action; @@ -1953,12 +2001,24 @@ assert(fi->type == TR_REMOVED); fi->action = action; fi->actions = actions; } +#else + Fflush(fd); + psm->cfd = Fdopen(fdDup(Fileno(fd)), psm->rpmio_flags); + rc = psmStage(psm, PSM_PKGSAVE); + saveerrno = errno; /* XXX FIXME: Fclose with libio destroys errno */ + Fclose(psm->cfd); + errno = saveerrno; + psm->cfd = NULL; +#endif exit: /* Restore root directory if changed. */ (void) psmStage(psm, PSM_CHROOT_OUT); - if (h) headerFree(h); + if (fi->h) { + headerFree(fi->h); + fi->h = NULL; + } if (oh) headerFree(oh); if (fd) { saveerrno = errno; /* XXX FIXME: Fclose with libio destroys errno */ diff --git a/po/rpm.pot b/po/rpm.pot index e33b2b2..ad52f3e 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-03-01 10:52-0500\n" +"POT-Creation-Date: 2001-03-01 11:57-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1808,7 +1808,7 @@ msgstr "" msgid "Could not open %s: %s\n" msgstr "" -#: build/pack.c:484 lib/psm.c:1913 +#: build/pack.c:484 lib/psm.c:1960 #, c-format msgid "Unable to write package: %s\n" msgstr "" @@ -1838,7 +1838,7 @@ msgstr "" msgid "Unable to write payload to %s: %s\n" msgstr "" -#: build/pack.c:566 lib/psm.c:1970 +#: build/pack.c:566 lib/psm.c:2030 #, c-format msgid "Wrote: %s\n" msgstr "" @@ -2894,58 +2894,58 @@ msgstr "" #. * was used up - if so, we should return a different error. #. #. XXX FIXME: Fclose with libio destroys errno -#: lib/psm.c:615 +#: lib/psm.c:627 #, c-format msgid "unpacking of archive failed%s%s: %s\n" msgstr "" -#: lib/psm.c:616 +#: lib/psm.c:628 msgid " on file " msgstr "" -#: lib/psm.c:659 +#: lib/psm.c:671 #, c-format msgid "cannot create %s %s\n" msgstr "" -#: lib/psm.c:665 +#: lib/psm.c:677 #, c-format msgid "cannot write to %s\n" msgstr "" -#: lib/psm.c:687 +#: lib/psm.c:699 msgid "installing a source package\n" msgstr "" -#: lib/psm.c:737 +#: lib/psm.c:749 msgid "source package contains no .spec file\n" msgstr "" -#: lib/psm.c:824 +#: lib/psm.c:836 msgid "source package expected, binary found\n" msgstr "" -#: lib/psm.c:1094 +#: lib/psm.c:1106 #, c-format msgid "execution of %s scriptlet from %s-%s-%s failed, waitpid returned %s\n" msgstr "" -#: lib/psm.c:1101 +#: lib/psm.c:1113 #, c-format msgid "execution of %s scriptlet from %s-%s-%s failed, exit status %d\n" msgstr "" -#: lib/psm.c:1462 +#: lib/psm.c:1474 #, c-format msgid "%s: running %s script(s) (if any)\n" msgstr "" -#: lib/psm.c:1536 lib/psm.c:1704 +#: lib/psm.c:1548 lib/psm.c:1722 #, c-format msgid "%s: %s-%s-%s has %d files, test = %d\n" msgstr "" -#: lib/psm.c:1605 +#: lib/psm.c:1617 msgid "skipping %s-%s-%s install, %%pre scriptlet failed rc %d\n" msgstr "" -- 2.7.4