How to fix/patch hardcoded values

Nuno Teixeira ed.arrakis at gmail.com
Tue Dec 29 10:48:58 UTC 2020


Hello,

I'm using:
${REINPLACE_CMD} 's,\./gitup.conf,${PREFIX}/etc/gitup.conf,'
${WRKSRC}/gitup.c

I didn't know about that sintax with "%":
${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX}' ${WRKSRC}/githup.c

Does it make any difference between the two expressions?

Thanks

Mathieu Arnold <mat at freebsd.org> escreveu no dia terça, 29/12/2020 à(s)
08:07:

> On Sun, Dec 27, 2020 at 09:58:13PM +0000, Nuno Teixeira wrote:
> > Hello I've just submited a new port net/gitup
> > <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252220> and I used a
> > simple workaround to help program find its config in /usr/local/etc
> instead
> > of (hardcoded) ./
> >
> > --- gitup.c.orig 2020-12-27 21:16:22 UTC
> > +++ gitup.c
> > @@ -2030,7 +2030,7 @@ main(int argc, char **argv)
> > ...
> > - const char         *configuration_file = "./gitup.conf";
> > + const char         *configuration_file = "/usr/local/etc/gitup.conf";
> >
> > Now I'm thinking that this might not be the best fix in case PREFIX is a
> > different one.
> >
> > Could I have an opinion on this?
>
> You need to change the patch to use %%PREFIX%% or %%LOCALBASE%%
> depending on whether this is a reference to a path/file installed by the
> software or by one of its dependency.  Then, in a post-patch target, you
> need to use REINPLACE_CMD to replace those to by they variables
> equivalent, something like:
>
> post-patch:
>         ${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX}' ${WRKSRC}/githup.c
>
> --
> Mathieu Arnold
>


More information about the freebsd-ports mailing list