1 |
Hello, everyone. |
2 |
|
3 |
Portage has currently two major QA mechanisms: repoman |
4 |
and install_qa_check(). While we would love to put all the QA |
5 |
in repoman and make it the ultimate tool preventing bad commits, it is |
6 |
very limited in power. Most importantly, it can't really access |
7 |
the build environment of an ebuild or the files installed by it. That's |
8 |
why install_qa_check() is very important. |
9 |
|
10 |
At the moment, install_qa_check() is one huge function that is run |
11 |
after src_install(). It does all the QA checks but also stripping, |
12 |
document compression and a few other random tasks since 'that was |
13 |
a convenient place to put them'. Since it is not really convenient to |
14 |
have all the QA checks randomly placed in one function, I've recently |
15 |
started refactoring that code. I would like to share my vision with you |
16 |
and get your feedback. |
17 |
|
18 |
|
19 |
I would like the post-install QA checks to be modularized, standardized |
20 |
and extensible. For a start, I've split most of the function into |
21 |
install-qa-check.d/ scripts in Portage and made install_qa_check() |
22 |
function run them [1]. However, that's just a start. |
23 |
|
24 |
I would like to have install-qa-check.d in three main places: |
25 |
|
26 |
1. /usr/lib/portage/install-qa-check.d (or alike) for scripts |
27 |
installed by Portage and other packages, |
28 |
|
29 |
2. /etc/portage/install-qa-check.d for extra scripts installed |
30 |
by sysadmin, |
31 |
|
32 |
3. ${repo}/metadata/install-qa-check.d for repository-specific |
33 |
QA checks. |
34 |
|
35 |
The rationale for (3) is quite simple: many of the modern QA checks are |
36 |
results of policies specific to Gentoo tree and the eclasses in it -- |
37 |
like my recent bash-completion checks (still in review queue). Keeping |
38 |
them in Portage is cumbersome, and has some code duplication factor. |
39 |
|
40 |
For this to work, the whole scheme needs to be standardized properly. |
41 |
I think that the following rules could do the job well: |
42 |
|
43 |
1. QA check scripts are run after src_install() but before any other |
44 |
post-install procedures such as stripping and compression. Checks have |
45 |
full access to the ebuild environment equivalent to src_install(). |
46 |
|
47 |
2. Checks are sourced in a subshell. This means that they can randomly |
48 |
play with environment, working directory and bash options without |
49 |
bothering to restore them. |
50 |
|
51 |
2a. That is, the snippet used to run them looks like: |
52 |
|
53 |
( source "${f}" || die "sourcing ${f} failed" ) |
54 |
|
55 |
2b. Unless someone knows a way around this, this means that the check |
56 |
-- unless 'die'-fatal -- needs to ensure non-zero status of last |
57 |
comment, likely via some trailing 'true' or ':'. Since we can't |
58 |
distinguish between non-zero return from script and non-zero exit due to |
59 |
syntax error or so. |
60 |
|
61 |
3. Checks can be non-fatal (output warnings) or fatal (die). Checks can |
62 |
also automatically fix some issues while outputting a warning (like we |
63 |
strip unsafe RPATHs right now or remove executable bits from static |
64 |
libs). |
65 |
|
66 |
3a. Do we want to legalize eqawarn at some point? Or just use ewarn |
67 |
here? |
68 |
|
69 |
3b. We really do want to legalize die in subshells. We can't live |
70 |
without it anyway, so why pretending it's illegal? |
71 |
|
72 |
4. Checks can inherit eclasses. This goes opposite the generic rule |
73 |
but allows us to save some code duplication. For example, we can get |
74 |
paths from eclasses instead of reinventing them. It's also relatively |
75 |
safe since we're in a subshell. |
76 |
|
77 |
4a. But you need to be careful not to break the working tree, or fail |
78 |
due to EAPI unsupported by eclass or something like that :). |
79 |
|
80 |
|
81 |
What do you think? Did I miss something? Do you have any ideas how to |
82 |
improve this? |
83 |
|
84 |
|
85 |
[1]:https://github.com/mgorny/portage/commit/install-qa-check-refactor |
86 |
|
87 |
-- |
88 |
Best regards, |
89 |
Michał Górny |