Page "PortfileRecipes" was changed by larryv@macports.org Diff URL: <https://trac.macports.org/wiki/PortfileRecipes?action=diff&version=47> Revision 47 Comment: add examples for extracting minor and patch versions Changes: -------8<------8<------8<------8<------8<------8<------8<------8<-------- Index: PortfileRecipes ========================================================================= --- PortfileRecipes (version: 46) +++ PortfileRecipes (version: 47) @@ -1,7 +1,7 @@ = Portfile Recipes = [[PageOutline(2-3,Table of Contents,inline)]] -== Branch and major versions == #branch +== Branch versions and version segments == #branch Often times, when a port's version is x.y.z, you want to be able to refer to just the x.y part, for a download URL or for other reasons. The de facto standard way to do this is {{{ @@ -10,12 +10,14 @@ This splits the version string into an array, takes the first two elements of the array, and glues them back together again. This example is from [browser:trunk/dports/devel/glib2 glib2]. -If you need to refer just to the x part (the major version) you can similarly do: +If you need to refer just one part of the version, you can similarly use: {{{ set major [lindex [split ${version} .] 0] -}}} -This splits the version string into an array and returns just the first element. -This example is from [browser:trunk/dports/lang/php5 php5]. +set minor [lindex [split ${version} .] 1] +set patch [lindex [split ${version} .] 2] +}}} +These split the version string into an array and return the desired element. +These examples are based on [browser:trunk/dports/lang/php5 php5]. == Fetching from a URL that uses GET parameters == #fetchwithgetparams -------8<------8<------8<------8<------8<------8<------8<------8<-------- -- Page URL: <https://trac.macports.org/wiki/PortfileRecipes> MacPorts <http://www.macports.org/> Ports system for Mac OS This is an automated message. Someone added your email address to be notified of changes on 'PortfileRecipes' page. If it was not you, please report to .
participants (1)
-
MacPorts