1 |
Hi all, |
2 |
|
3 |
I have thought a bit more about how to better organize the bash-side of |
4 |
portage and came to the conclusion that modularization of ebuild.sh (as |
5 |
proposed in the recent thread "Refactoring ebuild.sh") can't be the only |
6 |
and is not the best thing to do. |
7 |
|
8 |
There is a fair amount of shell scripts and functions in the portage svn |
9 |
repo that do not really belong there. For example all do*/new* scripts |
10 |
in the bin/ directory. These are scripts that are not specific to |
11 |
portage's implementation but the ebuilds that use it. That's why I think |
12 |
we should move them more towards the ebuilds: Inside the tree. |
13 |
|
14 |
This has the advantage that paludis/pkgcore don't have to keep their |
15 |
helper scripts in sync with portages, that they get more visible to |
16 |
ebuild devs (to some, especially the new ones, they seem like magic |
17 |
commands that just come out of the middle of nowhere) and most |
18 |
importantly, that they are where they belong. ;o) |
19 |
|
20 |
Having them in the tree rather than portage would avoid bugs along the |
21 |
lines of bug 121317 [1] and bug 136792 [2], or at least pull them off |
22 |
portage's radar. As those functions are really the ebuild devs' area, |
23 |
that's only a good thing, IMO. |
24 |
|
25 |
As they reminded me very much of eclass functions, I converted them into |
26 |
functions and put together an 'install-helpers.eclass'. Having them as |
27 |
functions has the advantage of being able to create all of the new* |
28 |
functions with zero redundancy and only few lines of code and being in |
29 |
the same line as other helping utilities like the ones provided by |
30 |
eutils and other eclasses. It has the disadvantage of not being able to |
31 |
execute them with `find -exec' or `xargs'. However, that is not too much |
32 |
of a problem in my eyes: I scanned the tree and out of the ~2400 ebuilds |
33 |
that use find -exec/exec/xargs, none used it in combination with the |
34 |
scripts I propose to convert to functions. |
35 |
|
36 |
Having them in an eclass raises the problem of ebuilds having to inherit |
37 |
said eclass, though. Even if it would be the correct way, I am not all |
38 |
that keen on adding a 'inherit install-helpers' to ~15'000 ebuilds, so I |
39 |
solved the problem this way: |
40 |
|
41 |
--- ebuild.sh 2006-09-03 15:39:22 UTC |
42 |
+++ ebuild.sh 2006-09-03 15:53:02 UTC |
43 |
@@ -1350,6 +1350,9 @@ |
44 |
# this can be left out of ebd variants, since they're unaffected. |
45 |
unset EBUILD_DEATH_HOOKS |
46 |
|
47 |
+# let the profiles define eclasses to automatically load for every ebuild |
48 |
+[[ -n ${PORTAGE_ECLASS_AUTOLOAD} ]] && inherit ${PORTAGE_ECLASS_AUTOLOAD} |
49 |
+ |
50 |
source ${EBUILD} || die "error sourcing ebuild" |
51 |
if ! hasq depend $EBUILD_PHASE; then |
52 |
RESTRICT="${PORTAGE_RESTRICT}" |
53 |
|
54 |
Setting PORTAGE_ECLASS_AUTOLOAD enables every repository to define its |
55 |
own set of "standard functions". |
56 |
|
57 |
Note that I don't really care how the functions/scripts get into the |
58 |
tree, it only matters to me *that* they are in the tree, so I'm open to |
59 |
other suggestions. Also, this is probably not the only heap of functions |
60 |
to move out of portage into the tree, I just didn't want to do more |
61 |
before I know what way to choose. |
62 |
|
63 |
Suggestions, comments, alternative approaches, flames, all are welcome. |
64 |
|
65 |
[1] http://bugs.gentoo.org/show_bug.cgi?id=121317 |
66 |
[2] http://bugs.gentoo.org/show_bug.cgi?id=136792 |
67 |
|
68 |
-- |
69 |
Kind Regards, |
70 |
|
71 |
Simon Stelling |
72 |
Gentoo/AMD64 developer |