Lot's of REINPLACE_CMD versus patch

From: Nuno Teixeira <eduardo_at_freebsd.org>
Date: Tue, 25 May 2021 06:02:36 UTC
Hello!

I'm working on a new port that have a lot of REINPLACE_CMDs and I'm getting
a lot of warnings saying, e.g.:
"REINPLACE_CMD ran, but did not modify file contents:
NsCDE/config/NsCDE-Font-120dpi.conf.bak.bak.bak.bak"

And this waring shows that this particular file was changed four times!

I'm thinking that REINPLACE_CMD is viable to small changes and for this
port I think that is better change all files manually and then create
patches with "make makepatch'

What do you think?

---
post-patch:
        ${CP} ${WRKSRC}/NsCDE/libexec/generate_subpanels
${WRKSRC}/generate_subpanels
        @${REINPLACE_CMD} -e 's@config/@etc/nscde/@g'
${WRKSRC}/generate_subpanels
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e 's@$$\[NSCDE_ROOT\]/share/doc/@'${PREFIX}'/share/doc/nscde/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e 's@$$\[NSCDE_ROOT\]/share/icons/@'${PREFIX}'/share/icons/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e 's@$$\[NSCDE_ROOT\]/share/@'${DATADIR}'/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD} -e 's@
$$\[NSCDE_ROOT\]/share@'${DATADIR}'@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/config ${WRKSRC}/NsCDE/lib/scripts -type f
-exec ${REINPLACE_CMD} -e
's@$$\[NSCDE_ROOT\]/libexec/@'${PREFIX}'/libexec/nscde/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e "s@$$\[NSCDE_ROOT\]/lib/@${PREFIX}/lib/nscde/@g"
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config ${WRKSRC}/NsCDE/lib/scripts -type f
-exec ${REINPLACE_CMD} -e 's@$$\[NSCDE_ROOT\]/bin/@'${PREFIX}'/sbin/@g' {}
\;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e 's@$$\[NSCDE_ROOT\]/config/@'${ETCDIR}'/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e 's@$${NSCDE_ROOT}/share/icons/@'${PREFIX}'/share/icons/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e 's@$${NSCDE_ROOT}/share/@'${DATADIR}'/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
-e 's@$$NSCDE_ROOT/share/@'${DATADIR}'/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/config -type f -name '*.conf' -exec ${MV}
{} {}.sample \;
        ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
${WRKSRC}/NsCDE/libexec ${WRKSRC}/NsCDE/config \
                ${WRKSRC}/NsCDE/share/applications -type f -exec
${REINPLACE_CMD} -e 's@$$NSCDE\_ROOT\/bin@'${PREFIX}'/sbin@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e 's@
$$NSCDE\_ROOT\/config@'${ETCDIR}'@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e 's@
$$NSCDE\_ROOT\/libexec@'${PREFIX}'/libexec/nscde@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
's@$$NSCDE\_ROOT\/lib\/@'${PREFIX}'/lib/nscde/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
${WRKSRC}/NsCDE/libexec ${WRKSRC}/NsCDE/share/config_templates \
                -type f -exec ${REINPLACE_CMD} -e
's@$$NSCDE\_ROOT\/share\/icons\/@'${PREFIX}'/share/icons/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
${WRKSRC}/NsCDE/libexec ${WRKSRC}/NsCDE/share/config_templates \
                -type f -exec ${REINPLACE_CMD} -e
's@$$NSCDE\_ROOT\/share\/doc\/@'${PREFIX}'/share/doc/nscde/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
${WRKSRC}/NsCDE/libexec ${WRKSRC}/NsCDE/share/config_templates \
                -type f -exec ${REINPLACE_CMD} -e
's@$$NSCDE\_ROOT\/share\/@'${DATADIR}'/@g'
{} \;
        ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
's@$${NSCDE_ROOT}/share/icons/@'${PREFIX}'/share/icons/@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
's@$${NSCDE_ROOT}/share/@'${DATADIR}'/@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
's@$${NSCDE_ROOT}/config/@'${ETCDIR}'/@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
's@$${NSCDE_ROOT}/libexec/@'${PREFIX}'/libexec/nscde/@g' {} \;
        ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
's@$${NSCDE_ROOT}/lib/@'${PREFIX}'/lib/nscde/@g' {} \;
        ${WRKSRC}/NsCDE/bin/ised -c 's/\*FrontPanel: \(.*x.*\), Id
NsCDE-Subpanel\(.*\), Frame 1, PressColorset 27, \\/\*FrontPanel: \1, Id
NsCDE-Subpanel\2, Frame 1, PressColorset 27, \\\n
Icon NsCDE\/FPSubArrowUp.xpm, PressIcon NsCDE\/FPSubArrowDown.xpm, \\/g' -f
"${WRKSRC}/NsCDE/config/NsCDE-FrontPanel.conf.sample"
        ${FIND} ${WRKSRC}/NsCDE -type f -exec ${REINPLACE_CMD} -e
's@^#!/usr/bin/env
ksh93@#!'${PREFIX}'/bin/ksh93@' {} \;
        ${FIND} ${WRKSRC}/NsCDE -type f -name '*.bak' -delete
        ( for HLP in ${PREFIX_FILES}; do ${REINPLACE_CMD} -e 's@$${PREFIX}@
'${PREFIX}'@g' ${WRKSRC}/$${HLP}; done )
---

Thanks,
eduardo