• sysutils/logwatch: Need to patch very first line of a script fails, dunno why

    From Michael Grimm@trashcan@ellael.org to muc.lists.freebsd.ports on Fri Jul 18 20:48:09 2025
    From Newsgroup: muc.lists.freebsd.ports

    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 rCa 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?
    Thanks in advance and regards,
    Michael--
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Grimm@trashcan@ellael.org to muc.lists.freebsd.ports on Fri Jul 18 20:51:43 2025
    From Newsgroup: muc.lists.freebsd.ports

    Michael Grimm <trashcan@ellael.org> wrote:
    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.
    I forgot to mention, that when removing the very first hunk starting at line 1, all other hunks are applied during 'poudriere testport' successfully. Only a patch starting at line 1 woes.
    Regards,
    Michael
    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Grimm@trashcan@ellael.org to muc.lists.freebsd.ports on Fri Jul 18 21:24:11 2025
    From Newsgroup: muc.lists.freebsd.ports

    Edward Sanford Sutton, III <mirror176@hotmail.com> 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 rCa 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
    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Grimm@trashcan@ellael.org to muc.lists.freebsd.ports on Fri Jul 18 21:26:42 2025
    From Newsgroup: muc.lists.freebsd.ports

    Miroslav Lachman <000.fbsd@quip.cz> wrote:

    On 18/07/2025 20:48, Michael Grimm wrote:
    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?
    Thanks in advance and regards,
    Michael

    Can it be that the file is already modified by shebangfix? it is in the Makefile:

    USES= perl5 shebangfix

    SHEBANG_FILES= scripts/logwatch.pl

    If there is a shebangfix there is no need to patch it.
    Bingo! Now I do understand what went wrong.
    And I can remove my last ${REINPLACE_CMD} as well.
    Thanks for your help, highly appreciated,
    Michael
    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2