SHA256
3
0
forked from pool/patch
OBS User unknown 2008-04-23 23:49:14 +00:00 committed by Git OBS Bridge
parent 3aeedafe31
commit ea52ba878c
4 changed files with 162 additions and 134 deletions

View File

@ -65,15 +65,13 @@ Index: patch-2.5.9/util.c
void void
move_file (char const *from, int volatile *from_needs_removal, move_file (char const *from, int volatile *from_needs_removal,
char *to, mode_t mode, bool backup) char *to, mode_t mode, bool backup)
@@ -164,6 +207,15 @@ move_file (char const *from, int volatil @@ -165,6 +208,13 @@ move_file (char const *from, int volatil
goto rename_succeeded; goto rename_succeeded;
} }
+ if (errno == EACCES && (s_is_chrblkfifosock(to) > 0)) + if (errno == EACCES && (s_is_chrblkfifosock(to) > 0))
+ { + {
+ cat_file_to_dev (from, to); + cat_file_to_dev (from, to);
+ if (backup)
+ insert_fid (to);
+ unlink(from); + unlink(from);
+ return; + return;
+ } + }

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Apr 23 10:53:19 CEST 2008 - agruen@suse.de
- remember-backup-files.diff: Fix bug when a file is touched by
the same patch more than twice. Move the test cases from the
patch header into separate files.
- patch-2.5.9-cat_if_device.diff: No need to remember the device
we write to as a backup file.
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Nov 2 01:57:03 CET 2007 - agruen@suse.de Fri Nov 2 01:57:03 CET 2007 - agruen@suse.de

View File

@ -1,7 +1,7 @@
# #
# spec file for package patch (Version 2.5.9) # spec file for package patch (Version 2.5.9)
# #
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine # This file and all modifications and additions to the pristine
# package are under the same license as the package itself. # package are under the same license as the package itself.
# #
@ -10,15 +10,16 @@
# norootforbuild # norootforbuild
Name: patch Name: patch
License: GPL v2 or later License: GPL v2 or later
Group: Productivity/Text/Utilities Group: Productivity/Text/Utilities
AutoReqProv: on AutoReqProv: on
Version: 2.5.9 Version: 2.5.9
Release: 223 Release: 252
Summary: GNU patch Summary: GNU patch
Source: ftp://prep.ai.mit.edu/pub/gnu/patch/%{name}-%{version}.tar.bz2 Source: ftp://prep.ai.mit.edu/pub/gnu/patch/%{name}-%{version}.tar.bz2
Url: http://www.gnu.org/software/patch/patch.html Url: ftp://alpha.gnu.org/gnu/diffutils/
Patch: trailing-cr-fix.diff Patch: trailing-cr-fix.diff
Patch1: remember-backup-files.diff Patch1: remember-backup-files.diff
Patch2: unified-reject-files.diff Patch2: unified-reject-files.diff
@ -73,57 +74,64 @@ make install \
%doc NEWS README %doc NEWS README
/usr/bin/patch /usr/bin/patch
%doc %{_mandir}/man1/patch.1.gz %doc %{_mandir}/man1/patch.1.gz
%changelog %changelog
* Fri Nov 02 2007 - agruen@suse.de * Wed Apr 23 2008 agruen@suse.de
- remember-backup-files.diff: Fix bug when a file is touched by
the same patch more than twice. Move the test cases from the
patch header into separate files.
- patch-2.5.9-cat_if_device.diff: No need to remember the device
we write to as a backup file.
* Fri Nov 02 2007 agruen@suse.de
- Patch fails to apply hunks with asymmetric context correctly. - Patch fails to apply hunks with asymmetric context correctly.
* Wed Jan 25 2006 - mls@suse.de * Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires - converted neededforbuild to BuildRequires
* Thu Jan 12 2006 - agruen@suse.de * Thu Jan 12 2006 agruen@suse.de
- remember-backup-files.diff: Fix case where a patch modifies a - remember-backup-files.diff: Fix case where a patch modifies a
read-only file more than once while --backup is used (test case read-only file more than once while --backup is used (test case
in the patch header). in the patch header).
* Thu Aug 18 2005 - mmj@suse.de * Thu Aug 18 2005 mmj@suse.de
- --reject-unified is called --unified-reject-files [#105151] - --reject-unified is called --unified-reject-files [#105151]
* Wed Jun 29 2005 - mmj@suse.de * Wed Jun 29 2005 mmj@suse.de
- Don't compile with -f-signed-char [#93883] - Don't compile with -f-signed-char [#93883]
- Don't strip explicitly - Don't strip explicitly
* Tue Jan 04 2005 - mmj@suse.de * Tue Jan 04 2005 mmj@suse.de
- Add patch to make patch able to write reject files to devices, - Add patch to make patch able to write reject files to devices,
named pipes and sockets [#45794] named pipes and sockets [#45794]
* Sun Jan 25 2004 - agruen@suse.de * Sun Jan 25 2004 agruen@suse.de
- Add --reject-unified option to produce unified reject files: - Add --reject-unified option to produce unified reject files:
Before, unified reject files were produced if the patch itself Before, unified reject files were produced if the patch itself
was unified; this could sometimes have been annoying. was unified; this could sometimes have been annoying.
- If a patch with C function names (diff -p) has rejects, include - If a patch with C function names (diff -p) has rejects, include
the function names in the reject files. the function names in the reject files.
* Sun Jan 11 2004 - adrian@suse.de * Sun Jan 11 2004 adrian@suse.de
- add %%defattr - add %%defattr
* Tue Oct 07 2003 - agruen@suse.de * Tue Oct 07 2003 agruen@suse.de
- remember-backup-files: Also include the file timestamps in the - remember-backup-files: Also include the file timestamps in the
hash table for non-POSIX-compliant systems that don't guarantee hash table for non-POSIX-compliant systems that don't guarantee
that i_dev + i_ino uniquely identifies a file. that i_dev + i_ino uniquely identifies a file.
- #32031: Create --global-reject-file even if --dry-run is - #32031: Create --global-reject-file even if --dry-run is
specified. Add a missing '\n'. specified. Add a missing '\n'.
* Wed Jul 16 2003 - agruen@suse.de * Wed Jul 16 2003 agruen@suse.de
- Replace trailing-cr-fix.diff with official upstream version that - Replace trailing-cr-fix.diff with official upstream version that
fixes this bug differently. fixes this bug differently.
* Mon Jun 30 2003 - agruen@suse.de * Mon Jun 30 2003 agruen@suse.de
- trailing-cr-fix.diff: Fix a bug in carriage return detection - trailing-cr-fix.diff: Fix a bug in carriage return detection
(DOS files) in the unified diff path. (DOS files) in the unified diff path.
- Disable patch that adds comments to C preprocessor style - Disable patch that adds comments to C preprocessor style
merges, as specified by POSIX.1-2001. merges, as specified by POSIX.1-2001.
* Wed Jun 25 2003 - agruen@suse.de * Wed Jun 25 2003 agruen@suse.de
- Fix bug introduced on June 5 that broke remember-backup-files. - Fix bug introduced on June 5 that broke remember-backup-files.
* Tue Jun 24 2003 - agruen@suse.de * Tue Jun 24 2003 agruen@suse.de
- smart-reject-file-format.diff: Work around a special case in - smart-reject-file-format.diff: Work around a special case in
which patches are not terminated with a '^' in the internal which patches are not terminated with a '^' in the internal
representation. The resulting error message was "internal error representation. The resulting error message was "internal error
in abort_hunk". in abort_hunk".
* Thu Jun 05 2003 - agruen@suse.de * Thu Jun 05 2003 agruen@suse.de
- Temporary reject file logic: Ooops, now must only close the - Temporary reject file logic: Ooops, now must only close the
temporary reject file after processing all patches, instead of temporary reject file after processing all patches, instead of
after each patch. after each patch.
* Thu Jun 05 2003 - agruen@suse.de * Thu Jun 05 2003 agruen@suse.de
- Upgrade to 2.5.9: Several fixes, obsoletes - Upgrade to 2.5.9: Several fixes, obsoletes
rename-same-file.patch. rename-same-file.patch.
- Fix and adapt global-reject-file patch: - Fix and adapt global-reject-file patch:
@ -142,11 +150,11 @@ make install \
tables instead of glibc's binary trees, requested from upstream tables instead of glibc's binary trees, requested from upstream
to ensure greater portability. to ensure greater portability.
- Add /* SYM */ comment to #endif lines for patch -D SYM, too. - Add /* SYM */ comment to #endif lines for patch -D SYM, too.
* Wed Apr 09 2003 - agruen@suse.de * Wed Apr 09 2003 agruen@suse.de
- Fix another bug with hard links and backup file generation. - Fix another bug with hard links and backup file generation.
- Fix backup file generation if the same file appears in the - Fix backup file generation if the same file appears in the
patch more than once. patch more than once.
* Wed Mar 26 2003 - mmj@suse.de * Wed Mar 26 2003 mmj@suse.de
- Update to 2.5.8: - Update to 2.5.8:
· Bugfixes · Bugfixes
· patch -D now outputs preprocessor lines without comments, as · patch -D now outputs preprocessor lines without comments, as
@ -156,37 +164,37 @@ make install \
from the time stamp from the time stamp
· Perforce is now supported · Perforce is now supported
· Patch lines beginning with "#" are comments and are ignored · Patch lines beginning with "#" are comments and are ignored
* Wed Jan 15 2003 - agruen@suse.de * Wed Jan 15 2003 agruen@suse.de
- Fix a bug with hardlinks (see rename-same-file.patch) - Fix a bug with hardlinks (see rename-same-file.patch)
* Tue Sep 17 2002 - ro@suse.de * Tue Sep 17 2002 ro@suse.de
- removed bogus self-provides - removed bogus self-provides
* Wed Feb 06 2002 - coolo@suse.de * Wed Feb 06 2002 coolo@suse.de
- called suse_update_config - called suse_update_config
* Mon Jun 25 2001 - uli@suse.de * Mon Jun 25 2001 uli@suse.de
- added patch adding "--global-reject" option by ak@suse.de - added patch adding "--global-reject" option by ak@suse.de
- bzipped tarball - bzipped tarball
* Tue Mar 06 2001 - bk@suse.de * Tue Mar 06 2001 bk@suse.de
- update to 2.5.4, added 2 patches from PLD and use buildroot - update to 2.5.4, added 2 patches from PLD and use buildroot
* Wed Nov 08 2000 - uli@suse.de * Wed Nov 08 2000 uli@suse.de
- now builds with -D_GNU_SOURCE, should avoid miscompilation that - now builds with -D_GNU_SOURCE, should avoid miscompilation that
breaks LFS support breaks LFS support
- added fix for offset output by Alessandro Rubini - added fix for offset output by Alessandro Rubini
- added fix and enhancement for --ifdef by Pete Buechler - added fix and enhancement for --ifdef by Pete Buechler
* Sun Feb 27 2000 - @suse.de * Sun Feb 27 2000 @suse.de
- added missing CFLAGS quotes. - added missing CFLAGS quotes.
* Sun Feb 27 2000 - bk@suse.de * Sun Feb 27 2000 bk@suse.de
- added PPC fixes by Uli back again (-fsigned-char, CPPFLAGS) - added PPC fixes by Uli back again (-fsigned-char, CPPFLAGS)
* Fri Feb 25 2000 - schwab@suse.de * Fri Feb 25 2000 schwab@suse.de
- Specfile cleanup, get rid of Makefile.Linux - Specfile cleanup, get rid of Makefile.Linux
- /usr/man -> /usr/share/man - /usr/man -> /usr/share/man
- Add group tag. - Add group tag.
* Mon Sep 13 1999 - bs@suse.de * Mon Sep 13 1999 bs@suse.de
- ran old prepare_spec on spec file to switch to new prepare_spec. - ran old prepare_spec on spec file to switch to new prepare_spec.
* Wed Aug 18 1999 - uli@suse.de * Wed Aug 18 1999 uli@suse.de
- fixed for PPC (-fsigned-char, CPPFLAGS) - fixed for PPC (-fsigned-char, CPPFLAGS)
* Tue Mar 16 1999 - ro@suse.de * Tue Mar 16 1999 ro@suse.de
- update to 2.5.3 using diff from jurix - update to 2.5.3 using diff from jurix
* Wed Jan 13 1999 - bs@suse.de * Wed Jan 13 1999 bs@suse.de
- applied patch from Egbert Eich (problems with non existing files fixed) - applied patch from Egbert Eich (problems with non existing files fixed)
* Thu Nov 05 1998 - ro@suse.de * Thu Nov 05 1998 ro@suse.de
- use libc's basename() for glibc - use libc's basename() for glibc

View File

@ -1,81 +1,6 @@
This patch remembers backup file names patch has already created This patch remembers backup file names patch has already created
in a binary tree, and prevents patch from overwriting backup in a binary tree, and prevents patch from overwriting backup
files it has created before. The bug can be reproduced as follows: files it has created before.
$ cat > f
< one
$ cat > f.patch
<--- f.orig 2003-04-09 01:48:01.000000000 +0200
<+++ f 2003-04-09 01:49:17.000000000 +0200
<@@ -2 +2 @@
<-one
<+two
<--- f.orig 2003-04-09 01:48:01.000000000 +0200
<+++ f 2003-04-09 01:49:17.000000000 +0200
<@@ -2 +2 @@
<-two
<+three
$ patch -p0 < f.patch
> patching file f
> Hunk #1 succeeded at 1 (offset -1 lines).
> patching file f
> Hunk #1 succeeded at 1 (offset -1 lines).
$ cat f.orig
> one
$ rm f f.orig f.patch
Here is another test case with hard links between source files.
$ cat > f
< one
$ ln f g
$ cat > fg.patch
<--- f.orig 2003-04-09 01:48:01.000000000 +0200
<+++ f 2003-04-09 01:49:17.000000000 +0200
<@@ -2 +2 @@
<-one
<+two
<--- g.orig 2003-04-09 01:48:01.000000000 +0200
<+++ g 2003-04-09 01:49:17.000000000 +0200
<@@ -2 +2 @@
<-one
<+two
$ patch -p0 < fg.patch
> patching file f
> Hunk #1 succeeded at 1 (offset -1 lines).
> patching file g
> Hunk #1 succeeded at 1 (offset -1 lines).
$ cat f.orig
> one
$ cat g.orig
> one
$ rm f f.orig g g.orig fg.patch
This test case failed with a Permission denied error with a previous
version of this patch:
$ echo 1 > f
$ echo 2 > f.new
$ diff -Nu f f.new > f.diff
$ mv f.new f
$ echo 3 > f.new
$ diff -Nu f f.new >> f.diff
$ rm f.new
$ echo 1 > f
$ chmod a=r f
$ strace -o ../log patch -p0 --backup < f.diff
> patching file f
> patching file f
Index: patch-2.5.9/Makefile.in Index: patch-2.5.9/Makefile.in
=================================================================== ===================================================================
@ -161,16 +86,17 @@ Index: patch-2.5.9/util.c
/* Move a file FROM (where *FROM_NEEDS_REMOVAL is nonzero if FROM /* Move a file FROM (where *FROM_NEEDS_REMOVAL is nonzero if FROM
needs removal when cleaning up at the end of execution) needs removal when cleaning up at the end of execution)
@@ -64,7 +72,7 @@ move_file (char const *from, int volatil @@ -64,6 +72,9 @@ move_file (char const *from, int volatil
struct stat to_st; struct stat to_st;
int to_errno = ! backup ? -1 : stat (to, &to_st) == 0 ? 0 : errno; int to_errno = ! backup ? -1 : stat (to, &to_st) == 0 ? 0 : errno;
- if (backup) + if (backup && ! to_errno && fid_exists (to, &to_st))
+ if (backup && (to_errno || ! fid_exists (to, &to_st))) + backup = false;
+
if (backup)
{ {
int try_makedirs_errno = 0; int try_makedirs_errno = 0;
char *bakname; @@ -123,6 +134,7 @@ move_file (char const *from, int volatil
@@ -123,6 +131,7 @@ move_file (char const *from, int volatil
quotearg_n (0, to), quotearg_n (1, bakname)); quotearg_n (0, to), quotearg_n (1, bakname));
while (rename (to, bakname) != 0) while (rename (to, bakname) != 0)
{ {
@ -178,34 +104,23 @@ Index: patch-2.5.9/util.c
if (errno != try_makedirs_errno) if (errno != try_makedirs_errno)
pfatal ("Can't rename file %s to %s", pfatal ("Can't rename file %s to %s",
quotearg_n (0, to), quotearg_n (1, bakname)); quotearg_n (0, to), quotearg_n (1, bakname));
@@ -133,6 +142,8 @@ move_file (char const *from, int volatil @@ -165,6 +177,7 @@ move_file (char const *from, int volatil
free (bakname);
}
+ else
+ backup = false;
if (from)
{
@@ -165,6 +176,8 @@ move_file (char const *from, int volatil
if (! to_dir_known_to_exist) if (! to_dir_known_to_exist)
makedirs (to); makedirs (to);
copy_file (from, to, 0, mode); copy_file (from, to, 0, mode);
+ if (backup) + insert_fid (to);
+ insert_fid (to);
return; return;
} }
@@ -173,6 +186,8 @@ move_file (char const *from, int volatil @@ -173,6 +186,7 @@ move_file (char const *from, int volatil
} }
rename_succeeded: rename_succeeded:
+ if (backup) + insert_fid (to);
+ insert_fid (to);
/* Do not clear *FROM_NEEDS_REMOVAL if it's possible that the /* Do not clear *FROM_NEEDS_REMOVAL if it's possible that the
rename returned zero because FROM and TO are hard links to rename returned zero because FROM and TO are hard links to
the same file. */ the same file. */
@@ -1011,3 +1026,105 @@ Fseek (FILE *stream, file_offset offset, @@ -1011,3 +1025,105 @@ Fseek (FILE *stream, file_offset offset,
if (file_seek (stream, offset, ptrname) != 0) if (file_seek (stream, offset, ptrname) != 0)
pfatal ("fseek"); pfatal ("fseek");
} }
@ -1505,3 +1420,101 @@ Index: patch-2.5.9/m4/nanosecond_stat.m4
+ if test $ac_cv_stat_timeval = yes; then + if test $ac_cv_stat_timeval = yes; then
+ AC_DEFINE(HAVE_STAT_TIMEVAL, 1, [Define to 1 if struct stat comtains struct timeval's.]) + AC_DEFINE(HAVE_STAT_TIMEVAL, 1, [Define to 1 if struct stat comtains struct timeval's.])
+ fi]) + fi])
Index: patch-2.5.9/remember-tests/hardlinks.test
===================================================================
--- /dev/null
+++ patch-2.5.9/remember-tests/hardlinks.test
@@ -0,0 +1,31 @@
+Test case with hard links between source files.
+
+$ cat > f
+< one
+
+$ ln f g
+$ cat > fg.patch
+<--- f.orig
+<+++ f
+<@@ -2 +2 @@
+<-one
+<+two
+<--- g.orig
+<+++ g
+<@@ -2 +2 @@
+<-one
+<+two
+
+$ ../patch -p0 < fg.patch
+> patching file f
+> Hunk #1 succeeded at 1 (offset -1 lines).
+> patching file g
+> Hunk #1 succeeded at 1 (offset -1 lines).
+
+$ cat f.orig
+> one
+
+$ cat g.orig
+> one
+
+$ rm f f.orig g g.orig fg.patch
Index: patch-2.5.9/remember-tests/multi-modify.test
===================================================================
--- /dev/null
+++ patch-2.5.9/remember-tests/multi-modify.test
@@ -0,0 +1,35 @@
+A patch that modifies the same file three times. An unpatched version of
+GNU patch will destroy the backup file.
+
+$ cat > f
+< one
+
+$ cat > f.patch
+<--- f.orig
+<+++ f
+<@@ -2 +2 @@
+<-one
+<+two
+<--- f.orig
+<+++ f
+<@@ -2 +2 @@
+<-two
+<+three
+<--- f.orig
+<+++ f
+<@@ -2 +2 @@
+<-three
+<+four
+
+$ ../patch -p0 < f.patch
+> patching file f
+> Hunk #1 succeeded at 1 (offset -1 lines).
+> patching file f
+> Hunk #1 succeeded at 1 (offset -1 lines).
+> patching file f
+> Hunk #1 succeeded at 1 (offset -1 lines).
+
+$ cat f.orig
+> one
+
+$ rm f f.orig f.patch
Index: patch-2.5.9/remember-tests/permission.test
===================================================================
--- /dev/null
+++ patch-2.5.9/remember-tests/permission.test
@@ -0,0 +1,17 @@
+This test case failed with a Permission denied error with a previous
+version of this patch.
+
+$ echo 1 > f
+$ echo 2 > f.new
+$ diff -Nu f f.new > f.diff
+$ mv f.new f
+$ echo 3 > f.new
+$ diff -Nu f f.new >> f.diff
+$ rm f.new
+$ echo 1 > f
+$ chmod a=r f
+$ ../patch -p0 --backup < f.diff
+> patching file f
+> patching file f
+
+$ rm -f f f.diff f.orig f.rej