Re: Lot's of REINPLACE_CMD versus patch

From: Mathieu Arnold <mat_at_freebsd.org>
Date: Tue, 25 May 2021 10:55:04 +0200
On Tue, May 25, 2021 at 07:36:06AM +0100, Nuno Teixeira wrote:
> Hello Mathieu,
> 
> Just a part of .post-install I have the files in directory "config" with 9
> REINPLACE_CMDs applied!
> Isn't better to use patches in this case? one patch for each file with this
> 9 changes?

It is better to use only one REINPLACE_CMD for each file, it avoids long
chains of changes that can each introduce strange things, and only for
changes that are variables, like /usr/local -> PREFIX.

> Mathieu Arnold <mat_at_freebsd.org> escreveu no dia terça, 25/05/2021 à(s)
> 07:28:
> 
> > On Tue, May 25, 2021 at 07:02:36AM +0100, Nuno Teixeira wrote:
> > > 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?
> >
> > Small changes vs big changes has nothing to do with when to use
> > REINPLACE_CMD.
> > As noted in [1], REINPLACE_CMD CAN only be used when replacing some
> > dynamic content, say, /usr/local -> ${PREFIX}.  In all other cases, a
> > patch MUST be used.
> >
> > 1:
> > https://docs.freebsd.org/en/books/porters-handbook/slow-porting/#slow-patch-automatic-replacements
> >
> > > ---
> > > post-patch:
> > >         ${CP} ${WRKSRC}/NsCDE/libexec/generate_subpanels
> > > ${WRKSRC}/generate_subpanels
> > >         _at_${REINPLACE_CMD} -e 's_at_config/_at_etc/nscde/_at_g'
> > > ${WRKSRC}/generate_subpanels
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e 's_at_$$\[NSCDE_ROOT\]/share/doc/_at_'${PREFIX}'/share/doc/nscde/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e 's_at_$$\[NSCDE_ROOT\]/share/icons/_at_'${PREFIX}'/share/icons/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e 's_at_$$\[NSCDE_ROOT\]/share/_at_'${DATADIR}'/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD} -e
> > 's_at_
> > > $$\[NSCDE_ROOT\]/share_at_'${DATADIR}'_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config ${WRKSRC}/NsCDE/lib/scripts -type
> > f
> > > -exec ${REINPLACE_CMD} -e
> > > 's_at_$$\[NSCDE_ROOT\]/libexec/_at_'${PREFIX}'/libexec/nscde/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e "s_at_$$\[NSCDE_ROOT\]/lib/_at_${PREFIX}/lib/nscde/_at_g"
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config ${WRKSRC}/NsCDE/lib/scripts -type
> > f
> > > -exec ${REINPLACE_CMD} -e 's_at_$$\[NSCDE_ROOT\]/bin/_at_'${PREFIX}'/sbin/_at_g'
> > {}
> > > \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e 's_at_$$\[NSCDE_ROOT\]/config/_at_'${ETCDIR}'/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e 's_at_$${NSCDE_ROOT}/share/icons/_at_'${PREFIX}'/share/icons/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e 's_at_$${NSCDE_ROOT}/share/_at_'${DATADIR}'/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/config -type f -exec ${REINPLACE_CMD}
> > > -e 's_at_$$NSCDE_ROOT/share/_at_'${DATADIR}'/_at_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_at_$$NSCDE\_ROOT\/bin_at_'${PREFIX}'/sbin_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
> > > ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e 's_at_
> > > $$NSCDE\_ROOT\/config_at_'${ETCDIR}'_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
> > > ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e 's_at_
> > > $$NSCDE\_ROOT\/libexec_at_'${PREFIX}'/libexec/nscde_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
> > > ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$$NSCDE\_ROOT\/lib\/_at_'${PREFIX}'/lib/nscde/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
> > > ${WRKSRC}/NsCDE/libexec ${WRKSRC}/NsCDE/share/config_templates \
> > >                 -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$$NSCDE\_ROOT\/share\/icons\/_at_'${PREFIX}'/share/icons/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
> > > ${WRKSRC}/NsCDE/libexec ${WRKSRC}/NsCDE/share/config_templates \
> > >                 -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$$NSCDE\_ROOT\/share\/doc\/_at_'${PREFIX}'/share/doc/nscde/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/bin ${WRKSRC}/NsCDE/lib
> > > ${WRKSRC}/NsCDE/libexec ${WRKSRC}/NsCDE/share/config_templates \
> > >                 -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$$NSCDE\_ROOT\/share\/_at_'${DATADIR}'/_at_g'
> > > {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$${NSCDE_ROOT}/share/icons/_at_'${PREFIX}'/share/icons/_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$${NSCDE_ROOT}/share/_at_'${DATADIR}'/_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$${NSCDE_ROOT}/config/_at_'${ETCDIR}'/_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$${NSCDE_ROOT}/libexec/_at_'${PREFIX}'/libexec/nscde/_at_g' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE/libexec -type f -exec ${REINPLACE_CMD} -e
> > > 's_at_$${NSCDE_ROOT}/lib/_at_'${PREFIX}'/lib/nscde/_at_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_at_^#!/usr/bin/env
> > > ksh93_at_#!'${PREFIX}'/bin/ksh93_at_' {} \;
> > >         ${FIND} ${WRKSRC}/NsCDE -type f -name '*.bak' -delete
> > >         ( for HLP in ${PREFIX_FILES}; do ${REINPLACE_CMD} -e 's_at_
> > $${PREFIX}_at_
> > > '${PREFIX}'_at_g' ${WRKSRC}/$${HLP}; done )
> > > ---
> > >
> > > Thanks,
> > > eduardo
> >
> > --
> > Mathieu Arnold
> >

-- 
Mathieu Arnold

Received on Tue May 25 2021 - 08:55:04 UTC

Original text of this message