Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch.exe regression: can not handle general patches #51

Open
zmughal opened this issue Jul 21, 2023 · 3 comments
Open

patch.exe regression: can not handle general patches #51

zmughal opened this issue Jul 21, 2023 · 3 comments

Comments

@zmughal
Copy link

zmughal commented Jul 21, 2023

When trying to apply a patch, patch gives the error:

patch: **** Can't rename file src/secure_allocator.hpp to src/secure_allocator.hpp.orig : No such file or directory

It appears to apply when there is a directory prefix, so for the above, a
workaround is to do -d src -p2 to remove the a/src/ part.


Test case:

Commands:

mkdir C:\b & cd C:\b
curl -OL https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz & curl -OL https://github.com/zeromq/libzmq/pull/4480.patch
tar xzf zeromq-4.3.4.tar.gz & cd zeromq-4.3.4
certUtil -hashfile src\secure_allocator.hpp MD5
patch --binary -p1 -i C:\b\4480.patch
certUtil -hashfile src\secure_allocator.hpp MD5
patch --binary -d src -p2 -i C:\b\4480.patch
certUtil -hashfile src\secure_allocator.hpp MD5
patch --version
where patch.exe

The following is a transcript with StrawberryPerl 5.38.1's patch.exe:

vagrant@VAGRANTVM C:\b>curl -OL https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz & curl -OL https://github.com/zeromq/libzmq/pull/4480.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2428k  100 2428k    0     0  4735k      0 --:--:-- --:--:-- --:--:-- 4735k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3537    0  3537    0     0   5513      0 --:--:-- --:--:-- --:--:-- 15051

vagrant@VAGRANTVM C:\b>tar xzf zeromq-4.3.4.tar.gz & cd zeromq-4.3.4

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
47cd75dd30c5d9a7d4bb6a42df377664
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -p1 -i C:\b\4480.patch
patching file src/secure_allocator.hpp
Hunk StrawberryPerl/Perl-Dist-Strawberry#1 succeeded at 95 (offset -4 lines).
patch: **** Can't rename file src/secure_allocator.hpp to src/secure_allocator.hpp.orig : No such file or directory

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
47cd75dd30c5d9a7d4bb6a42df377664
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -d src -p2 -i C:\b\4480.patch
patching file secure_allocator.hpp
Hunk StrawberryPerl/Perl-Dist-Strawberry#1 succeeded at 95 (offset -4 lines).

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
a616d5049eddb65001856dbbc8f5105c
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --version
GNU patch 2.7.5
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>where patch.exe
C:\Strawberry\c\bin\patch.exe

The following is a transcript with StrawberryPerl 5.32.1.1's patch.exe:

vagrant@VAGRANTVM C:\b>curl -OL https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz & curl -OL https://github.com/zeromq/libzmq/pull/4480.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2428k  100 2428k    0     0  4431k      0 --:--:-- --:--:-- --:--:-- 7833k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3537    0  3537    0     0   6267      0 --:--:-- --:--:-- --:--:--  6267

vagrant@VAGRANTVM C:\b>tar xzf zeromq-4.3.4.tar.gz & cd zeromq-4.3.4

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
47cd75dd30c5d9a7d4bb6a42df377664
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -p1 -i C:\b\4480.patch
patching file src/secure_allocator.hpp
Hunk StrawberryPerl/Perl-Dist-Strawberry#1 succeeded at 95 (offset -4 lines).

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
a616d5049eddb65001856dbbc8f5105c
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -d src -p2 -i C:\b\4480.patch
patching file secure_allocator.hpp
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file secure_allocator.hpp.rej

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
a616d5049eddb65001856dbbc8f5105c
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --version
patch 2.5.9
Copyright (C) 1988 Larry Wall
Copyright (C) 2003 Free Software Foundation, Inc.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

written by Larry Wall and Paul Eggert

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>where patch.exe
C:\Strawberry\c\bin\patch.exe

Connects with StrawberryPerl/Perl-Dist-Strawberry#74.

zmughal referenced this issue in zmughal-CPAN/p5-Alien-ZMQ-latest Jul 21, 2023
zmughal referenced this issue in zmughal-CPAN/p5-Alien-ZMQ-latest Jul 21, 2023
zmughal referenced this issue in zmughal-CPAN/p5-Alien-ZMQ-latest Jul 21, 2023
@shawnlaffan
Copy link
Contributor

The patch utility distributed with 5.38.0.1 (and 5.36.1.1) is built without any additional patching. The one distributed with 5.32.1.1 and earlier had some patches applied as part of its build.

Possibly we should apply one or more of the previous SP and MSYS2 patches.

https://github.com/StrawberryPerl/build-extlibs/blob/master/patches/patch-2.7.5/patch-2.7.5.diff
https://github.com/msys2/MSYS2-packages/blob/master/patch/msys2-patch-2.7.1.patch
https://github.com/msys2/MSYS2-packages/blob/master/patch/msys2-patch-manifest.patch

@shawnlaffan shawnlaffan transferred this issue from StrawberryPerl/Perl-Dist-Strawberry Jul 22, 2023
@shawnlaffan
Copy link
Contributor

shawnlaffan commented Jul 22, 2023

Issue transferred to the build-extlibs repo given that's where the code is.

@shawnlaffan
Copy link
Contributor

I have built patch with the MSYS and Strawberry Perl patches listed in #51 (comment)

It still does not work. In some cases it silently fails to make changes.

Unless someone knows of additional patches for the build, the simplest approach would seem to be to use a patch.exe from elsewhere.

The MSYS2 patch works but depends on msys-2.0.dll. The chocolatey patch.exe is version 2.5.9, which is the same as the numeric version that comes with SP 5.32 so presumably won't handle recent diff formats (StrawberryPerl/Perl-Dist-Strawberry#74). That needs to be tested, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants