Edward Sanford Sutton, III <[email protected]> wrote:
> On 7/18/25 11:48, Michael Grimm wrote:

>> Hi,
>> I am preparing for the upcoming logwatch-7.13 release, and ran into an issue 
>> I can't understand.
>> I do want to patch the logwatch.pl script by providing a 
>> 'files/patch-scripts_logwatch.pl' which starts as follows:
>> --- scripts/logwatch.pl.orig    2025-07-18 18:21:47 UTC
>> +++ scripts/logwatch.pl
>> @@ -1,4 +1,4 @@
>> -#!/usr/bin/perl -w
>> +#!/usr/local/bin/perl -w
>> use strict;
>> ##########################################################################
>> ##########################################################################
>> [followed by 17 other hunks]
>> Using "poudriere testport … sysutils/logwatch" I get:
>> =======================<phase: patch          >============================
>> ===== env: DEVELOPER_MODE=yes DEVELOPER=1 STRICT_DEPENDS=yes USER=root UID=0 
>> GID=0
>> ===>  Patching for logwatch-7.13
>> ===>  Applying FreeBSD patches for logwatch-7.13 from 
>> /usr/ports/sysutils/logwatch/files
>> Ignoring previously applied (or reversed) patch.
>> 18 out of 18 hunks ignored--saving rejects to scripts/logwatch.pl.rej
>> ===>  FAILED Applying FreeBSD patch-scripts_logwatch.pl
>> ===> FAILED to apply cleanly FreeBSD patch(es)  patch-scripts_logwatch.pl
>> *** Error code 1
>> Stop.
>> But: If I do apply that very same patch by 'patch < 
>> files/patch-scripts_logwatch.pl' at the appropriate location, all 18 hunks 
>> are applied successfully.
>> Can you help me to understand how to fix this?
> 
> As a workflow, I copy the file to file.orig, manually patch it, and then run 
> `make makepatch` in the port's folder to create the patches under files/ 
> appropriately. You can also use this to compare the result to your current 
> work.

That is how I produced that patch (also to please portlint). Errors see above.

> For this case you should consider replacing a static patch replacement with a 
> more dynamic replacement if possible (modify as needed):
> 
> post-patch:
> @${REINPLACE_CMD} -e 's|/usr/bin|${PREFIX}/bin|g' 
> ${WRKSRC}/scripts/logwatch.pl

After failing with the first hunk, I removed it and placed it into the Makefile:

pre-configure:
        ${REINPLACE_CMD}  -E \
        -e "s,/usr/bin/perl -w,/usr/local/bin/perl -w," \
        ${WRKSRC}/scripts/logwatch.pl

After that the port compiles successfully.

> though in such a particular case there is also the following predesigned fix 
> which may work:
> 
> USES= shebangfix
> SHEBANG_FILES= ./scripts/logwatch.pl

That's already been in the Makefile.

But: Bingo! After reading Miroslav's answer, I do understand why the first hunk 
fails because there is no need to patch it. And I can get rid of the last 
remaining ${REINPLACE_CMD} as well.

Thanks for your help, highly appreciated,
Michael





Reply via email to