File java-1_5_0-gcj-compat.spec of Package java-1_5_0-gcj-compat

#
# spec file for package java-1_5_0-gcj-compat (Version 1.5.0.0)
#
# Copyright (c) 2010 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
# icecream 0


Name:           java-1_5_0-gcj-compat
BuildRequires:  gcc-gij gcc-java gjdoc python-devel unzip
#!BuildIgnore:  antlr
BuildRequires:  antlr-bootstrap
# bnc#447342
BuildRequires:  openssl-certs
%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
Version:        1.5.0.0
Release:        109
%define section		free
%define gccsuffix %{nil}
%define gccbinsuffix %(rpm -q --qf "-%{VERSION}" gcc)
%define	origin		gcj%{gccsuffix}
%define priority	1500
%define	javaver		1.5.0
%define buildver	0
%define gccver		%(rpm -q --qf "%{VERSION}" gcc)
%define jgcver		1.0.76
%define cname     java-%{javaver}-%{origin}%{gccbinsuffix}
%define	sdklnk		java-%{javaver}-%{origin}
%define	jrelnk		jre-%{javaver}-%{origin}
%define	sdkdir		%{cname}-%{version}
%define	jredir		%{sdkdir}/jre
%define sdkbindir	%{_jvmdir}/%{sdklnk}/bin
%define jrebindir	%{_jvmdir}/%{jrelnk}/bin
%define jvmjardir %{_jvmjardir}/%{cname}-%{version}
# FIXME: this is not a good fix of name issue
%define jvmdir          %{_jvmdir}/%{sdklnk}%{gccbinsuffix}-%{version}
%define sdkjardir       %{_jvmdir}/%{sdkdir}/lib
Summary:        JPackage Runtime Scripts for GCJ
Group:          Development/Languages/Java
License:        GPLv2+
Url:            ftp://sources.redhat.com/pub/rhug/java-gcj-compat
Source0:        java-gcj-compat-%{jgcver}.tar.bz2
Source1:        baselibs.conf
# Call gij instead of gcj in the "java" wrapper script:
Patch0:         gcc43-fixes.patch
Patch1:         python_prefix.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# gcc-java should not be required, see Suse Bugzilla bug #151732
# even if it would be required it should have been a PreReq
# because gcj was called in the post install section
# now the gcj related stuff is only done via triggerin
#Requires:       gcc%{gccsuffix}-java >= %{gccver}
#PreReq:         libgcj%{gccsuffix} >= %{gccver}
#Requires:       libgcj%{gccsuffix} >= %{gccver}
PreReq:         gcc-gij
%if %{?!suse_version:1}0
%if %{?!mandriva_release:1}0
PreReq:         chkconfig which
%endif
%else
PreReq:         update-alternatives
%endif
PreReq:         coreutils
# Requires:	gjdoc
# See java-1_4_2-sun.spec:
Provides:       jre-%{javaver}-%{origin} = %{version}-%{release}
Provides:       jre-%{origin} = %{version}-%{release}
Provides:       jre-%{javaver}, java-%{javaver}, jre = %{javaver}
Provides:       java-%{origin} = %{version}-%{release}
Provides:       java = %{javaver}
Provides:       jndi, jdbc-stdext
Provides:       j2re = %{javaver}, j2re
# 32-bit versus 64-bit specific provides:
%ifarch %ix86 ppc s390
%define bits 32
%endif
%ifarch x86_64 ia64 s390x ppc64
%define bits 64
%endif
Provides:       jre-%{javaver}-%{origin}-%{bits} = %{version}-%{release}
Provides:       jre-%{javaver}-%{origin}-%{bits} = %{version}-%{release}
Provides:       jre-%{origin}-%{bits} = %{version}-%{release}
Provides:       jre-%{javaver}-%{bits}, java-%{javaver}-%{bits}, jre-%{bits} = %{javaver}
Provides:       java-%{origin}-%{bits} = %{version}-%{release}
Provides:       java-%{bits} = %{javaver}
Provides:       jndi-%{bits}, jdbc-stdext-%{bits}
# See java-1_4_2-sun.spec and Suse Bugzilla bug #148186:
Provides:       jre1.1.x jre1.2.x jre1.3.x jre1.4.x jre1.5.x
# See java-1_4_2-sun.spec and Suse Bugzilla bug #160828:
Provides:       jndi = %{javaver}, jndi-ldap = %{javaver}
Provides:       jndi-cos = %{javaver}, jndi-rmi = %{javaver}
Provides:       jndi-dns = %{javaver}
Provides:       jaas = %{javaver}
# also provide the java_1_4_2-gcj-compat
# see comment 15 bug #341578
Provides:       java-1_4_2-gcj-compat
Obsoletes:      java-1_4_2-gcj-compat
# not required #341578
# Requires:       classpath
# let's provide it here for now
Provides:       classpath = %{version}
Obsoletes:      classpath <= 0.95
Provides:       classpath-jta = %{version}
Obsoletes:      classpath-jta <= 0.95
Provides:       jta

%description
This package contains shell scripts and symbolic links to simulate a
JPackage Java runtime environment with GCJ.



Authors:
--------
    Thomas Fitzsimmons <fitzsim@redhat.com>

%package devel
License:        GPLv2+
Summary:        JPackage development scripts for GCJ
Group:          Development/Languages/Java
PreReq:         update-alternatives
PreReq:         coreutils
# See Suse Bugzilla bug #151732 comment #17:
Requires:       gcc-java >= %{gccver}
# Similar provides as in java-1_4_2-sun.spec:
Provides:       java-sdk-%{javaver}-%{origin} = %{version}
Provides:       java-sdk-%{javaver}
Provides:       java-sdk-%{origin} = %{version}
Provides:       java-sdk = %{javaver}
Provides:       java-%{javaver}-devel
Provides:       java-devel-%{origin} = %{version}
Provides:       java-devel = %{javaver}
Provides:       classpath-devel = %{version}
Obsoletes:      classpath-devel <= 0.95
Requires:       %{name} = %{version}-%{release}
# Why?
Requires:       gjdoc
# See java-1_4_2-sun.spec:
Provides:       j2sdk = %{javaver}
# Be able to check bytecode version
Requires:       unzip
Provides:       java-1_4_2-gcj-compat-devel
Obsoletes:      java-1_4_2-gcj-compat-devel

%description devel
This package contains shell scripts and symbolic links to simulate a
JPackage Java development environment with GCJ.



Authors:
--------
    Thomas Fitzsimmons <fitzsim@redhat.com>

%prep
%setup -q -n java-gcj-compat-%{jgcver}
%patch0 -p1
%patch1
# bnc#447342
for key in /etc/ssl/certs/*.pem; do
    # workaround for bnc#546843
  (yes | gkeytool%{gccbinsuffix} -import -keystore cacerts -file $key -storepass "" -alias `basename $key`) || :
done

%build
%configure --disable-symlinks --with-gcc-suffix=%{gccbinsuffix} --with-jvm-root-dir=%{_jvmdir} --with-java-home=%{_jvmdir}
make

%install
%makeinstall 
install -dm 755 $RPM_BUILD_ROOT%{_jvmdir}/%{cname}-%{version}/jre/lib
# make a link to ecj.jar in the lib dir:
ln -sf %{_javadir}/libgcj%{gccbinsuffix}.jar $RPM_BUILD_ROOT%{_jvmdir}/%{cname}-%{version}/jre/lib/jdtcore.jar
ln -sf %{_javadir}/libgcj%{gccbinsuffix}.jar $RPM_BUILD_ROOT%{_jvmdir}/%{cname}-%{version}/jre/lib/rt.jar
install -dm 755 $RPM_BUILD_ROOT%{_jvmdir}/%{cname}-%{version}/include
mkdir $RPM_BUILD_ROOT%{_jvmdir} || :
pushd $RPM_BUILD_ROOT%{_jvmdir}
   ln -s %{jredir} %{jrelnk}
   ln -s %{sdkdir} %{sdklnk}
popd
mkdir -p $RPM_BUILD_ROOT/%{jvmjardir}|| :
pushd $RPM_BUILD_ROOT%{_jvmjardir}
   ln -s %{sdkdir} %{jrelnk}
   ln -s %{sdkdir} %{sdklnk}
popd
mkdir -p $RPM_BUILD_ROOT/%{sdkjardir}|| :
mkdir -p $RPM_BUILD_ROOT/%_bindir
mkdir -p $RPM_BUILD_ROOT/%_libdir
mv $RPM_BUILD_ROOT/usr/local/%_lib/* $RPM_BUILD_ROOT/%_libdir || :
rm -rf $RPM_BUILD_ROOT/usr/local/
# generate file lists
find $RPM_BUILD_ROOT%{_jvmdir}/%{jredir} -type d \
  | sed 's|'$RPM_BUILD_ROOT'|%dir |' >  %{name}-%{version}-all.files
find $RPM_BUILD_ROOT%{_jvmdir}/%{jredir} -type f -o -type l \
  | sed 's|'$RPM_BUILD_ROOT'||'      >> %{name}-%{version}-all.files
cat %{name}-%{version}-all.files \
  > %{name}-%{version}.files
find $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}/bin -type f \
  | sed "s|^$RPM_BUILD_ROOT||"      > %{name}-%{version}-sdk-bin.files
# bnc#447342
install -d -m 0755 $RPM_BUILD_ROOT/%{_jvmdir}/%{jredir}/lib/security/
install -m 0644 cacerts $RPM_BUILD_ROOT/%{_jvmdir}/%{jredir}/lib/security/

%clean
rm -rf $RPM_BUILD_ROOT

%post
update-alternatives \
  --install %{_bindir}/java java %{jrebindir}/java %{priority} \
  --slave %{_jvmdir}/jre          jre          %{_jvmdir}/%{jrelnk} \
  --slave %{_jvmjardir}/jre       jre_exports  %{_jvmjardir}/%{jrelnk} \
  --slave %{_bindir}/rmiregistry  rmiregistry  %{jrebindir}/rmiregistry
update-alternatives \
  --install %{_jvmdir}/jre-%{origin} \
      jre_%{origin} %{_jvmdir}/%{jrelnk} %{priority} \
  --slave %{_jvmjardir}/jre-%{origin} \
      jre_%{origin}_exports %{_jvmjardir}/%{jrelnk}
update-alternatives \
  --install %{_jvmdir}/jre-%{javaver} \
      jre_%{javaver} %{_jvmdir}/%{jrelnk} %{priority} \
  --slave %{_jvmjardir}/jre-%{javaver} \
      jre_%{javaver}_exports %{_jvmjardir}/%{jrelnk}
# now the gcj related stuff is only done via triggerin
#ln -sf \
#  %{_javadir}/libgcj-`gcj%{gccsuffix} --version | head -n 1 | awk '{ print $3 }'`.jar \
#  %{_jvmdir}/%{cname}-%{version}/jre/lib/rt.jar
# little work-around if no version-less link to libgcj-x.y.z.jar does not exist 
if [ ! -e %{_javadir}/libgcj.jar ] && ls %{_javadir}/libgcj-[0-9]*.jar 2>/dev/null >&2
then
  pushd %{_javadir}/ 1>/dev/null
  for file in `ls libgcj-[0-9]*.jar`
  do
    LIBGCJ_NAME=$file
  done
  popd 1>/dev/null
else
  LIBGCJ_NAME=libgcj.jar
fi
pushd %{jvmjardir} 1>/dev/null
   ln -sf %{_javadir}/$LIBGCJ_NAME jndi-%{version}.jar
   ln -sf %{_javadir}/$LIBGCJ_NAME jndi-ldap-%{version}.jar
   ln -sf %{_javadir}/$LIBGCJ_NAME jndi-cos-%{version}.jar
   ln -sf %{_javadir}/$LIBGCJ_NAME jndi-rmi-%{version}.jar
   ln -sf %{_javadir}/$LIBGCJ_NAME jaas-%{version}.jar
   ln -sf %{_javadir}/$LIBGCJ_NAME jdbc-stdext-%{version}.jar
   ln -sf jdbc-stdext-%{version}.jar jdbc-stdext-3.0.jar
   for jar in *-%{version}.jar ; do
      ln -fs ${jar} $(echo $jar | sed "s|-%{version}.jar|-%{javaver}.jar|g")
      ln -fs ${jar} $(echo $jar | sed "s|-%{version}.jar|.jar|g")
   done
popd 1>/dev/null

%post devel
update-alternatives \
  --install %{_bindir}/javac javac %{sdkbindir}/javac %{priority} \
  --slave %{_jvmdir}/java     java_sdk          %{_jvmdir}/%{sdklnk} \
  --slave %{_jvmjardir}/java  java_sdk_exports  %{_jvmjardir}/%{sdklnk} \
  --slave %{_bindir}/javadoc  javadoc           %{sdkbindir}/javadoc \
  --slave %{_bindir}/javah    javah             %{sdkbindir}/javah \
  --slave %{_bindir}/jar      jar               %{sdkbindir}/jar \
  --slave %{_bindir}/rmic     rmic              %{sdkbindir}/rmic
update-alternatives \
  --install %{_jvmdir}/java-%{origin} \
      java_sdk_%{origin} %{_jvmdir}/%{sdklnk} %{priority} \
  --slave %{_jvmjardir}/java-%{origin} \
      java_sdk_%{origin}_exports %{_jvmjardir}/%{sdklnk}
update-alternatives \
  --install %{_jvmdir}/java-%{javaver} \
      java_sdk_%{javaver} %{_jvmdir}/%{sdklnk} %{priority} \
  --slave %{_jvmjardir}/java-%{javaver} \
      java_sdk_%{javaver}_exports %{_jvmjardir}/%{sdklnk}
# now the gcj related stuff is only done via triggerin
#ln -sf \
#  `gcj%{gccsuffix} -print-file-name=include/jni.h` \
#  %{_jvmdir}/%{cname}-%{version}/include/jni.h
# little work-around if no version-less link to libgcj-x.y.z.jar does not exist 
if [ ! -e %{_javadir}/libgcj-tools.jar ] && ls %{_javadir}/libgcj-tools-*.jar 2>/dev/null >&2
then
  pushd %{_javadir}/ 1>/dev/null
  for file in `ls libgcj-tools-*.jar`
  do
    LIBGCJTOOLS_NAME=$file
  done
  popd 1>/dev/null
else
  LIBGCJTOOLS_NAME=libgcj-tools.jar
fi
pushd %{sdkjardir} 1>/dev/null
  ln -sf %{_javadir}/$LIBGCJTOOLS_NAME tools.jar
popd 1>/dev/null

%postun
if [ $1 -eq 0 ] ; then
   rm -rf %{jvmjardir}/*
   update-alternatives --remove java %{jrebindir}/java
   update-alternatives --remove jre_%{origin}  %{_jvmdir}/%{jrelnk}
   update-alternatives --remove jre_%{javaver} %{_jvmdir}/%{jrelnk}
fi

%postun devel
if [ $1 -eq 0 ] ; then
   update-alternatives --remove javac %{sdkbindir}/javac
   update-alternatives --remove java_sdk_%{origin}  %{_jvmdir}/%{sdklnk}
   update-alternatives --remove java_sdk_%{javaver} %{_jvmdir}/%{sdklnk}
fi
## gcc-java requires libgcj and provides the gcj we run for the version
## string
## now the gcj related stuff is only done via triggerin
##% triggerin -- gcc% {gccsuffix}-java > % {gccver}
#
#% triggerin -- gcc% {gccsuffix}-java >= % {gccver}
#{
#  ln -sf \
#    % {_javadir}/libgcj-`gcj% {gccsuffix} --version | head -n 1 | awk '{ print $3 }'`.jar \
#    % {_jvmdir}/% {cname}-% {version}/jre/lib/rt.jar
#} || :
## now the gcj related stuff is only done via triggerin
## gcc-java requires libgcj-devel which provides jni.h
## this requirement is no PreReq (i.e. libgcj-devel may be installed after gcc-java
## so that jni.h may be not yet installed when this triggerin script runs)
## nevertheless the symbolic link can be created (even if it is only a broken link
## until libgcj-devel becomes actually installed)
##% triggerin devel -- gcc% {gccsuffix}-java > % {gccver}
#
#% triggerin devel -- gcc% {gccsuffix}-java >= % {gccver}
#{
#  ln -sf \
#    `gcj% {gccsuffix} -print-file-name=include/jni.h` \
#    % {_jvmdir}/% {cname}-% {version}/include/jni.h
#} || :

%files -f %{name}-%{version}.files
%defattr(-,root,root,-)
%doc
%dir %{_jvmdir}
%dir %{_jvmdir}/%{sdkdir}
#%{jvmjardir}/*.jar
%{_bindir}/*
%{_jvmdir}/%{jrelnk}
%{_jvmjardir}/
%exclude %{_jvmjardir}/%{sdklnk}
%{jvmjardir}
%{_jvmdir}/%{jredir}/lib/security

%files devel -f %{name}-%{version}-sdk-bin.files
%defattr(-,root,root)
%doc
%{_jvmdir}/%{sdkdir}/include
%{_jvmdir}/%{sdklnk}
%{_jvmjardir}/%{sdklnk}
%{python_sitelib}/*
%{jvmdir}
%exclude %{jvmdir}/jre

%changelog