File bsh2.spec of Package bsh2
#
# spec file for package bsh2
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2000-2008, JPackage Project
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define orig_name bsh
%define fversion 2.0b6
Name: bsh2
Version: 2.0.0.b6
Release: 0
Summary: Lightweight Scripting for Java (BeanShell Version 2.x)
License: SPL-1.0 OR LGPL-2.0+
Group: Development/Libraries/Java
Url: http://www.beanshell.org/
Source0: https://github.com/beanshell/beanshell/archive/%{fversion}.tar.gz
Source1: beanshell-2.0b5.pom
Source2: bsh-classpath-2.0b5.pom
Source3: bsh-commands-2.0b5.pom
Source4: bsh-core-2.0b5.pom
Source5: bsh-reflect-2.0b5.pom
Source6: bsh-util-2.0b5.pom
Source7: bsh-bsf-2.0b5.pom
Source8: bsh-classgen-2.0b5.pom
Source9: bsh-engine-2.0b5.pom
Patch1: %{name}-asm.patch
Patch2: %{name}-ClassGeneratorUtil.patch
#PATCH-FIX-OPENSUSE: use html output and JVM's built-in xmlns:redirect
Patch3: bsh-2.0b5-docs.patch
#PATCH-FIX-OPENSUSE: those two patches fixes a compatibility with a standard javax.script API
Patch1000: bsh2-fix-tests.patch
Patch1001: reproducible.patch
Patch1002: beanshell-2.0b6-target.patch
Patch1003: beanshell-2.0b6-getpeer.patch
BuildRequires: ant
BuildRequires: asm >= 1.5.3
BuildRequires: asm-javadoc
BuildRequires: bsf
BuildRequires: bsf-javadoc
BuildRequires: fdupes
# Disable this one whenever the javadoc build is fixed for jdk9
BuildRequires: java-devel
BuildRequires: javacc3
# Needed for maven conversions
BuildRequires: javapackages-local
BuildRequires: javapackages-tools
BuildRequires: servletapi4
Requires: bsf
Requires: javapackages-tools
Requires: objectweb-asm
BuildArch: noarch
%description
BeanShell is a small, free, embeddable, Java source interpreter with
object scripting language features, written in Java. BeanShell executes
standard Java statements and expressions, in addition to obvious
scripting commands and syntax. BeanShell supports scripted objects as
simple method closures like those in Perl and JavaScript(tm). You can
use BeanShell interactively for Java experimentation and debugging or
as a simple scripting engine for your applications. In short: BeanShell
is a dynamically interpreted Java, plus some useful stuff. Another way
to describe it is to say that in many ways BeanShell is to Java as
Tcl/Tk is to C: BeanShell is embeddable - You can call BeanShell from
your Java applications to execute Java code dynamically at run-time or
to provide scripting extensibility for your applications.
Alternatively, you can call your Java applications and objects from
BeanShell; working with Java objects and APIs dynamically. Since
BeanShell is written in Java and runs in the same space as your
application, you can freely pass references to "real live" objects into
scripts and return them as results.
With version 2.0 BeanShell becomes a fully Java compatible scripting
language. BeanShell is now capable of interpreting ordinary Java source
and loading .java source files from the class path. BeanShell scripted
classes are fully typed and appear to outside Java code and via
reflective inspection as ordinary classes. However their implementation
is fully dynamic and they may include arbitrary BeanShell scripts in
their bodies, methods, and constructors. Users may now freely mix
loose, unstructured BeanShell scripts, method closures, and full
scripted classes.
%package bsf
Summary: BSF support for bsh2
Group: Development/Libraries/Java
Requires: bsf
%description bsf
Lightweight Scripting for Java (BeanShell Version 2.x) (BSF support).
%package classgen
Summary: ASM support for bsh2
Group: Development/Libraries/Java
Requires: asm
%description classgen
Lightweight Scripting for Java (BeanShell Version 2.x) (ASM support).
%package manual
Summary: Documentation for bsh2
Group: Development/Libraries/Java
%description manual
Lightweight Scripting for Java (BeanShell Version 2.x) (Manual).
%package javadoc
Summary: Javadoc for bsh2
Group: Development/Libraries/Java
%description javadoc
Lightweight Scripting for Java (BeanShell Version 2.x) (Java Documentation).
%package demo
Summary: Demonstrations and samples for bsh2
Group: Development/Libraries/Java
Requires: %{name} = %{version}-%{release}
%description demo
Lightweight Scripting for Java (BeanShell Version 2.x) (demo and samples).
%prep
%setup -q -n beanshell-%{fversion}
%patch1 -p1
%patch2
%patch3 -p1
%patch1000 -p1
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
for j in $(find . -name "*.jar"); do
mv $j $j.no
done
# Remove bundled javax.script files under Sun's proprietary license
find engine/javax-src/javax/script/ -maxdepth 1 -type 'f' | xargs rm
mv tests/test-scripts/Data/addedCommand.jar.no tests/test-scripts/Data/addedCommand.jar
mv tests/test-scripts/Data/addclass.jar.no tests/test-scripts/Data/addclass.jar
%build
build-jar-repository -s -p lib asm/asm bsf javacc3 servlet
pushd engine/javax-src/
javac -cp $(build-classpath servlet) -source 1.6 -target 1.6 $(find . -name "*.java")
jar cf ../../lib/javaxscript.jar $(find . -name "*.class" -o -name "*.html")
popd
# set VERSION
perl -p -i -e 's|VERSION =.*;|VERSION = "%{version}";|' src/bsh/Interpreter.java
# remove internal asm code, use JPackage external jar instead
rm -rf src/bsh/org
perl -p -i -e 's|bsh.org.objectweb.asm|org.objectweb.asm|' src/bsh/ClassGeneratorUtil.java
ant \
-Dasm.javadoc=%{_javadocdir}/asm \
-Dbsf.javadoc=%{_javadocdir}/bsf \
-Djava.javadoc=%{_javadocdir}/java \
dist
(cd docs/faq && ant)
(cd docs/manual && ant)
%fdupes -s docs/
%install
# jars
mkdir -p %{buildroot}%{_javadir}/%{name}
rm -f dist/%{orig_name}-%{fversion}-src.jar
rm -f dist/%{orig_name}-%{fversion}-sources.jar
for jar in dist/*.jar; do
install -m 644 ${jar} %{buildroot}%{_javadir}/%{name}/`basename ${jar} -%{fversion}.jar`-%{version}.jar
done
(cd %{buildroot}%{_javadir}/%{name} && for jar in *-%{version}*; do ln -s ${jar} ${jar/-%{version}/}; done)
# poms
install -d -m 755 %{buildroot}%{_mavenpomdir}
install -m 644 %{SOURCE1} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh.pom
install -m 644 %{SOURCE2} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-classpath.pom
install -m 644 %{SOURCE3} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-commands.pom
install -m 644 %{SOURCE4} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-core.pom
install -m 644 %{SOURCE5} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-reflect.pom
install -m 644 %{SOURCE6} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-util.pom
install -m 644 %{SOURCE7} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-bsf.pom
install -m 644 %{SOURCE8} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-classgen.pom
install -m 644 %{SOURCE9} \
%{buildroot}%{_mavenpomdir}/JPP.%{name}-bsh-engine.pom
%add_maven_depmap JPP.%{name}-bsh.pom %{name}/bsh.jar -a org.beanshell:%{name}
%add_maven_depmap JPP.%{name}-bsh-classpath.pom %{name}/bsh-classpath.jar
%add_maven_depmap JPP.%{name}-bsh-commands.pom %{name}/bsh-commands.jar
%add_maven_depmap JPP.%{name}-bsh-core.pom %{name}/bsh-core.jar
%add_maven_depmap JPP.%{name}-bsh-reflect.pom %{name}/bsh-reflect.jar
%add_maven_depmap JPP.%{name}-bsh-util.pom %{name}/bsh-util.jar
%add_maven_depmap JPP.%{name}-bsh-bsf.pom %{name}/bsh-bsf.jar
%add_maven_depmap JPP.%{name}-bsh-classgen.pom %{name}/bsh-classgen.jar
%add_maven_depmap JPP.%{name}-bsh-engine.pom %{name}/bsh-engine.jar
# manual
find docs -name ".cvswrappers" -exec rm -f {} \;
find docs -name "*.xml" -exec rm -f {} \;
find docs -name "*.xsl" -exec rm -f {} \;
find docs -name "*.log" -exec rm -f {} \;
(cd docs/manual && mv -f html/* .)
(cd docs/manual && rm -rf html)
(cd docs/manual && rm -rf xsl)
# javadoc
mkdir -p %{buildroot}%{_javadocdir}/%{name}
cp -a javadoc/* %{buildroot}%{_javadocdir}/%{name}
# demo
for i in `find tests -name "*.bsh"`; do
perl -p -i -e 's,^\n?#!(/(usr/)?bin/java bsh\.Interpreter|/bin/sh),#!%{_bindir}/%{name},' $i
done
mkdir -p %{buildroot}%{_datadir}/%{name}
cp -a tests %{buildroot}%{_datadir}/%{name}
find %{buildroot}%{_datadir}/%{name} -type d \
| sed 's|'%{buildroot}'|%dir |' > %{name}-demo-%{version}.files
find %{buildroot}%{_datadir}/%{name} -type f -name "*.bsh" \
| sed 's|'%{buildroot}'|%attr(0755,root,root) |' >> %{name}-demo-%{version}.files
find %{buildroot}%{_datadir}/%{name} -type f ! -name "*.bsh" \
| sed 's|'%{buildroot}'|%attr(0644,root,root) |' >> %{name}-demo-%{version}.files
# bshservlet
mkdir -p %{buildroot}%{_datadir}/%{name}/bshservlet
(cd %{buildroot}%{_datadir}/%{name}/bshservlet
jar xf $RPM_BUILD_DIR/beanshell-%{fversion}/dist/bshservlet.war
)
# scripts
mkdir -p %{buildroot}%{_bindir}
cat > %{buildroot}%{_bindir}/%{name} << EOF
#!/bin/sh
#
# %{name} script
# JPackage Project (http://jpackage.sourceforge.net)
# Source functions library
. %{_datadir}/java-utils/java-functions
# Source system prefs
if [ -f %{_sysconfdir}/%{name}.conf ] ; then
. %{_sysconfdir}/%{name}.conf
fi
# Source user prefs
if [ -f \$HOME/.%{name}rc ] ; then
. \$HOME/.%{name}rc
fi
# Configuration
MAIN_CLASS=bsh.Interpreter
if [ -n "\$BSH_DEBUG" ]; then
BASE_FLAGS=-Ddebug=true
fi
BASE_JARS="%{name}.jar"
# Set parameters
set_jvm
set_classpath \$BASE_JARS
set_flags \$BASE_FLAGS
set_options \$BASE_OPTIONS
# Let's start
run "\$@"
EOF
cat > %{buildroot}%{_bindir}/%{name}doc << EOF
#!/usr/bin/env %{_bindir}/%{name}
EOF
cat scripts/bshdoc.bsh >> %{buildroot}%{_bindir}/%{name}doc
%fdupes -s %{buildroot}
%fdupes docs/
%files
%attr(0755,root,root) %{_bindir}/%{name}
%attr(0755,root,root) %{_bindir}/%{name}doc
%doc LICENSE
%dir %{_javadir}/%{name}
%{_javadir}/%{name}/%{orig_name}-%{version}.jar
%{_javadir}/%{name}/%{orig_name}.jar
%{_javadir}/%{name}/%{orig_name}-classpath*.jar
%{_javadir}/%{name}/%{orig_name}-commands*.jar
%{_javadir}/%{name}/%{orig_name}-core*.jar
%{_javadir}/%{name}/%{orig_name}-engine*.jar
%{_javadir}/%{name}/%{orig_name}-reflect*.jar
%{_javadir}/%{name}/%{orig_name}-util*.jar
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/bshservlet
%{_mavenpomdir}/*
%{_datadir}/maven-metadata/%{name}.xml*
%files bsf
%{_javadir}/%{name}/%{orig_name}-bsf*.jar
%files classgen
%{_javadir}/%{name}/%{orig_name}-classgen*.jar
%files manual
%doc docs/*
%files javadoc
%dir %{_javadocdir}/%{name}
%{_javadocdir}/%{name}
%files demo -f %{name}-demo-%{version}.files
%changelog