Hardcoded Versions, PortGroup-Defined Variables

Jeremy Lavergne jeremy at lavergne.gotdns.org
Wed Apr 28 11:31:41 PDT 2010

> Hello, I just received 4 lint reports from an automated system in MacPorts.  Here is one example:
>    Change: http://trac.macports.org/changeset/67067
>    Portfile: p5-file-readbackwards
>    Warning: Line 19 seems to hardcode the version number, consider using 
>    ${version} instead

The PortGroup is defined in ${prefix}/sources/rsync.macports.org/release/ports/_resources/port1.0/group, in particular we're after perl5-1.0.tcl to see how it handles versions for us.

You'll see there's a function called perl5.setup that actually sets the version of the port for us.  That means anytime after perl5-setup the ${version} is defined for us and we can use it wherever we'll make use of it.

Your example (repeated below) has the ${homepage} making use of a hard coded version.  The best thing to do would simply be use ${version} in place of the numbers.

homepage		http://search.cpan.org/~uri/File-ReadBackwards-1.04/
homepage		http://search.cpan.org/~uri/File-ReadBackwards-${version}/

You'll also notice that the perl5.setup function defines the ${homepage} for us already, so if it doesn't produce a valid one then you should override it like you're doing: manually define homepage after perl5.setup is called.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2435 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20100428/48ca3221/attachment.bin>

More information about the macports-dev mailing list