From 4f2d7949f03e1c198bc888f2d05f421d35c57e21 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 9 Oct 2017 18:53:29 +0100 Subject: reinit the tree, so we can have metadata --- dev-java/jython/Manifest | 13 ++ dev-java/jython/files/CVE-2016-4000.patch | 158 +++++++++++++++++ .../jython-2.5.2-distutils_scripts_location.patch | 11 ++ .../files/jython-2.5.2-respect_PYTHONPATH.patch | 15 ++ dev-java/jython/files/jython-2.7.0-build.xml.patch | 11 ++ dev-java/jython/files/jython-2.7_beta1-ant.patch | 28 +++ ...n-2.7_beta1-dont-always-recompile-classes.patch | 11 ++ .../files/jython-2.7_beta2-maxrepeat-import.patch | 16 ++ dev-java/jython/jython-2.7.0-r2.ebuild | 151 ++++++++++++++++ dev-java/jython/jython-2.7.0.ebuild | 191 +++++++++++++++++++++ dev-java/jython/metadata.xml | 14 ++ 11 files changed, 619 insertions(+) create mode 100644 dev-java/jython/Manifest create mode 100644 dev-java/jython/files/CVE-2016-4000.patch create mode 100644 dev-java/jython/files/jython-2.5.2-distutils_scripts_location.patch create mode 100644 dev-java/jython/files/jython-2.5.2-respect_PYTHONPATH.patch create mode 100644 dev-java/jython/files/jython-2.7.0-build.xml.patch create mode 100644 dev-java/jython/files/jython-2.7_beta1-ant.patch create mode 100644 dev-java/jython/files/jython-2.7_beta1-dont-always-recompile-classes.patch create mode 100644 dev-java/jython/files/jython-2.7_beta2-maxrepeat-import.patch create mode 100644 dev-java/jython/jython-2.7.0-r2.ebuild create mode 100644 dev-java/jython/jython-2.7.0.ebuild create mode 100644 dev-java/jython/metadata.xml (limited to 'dev-java/jython') diff --git a/dev-java/jython/Manifest b/dev-java/jython/Manifest new file mode 100644 index 000000000000..fd94924addfa --- /dev/null +++ b/dev-java/jython/Manifest @@ -0,0 +1,13 @@ +AUX CVE-2016-4000.patch 6415 SHA256 80f3e5adfbb6528043953ab5ad3c1a0dd1da49e7aa7865b640d0df7e74ed7d7b SHA512 8fef03e890e70a7a514a03e9b36c8b7b2ab744a7e7f53e9fbf970a2990553cdac9002cb6cdfd9a9fa0635d9bd231c41d98cdf0406889a162b9aa64c407a043f9 WHIRLPOOL 918287c512e55cb5b2e3d75546e4242deef09a9c060bb97588d74874848ef8302fecb4118f5ab5190435ec731808ca7279ee238e970aed8f598cc282594bd696 +AUX jython-2.5.2-distutils_scripts_location.patch 350 SHA256 832e6be53cd43db0107db86bcd214f109163824e41a1565821b032f8ce11a20d SHA512 bf6e32641c539251550c979630311f0d3e4299fb1e4545d6c9fe18d42beace3959dadc22eff39ea53f20960889e19c73acb309414f007980909cf3a32a6b1b5d WHIRLPOOL 148f307da7ef3c6dd0c3932c58a669fea927d16a1278e578ba8171e75c6df80eeeaea64e3bb43f6edff2c4c482031b30ba9a30cc42c73fdf07ab4a914742f3a0 +AUX jython-2.5.2-respect_PYTHONPATH.patch 551 SHA256 63bc68e3c2464b1c22da369b2035ad66e9a0b0402c6051d4cb2b958f367408c8 SHA512 773d595fb05b687dfce63b3c2f67c663135d9faddd811c0d6939bbdd6da3e295f7ece9d913923205ca6fb433d90fd494bccafd8b421f14ced1e493a1a40682c7 WHIRLPOOL 41ea2e9a99a7338dcd961fa033a7a77e94917afad85ee47fcfc5e2e49ab224a94215ffaed647f500099c15592515bc430f798caa31254ca8e3c39cf2a6d0ae31 +AUX jython-2.7.0-build.xml.patch 547 SHA256 ab808d84e0d8048c28ad29225282b37c082ae5c9c7e24758555cd94467f7e8d8 SHA512 d5a9cd75d99482996d3fd09b43c6becd2c45173e1a34116e74b43baba2235863eefbfd509bf714215bb311eb6f620d972249ad4593e067b91b5d7b88467f635a WHIRLPOOL 9a54db133815b90ef703bbe945ab0caa33c8b0eb7609dcb9545e3371bd4e2b21b550fbe8712f91138301f31a806d4bd7187de9500bdca987b0636c5a7e731e54 +AUX jython-2.7_beta1-ant.patch 996 SHA256 4162eb543c70071cac05c4220047296809733f2b6ade731ac995e7e0764260d7 SHA512 9d6888c0af9b0ca39f7e70c3aad868c17b65d2f703b1fcd05fb71fe0cc8a289ca055fadd878afdc7fd509e16099abb2ddf0de9053994010d09757f275d243c70 WHIRLPOOL 51da00d838e92acb2353d75b32450d02afb11e6cd27e7c05e7f73d67397eadf9871f527a138353513597980b564c69a2e6e959a30ca5eff3cdebaacf55b348cd +AUX jython-2.7_beta1-dont-always-recompile-classes.patch 309 SHA256 323b52653b511d3d4a299d0414716aa3d6e7bfa21094b6090363878f244d7af2 SHA512 75b25d98d8df13d0b9947cbc70a7da59097b89731210504cc26ab18680b93d9ce2cd177480870f985a87d3634d9034b8d9f1bac2c431f4cfe09ab0b54db78b18 WHIRLPOOL 76300b03adaad2d979e4a5a705088ef3410d93643fac0c87b333f88181d4f93c8185630467a272d7fd5f2439784e907814084f5a18f11715d9bc4ce102d03bc5 +AUX jython-2.7_beta2-maxrepeat-import.patch 457 SHA256 0840c1039c0e5821d0ceeb44bdfe1bda52fc2b9da00330c52c2056def2e09a24 SHA512 e06ddb36805e2545f351d9d5df651fa90b0b39d340e4772cbb24910f1e1c999463a21fbe4a62c9cc73f9ccdc0047f8900e6300602cb8d5b70cef7cacf1bd46d0 WHIRLPOOL dc685f8cd5d684a9ea72f3315d9d74b1e51712fb6ef46fb2dec24ec1cb1a1d0094d28c06e32a0089ff659b7a0c402e35b77725e7c971db46bd90767d0eaff3ad +DIST jython-2.7.0-sources.jar 15371691 SHA256 2b534595d4a08059ebb71b881c58ee830499bb6e9daba7c828a7f1f6c8943f7a SHA512 7583810245d694fd1d99a57ad504fcefdfbc1183def2cbb93ae3660f341104205c73041d846bdcf2b564b3cf4b770b481703c1dcdb1458396812c92d30ee9fa6 WHIRLPOOL e0dbd289c522b41ef2d3f54b01a2f6d44de8755e2eeb7863c8b807d1b179839f20d925e102db324cf85cd82503cd03106b5287ffa7a322a3902d6f24e9cd2a41 +EBUILD jython-2.7.0-r2.ebuild 4299 SHA256 e5d72b08a405a1f69ed621cd9b072102b0900f9cee95fe4fe55a553aaaa1b7d7 SHA512 433cfb7397f96a7e0e7673dab0f788d459d9fa490266d9434c0c0e82f0ecb1d28ed3276276fd3196f865e9a9a456ca75dc259060afddae8ada53700bddfc887e WHIRLPOOL eda646073b481c76fdd96163cfb8549753da2cd02f9a6b1eb8613d8129181db6ba8473d0f977c4359fd231a8673b13ff96d6147c402a85627b91313cfbf1f169 +EBUILD jython-2.7.0.ebuild 5666 SHA256 49b2ac3c6eafee7037c3f6b165f24810d4c0d403e634186be4342f90b728dbf3 SHA512 f8fa49e48f06ac9ecdcba3800d0e9050bd379df36058b0e7ee47a6d978dafdd3aaac8c03db28a80de12b7141259d9297827bc2d7de044a702864a9ed81bdf701 WHIRLPOOL c36b743cad1cc908e4185af8ce12287da9808cc5f56157872d57d906dc0a5bec4969bbd681fd2f013b873f5bcabf1789f0c77f4f06b80872d60b6314729c321e +MISC ChangeLog 6493 SHA256 db425c5e8ab43a03c932063d59e827148f0a3b48367c77f0a361b8594e515688 SHA512 70d8319bca8e3a4faec942dd16c88ca7a2441ea1b896f17b4559d645abcd62b1d3d78df78621556c6dbfb5b58d18c87ed99240b7dd3ba74c847a79bdd9bbe5f5 WHIRLPOOL 6c3b155f81af4cdf1f18b6290caa248e1a706dc943d730be7693711269b954cf33bd8909aa241890362d2c088f0d5f21610f77c11fcf9eb7dbc3541a86c03952 +MISC ChangeLog-2015 16851 SHA256 19dc522aedb70b79948459e970080a6d8a3a10303079a273586eb2a967b81380 SHA512 5e125a0a005ceb0fdcccd283b4f9dfd310af0e90e4b9be4901e47702a35db5f846373f3a27129020afb1659fe22406c89250bf610a95470d76ff82fe062c8b29 WHIRLPOOL 15b10f7f076cc1eb6d866320c2ffc1159adbba022e006a6ae308cd3ab38603cb81d91debf8950f48e0ee4e6a00736116e9447f8658b377884e093b3d5e06d1fd +MISC metadata.xml 406 SHA256 aa24488b1d0d7c1227a27148d330f242ddd8c6a65602c8a21a4e3ecf42b5a6b3 SHA512 9f2143723240241788a922cba2adbb5917114bc052b2590eb76777c5db4140ab0360c55cadb17fc5b2006d1947f37e91f5ce88d6abba500e6cb9419854014dac WHIRLPOOL 49104dcd67ccc7794af5b0bb38ce1a5dab51c6bcb40350dfcf4e98d67b2445a05d512184eca3e5f72b7b377bc2ecb6fb6824893fdb3aed6d8f08ba63d790c99c diff --git a/dev-java/jython/files/CVE-2016-4000.patch b/dev-java/jython/files/CVE-2016-4000.patch new file mode 100644 index 000000000000..81785eb05b07 --- /dev/null +++ b/dev-java/jython/files/CVE-2016-4000.patch @@ -0,0 +1,158 @@ + +# HG changeset patch +# User Jim Baker +# Date 1454384221 25200 +# Node ID d06e29d100c04576735e86c75a26c5f33669bb72 +# Parent b6735606c13df95f770527e629954407f82808c5 +Do not deserialize PyFunction objects. Fixes #2454 + +Instead use standard Python pickling; or subclass PyFunction. + +diff --git a/Lib/test/test_java_integration.py b/Lib/test/test_java_integration.py +--- a/Lib/test/test_java_integration.py ++++ b/Lib/test/test_java_integration.py +@@ -14,8 +14,9 @@ import re + from collections import deque + from test import test_support + +-from java.lang import (ClassCastException, ExceptionInInitializerError, String, Runnable, System, +- Runtime, Math, Byte) ++from java.lang import ( ++ ClassCastException, ExceptionInInitializerError, UnsupportedOperationException, ++ String, Runnable, System, Runtime, Math, Byte) + from java.math import BigDecimal, BigInteger + from java.net import URI + from java.io import (ByteArrayInputStream, ByteArrayOutputStream, File, FileInputStream, +@@ -656,13 +657,30 @@ class SerializationTest(unittest.TestCas + self.assertEqual(date_list, roundtrip_serialization(date_list)) + + def test_java_serialization_pycode(self): +- + def universal_answer(): + return 42 + + serialized_code = roundtrip_serialization(universal_answer.func_code) + self.assertEqual(eval(serialized_code), universal_answer()) + ++ def test_java_serialization_pyfunction(self): ++ # Not directly supported due to lack of general utility ++ # (globals will usually be in the function object in ++ # func_globals), and problems with unserialization ++ # vulnerabilities. Users can always subclass from PyFunction ++ # for specific cases, as seen in PyCascading ++ import new ++ def f(): ++ return 6 * 7 + max(0, 1, 2) ++ # However, using the new module, it's possible to create a ++ # function with no globals, which means the globals will come ++ # from the current context ++ g = new.function(f.func_code, {}, "g") ++ # But still forbid Java deserialization of this function ++ # object. Use pickling or other support instead. ++ with self.assertRaises(UnsupportedOperationException): ++ roundtrip_serialization(g) ++ + def test_builtin_names(self): + import __builtin__ + names = [x for x in dir(__builtin__)] +@@ -872,7 +890,7 @@ class SingleMethodInterfaceTest(unittest + future.get() + self.assertEqual(x, [42]) + +- @unittest.skip("FIXME: not working") ++ @unittest.skip("FIXME: not working; see http://bugs.jython.org/issue2115") + def test_callable_object(self): + callable_obj = CallableObject() + future = self.executor.submit(callable_obj) +diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py +--- a/Lib/test/test_new.py ++++ b/Lib/test/test_new.py +@@ -24,18 +24,10 @@ class NewTest(unittest.TestCase): + c = new.instance(C, {'yolks': 3}) + + o = new.instance(C) +- +- # __dict__ is a non dict mapping in Jython +- if test_support.is_jython: +- self.assertEqual(len(o.__dict__), 0, "new __dict__ should be empty") +- else: +- self.assertEqual(o.__dict__, {}, "new __dict__ should be empty") ++ self.assertEqual(o.__dict__, {}, "new __dict__ should be empty") + del o + o = new.instance(C, None) +- if test_support.is_jython: +- self.assertEqual(len(o.__dict__), 0, "new __dict__ should be empty") +- else: +- self.assertEqual(o.__dict__, {}, "new __dict__ should be empty") ++ self.assertEqual(o.__dict__, {}, "new __dict__ should be empty") + del o + + def break_yolks(self): +@@ -109,7 +101,14 @@ class NewTest(unittest.TestCase): + test_closure(g, (1, 1), ValueError) # closure is wrong size + test_closure(f, g.func_closure, ValueError) # no closure needed + +- if hasattr(new, 'code') and not test_support.is_jython: ++ # [Obsolete] Note: Jython will never have new.code() ++ # ++ # Who said that?!!! guess what, we do! :) ++ # ++ # Unfortunately we still need a way to compile to Python bytecode, ++ # so support is still incomplete, as seen in the fact that we need ++ # to get values from CPython 2.7. ++ if hasattr(new, 'code'): + def test_code(self): + # bogus test of new.code() + def f(a): pass +@@ -117,16 +116,16 @@ class NewTest(unittest.TestCase): + c = f.func_code + argcount = c.co_argcount + nlocals = c.co_nlocals +- stacksize = c.co_stacksize ++ stacksize = 1 # TODO c.co_stacksize + flags = c.co_flags +- codestring = c.co_code +- constants = c.co_consts +- names = c.co_names ++ codestring = 'd\x00\x00S' # TODO c.co_code ++ constants = (None,) # TODO c.co_consts ++ names = () # TODO c.co_names + varnames = c.co_varnames + filename = c.co_filename + name = c.co_name + firstlineno = c.co_firstlineno +- lnotab = c.co_lnotab ++ lnotab = '' # TODO c.co_lnotab, but also see http://bugs.jython.org/issue1638 + freevars = c.co_freevars + cellvars = c.co_cellvars + +diff --git a/src/org/python/core/PyBytecode.java b/src/org/python/core/PyBytecode.java +--- a/src/org/python/core/PyBytecode.java ++++ b/src/org/python/core/PyBytecode.java +@@ -66,6 +66,12 @@ public class PyBytecode extends PyBaseCo + + debug = defaultDebug; + ++ if (argcount < 0) { ++ throw Py.ValueError("code: argcount must not be negative"); ++ } else if (nlocals < 0) { ++ throw Py.ValueError("code: nlocals must not be negative"); ++ } ++ + co_argcount = nargs = argcount; + co_varnames = varnames; + co_nlocals = nlocals; // maybe assert = varnames.length; +diff --git a/src/org/python/core/PyFunction.java b/src/org/python/core/PyFunction.java +--- a/src/org/python/core/PyFunction.java ++++ b/src/org/python/core/PyFunction.java +@@ -545,6 +545,9 @@ public class PyFunction extends PyObject + @Override + public boolean isSequenceType() { return false; } + ++ private Object readResolve() { ++ throw new UnsupportedOperationException(); ++ } + + /* Traverseproc implementation */ + @Override + diff --git a/dev-java/jython/files/jython-2.5.2-distutils_scripts_location.patch b/dev-java/jython/files/jython-2.5.2-distutils_scripts_location.patch new file mode 100644 index 000000000000..fc9a95be89f9 --- /dev/null +++ b/dev-java/jython/files/jython-2.5.2-distutils_scripts_location.patch @@ -0,0 +1,11 @@ +--- a/Lib/distutils/command/install.py ++++ b/Lib/distutils/command/install.py +@@ -70,7 +70,7 @@ + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', +- 'scripts': '$base/bin', ++ 'scripts': '/usr/bin', + 'data' : '$base', + } + } diff --git a/dev-java/jython/files/jython-2.5.2-respect_PYTHONPATH.patch b/dev-java/jython/files/jython-2.5.2-respect_PYTHONPATH.patch new file mode 100644 index 000000000000..e695122ba1d6 --- /dev/null +++ b/dev-java/jython/files/jython-2.5.2-respect_PYTHONPATH.patch @@ -0,0 +1,15 @@ +--- a/src/org/python/core/PySystemState.java ++++ b/src/org/python/core/PySystemState.java +@@ -646,6 +646,12 @@ + if (jythonpath != null) { + registry.setProperty("python.path", jythonpath); + } ++ else { ++ jythonpath = System.getenv("PYTHONPATH"); ++ if (jythonpath != null) { ++ registry.setProperty("python.path", jythonpath); ++ } ++ } + } catch (SecurityException e) { + } + registry.putAll(postProperties); diff --git a/dev-java/jython/files/jython-2.7.0-build.xml.patch b/dev-java/jython/files/jython-2.7.0-build.xml.patch new file mode 100644 index 000000000000..1f0be614dbe5 --- /dev/null +++ b/dev-java/jython/files/jython-2.7.0-build.xml.patch @@ -0,0 +1,11 @@ +--- a/build.xml.orig 2015-06-27 16:12:08.442000000 +0000 ++++ b/build.xml 2015-06-27 16:12:15.684000000 +0000 +@@ -448,7 +448,7 @@ + + + +- ++ + + + diff --git a/dev-java/jython/files/jython-2.7_beta1-ant.patch b/dev-java/jython/files/jython-2.7_beta1-ant.patch new file mode 100644 index 000000000000..c86cae894a92 --- /dev/null +++ b/dev-java/jython/files/jython-2.7_beta1-ant.patch @@ -0,0 +1,28 @@ +--- jython-2.7-b1-sources/build.xml ++++ jython-2.7-b1-sources/build.xml +@@ -508,6 +509,7 @@ + + + ++ + +@@ -826,9 +829,6 @@ + + + +- +- +- + + + diff --git a/dev-java/jython/files/jython-2.7_beta1-dont-always-recompile-classes.patch b/dev-java/jython/files/jython-2.7_beta1-dont-always-recompile-classes.patch new file mode 100644 index 000000000000..326ef7f62afa --- /dev/null +++ b/dev-java/jython/files/jython-2.7_beta1-dont-always-recompile-classes.patch @@ -0,0 +1,11 @@ +--- a/src/org/python/core/imp.java ++++ b/src/org/python/core/imp.java +@@ -228,7 +228,7 @@ + } + if (testing && mtime != NO_MTIME) { + long time = ar.getMTime(); +- if (mtime != time) { ++ if (mtime < time) { + return null; + } + } diff --git a/dev-java/jython/files/jython-2.7_beta2-maxrepeat-import.patch b/dev-java/jython/files/jython-2.7_beta2-maxrepeat-import.patch new file mode 100644 index 000000000000..944bb195cb38 --- /dev/null +++ b/dev-java/jython/files/jython-2.7_beta2-maxrepeat-import.patch @@ -0,0 +1,16 @@ +diff -r 035eded55c4d lib-python/2.7/sre_constants.py +--- a/lib-python/2.7/sre_constants.py Wed Apr 16 18:30:13 2014 -0600 ++++ b/lib-python/2.7/sre_constants.py Fri Jul 25 10:31:27 2014 -0700 +@@ -15,7 +15,11 @@ + + MAGIC = 20031017 + +-from _sre import MAXREPEAT ++try: ++ from _sre import MAXREPEAT ++except ImportError: ++ import _sre ++ MAXREPEAT = _sre.MAXREPEAT = 65535 + + # SRE standard exception (access as sre.error) + # should this really be here? diff --git a/dev-java/jython/jython-2.7.0-r2.ebuild b/dev-java/jython/jython-2.7.0-r2.ebuild new file mode 100644 index 000000000000..852db859cfd4 --- /dev/null +++ b/dev-java/jython/jython-2.7.0-r2.ebuild @@ -0,0 +1,151 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 +JAVA_PKG_IUSE="doc source" + +inherit eutils java-pkg-2 java-ant-2 python-utils-r1 flag-o-matic + +MY_PV=${PV/_beta/-b} +MY_P=${PN}-${MY_PV} + +DESCRIPTION="An implementation of Python written in Java" +HOMEPAGE="http://www.jython.org" +SRC_URI="http://search.maven.org/remotecontent?filepath=org/python/${PN}/${MY_PV}/${MY_P}-sources.jar" + +LICENSE="PSF-2" +SLOT="2.7" +KEYWORDS="~amd64 x86 ~amd64-linux ~x86-linux ~x86-macos" +IUSE="examples test" + +CP_DEPEND="dev-java/antlr:3 + dev-java/netty-transport:0 + >=dev-java/asm-5:4 + dev-java/commons-compress:0 + dev-java/guava:20 + dev-java/jffi:1.2 + dev-java/jline:2 + dev-java/icu4j:52 + dev-java/jnr-constants:0 + dev-java/jnr-posix:3.0 + dev-java/jnr-netdb:1.0 + dev-java/stringtemplate:0 + dev-java/xerces:2 + java-virtuals/script-api:0 + java-virtuals/servlet-api:3.0" +RDEPEND="${CP_DEPEND} + >=virtual/jre-1.7" +DEPEND="${CP_DEPEND} + >=virtual/jdk-1.7 + app-arch/unzip + dev-java/ant-core:0 + test? ( + dev-java/junit:4 + dev-java/ant-junit:0 + )" + +S=${WORKDIR} + +RESTRICT="test" + +JAVA_ANT_REWRITE_CLASSPATH="yes" +JAVA_ANT_CLASSPATH_TAGS+=" java" + +EANT_BUILD_TARGET="developer-build" +EANT_TEST_EXTRA_ARGS="-Dpython.home=dist" + +# jdbc-informix and jdbc-oracle-bin (requires registration) aren't exposed. +# Uncomment and add to CDEPEND if you want either of them +#EANT_GENTOO_CLASSPATH+=",jdbc-informix" EANT_EXTRA_ARGS+=" -Dinformix.present" +#EANT_GENTOO_CLASSPATH+=",jdbc-oracle-bin" EANT_EXTRA_ARGS+=" -Doracle.present" + +PATCHES=( + "${FILESDIR}"/${PN}-2.5.2-distutils_scripts_location.patch + "${FILESDIR}"/${PN}-2.5.2-respect_PYTHONPATH.patch + "${FILESDIR}"/${PN}-2.7_beta1-ant.patch + "${FILESDIR}"/${PN}-2.7_beta1-dont-always-recompile-classes.patch + "${FILESDIR}"/${PN}-2.7_beta2-maxrepeat-import.patch + "${FILESDIR}"/${PN}-2.7.0-build.xml.patch + "${FILESDIR}"/CVE-2016-4000.patch +) + +src_prepare() { + default + + find \( -name '*.jar' -o -name '*.class' \ + -o -name '*.pyc' -o -name '*.exe' \) -delete + + # needed for launchertest + chmod +x tests/shell/test-jython.sh || die + + java-pkg-2_src_prepare +} + +src_configure() { + # apparently this can cause problems + append-flags -fno-stack-protector + + EANT_GENTOO_CLASSPATH_EXTRA="$(java-pkg_getjars --with-dependencies antlr-3,jnr-posix-3.0)" + EANT_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjars --build-only ant-core)" +} + +src_test() { + java-pkg-2_src_test +} + +src_install() { + local instdir=/usr/share/${PN}-${SLOT} + + java-pkg_newjar dist/${PN}-dev.jar + + java-pkg_register-optional-dependency jdbc-mysql + java-pkg_register-optional-dependency jdbc-postgresql + + insinto ${instdir} + doins -r dist/{Lib,registry} + + dodoc ACKNOWLEDGMENTS NEWS README.txt + + use doc && java-pkg_dohtml -r dist/Doc/javadoc + use source && java-pkg_dosrc src/* + use examples && java-pkg_doexamples Demo/* + + local java_args=( + -Dpython.home="${EPREFIX}"/usr/share/${PN}-${SLOT} + -Dpython.executable="${EPREFIX}"/usr/bin/jython${SLOT} + -Dpython.cachedir="\${HOME}/.jythoncachedir" + ) + + java-pkg_dolauncher jython${SLOT} \ + --main org.python.util.jython \ + --java_args "${java_args[*]}" + + # we need a wrapper to help python_optimize + cat <<-EOF > "${T}"/jython + exec java -cp "$(java-pkg_getjars "${EANT_GENTOO_CLASSPATH}"):${EANT_GENTOO_CLASSPATH_EXTRA}:dist/${PN}-dev.jar" \ + -Dpython.home="${ED}${instdir}" \ + -Dpython.cachedir="${T}/.jythoncachedir" \ + -Duser.home="${T}" \ + org.python.util.jython "\${@}" + EOF + chmod +x "${T}"/jython || die + + local -x PYTHON="${T}"/jython + # we can't get the path from the interpreter since it does some + # magic that fails on non-installed copy... + local PYTHON_SITEDIR=${EPREFIX}/usr/share/jython-${SLOT}/Lib/site-packages + python_export jython${SLOT} EPYTHON + + # compile tests (everything else is compiled already) + # we're keeping it quiet since jython reports errors verbosely + # and some of the tests are supposed to trigger compile errors + python_optimize "${ED}${instdir}"/Lib/test &>/dev/null + + # for python-exec + echo "EPYTHON='${EPYTHON}'" > epython.py || die + python_domodule epython.py + + # some of the class files end up with newer timestamps than the files they + # were generated from, make sure this doesn't happen + find "${ED}${instdir}"/Lib/ -name '*.class' | xargs touch +} diff --git a/dev-java/jython/jython-2.7.0.ebuild b/dev-java/jython/jython-2.7.0.ebuild new file mode 100644 index 000000000000..18b533ce3672 --- /dev/null +++ b/dev-java/jython/jython-2.7.0.ebuild @@ -0,0 +1,191 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=5 +JAVA_PKG_IUSE="doc examples source" + +inherit eutils java-pkg-2 java-ant-2 python-utils-r1 flag-o-matic + +MY_PV=${PV/_beta/-b} +MY_P=${PN}-${MY_PV} + +DESCRIPTION="An implementation of Python written in Java" +HOMEPAGE="http://www.jython.org" +SRC_URI="http://search.maven.org/remotecontent?filepath=org/python/${PN}/${MY_PV}/${MY_P}-sources.jar" + +LICENSE="PSF-2" +SLOT="2.7" +KEYWORDS="amd64 x86 ~amd64-linux ~x86-linux ~x86-macos" +IUSE="+readline test" +REQUIRED_USE="test? ( readline )" + +CDEPEND="dev-java/ant-core:0 + dev-java/antlr:3 + dev-java/netty-transport:0 + =dev-java/asm-5.0.3:4 + dev-java/commons-compress:0 + dev-java/guava:13 + >=dev-java/java-config-2.1.11-r3 + dev-java/jffi:1.2 + dev-java/jline:2 + dev-java/icu4j:52 + dev-java/jnr-constants:0 + dev-java/jnr-posix:3.0 + dev-java/jnr-netdb:1.0 + dev-java/stringtemplate:0 + dev-java/xerces:2 + java-virtuals/script-api:0 + java-virtuals/servlet-api:3.0 + readline? ( >=dev-java/libreadline-java-0.8.0:0 )" +RDEPEND="${CDEPEND} + >=virtual/jre-1.7" +DEPEND="${CDEPEND} + >=virtual/jdk-1.7 + app-arch/unzip + test? ( + dev-java/junit:4 + dev-java/ant-junit:0 + )" + +S=${WORKDIR} + +RESTRICT="test" + +JAVA_ANT_REWRITE_CLASSPATH="yes" +EANT_GENTOO_CLASSPATH="asm-4,commons-compress,guava-13,jffi-1.2,jline-2," +EANT_GENTOO_CLASSPATH+="jnr-constants,script-api,servlet-api-3.0," +EANT_GENTOO_CLASSPATH+="stringtemplate,xerces-2,icu4j-52,netty-transport,jnr-posix-3.0" + +JAVA_ANT_CLASSPATH_TAGS+=" java" + +EANT_BUILD_TARGET="developer-build" +EANT_TEST_EXTRA_ARGS="-Dpython.home=dist" + +# jdbc-informix and jdbc-oracle-bin (requires registration) aren't exposed. +# Uncomment and add to CDEPEND if you want either of them +#EANT_GENTOO_CLASSPATH+=",jdbc-informix" EANT_EXTRA_ARGS+=" -Dinformix.present" +#EANT_GENTOO_CLASSPATH+=",jdbc-oracle-bin" EANT_EXTRA_ARGS+=" -Doracle.present" + +PATCHES=( + "${FILESDIR}"/${PN}-2.5.2-distutils_scripts_location.patch + "${FILESDIR}"/${PN}-2.5.2-respect_PYTHONPATH.patch + "${FILESDIR}"/${PN}-2.7_beta1-ant.patch + "${FILESDIR}"/${PN}-2.7_beta1-dont-always-recompile-classes.patch + "${FILESDIR}"/${PN}-2.7_beta2-maxrepeat-import.patch + "${FILESDIR}"/${PN}-2.7.0-build.xml.patch +) + +java_prepare() { + find \( -name '*.jar' -o -name '*.class' \ + -o -name '*.pyc' -o -name '*.exe' \) -delete + + epatch "${PATCHES[@]}" + + if ! use readline; then + rm -v src/org/python/util/ReadlineConsole.java || die + fi + + # needed for launchertest + chmod +x tests/shell/test-jython.sh || die + + # apparently this can cause problems + append-flags -fno-stack-protector +} + +src_compile() { + use readline && EANT_GENTOO_CLASSPATH+=",libreadline-java" + + EANT_GENTOO_CLASSPATH_EXTRA="$(java-pkg_getjars --with-dependencies antlr-3,jnr-posix-3.0)" + EANT_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjars --build-only ant-core)" + + sed -i -e "1 a\ + CLASSPATH=\"$(java-pkg_getjars "${EANT_GENTOO_CLASSPATH}"):${EANT_GENTOO_CLASSPATH_EXTRA}\"" \ + src/shell/jython || die + + java-pkg-2_src_compile +} + +EANT_TEST_GENTOO_CLASSPATH="${EANT_GENTOO_CLASSPATH},junit-4" + +src_test() { + java-pkg-2_src_test +} + +src_install() { + local instdir=/usr/share/${PN}-${SLOT} + + java-pkg_newjar dist/${PN}-dev.jar + + java-pkg_register-optional-dependency jdbc-mysql + java-pkg_register-optional-dependency jdbc-postgresql + + insinto ${instdir} + doins -r dist/{Lib,registry} + + dodoc ACKNOWLEDGMENTS NEWS README.txt + + use doc && java-pkg_dohtml -r dist/Doc/javadoc + use source && java-pkg_dosrc src/* + use examples && java-pkg_doexamples Demo/* + + local java_args=( + -Dpython.home="${EPREFIX}"/usr/share/${PN}-${SLOT} + -Dpython.executable="${EPREFIX}"/usr/bin/jython${SLOT} + -Dpython.cachedir="\${HOME}/.jythoncachedir" + ) + + java-pkg_dolauncher jython${SLOT} \ + --main org.python.util.jython \ + --java_args "${java_args[*]}" + + if use readline; then + sed \ + -e "s/#\(python.console=org.python.util.ReadlineConsole\)/\1/" \ + -e "/#python.console.readlinelib=JavaReadline/a python.console.readlinelib=GnuReadline" \ + -i "${ED}"/usr/share/${PN}-${SLOT}/registry || die + fi + + # we need a wrapper to help python_optimize + cat <<-EOF > "${T}"/jython + exec java -cp "$(java-pkg_getjars "${EANT_GENTOO_CLASSPATH}"):${EANT_GENTOO_CLASSPATH_EXTRA}:dist/${PN}-dev.jar" \ + -Dpython.home="${ED}${instdir}" \ + -Dpython.cachedir="${T}/.jythoncachedir" \ + -Duser.home="${T}" \ + org.python.util.jython "\${@}" + EOF + chmod +x "${T}"/jython || die + + local -x PYTHON="${T}"/jython + # we can't get the path from the interpreter since it does some + # magic that fails on non-installed copy... + local PYTHON_SITEDIR=${EPREFIX}/usr/share/jython-${SLOT}/Lib/site-packages + python_export jython${SLOT} EPYTHON + + # compile tests (everything else is compiled already) + # we're keeping it quiet since jython reports errors verbosely + # and some of the tests are supposed to trigger compile errors + python_optimize "${ED}${instdir}"/Lib/test &>/dev/null + + # for python-exec + echo "EPYTHON='${EPYTHON}'" > epython.py || die + python_domodule epython.py + + # some of the class files end up with newer timestamps than the files they + # were generated from, make sure this doesn't happen + find "${ED}${instdir}"/Lib/ -name '*.class' | xargs touch +} + +pkg_postinst() { + if ! has_version dev-java/jython ; then + elog + elog "readline can be configured in the registry:" + elog + elog "python.console=org.python.util.ReadlineConsole" + elog "python.console.readlinelib=GnuReadline" + elog + elog "Global registry: '${EROOT}usr/share/${PN}-${SLOT}/registry'" + elog "User registry: '~/.jython'" + elog "See http://www.jython.org/docs/registry.html for more information." + elog + fi +} diff --git a/dev-java/jython/metadata.xml b/dev-java/jython/metadata.xml new file mode 100644 index 000000000000..6034fcc96aab --- /dev/null +++ b/dev-java/jython/metadata.xml @@ -0,0 +1,14 @@ + + + + + java@gentoo.org + Java + + + Use GNU readline instead of jline + + + jython + + -- cgit v1.2.3