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 http://bugs.opensuse.org/
#


%define Name    BeanShell
Name:           bsh
Version:        1.3.0
Release:        0
Summary:        Lightweight Scripting for Java
License:        LGPL-2.1+
Group:          Development/Libraries/Java
Url:            http://www.beanshell.org/
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

%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 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
results.

%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.

%prep
%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

%build
mkdir -p lib
export CLASSPATH=$(build-classpath bsf servletapi5 xalan-j2)
ant -Dant.build.javac.source=1.6 -Dant.build.javac.target=1.6 dist
(cd docs/faq && ant -Dant.build.javac.source=1.6 -Dant.build.javac.target=1.6)
(cd docs/manual && ant -Dant.build.javac.source=1.6 -Dant.build.javac.target=1.6)

%install
# jars
install -d -m 755 %{buildroot}%{_javadir}
install -m 644 dist/%{name}-%{version}.jar \
             %{buildroot}%{_javadir}/%{name}-%{version}.jar
install -m 644 dist/%{name}-bsf-%{version}.jar \
             %{buildroot}%{_javadir}/%{name}-bsf-%{version}.jar
install -m 644 dist/%{name}-classpath-%{version}.jar \
             %{buildroot}%{_javadir}/%{name}-classpath-%{version}.jar
install -m 644 dist/%{name}-commands-%{version}.jar \
             %{buildroot}%{_javadir}/%{name}-commands-%{version}.jar
install -m 644 dist/%{name}-core-%{version}.jar \
             %{buildroot}%{_javadir}/%{name}-core-%{version}.jar
install -m 644 dist/%{name}-reflect-%{version}.jar \
             %{buildroot}%{_javadir}/%{name}-reflect-%{version}.jar
install -m 644 dist/%{name}-util-%{version}.jar \
             %{buildroot}%{_javadir}/%{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} \
    %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
install -pm 644 %{SOURCE2} \
    %{buildroot}%{_mavenpomdir}/JPP-%{name}-bsf.pom

%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
  fi
done
chmod 755 tests/Template
cat > one << EOF
#!/bin/sh
EOF
cat tests/Interactive/reload/one >> one
cat one > tests/Interactive/reload/one
rm one
cat > two << EOF
#!/bin/sh
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
#!/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 %{buildroot}%{_prefix}

%files
%doc src/Changes.html src/License.txt src/README.txt
%attr(0755,root,root) %{_bindir}/%{name}
%attr(0755,root,root) %{_bindir}/%{name}doc
%{_javadir}/*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}
%{_datadir}/%{name}/webapps
%{_datadir}/maven-metadata/%{name}.xml
%{_mavenpomdir}/*
%exclude %{_datadir}/%{name}/tests

%files manual
%doc docs/*

%files javadoc
%{_javadocdir}/%{name}

%files demo
%doc tests/README.txt tests/Interactive/README
%{_datadir}/%{name}/tests

%changelog
openSUSE Build Service is sponsored by