Changes between Version 18 and Version 19 of snc


Ignore:
Timestamp:
Feb 6, 2009, 1:50:46 PM (16 years ago)
Author:
nerdling (Jeremy Lavergne)
Comment:

when to use patch files

Legend:

Unmodified
Added
Removed
Modified
  • snc

    v18 v19  
    66
    77Also hidden (to the point where I cannot find it) is how to write wrapper scripts; [source:trunk/dports/x11/wine/ wine] is considered the poster-portfile. Another example is [source:trunk/dports/math/pspp/ pspp]. The scripts should be included in the port's {{{files}}} directory and dynamically modified through the portfile by the [http://guide.macports.org/#reference.tcl-extensions tcl extensions], {{{xinstall}}} and {{{reinplace}}}.
    8 === Patch Files ===
    9 Use a patchfile when possible:  When the upstream source changes and your patch breaks, you'll have the context of the patchfile to know whether you need to update or remove the patchfile. Use reinplace to replace things like {{{${prefix} }}}and {{{${x11prefix} }}}and other variables that can be different on users' systems — ideally first have a patchfile that changes the prefix to {{{@PREFIX@}}} then use {{{reinplace}}} to change {{{@PREFIX@}}} to {{{${prefix} }}}.
     8=== When to Use Patch Files ===
     9There are 4 basic rules to follow when considering patch files.
     10 1. Do nothing, because MacPorts already puts{{{ --prefix=${prefix} }}}in {{{configure.pre_args}}} and most software uses configure scripts and most configure scripts understand that flag.
     11 1. If there is another flag you need to use instead, overwrite {{{configure.pre_args}}}.
     12 1. If there is no flag to do this, try an environment variable (e.g.,{{{ configure.env-append PREFIX=${prefix} }}}).
     13 1. If no environment variable exists for this, then patch.
    1014=== Do Not Hardcode /opt/local ===
    11 Speaking of {{{reinplace}}}, '''do not''' hardcode {{{/opt/local}}} anywhere! Instead, use {{{reinplace}}} for string manipulation in files.
     15Speaking of {{{reinplace}}}, '''do not''' hardcode {{{/opt/local}}} anywhere! Instead, use {{{reinplace}}} to replace things like {{{${prefix} }}}and {{{${x11prefix} }}}and other variables that can be different on users' systems.
    1216== Portindex ==
    1317Once you've created your portfile, it's best to test it with your copy of MacPorts.  The first step is to create a [http://guide.macports.org/#development.local-repositories local portfile repository] for testing. For this, I suggest creating the directory {{{~/ports}}}.   Inside this new directory, you should run {{{portindex}}} which will create the repository index of everything following the {{{./group/port/Portfile}}} heirarchy.  '''Note:''' This command should be run everytime you make changes as it will include the new index data for MacPorts. Also watch out for any errors it reports, which stop the portfile from showing up in MacPorts.