new version_format_string func by Michał Górny #327679
authorMike Frysinger <vapier@gentoo.org>
Sun, 18 Jul 2010 21:24:33 +0000 (21:24 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 18 Jul 2010 21:24:33 +0000 (21:24 +0000)
eclass/versionator.eclass

index 09d52dab3d0bc480ed27b73f88434269d8da40e9..bc0388ab87b01fedc1a6301dd9cc94e72a61904b 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.15 2008/06/12 12:48:34 opfer Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.16 2010/07/18 21:24:33 vapier Exp $
 
 # @ECLASS: versionator.eclass
 # @MAINTAINER:
@@ -470,6 +470,24 @@ version_sort() {
        __versionator_shopt_toggle off
 }
 
+# @FUNCTION: version_format_string
+# @USAGE: <format> [version]
+# @DESCRIPTION:
+# Reformat complicated version strings.  The first argument is the string
+# to reformat with while the rest of the args are passed on to the
+# get_version_components function.  You should make sure to single quote
+# the first argument since it'll have variables that get delayed expansion.s
+# @EXAMPLE:
+# P="cow-hat-1.2.3_p4"
+# MY_P=$(version_format_string '${PN}_source_$1_$2-$3_$4')
+# Now MY_P will be: cow-hat_source_1_2-3_p4
+version_format_string() {
+       local fstr=$1
+       shift
+       set -- $(get_version_components "$@")
+       eval echo "${fstr}"
+}
+
 __versionator__test_version_compare() {
        __versionator_shopt_toggle on
        local lt=1 eq=2 gt=3 p q