1 |
On Sat, Nov 04, 2006 at 01:33:49AM -0800, Zac Medico wrote: |
2 |
> Hi everyone, |
3 |
> |
4 |
> As many of you probably know already, bug 46223 [1] prevents the |
5 |
> proper uninstallation of a package when one or more of the eclasses |
6 |
> that it inherits are missing from the live portage tree. |
7 |
> |
8 |
> There are essentially two ways to solve this problem: |
9 |
> |
10 |
> Approach #1: Reuse the saved environment which contains a mixture of |
11 |
> eclasses and parts of the package manager (such as portage's |
12 |
> ebuild.sh) that performed the installation. |
13 |
|
14 |
That's not technically true; what is required is stripping the manager |
15 |
*out* of the env, leaving in only things that are part of the ebuild |
16 |
env (eapi crap basically). |
17 |
|
18 |
There are a few exceptions to this, but those exceptions are covering |
19 |
unversioned changes in the ebuild api (cue EAPI); example being the |
20 |
use function going silent after .50-r11; since older ebuilds relied on |
21 |
use echoing the flag to stdout if it was enabled, you have to use the |
22 |
ebuild envs copy of it to avoid breaking older installed ebuilds |
23 |
(something portage ignored, and broke I might add). |
24 |
|
25 |
|
26 |
> Approach #2: Save copies of the raw eclasses and use them, together |
27 |
> with the saved ebuild, to recreate the environment. |
28 |
> |
29 |
> A major advantage of approach #1 is that it can potentially provide |
30 |
> complete restoration of the install-time environment. The major |
31 |
> disadvantage is that the saved environment needs to be purified so |
32 |
> that parts of the package manager that did the install do not |
33 |
> interfere with the package manager that does the uninstall. |
34 |
> The |
35 |
> purification process could potentially be complex or error prone, |
36 |
> making it difficult to maintain or unreliable. |
37 |
|
38 |
The complexity comes down to tracking what the manager provides, and |
39 |
knowing the internal vars to strip (DISTDIR is a system specific |
40 |
setting, should be pulled from the local system everytime)... |
41 |
|
42 |
This actually is a *good* thing; |
43 |
|
44 |
1) forces ebuild.sh functionality to be written nonsucky, namely being |
45 |
aware of the side affects of function invocations; specifically, not |
46 |
bleeding vars (use local like a mad man). |
47 |
|
48 |
2) actually allows distdir/portdir to change between phases if the |
49 |
user (typically a dev) is running phases manually for testing, and |
50 |
happens to change something in between phases (happens, and is |
51 |
annoying). |
52 |
|
53 |
So... it requires having at least an audited ebuild.sh, which is |
54 |
pretty simple (good thing to do anyways), and a bash side that isn't |
55 |
fragile. |
56 |
|
57 |
The *one* spot I'd define as tricky is stripping functions out of the |
58 |
environment dump, since sans pkgcores filter-env, no good method |
59 |
existed for it till recently; <bash-3.2 would choke on certain |
60 |
functions (try f-x() { :; }; declare -f f-x on 3.1 sometime), which's |
61 |
--read-function blows, and the grep approach is a total no go (here |
62 |
ops can cause a fair bit of hell for line based grep). |
63 |
|
64 |
That said, with bash 3.2 doing a selective dump of the environment is |
65 |
now doable completely in pure bash, far simpler implementation. |
66 |
|
67 |
So, error prone? Not really in my experience; any bugs I've hit over |
68 |
the last 2 years of running ebd off and on have always been related |
69 |
to trying to match filter-env to bash parsing rules; with bash 3.2, |
70 |
can do it in about 10 lines of shell give or take. |
71 |
|
72 |
|
73 |
> Simplicity is the major advantage approach #2. The eclasses that |
74 |
> are used by a package could be stored in eclasses.tbz2 (much like |
75 |
> enviroment.bz2 is currently stored for each installed package), and |
76 |
> the environment could be recreated from scratch by using the ebuild |
77 |
> and eclasses in the normal inherit process. |
78 |
|
79 |
Addressed below... |
80 |
|
81 |
|
82 |
> This wouldn't |
83 |
> necessarily allow access to the complete build-time or install-time |
84 |
> environment, but that feature is not currently available anyway. |
85 |
|
86 |
Was at one point. Bit curious what happened to those changes since I |
87 |
went through and fixed all of that crap about a year back (it *may* |
88 |
have stayed only in the portage-2.1_alpha branch). |
89 |
|
90 |
|
91 |
> If |
92 |
> we save the raw eclasses for each installed package, we can easily |
93 |
> gain the ability to remove eclasses from the portage tree and make |
94 |
> incompatible api changes when necessary, without the complexity of |
95 |
> environment purification. |
96 |
|
97 |
That data isn't in the vdb *now*, and there is no way to force folks |
98 |
to upgrade *now*. |
99 |
|
100 |
This isn't one of the normal "wait six months, and then make them go |
101 |
through a bit of hell", this is "break their ability to use all |
102 |
preexisting binpkgs and make it far easier for folks to have pkgs |
103 |
that cannot be uninstalled". |
104 |
|
105 |
You cannot screw with the existing eclasses in a backwards |
106 |
incompatible way without running a real risk of breaking vdb/binpkg |
107 |
ebuilds (built ebuilds essentially); re-read glep33 and |
108 |
experiment locally if in doubt. |
109 |
|
110 |
|
111 |
> The sooner that we start storing eclasses.tbz2 for |
112 |
> each installed package, the sooner that we will be able to have more |
113 |
> freedom with the eclasses in the live portage tree. |
114 |
|
115 |
Reiterating it again since this is massively wrong; read glep33. |
116 |
Existing eclasses pretty much are stuck in the tree until it's decided |
117 |
to cause a fair bit of hell for folks lagging behind on their $PKG_MANAGER |
118 |
updates. |
119 |
|
120 |
That is the sole reason that glep33 required moving all new eclasses |
121 |
to eclass2, a location that existing managers do not know about; keeps |
122 |
folks who have crappy managers from touching the dynamic eclasses and |
123 |
winding up broke, while removing the static restriction on the new |
124 |
eclasses. |
125 |
|
126 |
|
127 |
> What do people think about these two approaches? Personally, I |
128 |
> would prefer approach #2 for the sake of simplicity and |
129 |
> maintainability. |
130 |
|
131 |
One thing that hasn't yet been mentioned is that ebuilds are written |
132 |
to expect their environment to be accessible through the phases; folks |
133 |
*expect* that if they set something in src_compile, it'll be there in |
134 |
src_install. |
135 |
|
136 |
Re-sourcing the ebuild/eclass for every phase means that it's now |
137 |
possible for the ebuild/eclass to inadvertantly corrupt the stored |
138 |
phase state; extension of this problem is that profile.env and friends |
139 |
get sourced *after* the ebuilds phase dump is restored. |
140 |
|
141 |
Short version; look at java-2 eclass, and note that they're using a |
142 |
user specific hook to restore the environment prior to every single |
143 |
phase execution. They're forced to do this because portage assumes it |
144 |
can rebuild the environment via re-executing code that is intended to |
145 |
*generate* an initial environment. |
146 |
|
147 |
You run from the (existing) saved env, it works now for vdb, for |
148 |
binpkgs, enables dynamic eclasses, and wipes out the entire class of |
149 |
issues from the manager/initial env screwing up the ebuilds expected |
150 |
stated. Approach #2 doesn't. |
151 |
|
152 |
Finally, portage already has an implementation of proper environemnt |
153 |
saving/restoration- portage-2.1_alpha* holds EBD, and pkgcore holds |
154 |
the current version of it. Ripping it out of pkgcore and pushing |
155 |
in the updates is fairly straight forward work (rote), and carries |
156 |
with it a 2x regen speedup while fixing the issues from above. |
157 |
|
158 |
Already got pkgcores cache, might as well rip out more bits ;) |
159 |
|
160 |
Not after the regen speed up via daemonizing ebuild.sh? Fair |
161 |
enough, the code for proper env saving/restoration isn't bound to it; |
162 |
can rip that out without issue. |
163 |
|
164 |
So... basically either pull a NIH, or nudge portage the remaining |
165 |
steps to gain the full support (harsh, but the environment data is |
166 |
there and has been for a long while, it's just a matter of using the |
167 |
work I've already done to finish the job). |
168 |
|
169 |
~harring |