Gentoo Archives: gentoo-portage-dev

From: Simon Stelling <blubb@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] Refactoring ebuild.sh
Date: Sat, 26 Aug 2006 17:55:30
Message-Id: 44F08AE1.8090306@gentoo.org
1 Hi all,
2
3 ebuild.sh is a mess. There are a lot of functions scattered to the four
4 winds. Searching for a function in ebuild.sh takes a lot of time, and it
5 is very tiring to scroll down huge chunks of totally unrelated functions
6 just to find the next one which one is after. The current layout also
7 makes it very hard to find the spots where new functions/variables are
8 loaded from other files, what gets overwritten when profiles/eclasses
9 are sourced etc.
10
11 I would like to change that, so I tried to categorize all the functions
12 we have in ebuild.sh. I ended up with this setup:
13
14 Sandbox:
15 addread()
16 addwrite()
17 adddeny()
18 addpredict()
19 lchown()
20 lchgrp()
21
22 Unknown?:
23 esyslog()
24
25 Debugging:
26 register_die_hook()
27 diefunc()
28 dump_trace()
29 debug-print()
30 debug-print-function()
31 debug-print-section()
32
33 Internal helpers:
34 strip_duplicate_slashes()
35 remove_path_entry()
36
37 Action functions:
38 dyn_setup()
39 dyn_unpack()
40 dyn_clean()
41 dyn_compile()
42 dyn_test()
43 dyn_install()
44 dyn_preinst()
45 dyn_help()
46
47 Abort handlers:
48 abort_handler()
49 abort_compile()
50 abort_unpack()
51 abort_test()
52 abort_install()
53 killparent()
54
55 Default functions for ebuilds:
56 pkg_setup()
57 pkg_nofetch()
58 src_unpack()
59 src_compile()
60 src_test()
61 src_install()
62 pkg_preinst()
63 pkg_postinst()
64 pkg_prerm()
65 pkg_postrm()
66 pkg_config()
67
68 Ebuild helpers:
69 into()
70 insinto()
71 exeinto()
72 docinto()
73 insopts()
74 diropts()
75 exeopts()
76 libopts()
77 keepdir()
78 unpack()
79 econf()
80 einstall()
81 use()
82 usev()
83 useq()
84 has_version()
85 portageq()
86 best_version()
87 use_with()
88 use_enable()
89 gen_wrapper()
90 check_KV()
91 inherit()
92 EXPORT_FUNCTIONS()
93
94 Internal eclass functions:
95 newdepend()
96 newrdepend()
97 newpdepend()
98 do_newdepend()
99
100 I moved them into own files within a subdir in bin/, called modules, and
101 source these files at the right time, so that nothing changes
102 functionality wise. The global scope code I left untouched, except for a
103 bunch of exports that set sane defaults for the do*/new* helpers.
104
105 This cuts down ebuild.sh to 403 lines, which makes it far more readable,
106 IMO.
107
108 Doing the refactoring I also saw that there is a esyslog() in
109 isolated-functions.sh and one in ebuild.sh. The latter, which does
110 nothing but return zero, overwrites the former one. Is this intended or not?
111
112 I also set all the functions that aren't meant to be overridden by saved
113 env, profile bashrc, portage bashrc or ebuilds/eclasses readonly. If an
114 ebuild would ever try to re-define a function which is internally used
115 by portage, it would fail sourcing, which is a good thing, IMO.
116
117 So, if noone objects, I would like to push the attached patch into SVN.
118
119 --
120 Kind regards,
121
122 Simon Stelling
123 Gentoo/AMD64 developer

Attachments

File name MIME type
ebuild-refactoring1.patch text/x-patch

Replies

Subject Author
Re: [gentoo-portage-dev] Refactoring ebuild.sh Brian Harring <ferringb@×××××.com>