Summary: Utility for modifying/upgrading files
Summary(ja): ファイルを修正/更新するためのユーティリティ
Name: patch
Version: 2.7.6
Release: 2%{?_dist_release}
License: GPLv2+
URL: http://www.gnu.org/software/patch/patch.html
Group: Development/Tools
Source: ftp://ftp.gnu.org/gnu/patch/patch-%{version}.tar.xz
Patch0: patch-2.7.6-avoid-set_file_attributes-sign-conversion-warnings.patch
Patch1: patch-2.7.6-test-suite-compatibility-fixes.patch
Patch2: patch-2.7.6-fix-korn-shell-incompatibility.patch
Patch3: patch-2.7.6-fix-segfault-with-mangled-rename-patch.patch
Patch4: patch-2.7.6-allow-input-files-to-be-missing-for-ed-style-patches.patch
Patch5: patch-CVE-2018-1000156.patch
Patch6: patch-2.7.6-CVE-2019-13638-invoked-ed-directly-instead-of-using-the-shell.patch
Patch7: patch-2.7.6-switch-from-fork-execlp-to-execute.patch
Patch8: patch-2.7.6-cleanups-in-do_ed_script.patch
Patch9: patch-2.7.6-avoid-warnings-gcc8.patch
Patch10: patch-2.7.6-check-of-return-value-of-fwrite.patch
Patch11: patch-2.7.6-fix-ed-style-test-failure.patch
Patch12: patch-2.7.6-dont-leak-temporary-file-on-failed-ed-style-patch.patch
Patch13: patch-2.7.6-dont-leak-temporary-file-on-failed-multi-file-ed-style-patch.patch
Patch14: patch-2.7.6-make-debug-output-more-useful.patch
Patch15: patch-2.7.6-CVE-2018-6952-fix-swapping-fake-lines-in-pch_swap.patch
Patch16: patch-2.7.6-improve_support_for_memory_leak_detection.patch
Patch17: patch-2.7.6-skip-ed-test-when-the-ed-utility-is-not-installed.patch
Patch18: patch-2.7.6-abort_when_cleaning_up_fails.patch
Patch19: patch-2.7.6-crash-RLIMIT_NOFILE.patch
Patch20: patch-2.7.6-CVE-2019-13636-symlinks.patch
Patch21: patch-2.7.6-avoid-invalid-memory-access-in-context-format-diffs.patch
Patch22: patch-2.7.6-CVE-2018-17942.patch
Patch23: patch-2.7.6-failed_assertion.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: ed

Vendor: Project Vine
Distribution: Vine Linux

%description
The patch program applies diff files to originals.  The diff command
is used to compare an original to a changed file.  Diff lists the
changes made to the file.  A person who has the original file can then
use the patch command with the diff file to add the changes to their
original file (patching the file).

Patch should be installed because it is a common way of upgrading
applications.

%description -l ja
patch プログラムは，diff ファイルをオリジナルファイルに適用します．
diff コマンドはオリジナルファイルと変更されたファイルとを比較する
のに使われます．diff はファイルになされた変更を出力します．
オリジナルファイルを持っていれば，この patch コマンドを使って，
diff が出力したファイルを適用することによりオリジナルファイルを
更新することが出来ます (ファイルに patch を適用する，と言います)．

patch は，アプリケーションをアップグレードする際に良く使われますので
是非インストールしておきましょう．


%prep
%setup -q
%patch0 -p1 -b .avoid-set_file_attributes-sign-conversion-warnings
%patch1 -p1 -b .test-suite-compatibility-fixes
%patch2 -p1 -b .fix-korn-shell-incompatibility
%patch3 -p1 -b .fix-segfault-with-mangled-rename-patch
%patch4 -p1 -b .allow-input-files-to-be-missing-for-ed-style-patches
# CVE-2018-1000156, Malicious patch files cause ed to execute arbitrary commands

%patch5 -p1 -b .CVE-2018-1000156
%patch6 -p1 -b .CVE-2019-13638-invoked-ed-directly-instead-of-using-the-shell
%patch7 -p1 -b .switch-from-fork-execlp-to-execute
%patch8 -p1 -b .cleanups-in-do_ed_script
%patch9 -p1 -b .avoid-warnings-gcc8
%patch10 -p1 -b .check-of-return-value-of-fwrite
%patch11 -p1 -b .fix-ed-style-test-failure
%patch12 -p1 -b .dont-leak-temporary-file-on-failed-ed-style-patch
%patch13 -p1 -b .dont-leak-temporary-file-on-failed-multi-file-ed-style-patch
%patch14 -p1 -b .make-debug-output-more-useful
%patch15 -p1 -b .CVE-2018-6952-fix-swapping-fake-lines-in-pch_swap
%patch16 -p1 -b .improve_support_for_memory_leak_detection
%patch17 -p1 -b .skip-ed-test-when-the-ed-utility-is-not-installed
%patch18 -p1 -b .abort_when_cleaning_up_fails
%patch19 -p1 -b .crash-RLIMIT_NOFILE
%patch20 -p1 -b .CVE-2019-13636-symlinks
%patch21 -p1 -b .avoid-invalid-memory-access-in-context-format-diffs
# CVE-2018-17942 gnulib: heap-based buffer overflow
%patch22 -p1 -b .CVE-2018-17942-gnulib_buffer_overflow
%patch23 -p1 -b .failed_assertion

%build
CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
autoreconf

%configure --disable-silent-rules

# XXX unset CPPFLAGS on (ultra?)sparc to avoid large file system support
%ifarch sparc sparc64
make CPPFLAGS=""
%else
make %{?_smp_mflags}
%endif

%check
make check

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc NEWS README
%{_bindir}/*
%{_mandir}/*/*

%changelog
* Thu Aug 29 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.7.6-2
- replaced all patches with rawhide's.

* Tue Mar 13 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.7.6-1
- new upstream release.
- dropped all patches.
- added Patch1000 to fix CVE-2018-6952.

* Sun Feb 02 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.6.1-4
- rebuild with VineSeed environment

* Mon May  7 2012 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.6.1-3
- add patch2 for fix CVE-2010-4651 (dir traversal) from fc13
- fix using %%{?_smp_mflags} in make section

* Thu Apr 14 2011 IWAI, Masaharu <iwai@alib.jp> 2.6.1-2
- build on current VineSeed
- add Vendor adn Distribution tags

* Sat Jan 16 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.6.1-1
- new upstream release
- added %%check section

* Sun Jun 15 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.5.4-30
- added Patch8 from Fedora development
  * Fri Feb  8 2008 Tim Waugh <twaugh@redhat.com> 2.5.4-32
  - Applied patch from 2.5.9 to allow spaces in filenames (bug #431887).
- applied new versioning policy
- spec in UTF-8

* Thu Jun  8 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.5.4-29vl1
- added Patch6, 8 from Fedora development
  * Wed Sep  7 2005 Tim Waugh <twaugh@redhat.com> 2.5.4-27
  - Applied patch from Ulrich Drepper to fix string overread (bug #167675).
  * Thu Aug 11 2005 Tim Waugh <twaugh@redhat.com> 2.5.4-25
  - Fixed CRLF detection (bug #154283).
  * Wed May  4 2005 Tim Waugh <twaugh@redhat.com> 2.5.4-24
  - Reverted last change (bug #154283, bug #156762).
  * Fri Apr 29 2005 Tim Waugh <twaugh@redhat.com> 2.5.4-23
  - Applied patch from Toshio Kuratomi to avoid problems with DOS-format
    newlines (bug #154283).

* Sat Apr 10 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 2.5.4-19vl1
- rebuild

* Tue Apr  8 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 2.5.4-15vl2
- rebuild

* Fri Dec 06 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.5.4-15vl1
- based on 2.5.4-15 from Rawhide and built for Vine Linux
- added Japanese summary and description

* Wed Nov 20 2002 Tim Powers <timp@redhat.com>
- rebuilt in current collinst

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Thu May 23 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Tue Apr  9 2002 Tim Waugh <twaugh@redhat.com> 2.5.4-12
- Fix error reporting when given bad options (bug #62981).

* Tue Mar  5 2002 Tim Waugh <twaugh@redhat.com> 2.5.4-11
- s/Copyright:/License:/.
- Fix -D behaviour (bug #60688).

* Tue May 29 2001 Tim Waugh <twaugh@redhat.com> 2.5.4-10
- Merge Mandrake patch:
  - fix possible segfault

* Fri Dec  1 2000 Tim Waugh <twaugh@redhat.com>
- Rebuild because of fileutils bug.

* Thu Nov  2 2000 Tim Waugh <twaugh@redhat.com>
- use .orig as default suffix, as per man page and previous behaviour
  (bug #20202).
- use better patch for this, from maintainer.

* Wed Oct  4 2000 Tim Waugh <twaugh@redhat.com>
- actually use the RPM_OPT_FLAGS

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Tue Jun 13 2000 Trond Eivind Glomsr <teg@redhat.com>
- Use %%makeinstall, %%{_tmppath} and %%{_mandir}

* Fri May 12 2000 Trond Eivind Glomsr <teg@redhat.com>
- added URL

* Wed Feb 16 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 2.5.4
- Fix up LFS support on Alpha (Bug #5732)

* Mon Feb  7 2000 Bill Nottingham <notting@redhat.com>
- handle compressed manpages

* Sun Jun 06 1999 Alan Cox <alan@redhat.com>
- Fix the case where stderr isnt flushed for ask(). Now the 'no such file'
  appears before the skip patch question, not at the very end, Doh!

* Mon Mar 22 1999 Jeff Johnson <jbj@redhat.com>
- (ultra?) sparc was getting large file system support.

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 7)

* Fri Dec 18 1998 Cristian Gafton <gafton@redhat.com>
- build against glibc 2.1

* Tue Sep  1 1998 Jeff Johnson <jbj@redhat.com>
- bump release to preserve newer than back-ported 4.2.

* Tue Jun 09 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr

* Tue Jun  9 1998 Jeff Johnson <jbj@redhat.com>
- Fix for problem #682 segfault.

* Fri Apr 24 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Tue Apr 07 1998 Cristian Gafton <gafton@redhat.com>
- added buildroot

* Tue Oct 21 1997 Cristian Gafton <gafton@redhat.com>
- updated to 2.5

* Mon Jun 02 1997 Erik Troan <ewt@redhat.com>
- built against glibc
