Gentoo Archives: gentoo-commits

From: Patrice Clement <monsieurp@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-java/groovy/, dev-java/groovy/files/
Date: Sun, 01 Nov 2015 21:40:01
Message-Id: 1446413551.52d0cdff64091542e27b945de4f1be716b09a02f.monsieurp@gentoo
1 commit: 52d0cdff64091542e27b945de4f1be716b09a02f
2 Author: Patrice Clement <monsieurp <AT> gentoo <DOT> org>
3 AuthorDate: Sun Nov 1 21:32:31 2015 +0000
4 Commit: Patrice Clement <monsieurp <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 1 21:32:31 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=52d0cdff
7
8 dev-java/groovy: Version bump. Fixes security bug 555470.
9
10 Package-Manager: portage-2.2.20.1
11 Signed-off-by: Patrice Clement <monsieurp <AT> gentoo.org>
12
13 dev-java/groovy/Manifest | 1 +
14 .../groovy/files/groovy-2.4.5-utils.gradle.patch | 116 ++++++++++++++++++
15 dev-java/groovy/groovy-2.4.5.ebuild | 133 +++++++++++++++++++++
16 3 files changed, 250 insertions(+)
17
18 diff --git a/dev-java/groovy/Manifest b/dev-java/groovy/Manifest
19 index df62640..d14223e 100644
20 --- a/dev-java/groovy/Manifest
21 +++ b/dev-java/groovy/Manifest
22 @@ -1,2 +1,3 @@
23 +DIST groovy-2.4.5.zip 10214173 SHA256 6fbbe2c1e16bd1c56b889cbcadff04d055a96568883f885ed904265e4e9d8780 SHA512 055b664d2bc9966f9dd5933ec89f22c28c18323b57db66eeec524c88bdc6ea1090f6f1dd866433d7232d837ca31ca83164d8894c0db1d69e72c7d41f20a8382d WHIRLPOOL c05dcb4afddc9ad217bb99d6cc9618e6a67e7f13f52b99ecc155a9b8e97079dcd8f83402cad61acdbcca4141018965320b8194a84dbf6036f2daf699a2111149
24 DIST groovy-src-1.7.5.zip 12875363 SHA256 9864b36d681ecc4e4a8f86c8b958203f8e2c01c150a3f992f5f63df552979067 SHA512 fa0f617d1894e6fd7b30216b69dc3060154a31d28a3831e7135b18377c5bc368d193d914d2b77a7daf28498562fb96c04794c874101b23dafb4421e3a1d59404 WHIRLPOOL 478346b89661f6b57cc5740df038e8bf3ced62a84a4de1dea3da94a9519cae6eba43cf583c4a81b2f459f6409a7387c2079098b12495b9f1b669260af4efaccb
25 DIST groovy-src-1.8.5.zip 13131836 SHA256 82f1e45e5886278a4c86ed15dfd90a84b7e43848c72537a235835c7557e8f8cd SHA512 23cddae38b6d0b1b83dae7cf7ebc3fe68f7e8ddb33cd6fa421c0c3c76ca8bf5a8b3fe72cabe915901305f513a2b3269baf205a7a0dd6b1c6f751496d51e0557a WHIRLPOOL 9db6d1da9304e8000de9954faf91d26d76c15e628a25a09c1291afc2ca8b33bbe24d44d891599548df6931db632ae6cd801e83cb05fb6abf33f3282f463a4482
26
27 diff --git a/dev-java/groovy/files/groovy-2.4.5-utils.gradle.patch b/dev-java/groovy/files/groovy-2.4.5-utils.gradle.patch
28 new file mode 100644
29 index 0000000..6f4638a
30 --- /dev/null
31 +++ b/dev-java/groovy/files/groovy-2.4.5-utils.gradle.patch
32 @@ -0,0 +1,116 @@
33 +--- gradle/utils.gradle.orig 2015-11-01 21:06:26.246486000 +0000
34 ++++ gradle/utils.gradle 2015-11-01 21:06:57.719486000 +0000
35 +@@ -16,57 +16,47 @@
36 + * specific language governing permissions and limitations
37 + * under the License.
38 + */
39 +-import org.codehaus.groovy.classgen.AnnotationVisitor
40 +-import org.objectweb.asm.ClassWriter
41 +-import org.objectweb.asm.FieldVisitor
42 +-import org.objectweb.asm.Label
43 +-import org.objectweb.asm.MethodVisitor
44 +-
45 +-import static org.objectweb.asm.Opcodes.*
46 +-
47 +-buildscript {
48 +- repositories {
49 +- mavenCentral()
50 +- }
51 +- dependencies {
52 +- classpath "org.ow2.asm:asm:$asmVersion"
53 +- }
54 +-}
55 ++import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
56 ++import static org.objectweb.asm.Opcodes.ACC_STATIC;
57 ++import static org.objectweb.asm.Opcodes.ACC_SUPER;
58 ++import static org.objectweb.asm.Opcodes.ALOAD;
59 ++import static org.objectweb.asm.Opcodes.ATHROW;
60 ++import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
61 ++import static org.objectweb.asm.Opcodes.RETURN;
62 ++import static org.objectweb.asm.Opcodes.V1_5;
63 ++
64 ++import java.io.File;
65 ++import java.io.FileOutputStream;
66 ++
67 ++import org.objectweb.asm.ClassWriter;
68 ++import org.objectweb.asm.Label;
69 ++import org.objectweb.asm.MethodVisitor;
70 +
71 +-/**
72 +- * This tasks generates an utility class which allows sneaky throwing.
73 +- */
74 +-task exceptionUtils {
75 +- ext.classFiles = [
76 +- "${buildDir}/generated-classes/org/codehaus/groovy/runtime/ExceptionUtils.class",
77 +- "${compileJava.destinationDir}/org/codehaus/groovy/runtime/ExceptionUtils.class"]
78 +- outputs.files classFiles
79 ++public class ExceptionUtils {
80 ++ private final static String gentooClassDestination = "target/classes/org/codehaus/groovy/runtime/ExceptionUtils.class";
81 +
82 +- doLast {
83 ++ public static void main(String[] args) {
84 + ClassWriter cw = new ClassWriter(0);
85 +- FieldVisitor fv;
86 + MethodVisitor mv;
87 +- AnnotationVisitor av0;
88 +-
89 +- cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, 'org/codehaus/groovy/runtime/ExceptionUtils', null, 'java/lang/Object', null);
90 +
91 +- cw.visitSource('ExceptionUtils.java', null);
92 ++ cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "org/codehaus/groovy/runtime/ExceptionUtils", null, "java/lang/Object", null);
93 ++ cw.visitSource("ExceptionUtils.java", null);
94 +
95 +- mv = cw.visitMethod(ACC_PUBLIC, '<init>', '()V', null, null);
96 ++ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
97 + mv.visitCode();
98 + Label l0 = new Label();
99 + mv.visitLabel(l0);
100 + mv.visitLineNumber(18, l0);
101 + mv.visitVarInsn(ALOAD, 0);
102 +- mv.visitMethodInsn(INVOKESPECIAL, 'java/lang/Object', '<init>', '()V', false);
103 ++ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
104 + mv.visitInsn(RETURN);
105 + Label l1 = new Label();
106 + mv.visitLabel(l1);
107 +- mv.visitLocalVariable('this', 'Lorg/codehaus/groovy/runtime/ExceptionUtils;', null, l0, l1, 0);
108 ++ mv.visitLocalVariable("this", "Lorg/codehaus/groovy/runtime/ExceptionUtils;", null, l0, l1, 0);
109 + mv.visitMaxs(1, 1);
110 + mv.visitEnd();
111 +
112 +- mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, 'sneakyThrow', '(Ljava/lang/Throwable;)V', null, null);
113 ++ mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "sneakyThrow", "(Ljava/lang/Throwable;)V", null, null);
114 + mv.visitCode();
115 + Label l2 = new Label();
116 + mv.visitLabel(l2);
117 +@@ -75,19 +65,21 @@
118 + mv.visitInsn(ATHROW);
119 + Label l3 = new Label();
120 + mv.visitLabel(l3);
121 +- mv.visitLocalVariable('e', 'Ljava/lang/Throwable;', null, l2, l3, 0);
122 ++ mv.visitLocalVariable("e", "Ljava/lang/Throwable;", null, l2, l3, 0);
123 + mv.visitMaxs(1, 1);
124 + mv.visitEnd();
125 +
126 + cw.visitEnd();
127 ++ FileOutputStream fos = null;
128 +
129 +- logger.lifecycle('Generating ExceptionUtils')
130 +- classFiles.each { classFile ->
131 +- def output = file(classFile)
132 +- output.parentFile.mkdirs()
133 +- output.withOutputStream {
134 +- it << cw.toByteArray()
135 +- }
136 +- }
137 +- }
138 ++ File f = new File(gentooClassDestination);
139 ++ f.getParentFile().mkdirs();
140 ++ try {
141 ++ fos = new FileOutputStream(f);
142 ++ fos.write(cw.toByteArray());
143 ++ fos.close();
144 ++ } catch (Exception e) {
145 ++ e.printStackTrace();
146 ++ }
147 ++ }
148 + }
149
150 diff --git a/dev-java/groovy/groovy-2.4.5.ebuild b/dev-java/groovy/groovy-2.4.5.ebuild
151 new file mode 100644
152 index 0000000..62183ff
153 --- /dev/null
154 +++ b/dev-java/groovy/groovy-2.4.5.ebuild
155 @@ -0,0 +1,133 @@
156 +# Copyright 1999-2015 Gentoo Foundation
157 +# Distributed under the terms of the GNU General Public License v2
158 +# $Id$
159 +
160 +EAPI=5
161 +JAVA_PKG_IUSE="doc source"
162 +
163 +inherit java-pkg-2 java-pkg-simple versionator
164 +
165 +MY_PN="${PN^^}"
166 +MY_PV="$(replace_all_version_separators _ ${PV})"
167 +MY_P="${MY_PN}_${MY_PV}"
168 +
169 +DESCRIPTION="A multi-faceted language for the Java platform"
170 +HOMEPAGE="http://www.groovy-lang.org/"
171 +SRC_URI="https://github.com/apache/incubator-${PN}/archive/${MY_P}.zip -> ${P}.zip"
172 +LICENSE="Apache-2.0"
173 +SLOT="0"
174 +KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
175 +IUSE=""
176 +
177 +CDEPEND="
178 + dev-java/jansi:0
179 + dev-java/xstream:0
180 + dev-java/commons-cli:1
181 + >=dev-java/asm-5.0.3:4
182 + >=dev-java/antlr-2.7.7-r7:0
183 +"
184 +
185 +RDEPEND="
186 + ${CDEPEND}
187 + >=virtual/jre-1.6"
188 +DEPEND="
189 + ${CDEPEND}
190 + >=virtual/jdk-1.6
191 + app-arch/unzip"
192 +
193 +JAVA_GENTOO_CLASSPATH="
194 + asm-4
195 + antlr
196 + jansi
197 + xstream
198 + commons-cli-1
199 +"
200 +
201 +S="${WORKDIR}/incubator-${PN}-${MY_P}"
202 +
203 +# ExceptionUtil filename.
204 +EU="ExceptionUtils.java"
205 +
206 +# List of antlr grammar files.
207 +ANTLR_GRAMMAR_FILES=(
208 + org/codehaus/groovy/antlr/groovy.g
209 + org/codehaus/groovy/antlr/java/java.g
210 +)
211 +
212 +# Patches utils.gradle. It basically rewrites ExceptionUtils.
213 +PATCHES=(
214 + "${FILESDIR}"/"${P}-utils.gradle.patch"
215 +)
216 +
217 +# Add target/classes to the CP as we're generating an extra class there.
218 +JAVA_GENTOO_CLASSPATH_EXTRA="target/classes"
219 +
220 +# This function cleans up the source directory.
221 +# We're ONLY interested in the "src/main" directory content and nothing else.
222 +# (for the time being).
223 +groovy_cleanup_source_files() {
224 + ebegin "Cleaning up useless files"
225 + mv src/main "${T}" || die
226 + mv gradle/utils.gradle "${T}" || die
227 + rm -rf * || die
228 + mv "${T}"/main/* . || die
229 + rm -rf "${T}"/main || die
230 + eend $?
231 +}
232 +
233 +java_prepare() {
234 + epatch "${PATCHES[@]}"
235 + groovy_cleanup_source_files
236 +}
237 +
238 +# This function generates the ANTLR grammar files.
239 +generate_antlr_grammar() {
240 + for grammar_file in "${@}"; do
241 + local my_grammar_file=$(basename ${grammar_file})
242 +
243 + einfo "Generating \"${my_grammar_file}\" grammar file"
244 + local my_grammar_dir=$(dirname ${grammar_file})
245 +
246 + cd "${S}/${my_grammar_dir}" || die
247 + antlr ${my_grammar_file} || die
248 +
249 + cd "${S}" || die
250 + done
251 +}
252 +
253 +# This function generates ExceptionUtils.class.
254 +# ExceptionUtils is a helper class needed when compiling Groovy 2.x.
255 +# Normally, this class is generated via a Gradle task at compile time. Since we
256 +# don't use Gradle here.. we've translated it into a plain Java file and have
257 +# it generate the same data.
258 +generate_exceptionutils() {
259 + ebegin "Copying ${EU}"
260 + mv "${T}/utils.gradle" "${EU}" || die
261 + eend $?
262 +
263 + ejavac -classpath "$(java-pkg_getjar --build-only asm-4 asm.jar)" ${EU}
264 +
265 + ebegin "Running ${EU%.java}"
266 + $(java-config -J) -classpath "$(java-pkg_getjar --build-only asm-4 asm.jar):." ${EU%.java} || die
267 + eend $?
268 +}
269 +
270 +src_compile() {
271 + generate_antlr_grammar "${ANTLR_GRAMMAR_FILES[@]}"
272 + generate_exceptionutils
273 + java-pkg-simple_src_compile
274 +}
275 +
276 +src_install() {
277 + java-pkg_dolauncher "groovyc" --main org.codehaus.groovy.tools.FileSystemCompiler
278 + java-pkg_dolauncher "groovy" --main groovy.ui.GroovyMain
279 + java-pkg-simple_src_install
280 +
281 + # TODO: groovy console and groovy shell are parts of the "subprojects"
282 + # directory. figure out a way to compile them. :\
283 + # java-pkg_dolauncher "groovysh" --main groovy.ui.InteractiveShell
284 + # java-pkg_dolauncher "groovyConsole" --main groovy.ui.Console
285 +
286 + # TODO: grape is written in groovy and to compile it, you need .. groovy.
287 + # java-pkg_dolauncher "grape" --main org.codehaus.groovy.tools.GrapeMain
288 +}