1 |
# Copyright 1999-2011 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/dev-java/jruby/jruby-1.5.6.ebuild,v 1.3 2011/10/19 01:25:10 fordfrog Exp $ |
4 |
|
5 |
EAPI="2" |
6 |
JAVA_PKG_IUSE="doc source test" |
7 |
inherit eutils java-pkg-2 java-ant-2 |
8 |
|
9 |
MY_PV="${PV/_rc1/RC1}" |
10 |
|
11 |
DESCRIPTION="Java-based Ruby interpreter implementation" |
12 |
HOMEPAGE="http://jruby.codehaus.org/" |
13 |
SRC_URI="http://jruby.org.s3.amazonaws.com/downloads/${PV}/${PN}-src-${PV}.tar.gz" |
14 |
LICENSE="|| ( CPL-1.0 GPL-2 LGPL-2.1 )" |
15 |
SLOT="0" |
16 |
KEYWORDS="amd64 x86" |
17 |
IUSE="bsf ssl" |
18 |
|
19 |
CDEPEND=">=dev-java/bytelist-1.0.6:0 |
20 |
>=dev-java/constantine-0.6:0 |
21 |
>=dev-java/jline-0.9.94:0 |
22 |
>=dev-java/joni-1.1.3:0 |
23 |
>=dev-java/jnr-posix-1.1.3:0 |
24 |
>=dev-java/jnr-netdb-1.0:0 |
25 |
>=dev-java/jvyamlb-0.2.5:0 |
26 |
>=dev-java/asm-3.2:3 |
27 |
dev-java/jcodings:0 |
28 |
>=dev-java/jffi-0.7_pre:0.4 |
29 |
dev-java/joda-time:0 |
30 |
dev-util/jay:0[java] |
31 |
dev-java/nailgun:0 |
32 |
dev-java/jaffl:0 |
33 |
dev-java/jgrapht:0 |
34 |
dev-java/ant-core:0 |
35 |
dev-java/bsf:2.3" |
36 |
|
37 |
RDEPEND="${CDEPEND} |
38 |
>=virtual/jre-1.6" |
39 |
|
40 |
DEPEND="${CDEPEND} |
41 |
virtual/jdk:1.6 |
42 |
test? ( |
43 |
dev-java/ant-junit4:0 |
44 |
dev-java/ant-trax:0 |
45 |
dev-java/junit:4 |
46 |
java-virtuals/jdk-with-com-sun |
47 |
dev-java/commons-logging:0 |
48 |
dev-java/xalan:0 |
49 |
>=dev-java/jna-posix-1.0.1:0 |
50 |
) |
51 |
!!<dev-ruby/jruby-1.3.1-r1" |
52 |
|
53 |
PDEPEND="ssl? ( dev-ruby/jruby-openssl )" |
54 |
|
55 |
# Tests fail. |
56 |
# Need to stop injecting jar's into classpath. |
57 |
RESTRICT="test" |
58 |
|
59 |
S="${WORKDIR}/${PN}-${MY_PV}" |
60 |
|
61 |
RUBY_HOME=/usr/share/${PN}/lib/ruby |
62 |
SITE_RUBY=${RUBY_HOME}/site_ruby |
63 |
GEMS=${RUBY_HOME}/gems |
64 |
|
65 |
JAVA_ANT_REWRITE_CLASSPATH="true" |
66 |
JAVA_ANT_IGNORE_SYSTEM_CLASSES="true" |
67 |
EANT_GENTOO_CLASSPATH="ant-core asm-3 bsf-2.3 bytelist constantine jay \ |
68 |
jcodings jffi-0.4 jline constantine \ |
69 |
joda-time joni jnr-posix jnr-netdb jvyamlb nailgun jaffl jgrapht" |
70 |
EANT_NEEDS_TOOLS="true" |
71 |
|
72 |
pkg_setup() { |
73 |
java-pkg-2_pkg_setup |
74 |
|
75 |
local fail |
76 |
|
77 |
for directory in "${GEMS}" "${SITE_RUBY}"; do |
78 |
if [[ -L ${directory} ]]; then |
79 |
eerror "${directory} is a symlink. Please do the following to resolve the situation:" |
80 |
echo 'emerge -an app-portage/gentoolkit' |
81 |
echo 'equery -qC b '"${directory}"' | sort | uniq | sed s/^/=/ > ~/jruby.fix' |
82 |
echo 'emerge -1C $(< ~/jruby.fix)' |
83 |
echo "rm ${directory}" |
84 |
echo 'emerge -1 $(< ~/jruby.fix)' |
85 |
echo 'rm ~/jruby.fix' |
86 |
|
87 |
eerror "For more information, please see http://bugs.gentoo.org/show_bug.cgi?id=302187" |
88 |
fail="true" |
89 |
fi |
90 |
done |
91 |
|
92 |
if [[ -n ${fail} ]]; then |
93 |
die "Please address the above errors, then run emerge --resume" |
94 |
fi |
95 |
} |
96 |
|
97 |
java_prepare() { |
98 |
epatch "${FILESDIR}"/${PN}-1.5.0-system-jars.patch |
99 |
epatch "${FILESDIR}/1.5.1/build.xml.patch" |
100 |
epatch "${FILESDIR}/1.5.1/testfixes.patch" |
101 |
|
102 |
# We don't need to use Retroweaver. There is a jarjar and a regular jar |
103 |
# target but even with jarjarclean, both are a pain. The latter target |
104 |
# is slightly easier so go with this one. |
105 |
sed -r -i \ |
106 |
-e 's/maxmemory="128m"/maxmemory="192m"/' \ |
107 |
-e "/RetroWeaverTask/d" \ |
108 |
-e "/<zipfileset .+\/>/d" \ |
109 |
build.xml || die |
110 |
|
111 |
sed -i -e '/Arndt/d' src/org/jruby/RubyBigDecimal.java |
112 |
|
113 |
# Delete the bundled JARs but keep invokedynamic.jar. |
114 |
# No source is available and it's only a dummy anyway. |
115 |
find build_lib -name "*.jar" ! -name "jsr292-mock.jar" -delete || die |
116 |
|
117 |
# change some defaults for Gentoo to work properly |
118 |
cat - >> src/org/jruby/jruby.properties <<EOF |
119 |
jruby.bindir = /usr/bin |
120 |
EOF |
121 |
} |
122 |
|
123 |
src_compile() { |
124 |
local flags="" |
125 |
use bsf && flags="-Dbsf.present=true" |
126 |
|
127 |
eant jar $(use_doc apidocs) -Djdk1.5+=true ${flags} |
128 |
} |
129 |
|
130 |
src_test() { |
131 |
if [ ${UID} == 0 ] ; then |
132 |
ewarn 'The tests will fail if run as root so skipping them.' |
133 |
ewarn 'Enable FEATURES="userpriv" if you want to run them.' |
134 |
return |
135 |
fi |
136 |
# Our jruby.jar is unbundled so we need to add the classpath to this test. |
137 |
sed -i "s:java -jar:java -Xbootclasspath/a\:#{ENV['JRUBY_CP']} -jar:g" test/test_load_compiled_ruby_class_from_classpath.rb || die |
138 |
sed -i "s@:refid => 'build.classpath'@:path =>\"#{ENV['JRUBY_CP']}:lib/jruby.jar\"@g" \ |
139 |
rakelib/commands.rake || die |
140 |
#sed -i "s@:refid => 'test.class.path'@:path => \"#{ENV['JRUBY_CP']}@g" \ |
141 |
# rakelib/commands.rake || die |
142 |
|
143 |
#bsf optionally depends on jruby, which means that the previously |
144 |
#installed jruby will be added to classpath, nasty things will happen. |
145 |
local cpath=`java-pkg_getjars ${EANT_GENTOO_CLASSPATH// /,},junit-4` |
146 |
cpath="$(echo ${cpath} | sed -e "s_${ROOT}/usr/share/jruby/lib/jruby.jar:__g")" |
147 |
cpath="${cpath}:$(java-pkg_getjars --build-only commons-logging,xalan)" |
148 |
EANT_GENTOO_CLASSPATH="" |
149 |
|
150 |
local flags="" |
151 |
use bsf && flags="-Dbsf.present=true" |
152 |
|
153 |
#Clear RUBYOPT |
154 |
export RUBYOPT="" |
155 |
export JRUBY_CP="${cpath}" |
156 |
ANT_TASKS="ant-junit4 ant-trax" \ |
157 |
JRUBY_OPTS="" eant test -Djdk1.5+=true -Djruby.bindir=bin \ |
158 |
-Dgentoo.classpath="${cpath}" ${flags} |
159 |
} |
160 |
|
161 |
src_install() { |
162 |
local bin |
163 |
|
164 |
java-pkg_dojar lib/${PN}.jar |
165 |
dodoc README docs/{*.txt,README.*} || die |
166 |
|
167 |
use doc && java-pkg_dojavadoc docs/api |
168 |
use source && java-pkg_dosrc src/org |
169 |
|
170 |
# We run the sed here in install so that we don't get the wrong |
171 |
# data during the test phase! |
172 |
sed \ |
173 |
-e '/++ebuild-cut-here++/, /--ebuild-cut-here--/ d' \ |
174 |
-e '/^JRUBY_HOME=/s:=:=/usr/share/jruby:' \ |
175 |
bin/jruby > "${T}"/jruby |
176 |
|
177 |
dobin "${T}"/jruby "${S}"/bin/j{irb{,_swing},rubyc} || die |
178 |
|
179 |
insinto "${RUBY_HOME}" |
180 |
doins -r "${S}"/lib/ruby/{1.8,1.9,site_ruby} || die |
181 |
|
182 |
# Remove all the references to RubyGems as we're just going to |
183 |
# install it through dev-ruby/rubygems. |
184 |
find "${D}${RUBY_HOME}" -type f \ |
185 |
'(' '(' -path '*rubygems*' -not -name 'jruby.rb' ')' -or -name 'ubygems.rb' -or -name 'datadir.rb' ')' \ |
186 |
-delete || die |
187 |
} |
188 |
|
189 |
pkg_postinst() { |
190 |
ewarn "If you're updating from <=jruby-1.4.0, you're going to get errors related" |
191 |
ewarn "to gentoo.rb load failure." |
192 |
ewarn "This is due to a stray definition of JRUBY_OPTS variable from the previous ebuilds." |
193 |
ewarn "To solve the problem, either login in a new shell, use 'env -i ${SHELL} --login'" |
194 |
ewarn "or explicitly unset the variable before running jruby." |
195 |
ewarn "" |
196 |
ewarn "Currently this package introduces issues/bugs that are not present within upstream" |
197 |
ewarn "releases. Therefore if you are wanting a stable build of jruby please do not" |
198 |
ewarn "use this package." |
199 |
} |