From: jbj Date: Wed, 20 Jun 2001 06:29:20 +0000 (+0000) Subject: - fix: partial sets of hardlinked files forbidden in payload. X-Git-Tag: rpm-4.4-release~1510 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f2d9ab25b9339314ac318cf0f968fe03c31be97;p=platform%2Fupstream%2Frpm.git - fix: partial sets of hardlinked files forbidden in payload. - fix: mark rpmdb files with %config to prevent erasure on downgrade. CVS patchset: 4891 CVS date: 2001/06/20 06:29:20 --- diff --git a/CHANGES b/CHANGES index 1e5b2f7..6bc32ae 100644 --- a/CHANGES +++ b/CHANGES @@ -121,6 +121,9 @@ - preliminary abstraction to support per-header methods. - finalize per-header methods, accessing headerFoo through vector. - make package ordering loop messages debug, not warning. + - remove {ia64,sparc}-linux.{prov,req}, changes merged into linux.*. + - fix: partial sets of hardlinked files forbidden in payload. + - fix: mark rpmdb files with %config to prevent erasure on downgrade. 4.0 -> 4.0.[12] - add doxygen and lclint annotations most everywhere. diff --git a/build/pack.c b/build/pack.c index 1817068..6ebb7b9 100644 --- a/build/pack.c +++ b/build/pack.c @@ -56,7 +56,7 @@ static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t csa, const char *fmode = rpmExpand(fmodeMacro, NULL); const char *failedFile = NULL; FD_t cfd; - int rc; + int rc, ec; if (!(fmode && fmode[0] == 'w')) fmode = xstrdup("w9.gzdio"); @@ -70,11 +70,16 @@ static int cpio_doio(FD_t fdo, /*@unused@*/ Header h, CSA_t csa, rc = fsmSetup(fi->fsm, FSM_PKGBUILD, ts, fi, cfd, &csa->cpioArchiveSize, &failedFile); (void) Fclose(cfd); - (void) fsmTeardown(fi->fsm); + ec = fsmTeardown(fi->fsm); + if (!rc) rc = ec; if (rc) { - rpmError(RPMERR_CPIO, _("create archive failed on file %s: %s\n"), + if (failedFile) + rpmError(RPMERR_CPIO, _("create archive failed on file %s: %s\n"), failedFile, cpioStrerror(rc)); + else + rpmError(RPMERR_CPIO, _("create archive failed: %s\n"), + cpioStrerror(rc)); rc = 1; } diff --git a/lib/cpio.c b/lib/cpio.c index 7d73ec0..6fc8cb0 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -211,7 +211,7 @@ const char *const cpioStrerror(int rc) case CPIOERR_HDR_SIZE: s = _("Header size too big"); break; case CPIOERR_UNKNOWN_FILETYPE: s = _("Unknown file type"); break; - case CPIOERR_MISSING_HARDLINK: s = _("Missing hard link"); break; + case CPIOERR_MISSING_HARDLINK: s = _("Missing hard link(s)"); break; case CPIOERR_MD5SUM_MISMATCH: s = _("MD5 sum mismatch"); break; case CPIOERR_INTERNAL: s = _("Internal error"); break; } diff --git a/lib/fsm.c b/lib/fsm.c index 7b46250..51f8e8f 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -19,6 +19,8 @@ int _fsm_debug = 0; +static int all_hardlinks_in_package = 1; + /* XXX Failure to remove is not (yet) cause for failure. */ /*@-exportlocal -exportheadervar@*/ int strict_erasures = 0; @@ -383,10 +385,6 @@ static int saveHardLink(/*@special@*/ /*@partial@*/ FSM_t fsm) /*@=observertrans =dependenttrans@*/ if (fsm->goal == FSM_PKGINSTALL) fsm->li->linksLeft++; -#if 0 -fprintf(stderr, "*** %p link[%d:%d] %d filex %d %s\n", fsm->li, fsm->li->linksLeft, st->st_nlink, (int)st->st_size, fsm->li->filex[fsm->li->linksLeft], fsm->li->files[fsm->li->linksLeft]); -#endif - if (fsm->goal == FSM_PKGBUILD) return (fsm->li->linksLeft > 0); @@ -1260,8 +1258,20 @@ int fsmStage(FSM_t fsm, fileStage stage) /*@loopbreak@*/ break; } + /* Flush partial sets of hard linked files. */ + if (!all_hardlinks_in_package) { + while ((fsm->li = fsm->links) != NULL) { + fsm->links = fsm->li->next; + fsm->li->next = NULL; + if (!rc) + rc = writeLinkedFile(fsm); + fsm->li = freeHardLink(fsm->li); + } + } + if (!rc) rc = fsmStage(fsm, FSM_TRAILER); + break; case FSM_CREATE: { rpmTransactionSet ts = fsmGetTs(fsm); @@ -1644,11 +1654,12 @@ int fsmStage(FSM_t fsm, fileStage stage) case FSM_DESTROY: fsm->path = _free(fsm->path); - /* Create any remaining links (if no error), and clean up. */ + /* Check for hard links missing from payload. */ while ((fsm->li = fsm->links) != NULL) { fsm->links = fsm->li->next; fsm->li->next = NULL; - if (fsm->goal == FSM_PKGINSTALL && fsm->commit && fsm->li->linksLeft) + if (fsm->goal == FSM_PKGINSTALL && + fsm->commit && fsm->li->linksLeft) { for (i = 0 ; i < fsm->li->linksLeft; i++) { if (fsm->li->filex[i] < 0) continue; @@ -1663,9 +1674,9 @@ int fsmStage(FSM_t fsm, fileStage stage) /*@loopbreak@*/ break; } } - if (fsm->goal == FSM_PKGBUILD) { + if (fsm->goal == FSM_PKGBUILD && all_hardlinks_in_package) { rc = CPIOERR_MISSING_HARDLINK; - } + } fsm->li = freeHardLink(fsm->li); } fsm->ldn = _free(fsm->ldn); diff --git a/rpm.spec.in b/rpm.spec.in index c96ed17..ea8647d 100644 --- a/rpm.spec.in +++ b/rpm.spec.in @@ -80,9 +80,7 @@ build packages using RPM. %package python Summary: Python bindings for apps which will manipulate RPM packages. Group: Development/Libraries -BuildRequires: popt >= 1.5 Requires: rpm = %{version} -Requires: popt >= 1.5 Requires: python >= 1.5.2 %description python @@ -223,7 +221,6 @@ fi %endif %define rpmattr %attr(0755, @RPMUSER@, @RPMGROUP@) -%define rpmdbattr %rpmattr %ghost %config(missingok) %files %defattr(-,root,root) @@ -236,6 +233,8 @@ fi %dir /etc/rpm %config(noreplace,missingok) /etc/rpm/macros.db1 %attr(0755, @RPMUSER@, @RPMGROUP@) %dir /var/lib/rpm + +%define rpmdbattr %attr(0644, @RPMUSER@, @RPMGROUP@) %verify(not md5 size mtime) %ghost %config(missingok) %rpmdbattr /var/lib/rpm/Basenames %rpmdbattr /var/lib/rpm/Conflictname %rpmdbattr /var/lib/rpm/__db.001 @@ -251,6 +250,7 @@ fi %rpmdbattr /var/lib/rpm/Requirename %rpmdbattr /var/lib/rpm/Requireversion %rpmdbattr /var/lib/rpm/Triggername + %endif %rpmattr %{__prefix}/bin/rpm2cpio