Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: scarabeus@g.o
Subject: Re: [gentoo-dev] [RFC] check-reqs.eclass.patch
Date: Tue, 30 Aug 2011 09:05:02
Message-Id: 20110830110601.201e6d6e@pomiocik.lan
In Reply to: Re: [gentoo-dev] [RFC] check-reqs.eclass.patch by "Tomáš Chvátal"
1 On Tue, 30 Aug 2011 10:04:50 +0200
2 Tomáš Chvátal <scarabeus@g.o> wrote:
3
4 > >> + [[ -n ${CHECKREQS_DISK_BUILD} ]]&& \
5 > >> + check-reqs_disk \
6 > >> + "${T}" \
7 > >> + "${CHECKREQS_DISK_BUILD}"
8 > >
9 > > Why not WORKDIR?
10 > I thought workdir is present later than $T plus it was used before
11 > and I just kept it.
12
13 Ok, WORKDIR may not exist in pkg_setup()/pkg_pretend() indeed.
14
15 On the other hand, you should perform those checks only when building
16 sources and not when installing binpkg. Think about that.
17
18 > >> +
19 > >> + [[ -n ${CHECKREQS_DISK_USR} ]]&& \
20 > >> + check-reqs_disk \
21 > >> + "${EROOT}/usr" \
22 > >> + "${CHECKREQS_DISK_USR}"
23 > >> +
24 > >> + [[ -n ${CHECKREQS_DISK_VAR} ]]&& \
25 > >> + check-reqs_disk \
26 > >> + "${EROOT}/var" \
27 > >> + "${CHECKREQS_DISK_VAR}"
28 > >> +}
29 > >
30 > > Also, it may be a good idea to add some kind of generic var for
31 > > this. Like:
32 > >
33 > > CHECKREQS_DISK_INSTALLED=( /usr 1234M /var 2345M )
34 > I dont think that syntax like this would be more readable than the
35 > current one. Plus I preffer keeping backcompat the easy way
36
37 But it won't limit you to random dirs in the fs.
38
39 > >> +# @DESCRIPTION:
40 > >> +# Internal function that returns number in megabites.
41 > >> +# Converts from 1G=1024 or 1T=1048576
42 > >> +check-reqs_get_megs() {
43 > >> + debug-print-function ${FUNCNAME} "$@"
44 > >> +
45 > >> + [[ -z ${1} ]]&& die "Usage: ${FUNCNAME} [size]"
46 > >> +
47 > >> + local unit=${1//[[:digit:]]/}
48 > >> + local size=${1//[[:alpha:]]/}
49 > >
50 > > Seems hacky and poor. What if one uses '1G234'? :P
51 > Yeah I will rather ignore it and just expect the users of the eclass
52 > are not complete asses.
53
54 Maybe you should simply use '#' and '%' like in clear shell
55 substitutions rather than running such a heavy substitutions?
56
57 Not to mention in your case basically getting the last char would
58 suffice.
59
60 > > Start from scratch, write check-reqs-r1, make it SIMPLE.
61 > >
62 > Won't create new function for simple usage like this.
63 >
64 > If you really consider this similar to python eclass you should look
65 > in that again, this is actually quite simple bash compared to it :)
66
67 Quite simple bash doesn't do regexps that much. And if someone uses
68 regexps that heavily, that means he misses a point.
69
70 --
71 Best regards,
72 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature