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

Attachments

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

Replies

Subject Author
Re: [gentoo-dev] [RFC] check-reqs.eclass.patch "Tomáš Chvátal" <scarabeus@g.o>
Re: [gentoo-dev] [RFC] check-reqs.eclass.patch Alec Warner <antarus@g.o>