1 |
On Sat, Aug 26, 2006 at 07:54:41PM +0200, Simon Stelling wrote: |
2 |
> Hi all, |
3 |
> |
4 |
> ebuild.sh is a mess. There are a lot of functions scattered to the four |
5 |
> winds. Searching for a function in ebuild.sh takes a lot of time, and it |
6 |
> is very tiring to scroll down huge chunks of totally unrelated functions |
7 |
> just to find the next one which one is after. The current layout also |
8 |
> makes it very hard to find the spots where new functions/variables are |
9 |
> loaded from other files, what gets overwritten when profiles/eclasses |
10 |
> are sourced etc. |
11 |
> |
12 |
> I would like to change that, so I tried to categorize all the functions |
13 |
> we have in ebuild.sh. I ended up with this setup: |
14 |
|
15 |
categorization is a bit whonky in a few spots- |
16 |
|
17 |
> Sandbox: |
18 |
> addread() |
19 |
> addwrite() |
20 |
> adddeny() |
21 |
> addpredict() |
22 |
> lchown() |
23 |
> lchgrp() |
24 |
> |
25 |
> Unknown?: |
26 |
> esyslog() |
27 |
> |
28 |
> Debugging: |
29 |
> register_die_hook() |
30 |
|
31 |
ebuild specific func, while debugging, it's not ebuild.sh debugging. |
32 |
|
33 |
> diefunc() |
34 |
> dump_trace() |
35 |
|
36 |
these are general utility, not debugging. |
37 |
|
38 |
> debug-print() |
39 |
> debug-print-function() |
40 |
> debug-print-section() |
41 |
> |
42 |
> Internal helpers: |
43 |
> strip_duplicate_slashes() |
44 |
> remove_path_entry() |
45 |
> |
46 |
> Action functions: |
47 |
> dyn_setup() |
48 |
> dyn_unpack() |
49 |
> dyn_clean() |
50 |
> dyn_compile() |
51 |
> dyn_test() |
52 |
> dyn_install() |
53 |
> dyn_preinst() |
54 |
> dyn_help() |
55 |
> |
56 |
> Abort handlers: |
57 |
> abort_handler() |
58 |
> abort_compile() |
59 |
> abort_unpack() |
60 |
> abort_test() |
61 |
> abort_install() |
62 |
> killparent() |
63 |
|
64 |
internal is a better label. |
65 |
|
66 |
|
67 |
> Default functions for ebuilds: |
68 |
> pkg_setup() |
69 |
> pkg_nofetch() |
70 |
> src_unpack() |
71 |
> src_compile() |
72 |
> src_test() |
73 |
> src_install() |
74 |
> pkg_preinst() |
75 |
> pkg_postinst() |
76 |
> pkg_prerm() |
77 |
> pkg_postrm() |
78 |
> pkg_config() |
79 |
> |
80 |
> Ebuild helpers: |
81 |
> into() |
82 |
> insinto() |
83 |
> exeinto() |
84 |
> docinto() |
85 |
> insopts() |
86 |
> diropts() |
87 |
> exeopts() |
88 |
> libopts() |
89 |
> keepdir() |
90 |
> unpack() |
91 |
> econf() |
92 |
> einstall() |
93 |
> use() |
94 |
> usev() |
95 |
> useq() |
96 |
> has_version() |
97 |
> portageq() |
98 |
> best_version() |
99 |
> use_with() |
100 |
> use_enable() |
101 |
> gen_wrapper() |
102 |
> check_KV() |
103 |
> inherit() |
104 |
> EXPORT_FUNCTIONS() |
105 |
|
106 |
Most of these are mislabed; gen_wrapper is an internal function that |
107 |
ebuilds shouldn't know about, nor ever access. It's existance was |
108 |
strictly to cover gcc's ass; considering it's usage was strictly |
109 |
implementation side (rather then ebuild side), probably can be |
110 |
dropped. |
111 |
|
112 |
Either way, ain't a helper. has is missing also... |
113 |
|
114 |
If you're going to try breaking the beast up, suggest you go the step |
115 |
further and break up what must be supplied from the ebuild.sh |
116 |
implementation, and what is bound to the ebuild's environment. |
117 |
|
118 |
|
119 |
> Internal eclass functions: |
120 |
> newdepend() |
121 |
> newrdepend() |
122 |
> newpdepend() |
123 |
> do_newdepend() |
124 |
|
125 |
These aren't eclass functions- usable without involving eclasses. |
126 |
inherit ought to be in internal eclass functions also (yes it's user |
127 |
visible, but it's also ebuild.sh implementation specific). |
128 |
|
129 |
|
130 |
> I moved them into own files within a subdir in bin/, called modules, and |
131 |
> source these files at the right time, so that nothing changes |
132 |
> functionality wise. The global scope code I left untouched, except for a |
133 |
> bunch of exports that set sane defaults for the do*/new* helpers. |
134 |
> |
135 |
> This cuts down ebuild.sh to 403 lines, which makes it far more readable, |
136 |
> IMO. |
137 |
|
138 |
Except there are now magic vars hidden away in submodules. If trying |
139 |
to seperate it into seperate blocks, document 'em. |
140 |
|
141 |
|
142 |
> I also set all the functions that aren't meant to be overridden by saved |
143 |
> env, profile bashrc, portage bashrc or ebuilds/eclasses readonly. |
144 |
|
145 |
Don't think much thought was put into this tbh- use* and has* (all but |
146 |
useq and hasq basically) are bound to the ebuild environment. |
147 |
|
148 |
Why? Because they got mangled transitioning from 2.0.50 2.0.51, for |
149 |
the ebuild to function properly it needs to use the original func from |
150 |
the environment, not what the ebuild.sh implementation tries to force. |
151 |
|
152 |
Identified all of them that are affected by this? |
153 |
|
154 |
Further, all of these are still overridable by *bashrc and env. |
155 |
|
156 |
|
157 |
> If an ebuild would ever try to re-define a function which is |
158 |
> internally used by portage, it would fail sourcing, which is a good |
159 |
> thing, IMO. |
160 |
|
161 |
Actually it doesn't fail sourcing. |
162 |
|
163 |
echo 'f() { echo "grande tiza"; }; :;' > t; |
164 |
. t |
165 |
readonly -f f |
166 |
. t && echo "it relies on the last exit code, which was $?" |
167 |
|
168 |
|
169 |
> So, if noone objects, I would like to push the attached patch into SVN. |
170 |
|
171 |
Drop the readonly crap; it's not actually blocking anything, just |
172 |
attempting to catch non real issues; in the process, it actually is a |
173 |
step in the wrong direction. |
174 |
|
175 |
If a func is going to marked as immutable, it's implicitly |
176 |
implementation specific- as such it has no business winding up in the |
177 |
environment file. |
178 |
|
179 |
Reordering is a bit arbitrary, but fine. Attempted env changes, would |
180 |
avoid those. |
181 |
|
182 |
~harring |