From 46c6a5d9065615935146896c0868eae1bb1f7d80 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Aug 09 2007 13:28:17 +0000 Subject: - avoid unnecessary .rpmsave / .rpmnew files by Tomas Mraz (#29470, #128622) - stricter docdir checking by Ralf S. Engelschall (#246819) - add lua license to docs --- diff --git a/rpm-4.4.2.1-config-mtime.patch b/rpm-4.4.2.1-config-mtime.patch new file mode 100644 index 0000000..4c15d2f --- /dev/null +++ b/rpm-4.4.2.1-config-mtime.patch @@ -0,0 +1,121 @@ +changeset: 6235:0d4b8cfd8dc9 +tag: tip +user: Panu Matilainen +date: Thu Aug 09 15:15:24 2007 +0300 +files: lib/rpmfi.c lib/rpmfi.h lib/transaction.c +description: +Avoid unnecessary .rpmnew and .rpmsave files (rhbz#128622) +Don't create .rpmnew and .rpmsave files when file/symlink on disk differs +just by timestamp. Patch by Tomas Mraz. + + +diff -r debbc872bbb3 -r 0d4b8cfd8dc9 lib/rpmfi.c +--- a/lib/rpmfi.c Thu Aug 09 14:18:11 2007 +0300 ++++ b/lib/rpmfi.c Thu Aug 09 15:15:24 2007 +0300 +@@ -22,6 +22,7 @@ + #include "rpmte.h" + #include "rpmts.h" + ++#include "legacy.h" /* XXX domd5 */ + #include "misc.h" /* XXX stripTrailingChar */ + #include "rpmmacro.h" /* XXX rpmCleanPath */ + #include "legacy.h" +@@ -625,6 +626,49 @@ fileAction rpmfiDecideFate(const rpmfi o + * merge the difference ala CVS, but... + */ + return save; ++} ++/*@=boundsread@*/ ++ ++/*@-boundsread@*/ ++int rpmfiConfigConflict(const rpmfi fi) ++{ ++ const char * fn = rpmfiFN(fi); ++ int flags = rpmfiFFlags(fi); ++ char buffer[1024]; ++ fileTypes newWhat, diskWhat; ++ struct stat sb; ++ ++ if (!(flags & RPMFILE_CONFIG) || lstat(fn, &sb)) { ++ return 0; ++ } ++ ++ diskWhat = whatis((int_16)sb.st_mode); ++ newWhat = whatis(rpmfiFMode(fi)); ++ ++ if (newWhat != LINK && newWhat != REG) ++ return 1; ++ ++ if (diskWhat != newWhat) ++ return 1; ++ ++ memset(buffer, 0, sizeof(buffer)); ++ if (newWhat == REG) { ++ const unsigned char * nmd5; ++ if (domd5(fn, (unsigned char *)buffer, 0, NULL)) ++ return 0; /* assume file has been removed */ ++ nmd5 = rpmfiMD5(fi); ++ if (nmd5 && !memcmp(nmd5, buffer, 16)) ++ return 0; /* unmodified config file */ ++ } else /* newWhat == LINK */ { ++ const char * nFLink; ++ if (readlink(fn, buffer, sizeof(buffer) - 1) == -1) ++ return 0; /* assume file has been removed */ ++ nFLink = rpmfiFLink(fi); ++ if (nFLink && !strcmp(nFLink, buffer)) ++ return 0; /* unmodified config file */ ++ } ++ ++ return 1; + } + /*@=boundsread@*/ + +diff -r debbc872bbb3 -r 0d4b8cfd8dc9 lib/rpmfi.h +--- a/lib/rpmfi.h Thu Aug 09 14:18:11 2007 +0300 ++++ b/lib/rpmfi.h Thu Aug 09 15:15:24 2007 +0300 +@@ -620,6 +620,14 @@ fileAction rpmfiDecideFate(const rpmfi o + /*@modifies nfi, fileSystem, internalState @*/; + + /** ++ * Return whether file is conflicting config ++ * @param fi file info ++ * @return 1 if config file and file on disk conflicts ++ */ ++int rpmfiConfigConflict(const rpmfi fi) ++ /*@*/; ++ ++/** + * Return formatted string representation of package disposition. + * @param fi file info set + * @return formatted string +diff -r debbc872bbb3 -r 0d4b8cfd8dc9 lib/transaction.c +--- a/lib/transaction.c Thu Aug 09 14:18:11 2007 +0300 ++++ b/lib/transaction.c Thu Aug 09 15:15:24 2007 +0300 +@@ -547,7 +547,7 @@ static void handleOverlappedFiles(const + /*@-boundswrite@*/ + switch (rpmteType(p)) { + case TR_ADDED: +- { struct stat sb; ++ { + int reportConflicts = + !(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACENEWFILES); + int done = 0; +@@ -556,7 +556,7 @@ static void handleOverlappedFiles(const + /* XXX is this test still necessary? */ + if (fi->actions[i] != FA_UNKNOWN) + /*@switchbreak@*/ break; +- if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) { ++ if (rpmfiConfigConflict(fi)) { + /* Here is a non-overlapped pre-existing config file. */ + fi->actions[i] = (FFlags & RPMFILE_NOREPLACE) + ? FA_ALTNAME : FA_BACKUP; +@@ -613,7 +613,7 @@ assert(otherFi != NULL); + /* Try to get the disk accounting correct even if a conflict. */ + fixupSize = rpmfiFSize(otherFi); + +- if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) { ++ if (rpmfiConfigConflict(fi)) { + /* Here is an overlapped pre-existing config file. */ + fi->actions[i] = (FFlags & RPMFILE_NOREPLACE) + ? FA_ALTNAME : FA_SKIP; + diff --git a/rpm-4.4.2.1-strict-docdir.patch b/rpm-4.4.2.1-strict-docdir.patch new file mode 100644 index 0000000..32b71ba --- /dev/null +++ b/rpm-4.4.2.1-strict-docdir.patch @@ -0,0 +1,26 @@ +diff -r e1802883bd62 -r cf3b54441b8a build/files.c +--- a/build/files.c Sat Jul 21 15:48:03 2007 +0300 ++++ b/build/files.c Mon Jul 23 10:02:54 2007 +0300 +@@ -1065,7 +1065,6 @@ static int compareFileListRecs(const voi + + /** + * Test if file is located in a %docdir. +- * @bug Use of strstr(3) might result in false positives. + * @param fl package file tree walk data + * @param fileName file path + * @return 1 if doc file, 0 if not +@@ -1073,9 +1072,12 @@ static int isDoc(FileList fl, const char + static int isDoc(FileList fl, const char * fileName) /*@*/ + { + int x = fl->docDirCount; +- ++ size_t k, l; ++ ++ k = strlen(fileName); + while (x--) { +- if (strstr(fileName, fl->docDirs[x]) == fileName) ++ l = strlen(fl->docDirs[x]); ++ if (l < k && strncmp(fileName, fl->docDirs[x], l) == 0 && fileName[l] == '/') + return 1; + } + return 0; diff --git a/rpm.spec b/rpm.spec index 682f6c3..3c97577 100644 --- a/rpm.spec +++ b/rpm.spec @@ -14,7 +14,7 @@ Summary: The RPM package management system Name: rpm Version: 4.4.2.1 %{expand: %%define rpm_version %{version}} -Release: 4%{?dist} +Release: 5%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source: rpm-%{rpm_version}.tar.gz @@ -32,6 +32,8 @@ Patch11: rpm-4.4.2.1-gnueabi.patch Patch12: rpm-4.4.2.1-arm-typos.patch Patch13: rpm-4.4.2.1-bdb-glibc.patch Patch14: rpm-4.4.2.1-rpm-glibc.patch +Patch15: rpm-4.4.2.1-config-mtime.patch +Patch16: rpm-4.4.2.1-strict-docdir.patch # XXX Beware, this is one murky license, partially GPL/LGPL dual-licensed # and several different components with their own licenses included... License: (GPLv2 and LGPLv2 with exceptions) and BSD and MIT and Sleepycat @@ -157,6 +159,8 @@ shell-like rules. %patch12 -p1 -b .armtypo %patch13 -p1 -b .bdb-glibc %patch14 -p1 -b .rpm-glibc +%patch15 -p1 -b .config-mtime +%patch16 -p1 -b .strict-docdir cp -f %{SOURCE2} scripts/find-debuginfo.sh %build @@ -235,6 +239,7 @@ done # copy db and file/libmagic license info to distinct names cp -p db/LICENSE LICENSE-bdb cp -p file/LEGAL.NOTICE LEGAL.NOTICE-file +cp -p lua/COPYRIGHT COPYRIGHT-lua # Get rid of unpackaged files { cd $RPM_BUILD_ROOT @@ -290,7 +295,7 @@ exit 0 %files -f %{name}.lang %defattr(-,root,root,-) %doc CHANGES GROUPS COPYING LICENSE-bdb LEGAL.NOTICE-file CREDITS ChangeLog -%doc doc/manual/[a-z]* +%doc COPYRIGHT-lua doc/manual/[a-z]* %attr(0755, rpm, rpm) /bin/rpm /etc/cron.daily/rpm @@ -460,6 +465,11 @@ exit 0 %{__includedir}/popt.h %changelog +* Thu Aug 9 2007 Panu Matilainen - 4.4.2.1-5 +- avoid unnecessary .rpmsave / .rpmnew files by Tomas Mraz (#29470, #128622) +- stricter docdir checking by Ralf S. Engelschall (#246819) +- add lua license to docs + * Thu Aug 9 2007 Panu Matilainen - 4.4.2.1-4 - fix new find-debuginfo.sh on noarch packages by Roland McGrath