packages java-bsh2.spec
      Pages: < 1 >  DOWNLOAD      
%define        javahome         %{_jvmdir}/jdk
%define        java_jarbin      %{javahome}/bin/jar
%define        java_javacbin    %{javahome}/bin/javac

Name:          java-bsh2
Version:       2.0b4
Release:       3mamba
Summary:       Lightweight Scripting for Java
Group:         Development/Libraries/Java
Vendor:        openmamba
Distribution:  openmamba
Packager:      Silvan Calarco <silvan.calarco@...>
URL:           http://www.beanshell.org/
# wget http://www.beanshell.org/bsh-2.0b4-src.jar
# http://sisyphus.ru/en/srpm/Sisyphus/bsh2/spec
# wget http://www.beanshell.org/bsh-2.0b5-src.zip
Source0:       BeanShell-2.0b4-src.tar.gz
Source1:       BeanShell-2.0b4-bsh.pom
Source2:       BeanShell-2.0b4-classpath.pom
Source3:       BeanShell-2.0b4-commands.pom
Source4:       BeanShell-2.0b4-core.pom
Source5:       BeanShell-2.0b4-reflect.pom
Source6:       BeanShell-2.0b4-util.pom
Source7:       BeanShell-2.0b4-bsf.pom
Source8:       BeanShell-2.0b4-classgen.pom
Source9:       java-bsh.png
Patch0:        java-bsh2-2.0b4-build.patch
Patch1:        java-bsh2-2.0b4-readline.patch
Patch2:        java-bsh2-2.0b4-asm.patch
Patch3:        java-bsh2-2.0b4-jedit.patch
Patch4:        java-bsh2-2.0b4-java15.patch
Patch5:        java-bsh2-2.0b4-crosslink.patch
Patch6:        java-bsh2-2.0b4-ClassGeneratorUtil.patch
Patch7:        java-bsh2-2.0b4-docs-faq_xsl.patch
Patch8:        java-bsh2-2.0b4-docs-manual_xsl.patch
License:       LGPL, Sun Public License
BuildRequires: apache-ant
BuildRequires: apache-ant-trax
BuildRequires: objectweb-asm1
BuildRequires: objectweb-asm1-javadoc
%if "%{stage1}" != "1"
BuildRequires: apache-tomcat5-servletapi5
BuildRequires: javacc3
%else
BuildRequires: java-servletapi4
BuildRequires: javacc
%endif
BuildRequires: jakarta-bsf
BuildRequires: jakarta-bsf-javadoc
#BuildRequires: java-libreadline
BuildRequires: xalan-j2-xsltc
Requires:      jakarta-bsf
Requires:      jpackage-utils
BuildRoot:     %{_tmppath}/%{name}-%{version}-root

%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.bsh.org.objectweb.asm.ClassWriter cannot be applied to 

%package bsf
Group:         Development/Libraries/Java
Summary:       BSF support for %{name}
Requires:      jakarta-bsf

%description bsf
BeanShell - Lightweight Scripting for Java.

This package contains BSF support for %{name}.

%package classgen
Group:         Development/Libraries/Java
Summary:       ASM support for %{name}
Requires:      objectweb-asm1

%description classgen
BeanShell - Lightweight Scripting for Java.

This package contains ASM support for %{name}.

%package demo
Group:         Development/Libraries/Java
Summary:       Examples for %{name}

%description demo
BeanShell - Lightweight Scripting for Java.

This package contains demonstrations and
samples for %{name}.

%package javadoc
Group:         Documentation
Summary:       Javadoc for %{name}

%description    javadoc
BeanShell - Lightweight Scripting for Java.

This package contains Javadoc for %{name}.

%package manual
Group:         Documentation
Summary:       Manual for %{name}

%description manual
BeanShell - Lightweight Scripting for Java.

This package contains documentation for %{name}.

%package console
Group:         Development/Tools
Summary:       %{name} console
Requires:      %{name} = %{?epoch:%epoch:}%{version}-%{release}

%description console
BeanShell - Lightweight Scripting for Java.

This package contains a menu entry for %{name}.

%prep

%setup -q -n BeanShell-%{version}
%patch0 -p1
#%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p0
%patch7 -p1
%patch8 -p1

for j in $(find . -name "*.jar"); do
	mv $j $j.no
done

for j in $(find . -name "CVS"); do
	rm -rf $j
done

for j in $(find . -name ".cvsignore"); do
	rm -rf $j
done

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

mkdir -p bsh-bsf/classes
mkdir -p lib

%build

pushd lib
	ln -sf $(build-classpath asm1/asm) .
%if "%{stage1}" != "1"
	ln -sf $(build-classpath javacc3) javacc.jar
	ln -sf $(build-classpath servletapi5) servlet.jar
%else
	ln -sf $(build-classpath javacc) javacc.jar
	ln -sf $(build-classpath servletapi4) servlet.jar
%endif
	ln -sf $(build-classpath bsf) bsf.jar
popd

#pushd engine/javax-src/ No such file or directory
#	export CLASSPATH=$(build-classpath servletapi5)
#	%{java_javacbin} $(find . -name "*.java")
#	%{java_jarbin} cf ../../lib/javaxscript.jar $(find . -name "*.class" -o -name "*.html")
#popd

%{__perl} -p -i -e 's|VERSION =.*;|VERSION = "%{version}-%{release}";|' src/bsh/Interpreter.java

# remove internal asm code
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
%if "%{stage1}" != "1"
export CLASSPATH=$(build-classpath asm1/asm bsf servletapi5 ant/ant-trax)
%else
export CLASSPATH=$(build-classpath asm1/asm bsf servletapi4 ant/ant-trax)
%endif

ant \
	-Dasm.javadoc=%{_javadocdir}/objectweb-asm1 \
	-Dbsf.javadoc=%{_javadocdir}/bsf \
	-Djava.javadoc=%{_javadocdir}/java \
	-Djava.awt.headless=false \
	dist test
#  	-Dexclude-servlet='bsh/servlet/*' \

export CLASSPATH=$CLASSPATH:$(build-classpath xalan-j2 xsltc ant/ant-trax)

(
	cd docs/faq
	ant
)

(	cd docs/manual
	ant
)

# see http://www.beanshell.org/bsh-2.0b4.jar http://www.beanshell.org/bsh-bsf-2.0b4.jar
export JAVA_HOME=%{javahome}
export CLASSPATH=$CLASSPATH:dist/bsh-%{version}.jar
%{java_javacbin} -d bsh-bsf/classes $(find bsf/src -name "*.java")
rm -rf bsh-bsf/classes/TestBshBSF.class
%{java_jarbin} uf dist/bsh-bsf-%{version}.jar -C bsh-bsf/classes .
%{java_jarbin} uf dist/bsh-%{version}.jar -C bsh-bsf/classes .

%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"


mkdir -p %{buildroot}%{_javadir}/bsh2
rm -f dist/bsh-%{version}-src.jar
pushd dist
	install -m 644 bsh-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-%{version}.jar
	install -m 644 bsh-bsf-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-bsf-%{version}.jar
	install -m 644 bsh-classgen-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-classgen-%{version}.jar
	install -m 644 bsh-classpath-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-classpath-%{version}.jar
	install -m 644 bsh-commands-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-commands-%{version}.jar
	install -m 644 bsh-core-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-core-%{version}.jar
	install -m 644 bsh-reflect-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-reflect-%{version}.jar
	install -m 644 bsh-util-%{version}.jar \
		%{buildroot}%{_javadir}/bsh2/bsh-util-%{version}.jar
popd


(
	cd %{buildroot}%{_javadir}/bsh2
	for jar in *-%{version}*; do
		ln -sf ${jar} ${jar/-%{version}/}
	done
)

mkdir -p %{buildroot}%{_datadir}/maven2/poms
install -pm 644 %{SOURCE1} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh.pom
install -pm 644 %{SOURCE2} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh-classpath.pom
install -pm 644 %{SOURCE3} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh-commands.pom
install -pm 644 %{SOURCE4} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh-core.pom
install -pm 644 %{SOURCE5} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh-reflect.pom
install -pm 644 %{SOURCE6} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh-util.pom
install -pm 644 %{SOURCE7} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh-bsf.pom
install -pm 644 %{SOURCE8} \
	%{buildroot}%{_datadir}/maven2/poms/JPP.bsh2-bsh-classgen.pom

%add_to_maven_depmap org.beanshell beanshell %{version} JPP/bsh2 bsh
%add_to_maven_depmap org.beanshell bsh %{version} JPP/bsh2 bsh
%add_to_maven_depmap org.beanshell bsh-classpath %{version} JPP/bsh2 bsh-classpath
%add_to_maven_depmap org.beanshell bsh-commands %{version} JPP/bsh2 bsh-commands
%add_to_maven_depmap org.beanshell bsh-core %{version} JPP/bsh2 bsh-core
%add_to_maven_depmap org.beanshell bsh-reflect %{version} JPP/bsh2 bsh-reflect
%add_to_maven_depmap org.beanshell bsh-util %{version} JPP/bsh2 bsh-util
%add_to_maven_depmap org.beanshell bsh-bsf %{version} JPP/bsh2 bsh-bsf
%add_to_maven_depmap org.beanshell bsh-classgen %{version} JPP/bsh2 bsh-classgen



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
)

mkdir -p %{buildroot}%{_javadocdir}/bsh2-%{version}
cp -pr javadoc/* %{buildroot}%{_javadocdir}/bsh2-%{version}
ln -s bsh2-%{version} %{buildroot}%{_javadocdir}/bsh2

for i in `find tests -name "*.bsh"`; do
	perl -p -i -e 's,^\n?#!(/(usr/)?bin/java bsh\.Interpreter|/bin/sh),#!%{_bindir}/bsh2,' $i
done

mkdir -p %{buildroot}%{_datadir}/bsh2/{bshservlet,bshservlet-wbsh}
#install -m 644 dist/bshservlet.war %{buildroot}%{_datadir}/bsh/webapps
#install -m 644 dist/bshservlet-wbsh.war %{buildroot}%{_datadir}/bsh/webapps
(
	cd %{buildroot}%{_datadir}/bsh2/bshservlet
	jar xf %{_builddir}/BeanShell-%{version}/dist/bshservlet.war
)

(
	cd %{buildroot}%{_datadir}/bsh2/bshservlet-wbsh
	jar xf %{_builddir}/BeanShell-%{version}/dist/bshservlet-wbsh.war
	rm -rf bsh-%{version}.jar
)

ln -sf ../../java/bsh2/bsh-%{version}.jar %{buildroot}%{_datadir}/bsh2/bshservlet-wbsh/bsh-%{version}.jar

cp -pr tests %{buildroot}%{_datadir}/bsh2

find %{buildroot}%{_datadir}/bsh2 -type d \
  | sed 's|'%{buildroot}'|%dir |' >  bsh2-demo-%{version}.files
find %{buildroot}%{_datadir}/bsh2 -type f -name "*.bsh" \
  | sed 's|'%{buildroot}'|%attr(0755,root,root) |'      >> bsh2-demo-%{version}.files
find %{buildroot}%{_datadir}/bsh2 -type f ! -name "*.bsh" \
  | sed 's|'%{buildroot}'|%attr(0644,root,root) |'      >> bsh2-demo-%{version}.files


mkdir -p %{buildroot}%{_bindir}

cat > %{buildroot}%{_bindir}/bsh2 << EOF
#!/bin/sh
#
# bsh2 script
# JPackage Project (http://jpackage.sourceforge.net)

# Source functions library
. %{_datadir}/java-utils/java-functions

# Source system prefs
if [ -f %{_sysconfdir}/bsh2.conf ] ; then
  . %{_sysconfdir}/bsh2.conf
fi

# Source user prefs
if [ -f \$HOME/.bsh2rc ] ; then
  . \$HOME/.bsh2rc
fi

# Configuration
MAIN_CLASS=bsh.Interpreter
if [ -n "\$BSH_DEBUG" ]; then
  BASE_FLAGS=-Ddebug=true
fi

BASE_JARS="bsh2/bsh"

#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

mkdir -p %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/bsh2-console.desktop << EOF
[Desktop Entry]
Version=1.0
Name=bsh2
GenericName=BeanShell Console
Comment=Lightweight Scripting for Java
Exec=bsh2-console
Icon=bsh2.png
Terminal=false
Type=Application
Categories=Development;Java;
EOF

for s in 16x16 32x32 64x64 ;do
	mkdir -p %{buildroot}%{_datadir}/icons/hicolor/$s/apps
	convert -resize $s %{SOURCE9} %{buildroot}%{_datadir}/icons/hicolor/$s/apps/bsh2.png
done

mkdir -p %{buildroot}%{_datadir}/pixmaps
cp -pr %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/bsh2.png %{buildroot}%{_datadir}/pixmaps

cat > %{buildroot}%{_bindir}/bsh2-console << EOF
#!/bin/sh
#
# bsh2 script
# JPackage Project (http://jpackage.sourceforge.net)

# Source functions library
. %{_datadir}/java-utils/java-functions

# Source system prefs
if [ -f %{_sysconfdir}/bsh2.conf ] ; then
  . %{_sysconfdir}/bsh2.conf
fi

# Source user prefs
if [ -f \$HOME/.bsh2rc ] ; then
  . \$HOME/.bsh2rc
fi

# Configuration
MAIN_CLASS=bsh.Console
if [ -n "\$BSH_DEBUG" ]; then
  BASE_FLAGS=-Ddebug=true
fi

BASE_JARS="bsh2/bsh"

#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}/bsh2doc << EOF
#!/usr/bin/env %{_bindir}/bsh2
EOF
cat scripts/bshdoc.bsh >> %{buildroot}%{_bindir}/bsh2doc

%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"

%files
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/bsh2
%attr(0755,root,root) %{_bindir}/bsh2doc
%dir %{_javadir}/bsh2
%{_javadir}/bsh2/bsh-%{version}.jar
%{_javadir}/bsh2/bsh.jar
%{_javadir}/bsh2/bsh-classpath-%{version}.jar
%{_javadir}/bsh2/bsh-classpath.jar
%{_javadir}/bsh2/bsh-commands-%{version}.jar
%{_javadir}/bsh2/bsh-commands.jar
%{_javadir}/bsh2/bsh-core-%{version}.jar
%{_javadir}/bsh2/bsh-core.jar
%{_javadir}/bsh2/bsh-reflect-%{version}.jar
%{_javadir}/bsh2/bsh-reflect.jar
%{_javadir}/bsh2/bsh-util-%{version}.jar
%{_javadir}/bsh2/bsh-util.jar
%dir %{_datadir}/bsh2
%{_datadir}/bsh2/bshservlet
%{_datadir}/bsh2/bshservlet-wbsh
%{_datadir}/maven2/poms
%{_mavendepmapfragdir}
%doc src/*.html src/*.txt

%post console
touch --no-create %{_datadir}/icons/hicolor
if [ -x /usr/bin/gtk-update-icon-cache ]; then
  	/usr/bin/gtk-update-icon-cache -q %{_datadir}/icons/hicolor
fi

%postun console
touch --no-create %{_datadir}/icons/hicolor
if [ -x /usr/bin/gtk-update-icon-cache ]; then
  	/usr/bin/gtk-update-icon-cache -q %{_datadir}/icons/hicolor
fi

%files console
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/bsh2-console
%{_datadir}/applications/bsh2-console.desktop
%{_datadir}/icons/hicolor/*x*/apps/bsh2.png
%{_datadir}/pixmaps/bsh2.png

%files bsf
%defattr(-,root,root)
%{_javadir}/bsh2/bsh-bsf-%{version}.jar
%{_javadir}/bsh2/bsh-bsf.jar

%files classgen
%defattr(-,root,root)
%{_javadir}/bsh2/bsh-classgen-%{version}.jar
%{_javadir}/bsh2/bsh-classgen.jar

%files demo -f bsh2-demo-%{version}.files
%defattr(-,root,root)

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

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

%changelog
* Sat Nov 27 2010 gil <puntogil@...> 2.0b4-3mamba
- fix broken link in %{_datadir}/bsh2/bshservlet-wbsh

* Thu Nov 04 2010 gil <puntogil@...> 2.0b4-2mamba
- rebuilt devel

* Tue Mar 17 2009 gil <puntogil@...> 2.0b4-1mamba
- update to 2.0b4
- renamed java-bsh2

* Tue Mar 17 2009 gil <puntogil@...> 1.3.0-3mamba
- add maven poms

* Fri Mar 13 2009 gil <puntogil@...> 1.3.0-2mamba
- add sub package console

* Thu Mar 05 2009 gil <puntogil@...> 1.3.0-1mamba
- package created by autospec