| 2 | |
| 3 | == Branch and major versions == #branch |
| 4 | |
| 5 | 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 |
| 6 | {{{ |
| 7 | set branch [join [lrange [split ${version} .] 0 1] .] |
| 8 | }}} |
| 9 | This splits the version string into an array, takes the first two elements of the array, and glues them back together again. |
| 10 | This example is from [browser:trunk/dports/devel/glib2 glib2]. |
| 11 | |
| 12 | If you need to refer just to the x part (the major version) you can similarly do: |
| 13 | {{{ |
| 14 | set major [lindex [split ${version} .] 0] |
| 15 | }}} |
| 16 | This splits the version string into an array and returns just the first element. |
| 17 | This example is from [browser:trunk/dports/lang/php5 php5]. |