File java-1_6_0-openjdk.spec of Package java-1_6_0-openjdk.import5329

# spec file for package java-1_6_0-openjdk
# 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

%define gcjbootstrap 0

%define jit_arches %{ix86} x86_64
# Turn on/off some features depending on openSUSE version
%define with_systemtap 0

%ifarch %{jit_arches}
%if 0%{?suse_version} >= 1130
%define with_systemtap 1

# XXX: systemtap does not work with gcj
%if %{gcjbootstrap}
%define with_systemtap 0

# If runtests is 0 test suites will not be run.
%define runtests 0

%define icedteaver 1.10.4
%define icedteasnapshot %{nil}
%define openjdkver b22
%define openjdkdate 28_feb_2011

%define genurl

%define accessmajorver 1.23
%define accessminorver 0
%define accessver %{accessmajorver}.%{accessminorver}
%define accessurl

%define hotspoturl
%define jaxpurl
%define jafurl
%define jaxwsurl

%define openjdkurlbase
%define openjdkurl %{openjdkurlbase}%{openjdkver}/
%define fedorazip  openjdk-6-src-%{openjdkver}-%{openjdkdate}-fedora.tar.bz2

%define mauvedate 2008-10-22

%define multilib_arches ppc64 sparc64 x86_64

%ifarch %{ix86}
%define archbuild i586
%define archinstall i386
%ifarch x86_64
%define archbuild amd64
%define archinstall amd64
%ifnarch %{jit_arches}
%define archbuild %{_arch}
%define archinstall %{_arch}
# Reduce build time from 27 hours to 12 hours by only running test
# suites on JIT architectures.
%ifnarch %{jit_arches}
%define runtests 0

%define buildoutputdir
# Convert an absolute path to a relative path.  Each symbolic link is
# specified relative to the directory in which it is installed so that
# it will resolve properly within chrooted installations.
%define script 'use File::Spec; print File::Spec->abs2rel($ARGV[0], $ARGV[1])'
%define abs2rel %{__perl} -e %{script}
%ifarch %{multilib_arches}
%define archsuffix      .%{_arch}
%define syslibdir       %{_prefix}/lib64
#% define _libdir         %{_prefix}/lib
%define archsuffix      %{nil}
%define syslibdir       %{_libdir}
# Standard JPackage naming and versioning defines.
%define origin          openjdk
%define priority        17105
%define javaver         1.6.0
%define buildver        0
# Hard-code libdir on 64-bit architectures to make the 64-bit JDK
# simply be another alternative.
%define sdkname         java-%{javaver}-%{origin}
%define archname        %{sdkname}
# Standard JPackage directories and symbolic links.
%define jrelnk          jre-%{javaver}-%{origin}
%define sdklnk          %{sdkname}
%define sdkdir          %{sdklnk}-%{javaver}
%define jredir          %{sdkdir}/jre
%define sdkbindir       %{_jvmdir}/%{sdklnk}/bin
%define jrebindir       %{_jvmdir}/%{jrelnk}/bin
%define jvmjardir       %{_jvmjardir}/%{sdkdir}
%define jvmjarlink      %{_jvmjardir}/%{sdklnk}
# For openSUSE >= 11.2 demo, sample and is noarch ==> share
%define sdkshare        %{_datadir}/%{sdkname}

%ifarch %{jit_arches}
# Where to install systemtap tapset (links)
# We would like these to be in a package specific subdir,
# but currently systemtap doesn't support that, so we have to
# use the root tapset dir for now. To distinquish between 64
# and 32 bit architectures we place the tapsets under the arch
# specific dir (note that systemtap will only pickup the tapset
# for the primary arch for now). Systemtap uses the machine name
# aka build_cpu as architecture specific directory name.
#%define tapsetdir	/usr/share/systemtap/tapset/%{sdkdir}
%define tapsetdir	%{_datadir}/systemtap/tapset/%{_build_cpu}

# cacert file
%define cacerts  %{_jvmdir}/%{jredir}/lib/security/cacerts

Name:           java-1_6_0-openjdk
Release:        0.<RELEASE2>
Summary:        Java runtime environment based on OpenJDK 6 and IcedTea 6
Group:          Development/Languages/Java
License:        GPLv2 ; - with the OpenJDK Assembly Exception and the GNU Classpath Exception
Source0:        %{url}icedtea6-%{icedteaver}%{icedteasnapshot}.tar.gz
# # download the openjdk from
# sh openjdk-6-src-%{openjdkver}-%{openjdkdate}.tar.gz
Source1:        %{fedorazip}
Source2:        %{accessurl}%{accessmajorver}/java-access-bridge-%{accessver}.tar.bz2
# wget -o
Source3:        %{genurl}
# wget mauve-%(date '+%Y-%m-%d').tar.bz2
Source5:        mauve-%{mauvedate}.tar.bz2
# from Fedora rpm
Source6:        mauve_tests
Source7:        %{hotspoturl}f0f676c5a2c6.tar.gz
Source8:        %{jaxpurl}
Source9:        %{jafurl}
Source10:       %{jaxwsurl}
Source1000:     java-1_6_0-openjdk-rpmlintrc
# those properties are for opeSUSE only
# FIXME: This patch needs to be fixed. optflags argument
# -mtune=generic is being ignored because it breaks several graphical
# applications.
Patch0:         java-1.6.0-openjdk-optflags.patch
Patch1:         java-1.6.0-openjdk-java-access-bridge-tck.patch
Patch2:         java-1.6.0-openjdk-java-access-bridge-idlj.patch
Patch3:         java-1.6.0-openjdk-java-access-bridge-security.patch
Patch4:         java-1.6.0-openjdk-accessible-toolkit.patch
# SUSE patches
Patch104:       openjdk-6-src-b09-gcc4-warningfixes.patch
Patch107:       openjdk-6-src-b14-no-return-in-nonvoid-function.patch
Patch108:       openjdk-6-src-b14-undefined-operation.patch
Patch109:       openjdk-6-src-b14-no-return-in-nonvoid-function-ix86.patch
# sent those patches to,
# he will (hopefully) be able to push them to upstream
# PATCH-FIX-OPENSUSE bnc#594415#c8
Patch110:       openjdk-6-src-b17-no-return-in-nonvoid-function-ppc.patch
# PATCH-FIX-OPENSUSE: avoid multiline comments - sent to upstream
Patch117:       openjdk-6-src-b20-no-multiline-comments.patch
# PATCH-FIX-OPENSUSE: suggest parentheses - sent to upstream
Patch119:       openjdk-6-src-b20-suggest-parentheses.patch
# PATCH-FIX-OPENSUSE: statement has no effect - sent to upstream
Patch120:       openjdk-6-src-b17-no-efect.patch
# PATCH-FIX-OPENSUSE: order of declaration and initialization don't match - sent to upstream
Patch121:       openjdk-6-src-b20-initialized-after.patch
# PATCH-FIX-OPENSUSE: unused variable warnings - sent to upstream
Patch122:       openjdk-6-src-b20-unused-variable.patch
# PATCH-FIX-OPENSUSE: remove -Werror from the all possible makefiles, it produces
# more errors especially in autogenerated files - hard to fix without a chance to quick upstream
Patch123:       openjdk-6-src-b20-no-werror.patch
# PATCH-FIX-OPENSUSE: gcc 4.5 warnings
Patch127:       openjdk-6-src-b20-defined-but-not-used.patch
# PATCH-FIX-OPENSUSE: gcc 4.5 warnings
Patch128:       openjdk-6-src-b20-may-be-used-uninitialized.patch
Patch129:       openjdk-6-src-b20-array-subscript-has-type-char.patch
# PATCH-FIX-OPENSUSE: the no-return-in-non-void again - now in openjdk-ecj
Patch132:       openjdk-ecj-6-src-b20-no-return-in-nonvoid-function.patch
# PATCH-FIX-OPENSUSE: the string and literal compare fix
Patch133:       openjdk-6-src-b20-stringcompare.patch
# PATCH-FIX-OPENSUSE: gcj on 11.2/x86_64 returns the NPE on this file - assume because of comments
Patch134:       openjdk-6-src-b20-gcj-workaround.patch
# PATCH-FIX-OPENSUSE: forward support for bouncycastle provider - requested by rgarrigue,
# will be sent to fedora as well. Applied only on systems with enabled nss (11.2+)
Patch135:       icedtea6-1.10.2-bouncycastle-provider-support.patch
# fixes build on 11.1/i586 and sle11/i586, which fails because code behind GNU_stack.note in
Patch136:       icedtea6-replace-gcc-stack-marking.patch
Patch1000:      java-1_6_0-openjdk-suse-desktop-files.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  alsa-lib-devel
BuildRequires:  quilt vim
BuildRequires:  cups-devel
BuildRequires:  desktop-file-utils
BuildRequires:  giflib-devel
BuildRequires:  xorg-x11
BuildRequires:  xorg-x11-proto-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:  rhino
BuildRequires:  wget
BuildRequires:  xalan-j2
# make sure to use bootstrap requires of ant
BuildRequires:  xerces-j2-bootstrap
#!BuildIgnore: xerces-j2 xml-commons-resolver xml-commons-apis xml-commons
BuildRequires:  ant
BuildRequires:  ant-nodeps
BuildRequires:  zip
%if %{gcjbootstrap}
BuildRequires:  ecj-bootstrap java-1_5_0-gcj-compat-devel
BuildRequires:  java-1_6_0-openjdk java-1_6_0-openjdk-devel

BuildRequires:  mozilla-nss-devel

# Mauve build requirements.
%if %{runtests}
BuildRequires:  xorg-x11-server-extra
BuildRequires:  xorg-x11-fonts
BuildRequires:  freetype2-devel >= 2.3.0
BuildRequires:  fontconfig
BuildRequires:  ecj

# Java Access Bridge for GNOME build requirements.
BuildRequires:  at-spi-devel
BuildRequires:  gawk
BuildRequires:  libbonobo-devel
BuildRequires:  pkgconfig >= 0.9.0
BuildRequires:  xorg-x11-util-devel

# pulse audio requirements
BuildRequires:  libpulse-devel >= 0.9.11
BuildRequires:  pulseaudio >= 0.9.11

#system tap
%if %{with_systemtap}
BuildRequires:  systemtap-sdt-devel >= 1.0

%if 0%{?suse_version} > 1110
#fixing RedHat bug #648499
BuildRequires:  lsb-release
#the /etc/SuSE-release is needed as well
BuildRequires:  distribution-release

# Zero-assembler build requirement.
%ifnarch %{jit_arches}
BuildRequires:  libffi-devel

%if %defined suse_version
BuildRequires:  fdupes
BuildRequires:  unzip
BuildRequires:  procps
BuildRequires:  gcc-c++
BuildRequires:  perl
BuildRequires:  update-desktop-files

# runtime ceritifacates generation available in 11.3+ - bnc#596177
%if %{suse_version} >= 1130
BuildRequires:  java-ca-certificates
Requires(post): java-ca-certificates
Requires(post): mozilla-nss
# the certificates will converted in a prep to standard keystore file - cacerts
# The openssl requirment seems to be necessary for build only.
Requires:       openssl
BuildRequires:  openssl-certs

Requires:       rhino
# Require jpackage-utils for ant.
Requires:       jpackage-utils >= 1.7.3
# Require zoneinfo data provided by tzdata-java subpackage.
Requires:       tzdata-java
%if ! %defined suse_version
# Post requires alternatives to install tool alternatives.
Requires(post):   update-alternatives
# Postun requires alternatives to uninstall tool alternatives.
Requires(postun): update-alternatives
# Post requires update-desktop-database to update desktop database
# for jnlp files.
Requires(post):   desktop-file-utils
# Postun requires update-desktop-database to update desktop database
# for jnlp files.
Requires(postun): desktop-file-utils
Requires(pre):  update-alternatives
%if %{with_systemtap}
Recommends:     systemtap >= 1.0
# Standard JPackage base provides.
Provides:       java-1.6.0-openjdk = %{version}-%{release}
Provides:       jre-%{javaver}-%{origin} = %{version}-%{release}
Provides:       jre-%{origin} = %{version}-%{release}
Provides:       jre-%{javaver} = %{version}-%{release}
Provides:       java-%{javaver} = %{version}-%{release}
Provides:       jre = %{javaver}
Provides:       java-%{origin} = %{version}-%{release}
Provides:       java = %{javaver}
# Standard JPackage extensions provides.
Provides:       jndi = %{version}
Provides:       jndi-ldap = %{version}
Provides:       jndi-cos = %{version}
Provides:       jndi-rmi = %{version}
Provides:       jndi-dns = %{version}
Provides:       jaas = %{version}
Provides:       jsse = %{version}
Provides:       jce = %{version}
Provides:       jdbc-stdext = 3.0
Provides:       jdbc-stdext = %{version}
Provides:       java-sasl = %{version}
# Required at least by fop
Provides:       jre1.3.x
Provides:       jre1.4.x
Provides:       jre1.5.x
Provides:       jre1.6.x
# bnc#542545
# 32-bit versus 64-bit specific provides:
%ifarch %ix86 ppc s390
%define bits 32
%ifarch x86_64 ia64 s390x
%define bits 64
Provides:       jre-1.6.0-%{origin}-%{bits} = %{version}-%{release}
Provides:       jre-%{origin}-%{bits} = %{version}-%{release}
Provides:       jre-1.6.0-%{bits}, java-1.6.0-%{bits}
Provides:       jre-%{bits} = %{javaver}
Provides:       java-%{origin}-%{bits} = %{version}-%{release}
Provides:       java-%{bits} = %{javaver}

This Java 6 compatible Java Runtime Environment is based on OpenJDK 6
and IcedTea 6.

It contains a Java virtual machine, runtime class libraries, and an
Java application launcher that are necessary to run programs written in
the Java progamming language. It is not a development environment and
does not contain development tools such as compilers and debuggers. For
development tools, see the java-1_6_0-openjdk-devel package.

The Java 6 Runtime Environment is intended for software developers and
vendors who wish to redistribute their applications.

%package devel
License:        GPLv2 ; - with the OpenJDK Assembly Exception and the GNU Classpath Exception
Summary:        Java SDK based on OpenJDK 6 and IcedTea 6
Group:          Development/Languages/Java
Requires:       %{name} = %{version}-%{release}
Requires(pre):  %{_sbindir}/update-alternatives
Provides:       java-1.6.0-openjdk-devel = %{version}-%{release}
Provides:       java-sdk-%{javaver}-%{origin} = %{version}
Provides:       java-sdk-%{javaver} = %{version}
Provides:       java-sdk-%{origin} = %{version}
Provides:       java-sdk = %{javaver}
Provides:       java-%{javaver}-devel = %{version}
Provides:       java-devel-%{origin} = %{version}
Provides:       java-devel = %{javaver}

%description devel
This Java 6 compatible Java SDK is based on OpenJDK 6 and IcedTea 6.

The Java 6 SDK is a development environment for building applications,
applets, and components using the Java programming language.

The Java 6 SDK includes tools useful for developing and testing
programs written in the Java programming language and running on the
Java platform. These tools are designed to be used from the command
line. Except for the appletviewer, these tools do not provide a
graphical user interface.

%package demo
License:        GPLv2 ; - with the OpenJDK Assembly Exception and the GNU Classpath Exception
# As 1.6.0 is stable, obsolete java-1_7_0-icedtea in openSUSE 11.0 and earlier:
Summary:        Sources for building demo applications with OpenJDK 6
Group:          Development/Languages/Java
Provides:       java-1.6.0-openjdk-demo = %{version}-%{release}
Requires:       %{name}-devel = %{version}-%{release}
%if 0%{?suse_version} >= 1120
BuildArch:      noarch

%description demo
This package provides sources of demonstration applications for OpenJDK
6 and is intented for aspiring Java developers which want to learn
about the features of OpenJDK 6.

%package src
License:        GPLv2 ; - with the OpenJDK Assembly Exception and the GNU Classpath Exception
# As 1.6.0 is stable, obsolete java-1_7_0-icedtea in openSUSE 11.0 and earlier:
Summary:        OpenJDK 6 Java class sources for developers
Group:          Development/Languages/Java
Requires:       %{name}-devel = %{version}-%{release}
%if 0%{?suse_version} >= 1120
BuildArch:      noarch

%description src
This package provides Java Runtime librarcy class sources of OpenJDK 6
and is intented for developers which may need them for investigating

%package javadoc
License:        GPLv2 ; - with the OpenJDK Assembly Exception and the GNU Classpath Exception
# As 1.6.0 is stable, obsolete java-1_7_0-icedtea in openSUSE 11.0 and earlier:
Summary:        Documentation of the Java API of OpenJDK 6
Group:          Development/Languages/Java
Requires(pre):  %{_sbindir}/update-alternatives
Provides:       java-1.6.0-openjdk-javadoc = %{version}-%{release}
Provides:       java-javadoc = %{version}-%{release}
Provides:       java-%{javaver}-javadoc = %{version}-%{release}
%if 0%{?suse_version} >= 1120
BuildArch:      noarch

%description javadoc
This package provides documentation of the API provided by OpenJDK 6
and is intented for Java developers which need to which API features
are provided by OpenJDK 6.

%setup -q -n icedtea6-%{icedteaver}
%setup -q -n icedtea6-%{icedteaver} -T -D -a 5
%setup -q -n icedtea6-%{icedteaver} -T -D -a 2
%patch0 -b .optflags
%patch136 -p1 -b .gnu-stack
%patch1000 -p1

cp %{SOURCE6} .

export LANG=en_US.UTF-8
%{configure} \
%ifarch %{jit_arches}
%if 0%{?suse_version} >= 1120
    --enable-nio2 \
%if %{with_systemtap}
    --enable-systemtap \
    --with-abs-install-dir=%{_jvmdir}/%{sdkdir} \
%if 0%{?suse_version} >= 1120
    --enable-pulse-java \
    --enable-nss \
    --with-hotspot-build=hs20 \
    --with-hotspot-src-zip=%{SOURCE7} \
    --with-jaf-drop-zip=%{SOURCE9} \
    --with-jaxp-drop-zip=%{SOURCE8} \
    --with-jaxws-drop-zip=%{SOURCE10} \
%if %{gcjbootstrap}
    --with-gcj-home=%{_jvmdir}/java-gcj \
    --with-jdk-home=%{_jvmdir}/%{sdkdir} \
    --disable-bootstrap \
    --with-xerces2-jar=%{_javadir}/xerces-j2-bootstrap.jar \
    --with-openjdk-src-zip=%{SOURCE1} \

sed -i 's/MEMORY_LIMIT = -J-Xmx512m/MEMORY_LIMIT = -J-Xmx768m/' Makefile
%if %{gcjbootstrap}
make stamps/patch-ecj.stamp
make patch
# Those patches are from Fedora package
patch -l -p0 -i %{PATCH3}
patch -l -p0 -i %{PATCH4}

# XXX: The quilt setup series fails with existing patches dir ... do not want to
# export an another patches dir, as this will not be in chroot, which is the
# reason I use quilt - to be able edit patches directly in chroot
function qpatch() {
    quilt import ${1} ${2}
    quilt push

qpatch -p0 %{PATCH104}
qpatch -p0 %{PATCH107}
qpatch -p0 %{PATCH108}
%ifarch %ix86
qpatch -p0 %{PATCH109}
%ifarch ppc ppc64
qpatch -p0 %{PATCH110}

for PATCH in \
    %{PATCH117} \
    %{PATCH119} \
    %{PATCH120} \
    %{PATCH121} \
    %{PATCH122} \
    %{PATCH123} \
    %{PATCH127} \
    %{PATCH128} \
%if %{gcjbootstrap}
    %{PATCH132} \
    %{PATCH134} \
    %{PATCH133} \
%if 0%{?suse_version} >= 1120
    %{PATCH135} \
        qpatch -p1 ${PATCH}

export JAVA_HOME=$(pwd)/%{buildoutputdir}/j2sdk-image

if [ -f %{buildoutputdir}/j2sdk-image/jre/lib/security/cacerts ]; then
        rm %{buildoutputdir}/j2sdk-image/jre/lib/security/cacerts
%if %{suse_version} < 1130
# ========== a default keystore ==========
# a cacerts generation - 11.3+ use java-ca-certificates package
for PEM in /etc/ssl/certs/*.pem; do
    ALIAS=$(basename ${PEM} .pem)
    awk '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/{ print $0; }' ${PEM} > ${ALIAS}.pem

    yes | $JAVA_HOME/jre/bin/keytool -import -alias ${ALIAS} -keystore %{buildoutputdir}/j2sdk-image/jre/lib/security/cacerts -storepass 'changeit' -file ${ALIAS}.pem || :
    rm ${ALIAS}.pem

# ========== java access bridge ==========
pushd java-access-bridge-%{accessver}
  patch -l -p1 < %{PATCH1}
  patch -l -p1 < %{PATCH2}
  export PATH=$JAVA_HOME/bin:$OLD_PATH
  export PATH=$OLD_PATH
  cp -a bridge/ $JAVA_HOME/jre/lib
  cp -a gnome-java-bridge.jar $JAVA_HOME/jre/lib/ext

%if %{runtests}
# Run jtreg test suite.
  echo ====================JTREG TESTING========================
  export DISPLAY=:20
  Xvfb :20 -screen 0 1x1x24 -ac&
  echo $! >
  make jtregcheck -k
  kill -9 `cat`
  unset DISPLAY
  rm -f
  echo ====================JTREG TESTING END====================
} || :

# Run Mauve test suite.
  pushd mauve-%{mauvedate}
    echo ====================MAUVE TESTING========================
    export DISPLAY=:20
    Xvfb :20 -screen 0 1x1x24 -ac&
    echo $! >
    $JAVA_HOME/bin/java Harness -vm $JAVA_HOME/bin/java \
      -file %{SOURCE6} -timeout 30000 2>&1 | tee mauve_output
    kill -9 `cat`
    unset DISPLAY
    rm -f
    echo ====================MAUVE TESTING END====================
} || :

export LANG=en_US.UTF-8
export STRIP_KEEP_SYMTAB=libjvm*
# skip /usr/lib/rpm/brp-check-bytecode-version:
pushd %{buildoutputdir}/j2sdk-image
  # Install main files.
  install -d -m 755 $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
  cp -a bin include lib $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
  # noarch sub packages in openSUSE >= 11.2
  %if 0%{?suse_version} >= 1120
  install -d -m 755 $RPM_BUILD_ROOT%{sdkshare}
  pushd $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
  mv $RPM_BUILD_ROOT%{sdkshare}
  ln -sf %{sdkshare}/
  install -d -m 755 $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}
  cp -a jre/bin jre/lib $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}
  # bnc#438674
  # Install a fontconfig file which don't reffer to agfa-fonts on openSUSE
  cp %{S:1001} $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}/lib/

%if %{with_systemtap}
  # Install systemtap support files.
  cp -a tapset $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
  install -d -m 755 $RPM_BUILD_ROOT%{tapsetdir}
  pushd $RPM_BUILD_ROOT%{tapsetdir}
    RELATIVE=$(%{abs2rel} %{_jvmdir}/%{sdkdir}/tapset %{tapsetdir})
    ln -sf $RELATIVE/*.stp .
  # Install extension symlinks.
  install -d -m 755 $RPM_BUILD_ROOT%{jvmjardir}
  pushd $RPM_BUILD_ROOT%{jvmjardir}
    RELATIVE=$(%{abs2rel} %{_jvmdir}/%{jredir}/lib %{jvmjardir})
    ln -sf $RELATIVE/jsse.jar jsse-%{version}.jar
    ln -sf $RELATIVE/jce.jar jce-%{version}.jar
    ln -sf $RELATIVE/rt.jar jndi-%{version}.jar
    ln -sf $RELATIVE/rt.jar jndi-ldap-%{version}.jar
    ln -sf $RELATIVE/rt.jar jndi-cos-%{version}.jar
    ln -sf $RELATIVE/rt.jar jndi-rmi-%{version}.jar
    ln -sf $RELATIVE/rt.jar jaas-%{version}.jar
    ln -sf $RELATIVE/rt.jar jdbc-stdext-%{version}.jar
    ln -sf jdbc-stdext-%{version}.jar jdbc-stdext-3.0.jar
    ln -sf $RELATIVE/rt.jar sasl-%{version}.jar
    for jar in *-%{version}.jar
      if [ x%{version} != x%{javaver} ]
        ln -sf $jar $(echo $jar | sed "s|-%{version}.jar|-%{javaver}.jar|g")
      ln -sf $jar $(echo $jar | sed "s|-%{version}.jar|.jar|g")

  # Install JCE policy symlinks.
  install -d -m 755 $RPM_BUILD_ROOT%{_jvmprivdir}/%{archname}/jce/vanilla

  # Install versionless symlinks.
  pushd $RPM_BUILD_ROOT%{_jvmdir}
    ln -sf %{jredir} %{jrelnk}
    ln -sf %{sdkdir} %{sdklnk}

  pushd $RPM_BUILD_ROOT%{_jvmjardir}
    ln -sf %{sdkdir} %{jrelnk}
    ln -sf %{sdkdir} %{sdklnk}

  # Install man pages.
  install -d -m 755 $RPM_BUILD_ROOT%{_mandir}/man1
  for manpage in man/man1/*
    # Convert man pages to UTF8 encoding.
    iconv -f ISO_8859-1 -t UTF8 $manpage -o $manpage.tmp
    mv -f $manpage.tmp $manpage
    install -m 644 -p $manpage $RPM_BUILD_ROOT%{_mandir}/man1/$(basename \
      $manpage .1)-%{sdkname}.1
  # Install demos and samples.
  cp -a demo $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
  # enable short-circuit
  mkdir -p sample/rmi
  [ -f bin/java-rmi.cgi ] && mv bin/java-rmi.cgi sample/rmi
  cp -a sample $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}

  # noarch sub packages in openSUSE >= 11.2
  %if 0%{?suse_version} >= 1120
  pushd $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
  # samples can go all
  mv sample $RPM_BUILD_ROOT%{sdkshare}
  ln -sf %{sdkshare}/sample

  # leave the demo/jvmti in the -devel package in %{_libdir} - contains .so files
  install -d -m 0755 $RPM_BUILD_ROOT%{sdkshare}/demo
  DEMODIRS=$(ls -1d demo/* | grep -v jvmti)
  mv $DEMODIRS $RPM_BUILD_ROOT%{sdkshare}/demo
  pushd demo
  for dir in $DEMODIRS; do
    ln -sf %{sdkshare}/$dir
# Install Javadoc documentation.
install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}
cp -a %{buildoutputdir}/docs $RPM_BUILD_ROOT%{_javadocdir}/%{sdkname}
# Install icons and menu entries.
for s in 16 24 32 48 ; do
  install -D -p -m 644 \
    openjdk/jdk/src/solaris/classes/sun/awt/X11/java-icon${s}.png \

# Install desktop files.
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/{applications,pixmaps}
%if ! %defined suse_version
for e in jconsole policytool ; do
    desktop-file-install --vendor=fedora --mode=644 \
        --dir=$RPM_BUILD_ROOT%{_datadir}/applications $e.desktop
for d in jconsole policytool; do
   install -m 0644 $d.desktop $RPM_BUILD_ROOT/%{_datadir}/applications/
    %suse_update_desktop_file $d
# Find JRE directories.
find $RPM_BUILD_ROOT%{_jvmdir}/%{jredir} -type d \
  | grep -v jre/lib/security \
  | grep -v jconsole.desktop \
  | sed 's|'$RPM_BUILD_ROOT'|%dir |' \
  > %{name}.files
# Find JRE files.
find $RPM_BUILD_ROOT%{_jvmdir}/%{jredir} -type f -o -type l \
  | grep -v jre/lib/security \
  | sed 's|'$RPM_BUILD_ROOT'||' \
  >> %{name}.files
# Find demo directories.
find $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}/demo \
  $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}/sample -type d \
  | sed 's|'$RPM_BUILD_ROOT'|%dir |' \
  > %{name}-demo.files
# Find non-documentation demo files.
find $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}/demo \
  $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}/sample \
  -type f -o -type l | sort \
  | grep -v README \
  | sed 's|'$RPM_BUILD_ROOT'||' \
  >> %{name}-demo.files
# Find documentation demo files.
find $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}/demo \
  $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}/sample \
  -type f -o -type l | sort \
  | grep README \
  | sed 's|'$RPM_BUILD_ROOT'||' \
  | sed 's|^|%doc |' \
  >> %{name}-demo.files
  # noarch sub packages in openSUSE >= 11.2
  %if 0%{?suse_version} >= 1120
  sed -i -e 's#%{_jvmdir}/%{sdkdir}#%{sdkshare}#' %{name}-demo.files
  # also move the jvmti content to the -devel
  sed -i '/jvmti/d' %{name}-demo.files

# fdupes links the files from JDK to JRE, so it breaks a JRE
# use it carefully :))
%fdupes -s $RPM_BUILD_ROOT/%{_jvmdir}/%{jredir}/

# noarch sub packages in openSUSE >= 11.2
%if 0%{?suse_version} >= 1120
%fdupes -s $RPM_BUILD_ROOT/%{sdkshare}

%fdupes -s $RPM_BUILD_ROOT/%{_jvmdir}/%{sdkdir}/demo
%fdupes -s $RPM_BUILD_ROOT%{_javadocdir}/%{sdkname}

%if ! %{suse_version} >= 1130
# touch %{buildroot}/%{_jvmdir}/%{jredir}/lib/security/cacerts
# %else
# bnc496378 - check the size of installed cacerts
# 32 bytes means a default empty one
if [[ $(stat -c "%s" $RPM_BUILD_ROOT/%{cacerts}) == "32" ]]; then
    echo "ERROR: Default keystore seems empty"
    exit 1



#fix of the previous workaround ;-) bnc#669716
#this will collect all empty lines in Sun Java alternatives
if [ -f %{_libexecdir}/%{name}/javafix ]; then
    /bin/sh %{_libexecdir}/%{name}/javafix

update-alternatives \
  --install %{_bindir}/java java %{jrebindir}/java %{priority} \
  --slave %{_jvmdir}/jre jre %{_jvmdir}/%{jrelnk} \
  --slave %{_jvmjardir}/jre jre_exports %{_jvmjardir}/%{jrelnk} \
  --slave %{_bindir}/keytool keytool %{jrebindir}/keytool \
  --slave %{_bindir}/orbd orbd %{jrebindir}/orbd \
  --slave %{_bindir}/policytool policytool %{jrebindir}/policytool \
  --slave %{_bindir}/rmid rmid %{jrebindir}/rmid \
  --slave %{_bindir}/rmiregistry rmiregistry %{jrebindir}/rmiregistry \
  --slave %{_bindir}/servertool servertool %{jrebindir}/servertool \
  --slave %{_bindir}/tnameserv tnameserv %{jrebindir}/tnameserv \
  --slave %{_mandir}/man1/java.1$ext java.1$ext \
  %{_mandir}/man1/java-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/keytool.1$ext keytool.1$ext \
  %{_mandir}/man1/keytool-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/orbd.1$ext orbd.1$ext \
  %{_mandir}/man1/orbd-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/policytool.1$ext policytool.1$ext \
  %{_mandir}/man1/policytool-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/rmid.1$ext rmid.1$ext \
  %{_mandir}/man1/rmid-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/rmiregistry.1$ext rmiregistry.1$ext \
  %{_mandir}/man1/rmiregistry-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/servertool.1$ext servertool.1$ext \
  %{_mandir}/man1/servertool-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/tnameserv.1$ext tnameserv.1$ext \
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}

if [ $1 -eq 0 ]
  if test -f /proc/sys/fs/binfmt_misc/jarexec
    echo '-1' > /proc/sys/fs/binfmt_misc/jarexec
  update-alternatives --remove java %{jrebindir}/java
  update-alternatives --remove jre_%{origin} %{_jvmdir}/%{jrelnk}
  update-alternatives --remove jre_%{javaver} %{_jvmdir}/%{jrelnk}

%if %{suse_version} >= 1130

# if there's no java, certificates are not generated
if [ ! -f /var/lib/ca-certificates/java-cacerts ]; then

# remove the default empty cacert file, if it's installed
if [ 0`stat -c "%s" %{cacerts} 2>/dev/null` = "032" ] ; then
    rm -f %{cacerts}

if [ ! -e %{cacerts} ]; then
    ln -s /var/lib/ca-certificates/java-cacerts %{cacerts}

%post devel
update-alternatives \
  --install %{_bindir}/javac javac %{sdkbindir}/javac %{priority} \
  --slave %{_jvmdir}/java java_sdk %{_jvmdir}/%{sdklnk} \
  --slave %{_jvmjardir}/java java_sdk_exports %{jvmjarlink} \
  --slave %{_bindir}/appletviewer appletviewer %{sdkbindir}/appletviewer \
  --slave %{_bindir}/apt apt %{sdkbindir}/apt \
  --slave %{_bindir}/extcheck extcheck %{sdkbindir}/extcheck \
  --slave %{_bindir}/jar jar %{sdkbindir}/jar \
  --slave %{_bindir}/jarsigner jarsigner %{sdkbindir}/jarsigner \
  --slave %{_bindir}/javadoc javadoc %{sdkbindir}/javadoc \
  --slave %{_bindir}/javah javah %{sdkbindir}/javah \
  --slave %{_bindir}/javap javap %{sdkbindir}/javap \
  --slave %{_bindir}/jconsole jconsole %{sdkbindir}/jconsole \
  --slave %{_bindir}/pack200                  pack200                     %{sdkbindir}/pack200 \
  --slave %{_bindir}/unpack200                unpack200                   %{sdkbindir}/unpack200 \
  --slave %{_bindir}/jdb jdb %{sdkbindir}/jdb \
  --slave %{_bindir}/jhat jhat %{sdkbindir}/jhat \
  --slave %{_bindir}/jinfo jinfo %{sdkbindir}/jinfo \
  --slave %{_bindir}/jmap jmap %{sdkbindir}/jmap \
  --slave %{_bindir}/jps jps %{sdkbindir}/jps \
  --slave %{_bindir}/jrunscript jrunscript %{sdkbindir}/jrunscript \
  --slave %{_bindir}/jsadebugd jsadebugd %{sdkbindir}/jsadebugd \
  --slave %{_bindir}/jstack jstack %{sdkbindir}/jstack \
  --slave %{_bindir}/jstat jstat %{sdkbindir}/jstat \
  --slave %{_bindir}/jstatd jstatd %{sdkbindir}/jstatd \
  --slave %{_bindir}/native2ascii native2ascii %{sdkbindir}/native2ascii \
  --slave %{_bindir}/rmic rmic %{sdkbindir}/rmic \
  --slave %{_bindir}/schemagen schemagen %{sdkbindir}/schemagen \
  --slave %{_bindir}/serialver serialver %{sdkbindir}/serialver \
  --slave %{_bindir}/wsgen wsgen %{sdkbindir}/wsgen \
  --slave %{_bindir}/wsimport wsimport %{sdkbindir}/wsimport \
  --slave %{_bindir}/xjc xjc %{sdkbindir}/xjc \
  --slave %{_mandir}/man1/appletviewer.1$ext appletviewer.1$ext \
  %{_mandir}/man1/appletviewer-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/apt.1$ext apt.1$ext \
  %{_mandir}/man1/apt-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/extcheck.1$ext extcheck.1$ext \
  %{_mandir}/man1/extcheck-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jar.1$ext jar.1$ext \
  %{_mandir}/man1/jar-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jarsigner.1$ext jarsigner.1$ext \
  %{_mandir}/man1/jarsigner-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/javac.1$ext javac.1$ext \
  %{_mandir}/man1/javac-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/javadoc.1$ext javadoc.1$ext \
  %{_mandir}/man1/javadoc-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/javah.1$ext javah.1$ext \
  %{_mandir}/man1/javah-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/javap.1$ext javap.1$ext \
  %{_mandir}/man1/javap-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jconsole.1$ext jconsole.1$ext \
  %{_mandir}/man1/jconsole-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jdb.1$ext jdb.1$ext \
  %{_mandir}/man1/jdb-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/pack200.1$ext pack200.1$ext \
  %{_mandir}/man1/pack200-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/unpack200.1$ext unpack200.1$ext \
  %{_mandir}/man1/unpack200-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jhat.1$ext jhat.1$ext \
  %{_mandir}/man1/jhat-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jinfo.1$ext jinfo.1$ext \
  %{_mandir}/man1/jinfo-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jmap.1$ext jmap.1$ext \
  %{_mandir}/man1/jmap-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jps.1$ext jps.1$ext \
  %{_mandir}/man1/jps-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jrunscript.1$ext jrunscript.1$ext \
  %{_mandir}/man1/jrunscript-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jsadebugd.1$ext jsadebugd.1$ext \
  %{_mandir}/man1/jsadebugd-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jstack.1$ext jstack.1$ext \
  %{_mandir}/man1/jstack-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jstat.1$ext jstat.1$ext \
  %{_mandir}/man1/jstat-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/jstatd.1$ext jstatd.1$ext \
  %{_mandir}/man1/jstatd-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/native2ascii.1$ext native2ascii.1$ext \
  %{_mandir}/man1/native2ascii-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/rmic.1$ext rmic.1$ext \
  %{_mandir}/man1/rmic-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/schemagen.1$ext schemagen.1$ext \
  %{_mandir}/man1/schemagen-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/serialver.1$ext serialver.1$ext \
  %{_mandir}/man1/serialver-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/wsgen.1$ext wsgen.1$ext \
  %{_mandir}/man1/wsgen-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/wsimport.1$ext wsimport.1$ext \
  %{_mandir}/man1/wsimport-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/xjc.1$ext xjc.1$ext \
update-alternatives \
  --install %{_jvmdir}/java-%{origin} \
  java_sdk_%{origin} %{_jvmdir}/%{sdklnk} %{priority} \
  --slave %{_jvmjardir}/java-%{origin} \
  java_sdk_%{origin}_exports %{jvmjarlink}
update-alternatives \
  --install %{_jvmdir}/java-%{javaver} \
  java_sdk_%{javaver} %{_jvmdir}/%{sdklnk} %{priority} \
  --slave %{_jvmjardir}/java-%{javaver} \
  java_sdk_%{javaver}_exports %{jvmjarlink}

%postun devel
if [ $1 -eq 0 ]
  update-alternatives --remove javac %{sdkbindir}/javac
  update-alternatives --remove java_sdk_%{origin} %{_jvmdir}/%{sdklnk}
  update-alternatives --remove java_sdk_%{javaver} %{_jvmdir}/%{sdklnk}

%post javadoc
update-alternatives \
  --install %{_javadocdir}/java javadocdir %{_javadocdir}/%{sdkname}/api \

%postun javadoc
if [ $1 -eq 0 ]
  update-alternatives --remove javadocdir %{_javadocdir}/%{sdkname}/api

%files -f %{name}.files
%doc %{buildoutputdir}/j2sdk-image/jre/ASSEMBLY_EXCEPTION
%doc %{buildoutputdir}/j2sdk-image/jre/LICENSE
%doc %{buildoutputdir}/j2sdk-image/jre/THIRD_PARTY_README
%doc openjdk/TRADEMARK
%doc ChangeLog
%doc NEWS

%dir %{_jvmdir}/%{sdkdir}
%dir %{_jvmdir}/%{jredir}/lib/security
%if %{suse_version} < 1130
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/cacerts
#%ghost %{_jvmdir}/%{jredir}/lib/security/cacerts
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/java.policy
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/nss.cfg
%config(noreplace) %{_jvmdir}/%{jredir}/lib/fontconfig.*
%config(noreplace) %{_jvmdir}/%{jredir}/lib/*.properties
%config(noreplace) %{_jvmdir}/%{jredir}/lib/management/jmxremote.access
%config(noreplace) %{_jvmdir}/%{jredir}/lib/management/
%config(noreplace) %{_jvmdir}/%{jredir}/lib/images/cursors/ 
%if %{suse_version} >= 1120
# links to the demo and sample dirs in noarch subpackages
%dir %{sdkshare}

%files devel
%doc %{buildoutputdir}/j2sdk-image/ASSEMBLY_EXCEPTION
%doc %{buildoutputdir}/j2sdk-image/LICENSE
#%doc %{buildoutputdir}/j2sdk-image/README.html
%doc %{buildoutputdir}/j2sdk-image/THIRD_PARTY_README
%doc openjdk/TRADEMARK
%dir %{_jvmdir}/%{sdkdir}/bin
%dir %{_jvmdir}/%{sdkdir}/include
%dir %{_jvmdir}/%{sdkdir}/lib
%if %{with_systemtap}
%dir %{_datadir}/systemtap/tapset
%dir %{tapsetdir}
%dir %{_jvmdir}/%{sdkdir}/tapset
# noarch sub packages in openSUSE >= 11.2
%if 0%{?suse_version} >= 1120
%dir %{_jvmdir}/%{sdkdir}/demo
# bnc#525097

%files demo -f %{name}-demo.files

%files src
# noarch sub packages in openSUSE >= 11.2
%if 0%{?suse_version} >= 1120
#doc mauve_tests
#doc mauve-%{mauvedate}/mauve_output

%files javadoc
%doc %{_javadocdir}/%{sdkname}

openSUSE Build Service is sponsored by