File xml-commons-apis-bootstrap.spec of Package xml-commons

#
# spec file for package xml-commons-apis-bootstrap (Version 1.3)
#
# Copyright (c) 2008 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/
#

# norootforbuild


Name:           xml-commons-apis-bootstrap
#!BuildIgnore:  antlr
BuildRequires:  antlr-bootstrap fastjar gcc-gij gcc-java java-1_4_2-gcj-compat java-1_4_2-gcj-compat-devel unzip zip
%if %{?!suse_version:1}0
%if %{?!mandriva_release:1}0
BuildRequires:  chkconfig which
%endif
%else
BuildRequires:  update-alternatives
%endif
%if %{undefined _jvmdir}
%define _jvmdir  %{_libdir}/jvm
%endif
%if %{undefined _jvmjardir}
%define _jvmjardir %{_libdir}/jvm-exports
%endif
%define       xml_commons_version 1.0.b2
%define       real_name xml-commons
%define       apis_jar %{real_name}-apis-bootstrap
%define       which_jar %{real_name}-which-bootstrap
Summary:        Common code for XML projects - bootstrapping package
Version:        1.3
Release:        227
# ... externals have to be checked out with svn ... see README.PACKAGER.xml-commons-external
Url:            http://xml.apache.org/commons/
License:        The Apache Software License
Group:          Development/Libraries/Java
AutoReqProv:    on
Source0:        %{real_name}-%{xml_commons_version}.tar.bz2
Source1:        %{real_name}-externals.tar.bz2
# files for the source package
Source42:       README.PACKAGER.xml-commons-external
# to be consistent with xml-commons.spec
Patch2:         xml-commons-jdk5-build.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
#BuildArchitectures: noarch
#ExclusiveArch: %ix86
BuildArch:      noarch
Provides:       xml-apis

%description
This is xml-apis from the java-bootrapping-tools package. DO NOT
INSTALL ... THIS IS JUST FOR PACKAGING & BOOTSTRAPPING JAVA PURPOSES!!



%package -n xml-commons-which-bootstrap
License:        The Apache Software License
Summary:        Which subproject of xml-commons
Group:          Development/Libraries/Java
Url:            http://xml.apache.org/commons/
Version:        1.0.b2
Release:        227

%description -n xml-commons-which-bootstrap
This is xml-which from the java-bootrapping-tools package. DO NOT
INSTALL ... THIS IS JUST FOR PACKAGING & BOOTSTRAPPING JAVA PURPOSES!!



%prep 
#<<< package descriptions end
#>>> %prep
# xml-commons
%setup -n %{real_name}-%{version}
pushd java
# use more up to date external sources
rm -rf external
tar -jxf %{SOURCE1}
#<<<
#>>> %build 
popd
%patch2 -b .sav

%build 
#>>> some useful functions ... used throughout bootstrap packages
# variables:
TARGET_DIR=`pwd`
CLASSPATH_ORIG="$CLASSPATH"
LIB_GCJ="`ls %{_javadir}/libgcj-*.jar`"
#>>> delete binary file and files not needed
function delBinaryFiles() {
  set +x
  echo deleting binary files ...
  for file in `find . -name "*.class" -o -name "*.jar" -o -name "*DELETED-BY-PACKAGER*"` 
  do 
    rm -rf $file
  done
  set -x
}
#<<<
#>>> make a string with all jar files found in target folder that can be used for a classpath string
# string is saved in JAR_CLASSPATH
function mkTargetClasspath() {
  set +x
  JAR_CLASSPATH=""
  for file in `find %{_javadir} -name "*.jar"`
  do
    JAR_CLASSPATH=$file:$JAR_CLASSPATH
  done
  set -x
}
#<<<
#>>> compiles all *.java file in the current directory tree
# uses mkTargetClasspath for CLASSPATH  variable
# uses LIB_GCJ for CLASSPATH
function compileFiles() {
  mkTargetClasspath
  set +x
  COMPILE_CLASSPATH_PATH=.:${JAR_CLASSPATH}
  echo using: $COMPILER_COMMAND $COMPILE_CLASSPATH_PATH $$file
  for file in `find . -name "*.java"`
  do
    echo -e "$COMPILER_COMMAND $COMPILE_CLASSPATH_PATH $file ... \c"
    $COMPILER_COMMAND $COMPILE_CLASSPATH_PATH $file
    # check for errors
    if [ $? != 0 ]
    then
      echo ERROR
      exit 1;
    fi
    echo done
  done
  set -x
}
#<<<
#>>> make jar archive
# PARAM#1: name of jar archive (without .jar suffix)
# uses $TARGET_DIR to move created jar to
function mkJar() {
  find  -name "version.txt" -or -name "*.class" -or -name "*.properties" -or -name "*.rsc" -or -name "*manifest*" |\
    xargs /usr/bin/fastjar -m manifest.* -cf ${1}.jar ;
  mv ${1}.jar $TARGET_DIR
}
#<<<
COMPILER_COMMAND="javac -C -ftarget=1.4 -classpath "
#<<< end functions
delBinaryFiles
#>>> xml-apis and xml-which
# compile external files
cd java/external/src
compileFiles
mkJar %{apis_jar}
delBinaryFiles
# compile the rest
cd ../../src/
# we use the resolver classes from the resolver package and therefore delete all related resolver files:
rm -r org/apache/xml/ 
rm manifest.resolver
compileFiles
mkJar %{which_jar}
delBinaryFiles
#<<< xml-commons end
#<<< build end
#>>> %install

%install
mkdir -p $RPM_BUILD_ROOT/%{_javadir}
cp %{apis_jar}.jar $RPM_BUILD_ROOT/%{_javadir}
cp %{which_jar}.jar $RPM_BUILD_ROOT/%{_javadir}
#<<< install end

%clean
rm -rf $RPM_BUILD_ROOT 
#>>> files

%files 
%defattr(-,root,root)   
#%dir %{_javadir}
%{_javadir}/%{apis_jar}.jar

%files -n xml-commons-which-bootstrap
%defattr(-,root,root)   
#%dir %{_javadir}
%{_javadir}/%{which_jar}.jar
#<<<
# vim:fdm=marker:foldmarker=#>>>,#<<<:foldcolumn=6:

%changelog
* Tue Jan 22 2008 mvyskocil@suse.cz
- fixed beta build
* Tue Aug 28 2007 skh@suse.de
- add BuildRequires: antlr-bootstrap and #!BuildIgnore: antlr to break
  build cycle caused further down the dependency chain
  (java-1_4_2-gcj-compat->gjdoc->antlr->ant->xml-commons-apis-bootstrap)
* Wed Jun 27 2007 rguenther@suse.de
- remove libgcj BuildRequires
* Wed May 02 2007 dbornkessel@suse.de
- added unzip to BuildRequires
* Fri Sep 29 2006 ro@suse.de
- added gcc-java,gcc-gij to BuildRequires
* Thu Sep 21 2006 dbornkessel@suse.de
- first version