How best to change a hard-coded config search path, before compilation

Lawrence Velázquez larryv at macports.org
Fri Nov 4 18:18:37 PDT 2016


> On Nov 4, 2016, at 8:53 PM, A. Karl Kornel <karl at kornel.us> wrote:
> 
> The first thing I was thinking of doing is using "reinplace" directly
> on the file in question, in the pre-build phase. The section method
> I came up with was to use a patch file to change the line, replacing
> "/etc" with "PREFIX_GOES_HERE" (or something), and then using
> reinplace to put in the correct path.
> 
> Both methods do the same thing, but in my mind the second method is
> better because it makes absolutely sure I am only changing one part of
> the file. Also, if the code changes in a future version, the patch
> will fail to apply. That will help me from missing changes.

We strongly prefer the second method, for the reasons you already gave.
Your portfile should contain a bit resembling this:

patchfiles use-macports-prefix.patch

post-patch {
	reinplace s|__PREFIX__|${prefix}| file.ext
}

vq


More information about the macports-dev mailing list