/[gentoo-x86]/eclass/check-reqs.eclass
Gentoo

Diff of /eclass/check-reqs.eclass

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

Revision 1.13 Revision 1.14
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2014 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/check-reqs.eclass,v 1.13 2012/10/19 03:35:15 patrick Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/check-reqs.eclass,v 1.14 2014/03/28 15:08:16 ulm Exp $
4 4
5# @ECLASS: check-reqs.eclass 5# @ECLASS: check-reqs.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# QA Team <qa@gentoo.org> 7# QA Team <qa@gentoo.org>
8# @AUTHOR: 8# @AUTHOR:
153} 153}
154 154
155# @FUNCTION: check-reqs_get_mebibytes 155# @FUNCTION: check-reqs_get_mebibytes
156# @DESCRIPTION: 156# @DESCRIPTION:
157# Internal function that returns number in mebibytes. 157# Internal function that returns number in mebibytes.
158# Converts from 1G=1024 or 1T=1048576 158# Returns 1024 for 1G or 1048576 for 1T.
159check-reqs_get_mebibytes() { 159check-reqs_get_mebibytes() {
160 debug-print-function ${FUNCNAME} "$@" 160 debug-print-function ${FUNCNAME} "$@"
161 161
162 [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]" 162 [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
163 163
174 esac 174 esac
175} 175}
176 176
177# @FUNCTION: check-reqs_get_number 177# @FUNCTION: check-reqs_get_number
178# @DESCRIPTION: 178# @DESCRIPTION:
179# Internal function that returns number without the unit. 179# Internal function that returns the numerical value without the unit.
180# Converts from 1G=1 or 150T=150. 180# Returns "1" for "1G" or "150" for "150T".
181check-reqs_get_number() { 181check-reqs_get_number() {
182 debug-print-function ${FUNCNAME} "$@" 182 debug-print-function ${FUNCNAME} "$@"
183 183
184 [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]" 184 [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
185 185
188 188
189 # Check for unset units and warn about them. 189 # Check for unset units and warn about them.
190 # Backcompat. 190 # Backcompat.
191 if [[ ${size} == ${1} ]]; then 191 if [[ ${size} == ${1} ]]; then
192 ewarn "QA: Package does not specify unit for the size check" 192 ewarn "QA: Package does not specify unit for the size check"
193 ewarn "QA: Assuming megabytes." 193 ewarn "QA: Assuming mebibytes."
194 ewarn "QA: File bug against the package. It should specify the unit." 194 ewarn "QA: File bug against the package. It should specify the unit."
195 fi 195 fi
196 196
197 echo ${size} 197 echo ${size}
198} 198}
199 199
200# @FUNCTION: check-reqs_get_unit 200# @FUNCTION: check-reqs_get_unit
201# @DESCRIPTION: 201# @DESCRIPTION:
202# Internal function that returns number without the unit. 202# Internal function that return the unit without the numerical value.
203# Converts from 1G=1 or 150T=150. 203# Returns "GiB" for "1G" or "TiB" for "150T".
204check-reqs_get_unit() { 204check-reqs_get_unit() {
205 debug-print-function ${FUNCNAME} "$@" 205 debug-print-function ${FUNCNAME} "$@"
206 206
207 [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]" 207 [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
208 208
209 local unit=${1:(-1)} 209 local unit=${1:(-1)}
210 210
211 case ${unit} in 211 case ${unit} in
212 G) echo "gigabytes" ;; 212 G) echo "GiB" ;;
213 [M0-9]) echo "megabytes" ;; 213 [M0-9]) echo "MiB" ;;
214 T) echo "terabytes" ;; 214 T) echo "TiB" ;;
215 *) 215 *)
216 die "${FUNCNAME}: Unknown unit: ${unit}" 216 die "${FUNCNAME}: Unknown unit: ${unit}"
217 ;; 217 ;;
218 esac 218 esac
219} 219}

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20