Gentoo Archives: gentoo-dev

From: Joshua Nichols <nichoj@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Changes to the way Java packages are built
Date: Tue, 20 Jun 2006 00:14:49
Message-Id: 44973CC3.9020901@gentoo.org
In Reply to: [gentoo-dev] Changes to the way Java packages are built by Joshua Nichols
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Joshua Nichols wrote:
5 > = Background =
6 >
7 > As some might have noticed, Java 1.5 has been package.masked for some
8 > time now. There are a number of issues introduced with 1.5 that have
9 > kept it in package.mask. Please see the Java 1.5 FAQ [1] for more details.
10 >
11 > [1] http://www.gentoo.org/proj/en/java/tiger-faq.xml
12 >
13 > About a year ago, work was begun on improving our part of the build
14 > system (read: Java related eclasses and our java-config tool) in a way
15 > to make it much more flexible in general, but specifically improve it to
16 > get around the known issues. It took about six months to fully develop.
17 > Unfortunately, the new system was not quite a drop-in replacement. So,
18 > it took from then until now to determine how to migrate from the current
19 > system to the new one in a sane way.
20 >
21 >
22 > = The Current System =
23 >
24 > To give some proper background, it is worth going over the current
25 > system briefly.
26 >
27 > == The Java Virtual Machine ==
28 > Each Java Virtual Machine (VM) installs an environment file into
29 > /etc/env.d/java. These files contain information about where JAVA_HOME
30 > is, the PATH to include, etc.
31 >
32 > VMs traditionally get installed at /opt/${P}
33 >
34 > We have the concept of a 'system' VM and a 'user' VM. The system VM is
35 > the default VM that will be used for root, and for users who haven't
36 > selected a user VM. The user VM is, as one might guess, selected on a
37 > per user basis. It is worth noting that root always uses the system VM,
38 > and as a result, packages use the system VM when being merged by emerge.
39 >
40 > java-config is used to set the system and user VM. When you do so, the
41 > appropriate file from /etc/env.d/java is copied to/etc/env.d/20java for
42 > the system VM or to ~/.gentoo/java-env for the user VM.
43 >
44 > java-config's notion of the current VM is tied entirely to the
45 > environment, specifically to JAVA_HOME. Therefore, if you change the
46 > system VM, you'd need to run env-update and then resource /etc/profile.
47 > Likewise, changing the user VM involves sourcing ~/.gentoo/java-env.
48 >
49 > The fact that you're tied to the environment is annoying, because as
50 > mentioned, you need re-source the appropriate files. Now imagine you
51 > have a ton of terminals open... you'd have to source the environment
52 > files from each one.
53 >
54 > == Packages ==
55 >
56 > When a Java package is built, information about it is saved in
57 > /usr/share/${PN}-${SLOT}/package.env (or /usr/share/${PN}/package.env if
58 > SLOT == 0). In particular, the jars that are associated with the package
59 > are recorded, as well as which jars from other packages are used.
60 > java-config can later be used to query for this information.
61 >
62 > == Eclasses ==
63 >
64 > There are currently 3 eclasses: java, java-pkg, and java-utils.
65 >
66 > java.eclass is used for packages which provide a VM.
67 > java-pkg.eclass is used for most Java packages. It provides tools for
68 > querying installed jars, and for installing various Java related files.
69 > java-utils.eclass provides a few utility functions for dealing with Java
70 > stuff.
71 >
72 > = The New System =
73 >
74 > == The Java Virtual Machine ==
75 > In addition to the concept of a system and a user VM, the new system has
76 > a build VM. As the name implies, the build VM is used for building
77 > packages (instead of the system VM). Sane defaults are defined on a per
78 > platform basis at /usr/share/java-config-2/config/jdk-defaults.conf [3].
79 > The build VM can further be configured by
80 > /etc/java-config-2/build/jdk.conf [4] .
81 >
82 > [3]
83 > https://svn.gentooexperimental.org/svn/java/java-config-ng/branches/axxo/config/jdk-defaults-x86.conf
84 > [4]
85 > https://svn.gentooexperimental.org/svn/java/java-config-ng/branches/axxo/config/jdk.conf
86 >
87 > For each Java release (ie 1.3, 1.4, 1.5, etc), you can specify which
88 > vendor and version to use at build time.
89 >
90 > In addition to being installed to /opt/${P}, VMs also now have a symlink
91 > in /usr/lib/jvm/${PN}-${SLOT}. The purpose of these symlinks is
92 > explained further down.
93 >
94 > The user and system VMs are now represented by symlinks pointing to VMs
95 > located in /usr/lib/jvm/. The system VM lives at
96 > /etc/java-config-2/current-system-vm, and the user VM at
97 > ~/.gentoo/java-config-2/current-user-vm . Additionally, an environment
98 > variable, GENTOO_VM, can be used to specify the VM used at a given
99 > instance. GENTOO_VM should be the name of a VM located in /usr/lib/jvm.
100 > So with regard to what VM is used, first GENTOO_VM is checked, then the
101 > user VM (for non-root users), and then lastly the system VM.
102 >
103 >
104 > All the trusty java binaries, ie java, javac, javadoc, jar, etc, now get
105 > wrappers installed into /usr/bin. These are actually symlinks to
106 > /usr/bin/run-java-tool. This is a script which will figure out which
107 > tool was invoked, and then determine which VM to used using the method
108 > mentioned above.
109 >
110 > == Packages ==
111 >
112 > We now save more information about the build environment at build time
113 > for each package. This information is saved at
114 > /usr/share/${PN}-${SLOT}/package.env. This is facilitate troubleshooting
115 > bugs. Specially, we collect the VM dependency is (ie >=virtual/jdk-1.4),
116 > what -source and -target were used , and which VM. We also keep track of
117 > where javadocs get installed, and where Java sources get installed,
118 > which are useful for integrating into IDEs like netbeans and eclipse.
119 >
120 > == Eclasses ==
121 >
122 > For each eclass we previously had, we have a updated version of the
123 > eclass, in addition to a few totally new eclasses.
124 >
125 > java-utils-2.eclass
126 > A utility eclass. All utility functions live here (as opposed to being
127 > spread between java-pkg and java-utils). Among other things, there are
128 > functions for figuring out which VM should be used for building, based
129 > on the DEPEND of a package (ie the virtual/jdk atom), and set GENTOO_VM
130 > accordingly.
131 >
132 > java-pkg-2.eclass
133 > The eclass the Java-only packages should inherit. It uses phase hooks
134 > in order to make sure that the environment is setup properly for each phase.
135 >
136 > java-pkg-opt-2.eclass
137 > Similar to java-pkg-2, except this is for packages that have optional
138 > Java support, ie a USE flag. Phase hooks are again used to ensure the
139 > environment is setup properly for each phase.
140 >
141 > java-ant-2.eclass
142 > Packages that build using ant should inherit this eclass. Essentially,
143 > this is eclass will ensure that build.xml files get rewritten such that
144 > javac tasks have the right source and target attributes. In other words,
145 > it makes sure that the right version bytecode gets compiled.
146 >
147 > java-vm-2.eclass
148 > This is the successor to java.eclass, but more aptly name.
149 >
150 > = Letting the Systems Coexist =
151 >
152 > Originally, the new eclasses were a replacement for the current
153 > eclasses, ie java-pkg-2 used to still be java-pkg, and java-utils-2 used
154 > to be still be java-utils. Additionally, java-config was unslotted, so
155 > the new version of it replaced the current one. Unfortunately, it was
156 > realized that the new system was not a 100% drop-in replacement for the
157 > current one, so we set forth with the task to find a way to migrate from
158 > one to the other.
159 >
160 > The method we decided on was to have the concept of having a
161 > 'generation' for each system, where the generation consists of the
162 > eclasses, a version of java-config, and the tools that support it. To
163 > cope with java-config, it is now slotted, and installs
164 > /usr/bin/java-config-<insert generation here> . There is then a wrapper
165 > for java-config at /usr/bin/java-config, which reads a variable
166 > WANT_JAVA_CONFIG to determine which java-config to use, or if not
167 > specified, the most recent version. The eclasses then export the
168 > appropriate value of WANT_JAVA_CONFIG to get the right version of
169 > java-config they need.
170 >
171 > The existing eclasses and java-config-1.x will be 'generation 1'. The
172 > new eclasses and java-config-2.x will be 'generation 2'.
173 >
174 > The first packages to be migrated to generation 2 will be the VMs. When
175 > installed, they will also install environment files that are compatible
176 > with generation 1. This will allow you to have both a system VM for
177 > generation 1, in addition to the system and build VM for generation 2.
178 > The consequence of this is that ebuilds using generation 1 will continue
179 > to build/run as they previously did, while allowing packages to be
180 > migrated to use generation 2 on a package-by-package basis. So, all
181 > existing ebuilds will continue to work, and will be replaced
182 > incrementally during our migration.
183 >
184 > A note on Java 1.5 here... The 1.5 JDKs don't install a generation-1
185 > compatible environment file. This is to prevent the problems already
186 > describe with 1.5, and should prevent them from happening. At this
187 > point, we should be able to unmask the 1.5 JDKs. So 1.5 will be
188 > available, but only to generation-2 packages.
189 >
190 > The next packages to be migrated will be ones that need the features of
191 > the new generation. In particular, this means packages which need Java
192 > 1.5 to build and/or run.
193 >
194 > Once these packages have been migrated, the rest of the tree which uses
195 > Java will be migrated as expediently as possible. I've written some
196 > notes about how to migrate over on our wiki [5]
197 > [5] https://projects.gentooexperimental.org/expj/wiki/Migrating_packages
198 >
199 > = Using the new system =
200 >
201 > I have written documentation on switching to the new system, from the
202 > user's perspective, over at our wiki [6]
203 >
204 > [6]
205 > https://projects.gentooexperimental.org/expj/wiki/Using_migration-overlay
206 >
207 > = Feedback =
208 >
209 > Obviously, these aren't exactly light changes that need to be made.
210 > Therefore, it's important to get as much feedback as possible, and to
211 > make the upgrade process as smooth as possible.
212 >
213 > I'd hope to get these changes put into the tree in the next week or two,
214 > pending feedback. This development has been a long time in the making,
215 > and the Java 1.5 problem has been a thorn in our side for long enough.
216
217 My apologies if I didn't make it clear, but I should point out that
218 these changes are slightly disruptive to the end-user. By this, I mean
219 there are actions that the user would need to take aside from just doing
220 an emerge world. The steps needed are outlined in the
221 using_migration-overlay wiki page [1]
222
223 [1]
224 https://projects.gentooexperimental.org/expj/wiki/Using_migration-overlay
225
226 So... I really would like as much feedback in particular on switching
227 over to the new system from the user's perspective. I'd like to get the
228 process as streamlined as to suppress as much pain and suffering as
229 possible...
230
231 Regards,
232
233 Josh
234 -----BEGIN PGP SIGNATURE-----
235 Version: GnuPG v1.4.3 (GNU/Linux)
236 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
237
238 iD8DBQFElzzD8ATTzZyw6sMRAnbrAJ9dmcuXTNeKeD8DjhwSNlEDAGUHRQCfbIrQ
239 DfNSwV4XbWbU+69o2dxshMY=
240 =YH4V
241 -----END PGP SIGNATURE-----
242 --
243 gentoo-dev@g.o mailing list