From b9d34b53886e24ece6cd7fc1b746862a672e3ab0f4a6c2e2692033440d62ff1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Tue, 5 Dec 2017 12:33:01 +0000 Subject: [PATCH] backport some fixes OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=421 --- editdwarf.diff | 20 +++++ hardlink.diff | 156 ++++++++++++++++++++++++++++++++++++ rofs.diff | 15 ++++ rpm.changes | 5 ++ rpm.spec | 6 +- transfiletriggerpostun.diff | 21 +++++ 6 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 editdwarf.diff create mode 100644 hardlink.diff create mode 100644 rofs.diff create mode 100644 transfiletriggerpostun.diff diff --git a/editdwarf.diff b/editdwarf.diff new file mode 100644 index 0000000..8451921 --- /dev/null +++ b/editdwarf.diff @@ -0,0 +1,20 @@ +debugedit: edit_dwarf2 check lndx is in range before checking r_offset. + +upstream commit 7e9af0c000868ad6272a9577f9daed991599419b +--- ./tools/debugedit.c.orig 2017-12-05 11:59:10.287010024 +0000 ++++ ./tools/debugedit.c 2017-12-05 12:00:02.776862694 +0000 +@@ -2171,10 +2171,10 @@ edit_dwarf2 (DSO *dso) + r_offset = rel.r_offset; + } + +- while (r_offset > (dso->lines.table[lndx].old_idx +- + 4 +- + dso->lines.table[lndx].unit_length) +- && lndx < dso->lines.used) ++ while (lndx < dso->lines.used ++ && r_offset > (dso->lines.table[lndx].old_idx ++ + 4 ++ + dso->lines.table[lndx].unit_length)) + lndx++; + + if (lndx >= dso->lines.used) diff --git a/hardlink.diff b/hardlink.diff new file mode 100644 index 0000000..3e1e057 --- /dev/null +++ b/hardlink.diff @@ -0,0 +1,156 @@ +Create first hard link file and keep open, write it at end + +upstream commit e276991614fd127f21aba94946f81f22cb7e6b73 +upstream commit 0afe0c3c6cba64d8b7adcdec6ed70f8d32961b58 +upstream commit ef3ff412c33a71be6b3543a50c244377dff3d9e7 +--- ./lib/fsm.c.orig 2017-10-05 10:04:56.977602149 +0000 ++++ ./lib/fsm.c 2017-12-05 12:05:19.529973029 +0000 +@@ -218,56 +218,76 @@ static int linkSane(FD_t wfd, const char + sb.st_dev == lsb.st_dev && sb.st_ino == lsb.st_ino); + } + +-/** \ingroup payload +- * Create file from payload stream. +- * @return 0 on success +- */ +-static int expandRegular(rpmfi fi, const char *dest, rpmpsm psm, int exclusive, int nodigest, int nocontent) ++static void wfd_close(FD_t *wfdp) + { +- FD_t wfd = NULL; +- int rc = 0; ++ if (wfdp && *wfdp) { ++ int myerrno = errno; ++ static int oneshot = 0; ++ static int flush_io = 0; ++ if (!oneshot) { ++ flush_io = rpmExpandNumeric("%{?_flush_io}"); ++ oneshot = 1; ++ } ++ if (flush_io) { ++ int fdno = Fileno(*wfdp); ++ fsync(fdno); ++ } ++ Fclose(*wfdp); ++ *wfdp = NULL; ++ errno = myerrno; ++ } ++} + ++static int wfd_open(FD_t *wfdp, const char *dest, int exclusive) ++{ ++ int rc = 0; + /* Create the file with 0200 permissions (write by owner). */ + { + mode_t old_umask = umask(0577); +- wfd = Fopen(dest, exclusive ? "wx.ufdio" : "a.ufdio"); ++ *wfdp = Fopen(dest, exclusive ? "wx.ufdio" : "a.ufdio"); + umask(old_umask); + + /* If reopening, make sure the file is what we expect */ +- if (!exclusive && wfd != NULL && !linkSane(wfd, dest)) { ++ if (!exclusive && *wfdp != NULL && !linkSane(*wfdp, dest)) { + rc = RPMERR_OPEN_FAILED; + goto exit; + } + } +- if (Ferror(wfd)) { ++ if (Ferror(*wfdp)) { + rc = RPMERR_OPEN_FAILED; + goto exit; + } + ++ return 0; ++ ++exit: ++ wfd_close(wfdp); ++ return rc; ++} ++ ++/** \ingroup payload ++ * Create file from payload stream. ++ * @return 0 on success ++ */ ++static int expandRegular(rpmfi fi, const char *dest, rpmpsm psm, int exclusive, int nodigest, int nocontent) ++{ ++ FD_t wfd = NULL; ++ int rc; ++ ++ rc = wfd_open(&wfd, dest, exclusive); ++ if (rc != 0) ++ goto exit; ++ + if (!nocontent) + rc = rpmfiArchiveReadToFilePsm(fi, wfd, nodigest, psm); ++ wfd_close(&wfd); + exit: +- if (wfd) { +- int myerrno = errno; +- static int oneshot = 0; +- static int flush_io = 0; +- if (!oneshot) { +- flush_io = rpmExpandNumeric("%{?_flush_io}"); +- oneshot = 1; +- } +- if (flush_io) { +- int fdno = Fileno(wfd); +- fsync(fdno); +- } +- Fclose(wfd); +- errno = myerrno; +- } + return rc; + } + + static int fsmMkfile(rpmfi fi, const char *dest, rpmfiles files, + rpmpsm psm, int nodigest, int *setmeta, +- int * firsthardlink) ++ int * firsthardlink, FD_t *firstlinkfile) + { + int rc = 0; + int numHardlinks = rpmfiFNlink(fi); +@@ -276,7 +296,7 @@ static int fsmMkfile(rpmfi fi, const cha + /* Create first hardlinked file empty */ + if (*firsthardlink < 0) { + *firsthardlink = rpmfiFX(fi); +- rc = expandRegular(fi, dest, psm, 1, nodigest, 1); ++ rc = wfd_open(firstlinkfile, dest, 1); + } else { + /* Create hard links for others */ + char *fn = rpmfilesFN(files, *firsthardlink); +@@ -294,7 +314,8 @@ static int fsmMkfile(rpmfi fi, const cha + rc = expandRegular(fi, dest, psm, 1, nodigest, 0); + } else if (rpmfiArchiveHasContent(fi)) { + if (!rc) +- rc = expandRegular(fi, dest, psm, 0, nodigest, 0); ++ rc = rpmfiArchiveReadToFilePsm(fi, *firstlinkfile, nodigest, psm); ++ wfd_close(firstlinkfile); + *firsthardlink = -1; + } else { + *setmeta = 0; +@@ -861,6 +882,7 @@ int rpmPackageFilesInstall(rpmts ts, rpm + int nodigest = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOFILEDIGEST) ? 1 : 0; + int nofcaps = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCAPS) ? 1 : 0; + int firsthardlink = -1; ++ FD_t firstlinkfile = NULL; + int skip; + rpmFileAction action; + char *tid = NULL; +@@ -932,7 +954,7 @@ int rpmPackageFilesInstall(rpmts ts, rpm + if (S_ISREG(sb.st_mode)) { + if (rc == RPMERR_ENOENT) { + rc = fsmMkfile(fi, fpath, files, psm, nodigest, +- &setmeta, &firsthardlink); ++ &setmeta, &firsthardlink, &firstlinkfile); + } + } else if (S_ISDIR(sb.st_mode)) { + if (rc == RPMERR_ENOENT) { +@@ -970,7 +992,8 @@ int rpmPackageFilesInstall(rpmts ts, rpm + /* we skip the hard linked file containing the content */ + /* write the content to the first used instead */ + char *fn = rpmfilesFN(files, firsthardlink); +- rc = expandRegular(fi, fn, psm, 0, nodigest, 0); ++ rc = rpmfiArchiveReadToFilePsm(fi, firstlinkfile, nodigest, psm); ++ wfd_close(&firstlinkfile); + firsthardlink = -1; + free(fn); + } diff --git a/rofs.diff b/rofs.diff new file mode 100644 index 0000000..c08abb2 --- /dev/null +++ b/rofs.diff @@ -0,0 +1,15 @@ +Don't bother retrying locking on read-only filesystem (RhBug:1502134) + +upstream commit f25752a8cd6b161f3002dc7839242872ecb59547 +--- ./lib/rpmlock.c.orig 2017-08-10 08:08:07.122108699 +0000 ++++ ./lib/rpmlock.c 2017-12-05 12:02:26.248459858 +0000 +@@ -30,7 +30,8 @@ static rpmlock rpmlock_new(const char *l + (void) umask(oldmask); + + if (lock->fd == -1) { +- lock->fd = open(lock_path, O_RDONLY); ++ if (errno != EROFS) ++ lock->fd = open(lock_path, O_RDONLY); + if (lock->fd == -1) { + free(lock); + lock = NULL; diff --git a/rpm.changes b/rpm.changes index 3a7e3a6..ef91303 100644 --- a/rpm.changes +++ b/rpm.changes @@ -21,6 +21,11 @@ Fri Dec 1 17:15:13 CET 2017 - mls@suse.de * perlprov.diff * python3-abi-kind.diff * rpmrctests.diff +- new patches (backports from master): + * editdwarf.diff + * rofs.diff + * transfiletriggerpostun.diff + * hardlink.diff ------------------------------------------------------------------- Thu Nov 23 13:41:13 UTC 2017 - rbrown@suse.com diff --git a/rpm.spec b/rpm.spec index 03ce64a..5cb610c 100644 --- a/rpm.spec +++ b/rpm.spec @@ -127,6 +127,10 @@ Patch99: enable-postin-scripts-error.diff Patch100: rpm-findlang-inject-metainfo.patch Patch102: emptymanifest.diff Patch103: find-lang-qt-qm.patch +Patch104: editdwarf.diff +Patch105: rofs.diff +Patch106: transfiletriggerpostun.diff +Patch107: hardlink.diff Patch6464: auto-config-update-aarch64-ppc64le.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build # @@ -222,7 +226,7 @@ rm -f rpmdb/db.h %patch -P 70 -P 71 -P 73 -P 74 -P 75 -P 77 -P 78 %patch -P 85 %patch -P 93 -P 94 -P 99 -%patch -P 100 -P 102 -P 103 +%patch -P 100 -P 102 -P 103 -P 104 -P 105 -P 106 -P 107 %ifarch aarch64 ppc64le %patch6464 diff --git a/transfiletriggerpostun.diff b/transfiletriggerpostun.diff new file mode 100644 index 0000000..652737f --- /dev/null +++ b/transfiletriggerpostun.diff @@ -0,0 +1,21 @@ +Fix not all %transfiletriggerpostun triggers executing (RhBug:1514085) + +upstream commit db1b99db2543b2c2526a2e116daeffa0498d5de4 +--- ./lib/rpmtriggers.c.orig 2017-10-05 10:04:57.121602122 +0000 ++++ ./lib/rpmtriggers.c 2017-12-05 12:04:35.448096904 +0000 +@@ -106,7 +106,6 @@ void rpmtriggersPrepPostUnTransFileTrigs + rpmfiles files; + rpmds rpmdsTriggers; + rpmds rpmdsTrigger; +- int tix = 0; + + ii = rpmdbIndexIteratorInit(rpmtsGetRdb(ts), RPMDBI_TRANSFILETRIGGERNAME); + mi = rpmdbNewIterator(rpmtsGetRdb(ts), RPMDBI_PACKAGES); +@@ -131,6 +130,7 @@ void rpmtriggersPrepPostUnTransFileTrigs + if (rpmdbGetIteratorCount(mi)) { + /* Filter triggers and save only trans postun triggers into ts */ + while ((trigH = rpmdbNextIterator(mi)) != NULL) { ++ int tix = 0; + rpmdsTriggers = rpmdsNew(trigH, RPMTAG_TRANSFILETRIGGERNAME, 0); + while ((rpmdsTrigger = rpmdsFilterTi(rpmdsTriggers, tix))) { + if ((rpmdsNext(rpmdsTrigger) >= 0) &&