Gentoo Archives: gentoo-dev

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

Replies