File bsh.spec of Package bsh

#
# spec file for package bsh
#
# Copyright (c) 2011 SUSE LINUX Products 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/
#

# icecream 0


Name:           bsh
%define name		bsh
%define Name		BeanShell
%define version		1.3.0
%define fversion	1.3.0
%define release		6jpp
%define section		free
Version:        1.3.0
Release:        340
Summary:        Lightweight Scripting for Java
License:        LGPL-2.1+
Source0:        %{name}-%{fversion}-src.tar.bz2
Source1:        bsh-1.3.0.pom
Source2:        bsh-bsf-1.3.0.pom
Patch0:         %{name}-build.patch
Patch2:         %{name}-java14compat.patch
BuildRequires:  ant-trax
BuildRequires:  bsf
BuildRequires:  perl
BuildRequires:  jpackage-utils >= 1.7.2
BuildRequires:  java-devel
BuildRequires:  servletapi5
BuildRequires:  fdupes
BuildRequires:  xalan-j2
PreReq:         coreutils
Requires:       bsf
Requires:       jpackage-utils >= 1.5
Url:            http://www.beanshell.org/
Group:          Development/Libraries/Java
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 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
License:        LGPL-2.1+
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
License:        LGPL-2.1+
PreReq:         coreutils
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
License:        LGPL-2.1+
Summary:        Demonstration and sample files for bsh
Group:          Development/Libraries/Java
AutoReqProv:    no
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
%patch2
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 dist
(cd docs/faq && ant)
(cd docs/manual && ant)

%install
# jars
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}
install -m 644 dist/%{name}-%{version}.jar \
             $RPM_BUILD_ROOT%{_javadir}/%{name}-%{version}.jar
install -m 644 dist/%{name}-bsf-%{version}.jar \
             $RPM_BUILD_ROOT%{_javadir}/%{name}-bsf-%{version}.jar
install -m 644 dist/%{name}-classpath-%{version}.jar \
             $RPM_BUILD_ROOT%{_javadir}/%{name}-classpath-%{version}.jar
install -m 644 dist/%{name}-commands-%{version}.jar \
             $RPM_BUILD_ROOT%{_javadir}/%{name}-commands-%{version}.jar
install -m 644 dist/%{name}-core-%{version}.jar \
             $RPM_BUILD_ROOT%{_javadir}/%{name}-core-%{version}.jar
install -m 644 dist/%{name}-reflect-%{version}.jar \
             $RPM_BUILD_ROOT%{_javadir}/%{name}-reflect-%{version}.jar
install -m 644 dist/%{name}-util-%{version}.jar \
             $RPM_BUILD_ROOT%{_javadir}/%{name}-util-%{version}.jar
(cd $RPM_BUILD_ROOT%{_javadir} && for jar in *-%{version}*; do ln -sf ${jar} ${jar/-%{version}/}; done)
%add_to_maven_depmap %{name} %{name} %{version} JPP %{name}
%add_to_maven_depmap %{name} %{name}-bsf %{version} JPP %{name}-bsf
# poms
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/maven2/poms
install -pm 644 %{SOURCE1} \
    $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.%{name}.pom
install -pm 644 %{SOURCE2} \
    $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.%{name}-bsf.pom
# 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 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -pr javadoc/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
# demo
for i in `find tests -name \*.bsh`; do
  perl -p -i -e 's,^\n?#!(/(usr/)?bin/java bsh\.Interpreter|/bin/sh),#!/usr/bin/env %{_bindir}/%{name},' $i
  if head -1 $i | grep '#!/usr/bin/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 $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -pr tests $RPM_BUILD_ROOT%{_datadir}/%{name}
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/webapps
install -m 644 dist/bshservlet.war $RPM_BUILD_ROOT%{_datadir}/%{name}/webapps
install -m 644 dist/bshservlet-wbsh.war $RPM_BUILD_ROOT%{_datadir}/%{name}/webapps
# scripts
install -d $RPM_BUILD_ROOT%{_bindir}
cat > $RPM_BUILD_ROOT%{_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 > $RPM_BUILD_ROOT%{_bindir}/%{name}doc << EOF
#!/usr/bin/env %{_bindir}/%{name}
EOF
cat scripts/bshdoc.bsh >> $RPM_BUILD_ROOT%{_bindir}/%{name}doc
%fdupes ${RPM_BUILD_ROOT}/usr

%post javadoc
rm -f %{_javadocdir}/%{name}
ln -s %{name}-%{version} %{_javadocdir}/%{name}

%postun javadoc
if [ "$1" = "0" ]; then
    rm -f %{_javadocdir}/%{name}
fi

%post
%update_maven_depmap

%postun
%update_maven_depmap

%files
%defattr(-,root,root)
%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}/maven2
%{_datadir}/maven2/poms
%{_datadir}/maven2/poms/*
%{_mavendepmapfragdir}
%exclude %{_datadir}/%{name}/tests

%files manual
%defattr(-,root,root)
%doc docs/*

%files javadoc
%defattr(-,root,root)
%{_javadocdir}/%{name}-%{version}

%files demo
%defattr(-,root,root)
%doc tests/README.txt tests/Interactive/README
%{_datadir}/%{name}/tests

%changelog