/[gentoo-x86]/eclass/versionator.eclass
Gentoo

Diff of /eclass/versionator.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.9 Revision 1.10
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.9 2005/07/06 20:23:20 agriffis Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/versionator.eclass,v 1.10 2006/03/21 00:49:54 kugelfang Exp $
4# 4#
5# Original Author: Ciaran McCreesh <ciaranm@gentoo.org> 5# Original Author: Ciaran McCreesh <ciaranm@gentoo.org>
6# 6#
7# This eclass provides functions which simplify manipulating $PV and similar 7# This eclass provides functions which simplify manipulating $PV and similar
8# variables. Most functions default to working with $PV, although other 8# variables. Most functions default to working with $PV, although other
14# Simple Example 2: $PV is 1.4.5, we want 1: 14# Simple Example 2: $PV is 1.4.5, we want 1:
15# MY_MAJORV=$(get_major_version ) 15# MY_MAJORV=$(get_major_version )
16# 16#
17# Full list of user usable functions provided by this eclass (see the functions 17# Full list of user usable functions provided by this eclass (see the functions
18# themselves for documentation): 18# themselves for documentation):
19# get_all_version_components ver_str 19# get_all_version_components ver_str
20# get_version_components ver_str 20# get_version_components ver_str
21# get_major_version ver_str 21# get_major_version ver_str
22# get_version_component_range range ver_str 22# get_version_component_range range ver_str
23# get_after_major_version ver_str 23# get_after_major_version ver_str
24# replace_version_separator index newvalue ver_str 24# replace_version_separator index newvalue ver_str
25# replace_all_version_separators newvalue ver_str 25# replace_all_version_separators newvalue ver_str
26# delete_version_separator index ver_str 26# delete_version_separator index ver_str
27# delete_all_version_separators ver_str 27# delete_all_version_separators ver_str
28# get_version_component_count ver_str
29# get_last_version_component_index ver_str
28# 30#
29# Rather than being a number, the index parameter can be a separator character 31# Rather than being a number, the index parameter can be a separator character
30# such as '-', '.' or '_'. In this case, the first separator of this kind is 32# such as '-', '.' or '_'. In this case, the first separator of this kind is
31# selected. 33# selected.
32# 34#
33# There's also: 35# There's also:
34# version_is_at_least want have 36# version_is_at_least want have
35# which may be buggy, so use with caution. 37# which may be buggy, so use with caution.
36
37 38
38shopt -s extglob 39shopt -s extglob
39 40
40# Split up a version string into its component parts. If no parameter is 41# Split up a version string into its component parts. If no parameter is
41# supplied, defaults to $PV. 42# supplied, defaults to $PV.
212# 1b.2.3 -> 1b23 213# 1b.2.3 -> 1b23
213delete_all_version_separators() { 214delete_all_version_separators() {
214 replace_all_version_separators "" "${1}" 215 replace_all_version_separators "" "${1}"
215} 216}
216 217
218# How many version components are there in $1 (defaults to $PV)?
219# 1.0.1 -> 3
220# 3.0c-r1 -> 4
221#
222get_version_component_count() {
223 local a
224 a=( $(get_version_components "${1:-${PV}}" ) )
225 echo ${#a[@]}
226}
227
228# What is the index of the last version component in $1 (defaults to $PV)?
229# Equivalent to get_version_component_count - 1.
230# 1.0.1 -> 3
231# 3.0c-r1 -> 4
232#
233get_last_version_component_index() {
234 echo $(( $(get_version_component_count "${1:-${PV}}" ) - 1 ))
235}
236
217# Is $2 (defaults to $PVR) at least version $1? Intended for use in eclasses 237# Is $2 (defaults to $PVR) at least version $1? Intended for use in eclasses
218# only. May not be reliable, be sure to do very careful testing before actually 238# only. May not be reliable, be sure to do very careful testing before actually
219# using this. Prod ciaranm if you find something it can't handle. 239# using this. Prod ciaranm if you find something it can't handle.
220version_is_at_least() { 240version_is_at_least() {
221 local want_s="$1" have_s="${2:-${PVR}}" r 241 local want_s="$1" have_s="${2:-${PVR}}" r

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20