On Wed, 32 Aug 2011 10:57:08 +0200 Tomáš Chvátal <scarab...@gentoo.org> wrote:
> Good pointer is that we should probably check if the > MERGE_TYPE=binary and not check-reqs ram and disk_build in that case. > But there is slight problem how to do it in older eapis. We simply don't. Life is hard :P. > Also Michal if you want to have that DISK array thingu there could > you write a patch? Well, I don't see really a need for that if we're still keeping old vars. Now about the code: * I don't see units mentioned nor described in @DESCRIPTION or vars, > EXPORT_FUNCTIONS pkg_setup > case "${EAPI:-0}" in > 0|1|2|3) ;; > 4) EXPORT_FUNCTIONS pkg_pretend ;; > *) die "EAPI=${EAPI} is not supported" ;; > esac Either you export them (which breaks backwards compat) or require users to call them (your @CODE@). Don't do both, it's confusing. > check-reqs_get_megs() { > debug-print-function ${FUNCNAME} "$@" > > [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]" > > local unit=${1#${1%?}} > local size local unit=${1:(-1)} > > # Temporary workaround for unset units. > # Backcompat. > if [[ "${unit//*([[:digit:]])}" ]]; then > # the unit itself was set ; strip it out > size=${1%\%} > else > size=${1} > unit="M" > fi local size=${1%[GMT]} > > case ${unit} in > [gG]) echo $((1024 * ${size})) ;; > [mM]) echo ${size} ;; > [tT]) echo $((1024 * 1024 * ${size})) ;; I'd just go with capital letters there. [0-9]) echo ${size} ;; (you can add that to the 'M' cond) > *) > die "${FUNCNAME}: Unknown unit size: ${unit}" Size unit. Again. > ;; > esac > } > [gG]) echo "Gigabytes" ;; > [mM]) echo "Megabytes" ;; > [tT]) echo "Terabytes" ;; gibibytes, mebibytes, tebibytes. > # @FUNCTION: check-reqs_memory > # @DESCRIPTION: > # Internal function that checks space on the RAM. 'space on the RAM' sounds bad :P. > check-reqs_start_phase \ > $(check-reqs_get_number ${size}) \ > $(check-reqs_get_unit ${size}) \ > "RAM" Move the number/unit split to _start_phase()? > actual_memory=$(sed -n -e '/MemTotal:/s/^[^:]*: > *\([0-9]\+\) kB/\1/p' \ /proc/meminfo) awk '/MemTotal/ { print $2 }' /proc/meminfo > space_megs=$(df -Pm ${1} 2>/dev/null | sed -n \ > '$s/\(\S\+\s\+\)\{3\}\([0-9]\+\).*/\2/p' 2>/dev/null) OMFG. space_megs=$(df -Pm "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}') I guess. > # @FUNCTION: check-reqs_unsattisfied unsatisfied. > # @DEAULT_UNSET @INTERNAL. -- Best regards, Michał Górny
signature.asc
Description: PGP signature