On Tue, 30 Aug 2011 10:04:50 +0200 Tomáš Chvátal <scarab...@gentoo.org> wrote:
> >> + [[ -n ${CHECKREQS_DISK_BUILD} ]]&& \ > >> + check-reqs_disk \ > >> + "${T}" \ > >> + "${CHECKREQS_DISK_BUILD}" > > > > Why not WORKDIR? > I thought workdir is present later than $T plus it was used before > and I just kept it. Ok, WORKDIR may not exist in pkg_setup()/pkg_pretend() indeed. On the other hand, you should perform those checks only when building sources and not when installing binpkg. Think about that. > >> + > >> + [[ -n ${CHECKREQS_DISK_USR} ]]&& \ > >> + check-reqs_disk \ > >> + "${EROOT}/usr" \ > >> + "${CHECKREQS_DISK_USR}" > >> + > >> + [[ -n ${CHECKREQS_DISK_VAR} ]]&& \ > >> + check-reqs_disk \ > >> + "${EROOT}/var" \ > >> + "${CHECKREQS_DISK_VAR}" > >> +} > > > > Also, it may be a good idea to add some kind of generic var for > > this. Like: > > > > CHECKREQS_DISK_INSTALLED=( /usr 1234M /var 2345M ) > I dont think that syntax like this would be more readable than the > current one. Plus I preffer keeping backcompat the easy way But it won't limit you to random dirs in the fs. > >> +# @DESCRIPTION: > >> +# Internal function that returns number in megabites. > >> +# Converts from 1G=1024 or 1T=1048576 > >> +check-reqs_get_megs() { > >> + debug-print-function ${FUNCNAME} "$@" > >> + > >> + [[ -z ${1} ]]&& die "Usage: ${FUNCNAME} [size]" > >> + > >> + local unit=${1//[[:digit:]]/} > >> + local size=${1//[[:alpha:]]/} > > > > Seems hacky and poor. What if one uses '1G234'? :P > Yeah I will rather ignore it and just expect the users of the eclass > are not complete asses. Maybe you should simply use '#' and '%' like in clear shell substitutions rather than running such a heavy substitutions? Not to mention in your case basically getting the last char would suffice. > > Start from scratch, write check-reqs-r1, make it SIMPLE. > > > Won't create new function for simple usage like this. > > If you really consider this similar to python eclass you should look > in that again, this is actually quite simple bash compared to it :) Quite simple bash doesn't do regexps that much. And if someone uses regexps that heavily, that means he misses a point. -- Best regards, Michał Górny
signature.asc
Description: PGP signature