[Bug 259772] Mk/Scripts/sed_checked.sh: Make it respect REINPLACE_ARGS

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 11 Nov 2021 11:20:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259772

--- Comment #2 from Yasuhiro Kimura <yasu@freebsd.org> ---
(In reply to Mathieu Arnold from comment #1)

I created attached patch to fix the issue I faced while I was handling the
problem reported as bug #257017.

To fix it I need to modified some lines of a original source file. So I added
following post-patch target to mail/rainloop/Makefile

----------------------------------------------------------------------
post-patch:
        ${REINPLACE_CMD} 's/__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND =
false/__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND = true/' \
       
${WRKSRC}/rainloop/v/${PORTVERSION}/app/libraries/MailSo/Smtp/SmtpClient.php
----------------------------------------------------------------------

But it caused plist error because ${WRKSRC}/rainloop is copied to staging area
by using COPYTREE_SHARE at do-install target and backup file created at
post-patch target is also copied.

To fix it I added "REINPLACE_ARGS=-i ''" to Makefile to prevent backup file
from being created. It works as is expected with non-developer mode. But with
developer mode plist error still happens as sed_checked.sh creates backup file.
Since I put 'DEVELOPER=yes' in make.conf of my system, it's a bit bothersome to
comment it out each time I try to check plist with `make check-plist`. So I
changed post-patch target as following.

----------------------------------------------------------------------
post-patch:
        ${REINPLACE_CMD} 's/__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND =
false/__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND = true/' \
       
${WRKSRC}/rainloop/v/${PORTVERSION}/app/libraries/MailSo/Smtp/SmtpClient.php
        ${RM}
${WRKSRC}/rainloop/v/${PORTVERSION}/app/libraries/MailSo/Smtp/SmtpClient.php.bak
----------------------------------------------------------------------

By applying attached patch the behavior of sed_checked.sh changes as following.

* If "REINPLACE_ARGS=-i ''" is specified it creates backup file with
".sed_checked" as extension, compares old and new file, and after that removes
backup file.
* If REINPLACE_ARGS is set to other non-default value (e.g. "-i.backup"), it
behaves just same as before except that specified value is used as extension of
backup file instead of ".bak".

So it respects REINPLACE_ARGS and also do its job. And it makes `make
check-plist` works fine with developer mode in my case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.