1 |
On Wed, Aug 31, 2011 at 3:14 AM, Michał Górny <mgorny@g.o> wrote: |
2 |
> On Wed, 32 Aug 2011 10:57:08 +0200 |
3 |
> Tomáš Chvátal <scarabeus@g.o> wrote: |
4 |
> |
5 |
>> Good pointer is that we should probably check if the |
6 |
>> MERGE_TYPE=binary and not check-reqs ram and disk_build in that case. |
7 |
>> But there is slight problem how to do it in older eapis. |
8 |
> |
9 |
> We simply don't. Life is hard :P. |
10 |
> |
11 |
>> Also Michal if you want to have that DISK array thingu there could |
12 |
>> you write a patch? |
13 |
> |
14 |
> Well, I don't see really a need for that if we're still keeping old |
15 |
> vars. |
16 |
> |
17 |
> Now about the code: |
18 |
> |
19 |
> * I don't see units mentioned nor described in @DESCRIPTION or vars, |
20 |
> |
21 |
>> EXPORT_FUNCTIONS pkg_setup |
22 |
>> case "${EAPI:-0}" in |
23 |
>> 0|1|2|3) ;; |
24 |
>> 4) EXPORT_FUNCTIONS pkg_pretend ;; |
25 |
>> *) die "EAPI=${EAPI} is not supported" ;; |
26 |
>> esac |
27 |
> |
28 |
> Either you export them (which breaks backwards compat) or require users |
29 |
> to call them (your @CODE@). Don't do both, it's confusing. |
30 |
> |
31 |
>> check-reqs_get_megs() { |
32 |
>> debug-print-function ${FUNCNAME} "$@" |
33 |
>> |
34 |
>> [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]" |
35 |
>> |
36 |
>> local unit=${1#${1%?}} |
37 |
>> local size |
38 |
> |
39 |
> local unit=${1:(-1)} |
40 |
> |
41 |
>> |
42 |
>> # Temporary workaround for unset units. |
43 |
>> # Backcompat. |
44 |
>> if [[ "${unit//*([[:digit:]])}" ]]; then |
45 |
>> # the unit itself was set ; strip it out |
46 |
>> size=${1%\%} |
47 |
>> else |
48 |
>> size=${1} |
49 |
>> unit="M" |
50 |
>> fi |
51 |
> |
52 |
> local size=${1%[GMT]} |
53 |
> |
54 |
>> |
55 |
>> case ${unit} in |
56 |
>> [gG]) echo $((1024 * ${size})) ;; |
57 |
>> [mM]) echo ${size} ;; |
58 |
>> [tT]) echo $((1024 * 1024 * ${size})) ;; |
59 |
|
60 |
Also it is my understanding that all tokens in $(()) go through |
61 |
expansion, so for instance: |
62 |
|
63 |
$(( 1024 * 1024 * size )) |
64 |
|
65 |
and |
66 |
|
67 |
$(( 1024 * 1024 * ${size})) are equivalent. |
68 |
|
69 |
Is this only in bash4? |
70 |
Do we have a style preference? |
71 |
|
72 |
> |
73 |
> I'd just go with capital letters there. |
74 |
> |
75 |
> [0-9]) echo ${size} ;; |
76 |
> |
77 |
> (you can add that to the 'M' cond) |
78 |
> |
79 |
>> *) |
80 |
>> die "${FUNCNAME}: Unknown unit size: ${unit}" |
81 |
> |
82 |
> Size unit. Again. |
83 |
> |
84 |
>> ;; |
85 |
>> esac |
86 |
>> } |
87 |
> |
88 |
>> [gG]) echo "Gigabytes" ;; |
89 |
>> [mM]) echo "Megabytes" ;; |
90 |
>> [tT]) echo "Terabytes" ;; |
91 |
> |
92 |
> gibibytes, mebibytes, tebibytes. |
93 |
> |
94 |
>> # @FUNCTION: check-reqs_memory |
95 |
>> # @DESCRIPTION: |
96 |
>> # Internal function that checks space on the RAM. |
97 |
> |
98 |
> 'space on the RAM' sounds bad :P. |
99 |
> |
100 |
>> check-reqs_start_phase \ |
101 |
>> $(check-reqs_get_number ${size}) \ |
102 |
>> $(check-reqs_get_unit ${size}) \ |
103 |
>> "RAM" |
104 |
> |
105 |
> Move the number/unit split to _start_phase()? |
106 |
> |
107 |
>> actual_memory=$(sed -n -e '/MemTotal:/s/^[^:]*: |
108 |
>> *\([0-9]\+\) kB/\1/p' \ /proc/meminfo) |
109 |
> |
110 |
> awk '/MemTotal/ { print $2 }' /proc/meminfo |
111 |
> |
112 |
>> space_megs=$(df -Pm ${1} 2>/dev/null | sed -n \ |
113 |
>> '$s/\(\S\+\s\+\)\{3\}\([0-9]\+\).*/\2/p' 2>/dev/null) |
114 |
> |
115 |
> OMFG. |
116 |
> |
117 |
> space_megs=$(df -Pm "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}') |
118 |
> |
119 |
> I guess. |
120 |
> |
121 |
>> # @FUNCTION: check-reqs_unsattisfied |
122 |
> |
123 |
> unsatisfied. |
124 |
> |
125 |
>> # @DEAULT_UNSET |
126 |
> |
127 |
> @INTERNAL. |
128 |
> |
129 |
> -- |
130 |
> Best regards, |
131 |
> Michał Górny |
132 |
> |