modifying patch files

Anders F Björklund afb at
Sun Sep 13 00:40:42 PDT 2009

Jack Howarth wrote:

>    I have run into an issue that is unclear on MacPorts. In fink
> we often would put placekeepers in a patch such as @FINKPREFIX@
> and use the command...
> sed 's|@FINKPREFIX@|%p|g' <%{PatchFile} | patch -p1
> to replace the @FINKPREFIX@ with the actual fink installation  
> directory.
> How do you handle this situation in MacPorts where you want to
> generalize the MacPorts prefix in a Makefile patch for instance
> to survive the case of a user installing MacPorts in a non-default
> location other than /opt/local?

If you don't want to remember all the zillion files
that your port may need patching, then you _can_ do
override to do something similar in MacPorts as well:

patch {
   foreach patch $patchfiles {
     system "cd '${workpath}/${distname}' && \
             sed -e 's#@@PREFIX@@#${prefix}#g' '${portpath}/$ 
{filesdir}/${patch}' | patch -p0"

But that's usually only needed for some really stupid
and unportable ports, like for instance "yum" and such.
(since it loves to hardcode /usr and #!/usr/bin/python)

Someone suggested it should be a "patch" feature, but
nobody bothered implementing it (as far as I know)...
Like: "patch.replace @@PREFIX@@=${prefix}", or somesuch


More information about the macports-dev mailing list