File bsh.spec of Package bsh

# spec file for package bsh
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# 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

%define Name    BeanShell
Name:           bsh
Version:        1.3.0
Release:        0
Summary:        Lightweight Scripting for Java
License:        LGPL-2.1+
Group:          Development/Libraries/Java
Source0:        %{name}-%{version}-src.tar.bz2
Source1:        bsh-1.3.0.pom
Source2:        bsh-bsf-1.3.0.pom
Patch0:         %{name}-build.patch
Patch1:         bsh-getpeer.patch
BuildRequires:  ant
BuildRequires:  bsf
BuildRequires:  fdupes
BuildRequires:  java-devel
# Needed for maven conversions
BuildRequires:  javapackages-local
BuildRequires:  javapackages-tools
BuildRequires:  perl
BuildRequires:  servletapi5
BuildRequires:  xalan-j2
Requires:       bsf
Requires:       javapackages-tools
BuildArch:      noarch

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 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 runtime 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. Because 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

%package manual
Summary:        Manual for bsh
Group:          Development/Libraries/Java

%description manual
BeanShell is a small, free, embeddable, Java source interpreter with
object scripting language features, written in Java.

This package contains the manual for BeanShell.

%package javadoc
Summary:        Javadoc for bsh
Group:          Development/Libraries/Java

%description javadoc
BeanShell is a small, free, embeddable, Java source interpreter with
object scripting language features, written in Java.

This package contains the javadoc documentation for BeanShell.

%package demo
Summary:        Demonstration and sample files for bsh
Group:          Development/Libraries/Java
Requires:       %{name} = %{version}
Requires:       coreutils

%description demo
BeanShell is a small, free, embeddable, Java source interpreter with
object scripting language features, written in Java.

This package contains sample and demonstration files for BeanShell.

%setup -q -n %{Name}
%patch0 -p1
%patch1 -p1
find . -name "*.jar" -exec rm -f {} \;
# remove all CVS files
for dir in `find . -type d -name CVS`; do rm -rf $dir; done
for file in `find . -type f -name .cvsignore`; do rm -rf $file; done
# fix permissions
find . -type 'f' | xargs chmod 0644

mkdir -p lib
export CLASSPATH=$(build-classpath bsf servletapi5 xalan-j2)
ant dist
(cd docs/faq && ant
(cd docs/manual && ant

# jars
install -d -m 755 %{buildroot}%{_javadir}
install -m 644 dist/%{name}-%{version}.jar \
install -m 644 dist/%{name}-bsf-%{version}.jar \
install -m 644 dist/%{name}-classpath-%{version}.jar \
install -m 644 dist/%{name}-commands-%{version}.jar \
install -m 644 dist/%{name}-core-%{version}.jar \
install -m 644 dist/%{name}-reflect-%{version}.jar \
install -m 644 dist/%{name}-util-%{version}.jar \
(cd %{buildroot}%{_javadir} && for jar in *-%{version}*; do ln -sf ${jar} ${jar/-%{version}/}; done)

# poms
install -d -m 755 %{buildroot}%{_mavenpomdir}
install -pm 644 %{SOURCE1} \
install -pm 644 %{SOURCE2} \

%add_maven_depmap JPP-%{name}.pom %{name}.jar -a org.beanshell:%{name}
%add_maven_depmap JPP-%{name}-bsf.pom %{name}-bsf.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 html/* .)
(cd docs/manual && rm -rf html)
(cd docs/manual && rm -rf xsl)
# javadoc
install -d -m 755 %{buildroot}%{_javadocdir}/%{name}
cp -pr javadoc/* %{buildroot}%{_javadocdir}/%{name}
# demo
for i in `find tests -name \*.bsh` tests/Template; do
  perl -p -i -e 's,^\n?#!(/(usr/)?bin/java bsh\.Interpreter|/bin/sh),#!%{_bindir}/env %{_bindir}/%{name},' $i
  if head -1 $i | grep '#!%{_bindir}/env %{_bindir}/%{name}' >/dev/null; then
    chmod 755 $i
chmod 755 tests/Template
cat > one << EOF
cat tests/Interactive/reload/one >> one
cat one > tests/Interactive/reload/one
rm one
cat > two << EOF
cat tests/Interactive/reload/two >> two
cat two > tests/Interactive/reload/two
rm two
install -d -m 755 %{buildroot}%{_datadir}/%{name}
cp -pr tests %{buildroot}%{_datadir}/%{name}
install -d -m 755 %{buildroot}%{_datadir}/%{name}/webapps
install -m 644 dist/bshservlet.war %{buildroot}%{_datadir}/%{name}/webapps
install -m 644 dist/bshservlet-wbsh.war %{buildroot}%{_datadir}/%{name}/webapps
# scripts
install -d %{buildroot}%{_bindir}
cat > %{buildroot}%{_bindir}/%{name} << EOF
# %{name} script
# JPackage Project (
# Source functions library
. %{_datadir}/java-utils/java-functions
# Source system prefs
if [ -f %{_sysconfdir}/%{name}.conf ] ; then
  . %{_sysconfdir}/%{name}.conf
# Source user prefs
if [ -f \$HOME/.%{name}rc ] ; then
  . \$HOME/.%{name}rc
# Configuration
if [ -n "\$BSH_DEBUG" ]; then
#if [ -f /usr/lib/ ]; 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"
# Set parameters
set_classpath \$BASE_JARS
set_flags \$BASE_FLAGS
set_options \$BASE_OPTIONS
# Let's start
run "\$@"
cat > %{buildroot}%{_bindir}/%{name}doc << EOF
#!/usr/bin/env %{_bindir}/%{name}
cat scripts/bshdoc.bsh >> %{buildroot}%{_bindir}/%{name}doc
%fdupes %{buildroot}%{_prefix}

%doc src/Changes.html src/License.txt src/README.txt
%attr(0755,root,root) %{_bindir}/%{name}
%attr(0755,root,root) %{_bindir}/%{name}doc
%dir %{_datadir}/%{name}
%exclude %{_datadir}/%{name}/tests

%files manual
%doc docs/*

%files javadoc

%files demo
%doc tests/README.txt tests/Interactive/README

openSUSE Build Service is sponsored by