1 |
2009-08-21 22:56:41 David Leverton napisał(a): |
2 |
> In EAPI 3, most commands and functions provided by the package |
3 |
> manager automatically call die if they fail. There's also a |
4 |
> new "nonfatal" function that can be used to suppress this |
5 |
> behaviour: by prefixing a function/command call with nonfatal, |
6 |
> the automatic die behaviour is suppressed during the executation |
7 |
> of that function/command. |
8 |
> |
9 |
> The difficulty here is that it's not clear what nonfatal should |
10 |
> do to explicit die and assert calls. On the one hand, if |
11 |
> nonfatal does suppress these functions, then nonfatal can be |
12 |
> usefully used with eclass functions - silly hypothetical example: |
13 |
> |
14 |
> # eclass |
15 |
> escons() { |
16 |
> scons "${@}" || die "scons failed" |
17 |
> } |
18 |
> |
19 |
> # ebuild |
20 |
> nonfatal escons || do_something_else |
21 |
> |
22 |
> On the other hand, it could be risky to change the behaviour of |
23 |
> existing functions like that: |
24 |
> |
25 |
> do_foo() { |
26 |
> cd foo || die "cd failed" |
27 |
> # something that would be dangerous if run in some other directory |
28 |
> } |
29 |
> |
30 |
> If called as "nonfatal do_foo" and the cd failed, do_foo |
31 |
> /wouldn't/ return a failure code - it would proceed with the rest |
32 |
> of its body and wreak all manner of havoc. |
33 |
> |
34 |
> One way around this would be to add either an option to die to |
35 |
> explicitly tell it to respect nonfatal, or an alternative die |
36 |
> function. This would allow eclasses to choose to respect |
37 |
> nonfatal when it's safe to do so, but without changing existing |
38 |
> behaviour. The disadvantage of this is that it would require |
39 |
> changes to all eclass functions that could potentially use it, |
40 |
> plus the slight ugliness of making them handle older EAPIs as |
41 |
> well. |
42 |
> |
43 |
> Another option would be to make die respect nonfatal by default, |
44 |
> and add an option that doesn't. This wouldn't require changes to |
45 |
> eclasses that want the nonfatal behaviour, but it would require |
46 |
> some care to make sure that it was used when necessary. A |
47 |
> potential advantage of this over the previous solution is that if |
48 |
> the "force" option is implemented with an environment variable, |
49 |
> it can be used regardless of EAPI - the previous example could be |
50 |
> changed to something like |
51 |
> |
52 |
> do_foo() { |
53 |
> cd foo || DIE_FORCE=1 die "cd failed" |
54 |
> # something that would be dangerous if run in some other directory |
55 |
> } |
56 |
> |
57 |
> Does anyone have any opinions on which of the four options (#1 |
58 |
> make die respect nonfatal, #2 make die always die, #3 add a new |
59 |
> die variant that respects nonfatal, #4 make regular die respect |
60 |
> nonfatal, and add a new variant that doesn't) we should go with? |
61 |
|
62 |
I think that 'DIE_FORCE=1 die "${die_message}"' (which was invented by me) would be the |
63 |
best option. It will allow to use nonfatal() with eclass functions with the smallest |
64 |
number of required changes in eclasses. |
65 |
|
66 |
I would like to also notice that (not yet approved by Council) definition of nonfatal() |
67 |
in PMS was recently drastically changed without proper discussion with developers of |
68 |
other package managers. [1] was sent about 20 minutes after discussion about nonfatal() |
69 |
started in #gentoo-portage in about 2009-08-06 19:45 UTC. |
70 |
(I'm attaching IRC log from #gentoo-portage (in UTC+02 timezone).) |
71 |
I think that such drastic changes should be first discussed on gentoo-dev mailing list. |
72 |
|
73 |
[1] http://archives.gentoo.org/gentoo-pms/msg_5ae501394eaeff148cfc349f84d960c9.xml |
74 |
|
75 |
-- |
76 |
Arfrever Frehtes Taifersar Arahesis |