mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-05-04 20:06:43 +02:00
testing/jruby: new abuild
http://jruby.org An implementation of Ruby on the JVM
This commit is contained in:
parent
3a04509d16
commit
f5a1bc4bd7
175
testing/jruby/APKBUILD
Normal file
175
testing/jruby/APKBUILD
Normal file
@ -0,0 +1,175 @@
|
||||
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
|
||||
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
|
||||
# Note: This abuild excludes Truffle, because it's still experimental,
|
||||
# so it's probably not much usable for regular users.
|
||||
pkgname=jruby
|
||||
pkgver=9.0.5.0
|
||||
pkgrel=0
|
||||
pkgdesc="An implementation of Ruby on the JVM"
|
||||
url="http://jruby.org"
|
||||
arch="noarch"
|
||||
license="EPL GPL-2 LGPL-2.1 custom"
|
||||
# libc6-compat: https://github.com/jnr/jnr-posix/issues/73
|
||||
depends="java-jffi-native>=1.2 libc6-compat openjdk8-jre"
|
||||
makedepends="openjdk8 zip"
|
||||
install="$pkgname.post-install"
|
||||
subpackages="$pkgname-irb $pkgname-maven $pkgname-minitest $pkgname-rake
|
||||
$pkgname-rdoc $pkgname-readline $pkgname-testunit $pkgname-libs
|
||||
"
|
||||
# jruby (launch script): https://github.com/jruby/jruby/pull/1860
|
||||
source="https://s3.amazonaws.com/jruby.org/downloads/$pkgver/$pkgname-bin-$pkgver.tar.gz
|
||||
jruby
|
||||
"
|
||||
builddir="$srcdir/$pkgname-$pkgver"
|
||||
|
||||
_destdir="/usr/share/$pkgname"
|
||||
_bindir="$_destdir/bin"
|
||||
_rubydir="$_destdir/lib/ruby"
|
||||
_gemdir="$_rubydir/gems/shared"
|
||||
_stdlibdir="$_rubydir/stdlib"
|
||||
|
||||
_arch="$CARCH"
|
||||
case "$CARCH" in
|
||||
arm*) _arch=arm;;
|
||||
x86) _arch=i386;;
|
||||
esac
|
||||
|
||||
prepare() {
|
||||
cd "$builddir/bin"
|
||||
rm *.bat *.dll *.exe
|
||||
rm jirb_swing jruby jruby+truffle jruby200.sh jruby.*
|
||||
|
||||
cd "$builddir/lib/ruby/stdlib"
|
||||
rm -r win32 Win32API.rb
|
||||
find ./ffi/platform -type d -mindepth 1 ! -name "$_arch-linux" -exec rm -r {} +
|
||||
|
||||
# Remove useless native binaries from JARs.
|
||||
zip -qd jline/jline/*/jline-*.jar META-INF/native/*
|
||||
zip -qd "$builddir"/lib/jruby.jar jni/*
|
||||
}
|
||||
|
||||
build() {
|
||||
return 0
|
||||
}
|
||||
|
||||
package() {
|
||||
depends="$pkgname-libs"
|
||||
|
||||
cd "$builddir"
|
||||
|
||||
install -m644 -D "$builddir"/lib/jruby.jar \
|
||||
"$pkgdir"$_destdir/lib/jruby.jar || return 1
|
||||
|
||||
install -m755 -D "$srcdir"/jruby "$pkgdir"$_bindir/jruby || return 1
|
||||
|
||||
# Some of the below copied files will be moved to subpackages by split functions.
|
||||
|
||||
install -dm755 "$pkgdir"$_rubydir
|
||||
cp -r lib/ruby/.mvn lib/ruby/gems lib/ruby/stdlib \
|
||||
"$pkgdir"$_destdir/lib/ruby/ || return 1
|
||||
|
||||
cp bin/* "$pkgdir"$_bindir/ || return 1
|
||||
|
||||
install -dm755 "$pkgdir"/usr/bin
|
||||
local file; for file in jgem jirb jruby jrubyc; do
|
||||
ln -sf $_bindir/$file "$pkgdir"/usr/bin/$file || return 1
|
||||
done
|
||||
|
||||
install -m644 -D COPYING \
|
||||
"$pkgdir/usr/share/licenses/$pkgname"/COPYING
|
||||
}
|
||||
|
||||
irb() {
|
||||
pkgdesc="Interactive Ruby console"
|
||||
depends="$pkgname $pkgname-readline"
|
||||
|
||||
_mvgem irb
|
||||
_mv $_bindir/irb usr/bin/jirb
|
||||
}
|
||||
|
||||
maven() {
|
||||
pkgdesc="JRuby wrapper for Maven 3"
|
||||
depends="$pkgname maven>=3.3.3"
|
||||
|
||||
local file; for file in maven/ maven.rb ruby-maven.rb ruby_maven.rb; do
|
||||
_mv $_stdlibdir/$file || return 1
|
||||
done
|
||||
|
||||
_mv $_rubydir/.mvn || return 1
|
||||
ln -sf /usr/share/java/maven-3 "$subpkgdir"$_rubydir/maven-home
|
||||
}
|
||||
|
||||
minitest() {
|
||||
pkgdesc="Ruby testing tool supporting TDD, BDD, mocking, and benchmarking"
|
||||
depends="$pkgname"
|
||||
|
||||
_mvgem minitest
|
||||
}
|
||||
|
||||
rake() {
|
||||
pkgdesc="Ruby based make-like utility."
|
||||
depends="$pkgname"
|
||||
|
||||
_mvgem rake || return 1
|
||||
_mv $_bindir/rake
|
||||
}
|
||||
|
||||
rdoc() {
|
||||
pkgdesc="Ruby documentation tool"
|
||||
depends="$pkgname $pkgname-irb"
|
||||
|
||||
_mvgem rdoc || return 1
|
||||
_mv $_bindir/rdoc $_bindir/ri
|
||||
}
|
||||
|
||||
readline() {
|
||||
pkgdesc="Readline support for JRuby"
|
||||
depends="$pkgname java-jansi-native"
|
||||
|
||||
_mv $_stdlibdir/jline || return 1
|
||||
mv "$pkgdir"$_stdlibdir/readline* "$subpkgdir"$_stdlibdir/
|
||||
}
|
||||
|
||||
testunit() {
|
||||
pkgdesc="Legacy xUnit family unit testing framework for Ruby."
|
||||
depends="$pkgname"
|
||||
|
||||
_mvgem test-unit || return 1
|
||||
_mv $_stdlibdir/test $_bindir/testrb
|
||||
}
|
||||
|
||||
libs() {
|
||||
pkgdesc="JRuby's standard libraries"
|
||||
depends=""
|
||||
|
||||
_mv $_rubydir/gems $_rubydir/stdlib
|
||||
}
|
||||
|
||||
|
||||
_mv() {
|
||||
local path; for path in "$@"; do
|
||||
mkdir -p "$subpkgdir"/${path%/*}
|
||||
mv "$pkgdir"/$path "$subpkgdir"/${path%/*}/ || return 1
|
||||
done
|
||||
}
|
||||
|
||||
_mvgem() {
|
||||
local name="$1"
|
||||
local file
|
||||
|
||||
cd "$pkgdir"
|
||||
for file in ./$_stdlibdir/$name.rb \
|
||||
./$_stdlibdir/$name \
|
||||
./$_gemdir/gems/$name-* \
|
||||
./$_gemdir/specifications/default/$name-*; do
|
||||
[ -e "$pkgdir"/$file ] || continue
|
||||
_mv "$file"
|
||||
done
|
||||
}
|
||||
|
||||
md5sums="1d2dc649cbacbe26418ef3ba421018b1 jruby-bin-9.0.5.0.tar.gz
|
||||
7e6d8f6168f4a69109ea9d14e3e9f874 jruby"
|
||||
sha256sums="9ef392bd859690c9a838f6475040345e0c512f7fcc0b37c809a91cf671f5daf3 jruby-bin-9.0.5.0.tar.gz
|
||||
51794ecefb0d8fd3084ffb10867e2feffc9ccfadb45021af68520cf75fe58590 jruby"
|
||||
sha512sums="7c61cf010fbae571cd6ba334aefcfd917f6de8224d014026297b840d0b890523e94b2fea20f154c82c25c4f9d5992b9481fb569646a7023e5ddb42db1baf5f34 jruby-bin-9.0.5.0.tar.gz
|
||||
d0f19f791274f00f5b35a5e9a5dfe885d58330ebd3fd959f7325e545357497609403b5646988651265d08ac7a08cfec8b88ec260da558bcb0db623d9b8ce5a20 jruby"
|
||||
231
testing/jruby/jruby
Normal file
231
testing/jruby/jruby
Normal file
@ -0,0 +1,231 @@
|
||||
#!/bin/sh
|
||||
# vim: set ts=4:
|
||||
#
|
||||
# This jruby start script is rewrite of (poor) upstream's jruby.bash.
|
||||
# It's POSIX compatible, more clean, with sensible defaults for Alpine Linux
|
||||
# and without Windows, OS X and Truffle stuff. Beside that it should support
|
||||
# all the options of jruby.bash (hopefully) with the same behaviour.
|
||||
#
|
||||
# -----BEGIN HELP-----
|
||||
#
|
||||
# Environment variables:
|
||||
# CLASSPATH Additional paths to be added to the end of the Java classpath.
|
||||
# This may be overwritten by CLI argument -J-classpath or -J-cp.
|
||||
# JAVA_HOME Path to directory where is JRE/JVM installed to use specific java/jdb binary,
|
||||
# not the one on the PATH.
|
||||
# JAVA_OPTS Default options to be passed to JVM.
|
||||
# JRUBY_HOME Path to directory where JRuby is installed (default is /usr/share/java/jruby).
|
||||
# JRUBY_OPTS Default JRuby command line arguments.
|
||||
# JRUBY_SHELL Path to the system shell executable (default is /bin/sh).
|
||||
# PROFILE_ARGS Arguments for the instrumented profiler.
|
||||
#
|
||||
# Deprecated environment variables (for compatibility):
|
||||
# JAVA_MEM The -Xmx (maximum memory allocation) parameter for JVM (e.g. -Xmx128M).
|
||||
# This may be overwritten by CLI argument -J-Xmx.
|
||||
# JAVA_STACK The -Xss (stack size) parameter for JVM (default is -Xss2048k).
|
||||
# This may be overwritten by CLI argument -J-Xss.
|
||||
# JAVA_VM What JIT mode to use; -client, or -server (default is -server).
|
||||
# This may be overwritten by CLI arguments --server, --client, and --dev.
|
||||
# JRUBY_PARENT_CLASSPATH Classpath propagated from the parent JRuby process.
|
||||
#
|
||||
# All the environment variables are optional.
|
||||
# -----END HELP-----
|
||||
#
|
||||
set -eu
|
||||
|
||||
readonly MAIN_CLASS_JRUBY='org.jruby.Main'
|
||||
readonly MAIN_CLASS_NGCLIENT='org.jruby.util.NailMain'
|
||||
readonly MAIN_CLASS_NGSERVER='org.jruby.main.NailServerMain'
|
||||
|
||||
readonly JRUBY_HOME="${JRUBY_HOME:-"/usr/share/jruby"}"
|
||||
readonly JRUBY_CP="$JRUBY_HOME/lib/jruby.jar"
|
||||
readonly JRUBY_SHELL="${JRUBY_SHELL:-"/bin/sh"}"
|
||||
readonly NAILGUN_CMD="$JRUBY_HOME/tool/nailgun/ng"
|
||||
readonly PROFILE_ARGS="${PROFILE_ARGS:-}"
|
||||
|
||||
|
||||
java_stack="${JAVA_STACK:-"-Xss2048k"}"
|
||||
java_cmd="${JAVA_HOME:+"$JAVA_HOME/bin/"}java"
|
||||
|
||||
java_opts="${JAVA_OPTS:-} ${JAVA_MEM:-} $java_stack
|
||||
-Dorg.xerial.snappy.use.systemlib=true"
|
||||
|
||||
# Use the same classpath propagated from parent jruby, if provided.
|
||||
classpath="${JRUBY_PARENT_CLASSPATH:-}"
|
||||
if [ -z "$classpath" ]; then
|
||||
_excluded='jruby.jar jruby-truffle.jar jruby-complete.jar'
|
||||
|
||||
# Add all JARs from $JRUBY_HOME/lib to the classpath, except $_excluded.
|
||||
classpath=$(find "$JRUBY_HOME/lib" -maxdepth 1 \
|
||||
-name '*.jar' $(printf '! -name %s ' $_excluded) -print0 \
|
||||
| xargs -0 printf '%s:')
|
||||
classpath="${classpath%?}" # %? removes leading ":"
|
||||
fi
|
||||
|
||||
extra_cp="${CLASSPATH:-}"
|
||||
java_vm="${JAVA_VM:-"-server"}"
|
||||
main_class="$MAIN_CLASS_JRUBY"
|
||||
nailgun_client='no'
|
||||
ruby_args=''
|
||||
verify_jruby='no'
|
||||
|
||||
|
||||
# Split out any -J argument for passing to the JVM.
|
||||
# Scanning for args is aborted by '--'.
|
||||
set -- ${JRUBY_OPTS:-} $@
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
# Stuff after "-J" goes to JVM.
|
||||
-J | -J-X)
|
||||
"$java_cmd" -help
|
||||
printf '\n(Prepend -J in front of these options when using "jruby" command)\n'
|
||||
exit 1
|
||||
;;
|
||||
-J-classpath | -J-cp)
|
||||
extra_cp="$2"
|
||||
shift
|
||||
;;
|
||||
-J-ea)
|
||||
verify_jruby='yes'
|
||||
java_opts="$java_opts ${1:2}"
|
||||
;;
|
||||
-J*)
|
||||
java_opts="$java_opts ${1:2}"
|
||||
;;
|
||||
# Pass -X... and -X? search options through.
|
||||
-X*\.\.\.|-X*\?)
|
||||
ruby_args="$ruby_args $1"
|
||||
;;
|
||||
# Match -Xa.b.c=d to translate to -Da.b.c=d as a Java option.
|
||||
-X*)
|
||||
val=${1:2}
|
||||
if expr "$val" : '.*[.]' > /dev/null; then
|
||||
java_opts="$java_opts -Djruby.$val"
|
||||
else
|
||||
ruby_args="$ruby_args -X$val"
|
||||
fi
|
||||
;;
|
||||
# Match switches that take an argument.
|
||||
-C | -e | -I | -S)
|
||||
ruby_args="$ruby_args $1 $2"
|
||||
shift
|
||||
;;
|
||||
# Match same switches with argument stuck together.
|
||||
-e* | -I* | -S*)
|
||||
ruby_args="$ruby_args $1"
|
||||
;;
|
||||
# Run with JMX management enabled.
|
||||
--manage)
|
||||
java_opts="$java_opts -Dcom.sun.management.jmxremote \
|
||||
-Djruby.management.enabled=true"
|
||||
;;
|
||||
# Don't launch a GUI window, no matter what.
|
||||
--headless)
|
||||
java_opts="$java_opts -Djava.awt.headless=true"
|
||||
;;
|
||||
# Run under JDB (debug mode).
|
||||
--jdb)
|
||||
java_cmd="${JAVA_HOME:+"$JAVA_HOME/bin/"}jdb"
|
||||
java_opts="$java_opts -sourcepath $JRUBY_HOME/lib/ruby/1.9:."
|
||||
ruby_args="$ruby_args -X+C"
|
||||
;;
|
||||
--client | --server)
|
||||
java_vm="${1#?}" # #? removes leading "-"
|
||||
;;
|
||||
--dev)
|
||||
java_vm='-client'
|
||||
java_opts="$java_opts -XX:+TieredCompilation -XX:TieredStopAtLevel=1 \
|
||||
-Djruby.compile.mode=OFF -Djruby.compile.invokedynamic=false"
|
||||
;;
|
||||
--sample)
|
||||
java_opts="$java_opts -Xprof"
|
||||
;;
|
||||
# Start up as Nailgun server.
|
||||
--ng-server)
|
||||
main_class="$MAIN_CLASS_NGSERVER"
|
||||
verify_jruby='yes'
|
||||
;;
|
||||
# Use native Nailgun client to toss commands to server.
|
||||
--ng-client | --ng)
|
||||
nailgun_client='yes'
|
||||
;;
|
||||
# Warn but ignore.
|
||||
--1.8 | --1.9 | --2.0)
|
||||
echo "WARNING: $1 is ignored"
|
||||
;;
|
||||
-h | -help | --help)
|
||||
"$java_cmd" -help
|
||||
# Print help from the top of this script.
|
||||
sed -En '/-{5}BEGIN HELP-{5}/,/-{5}END HELP-{5}/p' "$0" \
|
||||
| sed -E "s/^# ?//; 1d;\$d;"
|
||||
exit 0
|
||||
;;
|
||||
# Abort processing on the double dash.
|
||||
--)
|
||||
break
|
||||
;;
|
||||
# Other opts go to ruby.
|
||||
-*)
|
||||
ruby_args="$ruby_args $1"
|
||||
;;
|
||||
# Abort processing on first non-opt arg.
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Remove possible duplications of some common JVM options.
|
||||
for opt in -Xmx -Xms -Xss; do
|
||||
val=$(expr "$java_opts" : ".*$opt\([^ \t]*\).*" ||:) # gets the later one
|
||||
if [ -n "$val" ]; then
|
||||
# Remove all occurrences of $opt and append the last one to the end.
|
||||
java_opts=$(echo "$java_opts" | sed "s/$opt[^ \t]*//g")
|
||||
java_opts="$java_opts ${opt}${val}"
|
||||
fi
|
||||
done
|
||||
|
||||
classpath="$classpath${extra_cp:+":$extra_cp"}"
|
||||
java_opts="$java_opts $java_vm
|
||||
-Djruby.home=$JRUBY_HOME
|
||||
-Djruby.lib=$JRUBY_HOME/lib
|
||||
-Djruby.script=jruby
|
||||
-Djruby.shell=$JRUBY_SHELL"
|
||||
|
||||
# Append the rest of the arguments.
|
||||
ruby_args="$ruby_args $@"
|
||||
|
||||
# Put $ruby_args back into the position arguments $1, $2, ...
|
||||
set -- $ruby_args
|
||||
|
||||
|
||||
if [ "$nailgun_client" = 'yes' ]; then
|
||||
if [ ! -f "$NAILGUN_CMD" ]; then
|
||||
echo 'ERROR: ng executable not found' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
exec "$NAILGUN_CMD" $MAIN_CLASS_NGCLIENT $@
|
||||
|
||||
elif [ "$verify_jruby" = 'yes' ]; then
|
||||
[ -n "$PROFILE_ARGS" ] && echo 'Running with instrumented profiler'
|
||||
|
||||
set +e
|
||||
"$java_cmd" $PROFILE_ARGS $java_opts \
|
||||
-classpath "$JRUBY_CP:$classpath" $main_class $@
|
||||
exit_code=$?
|
||||
set -e
|
||||
|
||||
if [ -n "$PROFILE_ARGS" ]; then
|
||||
echo 'Profiling results:'
|
||||
cat profile.txt
|
||||
rm profile.txt
|
||||
fi
|
||||
|
||||
exit $exit_code
|
||||
|
||||
else
|
||||
exec "$java_cmd" $java_opts -Xbootclasspath/a:"$JRUBY_CP" \
|
||||
${classpath:+"-classpath $classpath"} \
|
||||
$main_class $@
|
||||
fi
|
||||
13
testing/jruby/jruby.post-install
Normal file
13
testing/jruby/jruby.post-install
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# TODO: Remove after merging musl-1.1.14-r8 into stable branch.
|
||||
|
||||
if [ ! -e /usr/lib/libcrypt.so* ]; then
|
||||
cat <<-EOF 1>&2
|
||||
* Symlink /usr/lib/libcrypt.so* does not exist, you probably use older
|
||||
* revision of lib6-compat package. Since it's necessary for JRuby to work
|
||||
* correctly, it'll be created now.
|
||||
EOF
|
||||
|
||||
ln -s /usr/lib/libc.so /usr/lib/libcrypt.so.1
|
||||
fi
|
||||
Loading…
x
Reference in New Issue
Block a user