File bsh2.spec of Package bsh2
#
# spec file for package bsh2
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2000-2008, JPackage Project
# All rights reserved.
#
# 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.0b5
Name: bsh2
Version: 2.0.0.b5
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: http://www.beanshell.org/bsh-2.0b5-src.tar.bz2
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: bsh2-standard-script-api.patch
# bnc#967593
Patch4: bsh2-avoid-deserialization-xthis.patch
Patch5: bsh2-prevent-deserialization.patch
Requires(post): javapackages-tools
Requires(postun): javapackages-tools
Requires: bsf
Requires: javapackages-tools
Requires: objectweb-asm
BuildRequires: ant
BuildRequires: asm >= 1.5.3
BuildRequires: bsf
BuildRequires: java-devel >= 1.6.0
BuildRequires: javacc3
#BuildRequires: servlet_2_3_api
BuildRequires: ant-trax
BuildRequires: asm-javadoc
BuildRequires: bsf-javadoc
BuildRequires: javapackages-tools
BuildRequires: servletapi4
#BuildRequires: xalan-j2
BuildRequires: fdupes
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%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: Lightweight Scripting for Java (BeanShell Version 2.x) (BSF support)
Group: Development/Libraries/Java
Requires: bsf
%description bsf
BSF support for bsh2.
%package classgen
Summary: Lightweight Scripting for Java (BeanShell Version 2.x) (ASM support)
Group: Development/Libraries/Java
Requires: asm
%description classgen
ASM support for bsh2.
%package manual
Summary: Lightweight Scripting for Java (BeanShell Version 2.x) (Manual)
Group: Development/Libraries/Java
%description manual
Documentation for bsh2.
%package javadoc
PreReq: coreutils
Summary: Lightweight Scripting for Java (BeanShell Version 2.x) (Java Documentation)
Group: Development/Libraries/Java
%description javadoc
Javadoc for bsh2.
%package demo
Summary: Lightweight Scripting for Java (BeanShell Version 2.x) (demo and samples)
Group: Development/Libraries/Java
AutoReqProv: no
Requires: %{name} = %{version}-%{release}
%description demo
Demonstrations and samples for bsh2.
%package src
Summary: Lightweight Scripting for Java (BeanShell Version 2.x) (demo and samples)
Group: Development/Libraries/Java
%description src
Source code of beanshell used for build of jEdit.
%prep
%setup -q -n BeanShell-%{fversion}
%patch1 -p1
%patch2 -p0
%patch3 -p1
%patch1000 -p1
%patch1001 -p1
%patch4 -p1
%patch5 -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
pushd lib
ln -sf $(build-classpath asm/asm)
ln -sf $(build-classpath bsf)
ln -sf $(build-classpath javacc3) javacc.jar
ln -sf $(build-classpath servlet)
#mv javaxscript.jar.no javaxscript.jar
popd
pushd engine/javax-src/
export CLASSPATH=$(build-classpath servlet)
javac $(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}-%{release}";|' 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
# remove servlet dependency
#%__rm -rf src/bsh/servlet
#ant -Dexclude-servlet='bsh/servlet/*'
/usr/bin/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}
#rap#%__rm -f dist/%{orig_name}-%{fversion}.jar
rm -f dist/%{orig_name}-%{fversion}-src.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"
#if [ -f /usr/lib/libJavaReadline.so ]; then
# BASE_FLAGS="$BASE_FLAGS -Djava.library.path=/usr/lib"
# BASE_FLAGS="\$BASE_FLAGS -Dbsh.console.readlinelib=GnuReadline"
# BASE_JARS="\$BASE_JARS libreadline-java.jar"
#fi
# 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/
# src
# bsh2-src - copy from debian/rules
%{__install} -d -m 0755 %{buildroot}%{_usrsrc}/%{name}-src
%{__tar} --exclude classes --exclude dist --exclude api \
-cjf %{buildroot}%{_usrsrc}/%{name}-src/%{name}.tar.bz2 *
%files
%defattr(0644,root,root,0755)
%attr(0755,root,root) %{_bindir}/%{name}
%attr(0755,root,root) %{_bindir}/%{name}doc
%doc src/License.txt
%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}/*
%{_mavendepmapfragdir}/*
%files bsf
%defattr(0644,root,root,0755)
%{_javadir}/%{name}/%{orig_name}-bsf*.jar
%files classgen
%defattr(0644,root,root,0755)
%{_javadir}/%{name}/%{orig_name}-classgen*.jar
%files manual
%defattr(0644,root,root,0755)
%doc docs/*
%files javadoc
%defattr(0644,root,root,0755)
%dir %{_javadocdir}/%{name}
%{_javadocdir}/%{name}
%files demo -f %{name}-demo-%{version}.files
%defattr(0644,root,root,0755)
%files src
%defattr(0644,root,root,0755)
%{_usrsrc}/%{name}-src
%changelog