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

# spec file for package java-1_6_0-openjdk
# Copyright (c) 2021 SUSE LLC
# 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

%{!?make_build:%global make_build make %{?_smp_mflags}}
%{!?aarch64:%global aarch64 aarch64 arm64 armv8}
%define jit_arches %{ix86} x86_64
# Turn on/off some features depending on openSUSE version
%define with_systemtap 0
# If runtests is 0 test suites will not be run.
%define runtests 0
# 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}
# Standard JPackage naming and versioning defines.
%define priority        1605
%define javaver         1.6.0
%define buildver        44
%define icedteaver      1.13.13
%define icedteasnapshot %{nil}
%define openjdkver      b%{buildver}
%define openjdkdate     30_aug_2017
%define cleanedtarball  openjdk-6-src-%{openjdkver}-%{openjdkdate}-cleaned.tar.xz
%define mauvedate       2008-10-22
%define buildoutputdir
%define sdkname         java-%{javaver}-openjdk
%define archname        %{sdkname}
# Standard JPackage directories and symbolic links.
%define jrelnk          jre-%{javaver}-openjdk
%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}
# cacert file
%define cacerts  %{_jvmdir}/%{jredir}/lib/security/cacerts
%ifarch %{jit_arches}
%if 0%{?suse_version} >= 1130
%define with_systemtap 1
%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
# 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       %{_datadir}/systemtap/tapset/%{_build_cpu}
# bnc#542545
# 32-bit versus 64-bit specific provides:
%ifarch %{ix86} ppc s390 %{arm}
%define bits 32
%ifarch x86_64 ia64 s390x
%define bits 64
%ifarch %{arm} %{aarch64}
%bcond_with docs
%bcond_without docs
%bcond_without bootstrap
Name:           java-1_6_0-openjdk
Version:        %{javaver}.%{buildver}
Release:        0
Summary:        Java runtime environment based on OpenJDK 6 and IcedTea 6
License:        GPL-2.0-with-classpath-exception
Group:          Development/Languages/Java
# # download the openjdk from
# sh openjdk-6-src-%{openjdkver}-%{openjdkdate}.tar.xz
Source1:        %{cleanedtarball}
Source5:        mauve-%{mauvedate}.tar.bz2
# from Fedora rpm
Source6:        mauve_tests
Source1000:     java-1_6_0-openjdk-rpmlintrc
# those properties are for opeSUSE only
#PGP signature
# FIXME: This patch needs to be fixed. optflags argument
# -mtune=generic is being ignored because it breaks several graphical
# applications.
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
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-b32-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: unused variable warnings - sent to upstream
Patch122:       openjdk-6-src-b20-unused-variable.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: some missing bits for ppc64le and aarch64
Patch135:       icedtea6-1.13.5-add-zero-ports-ecj.patch
#PATH-FIX-UPSTREAM:, bnc#792951
Patch139:       openjdk-7-src-b147-awt-crasher.patch
#PATCH-FIX-OPENSUSE: add zero archs
Patch140:       icedtea6-1.13.5-add-zero-ports.patch
#PATCH-FIX-OPENSUSE: missing include
Patch145:       implicit-fortify-decl.patch
Patch146:       implicit-fortify-decl-ecj.patch
#PATCH-FIX-OPENSUSE: build with gcj6 and gcc7
Patch150:       openjdk-libjvm-link.patch
Patch151:       openjdk-libjvm-link-ecj.patch
#PATCH-FIX-OPENSUSE: Don't try to link with libnsl
Patch160:       openjdk-libnsl.patch
Patch161:       openjdk-libnsl-ecj.patch
Patch170:       required-freetype.patch
Patch171:       required-freetype-ecj.patch
Patch180:       new-kernel.patch
Patch181:       new-kernel-ecj.patch
Patch190:       relocinfo.patch
Patch191:       relocinfo-ecj.patch
Patch200:       gcc-fno-common-fix.patch
Patch201:       gcc-fno-common-fix-ecj.patch
Patch210:       no-return-nonvoid.patch
Patch211:       no-return-nonvoid-ecj.patch
Patch220:       no-sys-sysctl.patch
Patch221:       no-sys-sysctl-ecj.patch
Patch1000:      java-1_6_0-openjdk-suse-desktop-files.patch
Patch1001:      icedtea6-1.13.13-aarch64.patch
Patch1002:      icedtea6-1.13.13-b44.patch
Patch1003:      no-preload.patch
BuildRequires:  alsa-lib-devel
BuildRequires:  ant
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  cups-devel
BuildRequires:  desktop-file-utils
BuildRequires:  fastjar
BuildRequires:  fdupes
BuildRequires:  gawk
BuildRequires:  gcc-c++
BuildRequires:  giflib-devel
BuildRequires:  jpackage-utils >= 1.7.3
BuildRequires:  krb5-devel
BuildRequires:  libjpeg-devel
BuildRequires:  liblcms2-devel
BuildRequires:  libpng-devel
BuildRequires:  libpulse-devel >= 0.9.11
BuildRequires:  mozilla-nss-devel
BuildRequires:  perl
BuildRequires:  procps
BuildRequires:  pulseaudio >= 0.9.11
BuildRequires:  rhino
BuildRequires:  unzip
BuildRequires:  update-desktop-files
BuildRequires:  wget
BuildRequires:  xalan-j2
BuildRequires:  xorg-x11
BuildRequires:  xorg-x11-devel
BuildRequires:  xorg-x11-proto-devel
BuildRequires:  xorg-x11-util-devel
BuildRequires:  xz
BuildRequires:  zip
BuildRequires:  zlib-devel
#!BuildIgnore:  xml-commons
#!BuildIgnore:  xml-commons-apis
#!BuildIgnore:  xml-commons-resolver
# Require zoneinfo data provided by timezone-java subpackage.
Requires:       timezone-java
Requires(pre):  update-alternatives
# Standard JPackage base provides.
Provides:       java = %{javaver}
Provides:       java-%{javaver} = %{version}-%{release}
Provides:       java-%{javaver}-openjdk = %{version}-%{release}
Provides:       java-openjdk = %{version}-%{release}
Provides:       jre = %{javaver}
Provides:       jre-%{javaver} = %{version}-%{release}
Provides:       jre-%{javaver}-openjdk = %{version}-%{release}
Provides:       jre-openjdk = %{version}-%{release}
# Standard JPackage extensions provides.
Provides:       jaas = %{version}
Provides:       java-sasl = %{version}
Provides:       jce = %{version}
Provides:       jdbc-stdext = %{version}
Provides:       jdbc-stdext = 3.0
Provides:       jndi = %{version}
Provides:       jndi-cos = %{version}
Provides:       jndi-dns = %{version}
Provides:       jndi-ldap = %{version}
Provides:       jndi-rmi = %{version}
Provides:       jsse = %{version}
# Required at least by fop
Provides:       java-%{bits} = %{javaver}
Provides:       java-%{javaver}-%{bits}
Provides:       java-openjdk-%{bits} = %{version}-%{release}
Provides:       jre-%{bits} = %{javaver}
Provides:       jre-%{javaver}-%{bits}
Provides:       jre-%{javaver}-openjdk-%{bits} = %{version}-%{release}
Provides:       jre-openjdk-%{bits} = %{version}-%{release}
Provides:       jre1.3.x
Provides:       jre1.4.x
Provides:       jre1.5.x
Provides:       jre1.6.x
Provides:       java-headless = %{version}-%{release}
%if 0%{?suse_version} < 1200
BuildRequires:  ant-nodeps
BuildRequires:  libxslt
%if  0%{?suse_version} < 1220
BuildRequires:  libxslt1
BuildRequires:  libxslt-tools
# make sure to use bootstrap requires of ant
%if 0%{?suse_version} < 1230
BuildRequires:  xerces-j2-bootstrap
BuildRequires:  xerces-j2
%if %{with bootstrap}
BuildRequires:  java-devel
BuildConflicts: java >= 1.7
BuildConflicts: java-devel >= 1.7
BuildConflicts: java-headless >= 1.7
BuildRequires:  %{name}-devel
# Mauve build requirements.
%if %{runtests}
BuildRequires:  fontconfig
BuildRequires:  freetype2-devel >= 2.3.0
BuildRequires:  xorg-x11-fonts
BuildRequires:  xorg-x11-server-extra
%if 0%{?suse_version} >= 1230
BuildRequires:  xprop
#system tap
%if %{with_systemtap}
BuildRequires:  systemtap-sdt-devel >= 1.0
%if 0%{?suse_version} > 1110
#the /etc/SUSE-release is needed as well
BuildRequires:  distribution-release
#fixing RedHat bug #648499
BuildRequires:  lsb-release
BuildConflicts: dummy-release
# Zero-assembler build requirement.
%ifnarch %{jit_arches}
BuildRequires:  libffi-devel
# runtime ceritifacates generation available in 11.3+ - bnc#596177
%if 0%{?suse_version} >= 1130
BuildRequires:  java-ca-certificates
Requires(post): java-ca-certificates
Requires(post): mozilla-nss
BuildRequires:  openssl-certs
# the certificates will converted in a prep to standard keystore file - cacerts
# The openssl requirment seems to be necessary for build only.
Requires:       openssl
%if %{with_systemtap}
Recommends:     systemtap >= 1.0

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
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-%{javaver}-devel = %{version}
Provides:       java-%{javaver}-openjdk-devel = %{version}-%{release}
Provides:       java-devel = %{javaver}
Provides:       java-devel-openjdk = %{version}
Provides:       java-sdk = %{javaver}
Provides:       java-sdk-%{javaver} = %{version}
Provides:       java-sdk-%{javaver}-openjdk = %{version}
Provides:       java-sdk-openjdk = %{version}

%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
Summary:        Sources for building demo applications with OpenJDK 6
Group:          Development/Languages/Java
Requires:       %{name}-devel = %{version}-%{release}
Provides:       java-%{javaver}-openjdk-demo = %{version}-%{release}

%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
Summary:        OpenJDK 6 Java class sources for developers
Group:          Development/Languages/Java
Requires:       %{name}-devel = %{version}-%{release}

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

%if %{with docs}
%package javadoc
Summary:        Documentation of the Java API of OpenJDK 6
Group:          Development/Languages/Java
Requires(pre):  %{_sbindir}/update-alternatives
Provides:       java-%{javaver}-javadoc = %{version}-%{release}
Provides:       java-%{javaver}-openjdk-javadoc = %{version}-%{release}
Provides:       java-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.


%package accessibility
Summary:        Accessibility connector for OpenJDK 6
Group:          Development/Languages/Java
Requires:       %{name} = %{version}-%{release}
Requires:       java-atk-wrapper

%description accessibility
Enables accessibility support in OpenJDK by using java-at-wrapper. This allows
compatible at-spi2 based accessibility programs to work for AWT and Swing-based
programs.  Please note, the java-atk-wrapper is still in beta, and also OpenJDK
itself is still in phase of tuning to be working with accessibility features.
Although working pretty fine, there are known issues with accessibility on, so
do not rather install this package unless you really need.

%setup -q -n icedtea6-%{icedteaver}
%setup -q -n icedtea6-%{icedteaver} -T -D -a 5
%patch1000 -p1
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
rm -f *.desktop

cp %{SOURCE6} .

%define _lto_cflags %{nil}
export LANG=en_US.UTF-8

# macro _smp_mflags is too makefile centric, so it's better
# get the number directly
export NUMCPUS=`%{_bindir}/getconf _NPROCESSORS_ONLN`

export CFLAGS=$(rpm -E '%{optflags}' | sed 's/-Wall\>//' | sed 's/-Werror=return-type\>//')
export CFLAGS="$CFLAGS -fno-strict-aliasing"
%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 \
    --enable-system-zlib \
    --enable-system-jpeg \
    --enable-system-png \
    --enable-system-gif \
    --enable-system-lcms \
%if %{with bootstrap}
    --enable-bootstrap \
    --enable-bootstrap-tools \
    --disable-bootstrap \
    --with-jdk-home="%{_sysconfdir}/alternatives/java_sdk" \
%if %{with docs}
    --enable-docs \
    --disable-docs \
    --with-openjdk-src-zip=%{SOURCE1} \
%ifnarch %{arm} %{aarch64}
    --with-parallel-jobs=${NUMCPUS} \
    --with-parallel-jobs=1 \
%if ! %{runtests}
    --without-tests \
	--without-hotspot-tests \

%if %{with bootstrap}
%make_build patch-ecj patch
%make_build patch

# Those patches are from Fedora package
patch -p0 -i %{PATCH3}
patch -p0 -i %{PATCH4}

patch -p0 -i %{PATCH104}
patch -p0 -i %{PATCH107}

%ifarch %{ix86}
patch -p0 -i %{PATCH109}

%if ! %{with bootstrap}
%ifarch ppc ppc64 s390 s390x
patch -p1 -i %{PATCH110}

patch -p1 -i %{PATCH117}
patch -p1 -i %{PATCH119}
patch -p1 -i %{PATCH120}
patch -p1 -i %{PATCH122}
patch -p1 -i %{PATCH127}
patch -p1 -i %{PATCH128}
patch -p0 -i %{PATCH145}
patch -p0 -i %{PATCH150}
patch -p0 -i %{PATCH160}
patch -p0 -i %{PATCH170}
patch -p0 -i %{PATCH180}
patch -p0 -i %{PATCH190}
patch -p1 -i %{PATCH200}
patch -p1 -i %{PATCH210}
patch -p0 -i %{PATCH220}

%if %{with bootstrap}
patch -p1 -i %{PATCH132}
patch -p1 -i %{PATCH134}
patch -p1 -i %{PATCH133}
patch -p1 -i %{PATCH135}
patch -p0 -i %{PATCH146}
patch -p0 -i %{PATCH151}
patch -p0 -i %{PATCH161}
patch -p0 -i %{PATCH171}
patch -p0 -i %{PATCH181}
patch -p0 -i %{PATCH191}
patch -p1 -i %{PATCH201}
patch -p1 -i %{PATCH211}
patch -p0 -i %{PATCH221}
patch -p1 -i %{PATCH129}

#AWT crasher
patch -p1 -i %{PATCH139}

#Add other zero architectures
patch -p1 -i %{PATCH140}

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 0%{?suse_version} < 1130
# ========== a default keystore ==========
# a cacerts generation - 11.3+ use java-ca-certificates package
for PEM in %{_sysconfdir}/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

%if %{runtests}
# Run jtreg test suite.
  echo ====================JTREG TESTING========================
  export DISPLAY=:20
  Xvfb :20 -screen 0 1x1x24 -ac&
  echo $! >
  %make_build 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

%if 0%{?suse_version} >= 1120
#BOUNCY-HACK: this is very nasty to do, but as make patch does much more than make .. this just works :)
    find . -type f -name '' | while read F; do
        MAXN=$(grep ^security.provider "${F}" | sed 's/security\.provider\.\([0-9]\+\).*/\1/' | sort -n | tail -n 1)
        BC="# API support\n# will be enabled after installation of bouncycastle.rpm\n#security.provider.$((MAXN+1))=org.bouncycastle.jce.provider.BouncyCastleProvider"
        sed -i "${F}" -e "s/^security\.provider\.${MAXN}=.*/&\n${BC}/"
    find . -type f -name '' -delete

  # Install main files.
  install -d -m 755 %{buildroot}%{_jvmdir}/%{sdkdir}
  cp -a bin include lib %{buildroot}%{_jvmdir}/%{sdkdir}
  install -d -m 755 %{buildroot}%{_jvmdir}/%{jredir}
  cp -a jre/bin jre/lib %{buildroot}%{_jvmdir}/%{jredir}
  # bnc#438674
  # Install a fontconfig file which don't reffer to agfa-fonts on openSUSE
  cp %{SOURCE1001} %{buildroot}%{_jvmdir}/%{jredir}/lib/

%if %{with_systemtap}
  # Install systemtap support files.
  install -dm 755 %{buildroot}%{_jvmdir}/%{sdkdir}/tapset
  for i in tapset/*.stp; do
    cp -a $i %{buildroot}%{_jvmdir}/%{sdkdir}/tapset/$(basename $i .stp)-%{javaver}.stp
  install -d -m 755 %{buildroot}%{tapsetdir}
  pushd %{buildroot}%{tapsetdir}
    RELATIVE=$(%{abs2rel} %{_jvmdir}/%{sdkdir}/tapset %{tapsetdir})
    ln -sf $RELATIVE/*.stp .
  # Install extension symlinks.
  install -d -m 755 %{buildroot}%{jvmjardir}
  pushd %{buildroot}%{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 %{buildroot}%{_jvmprivdir}/%{archname}/jce/vanilla

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

  pushd %{buildroot}%{_jvmjardir}
    ln -sf %{sdkdir} %{jrelnk}
    ln -sf %{sdkdir} %{sdklnk}

  # Install man pages.
  install -d -m 755 %{buildroot}%{_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 %{buildroot}%{_mandir}/man1/$(basename \
      $manpage .1)-%{sdkname}.1
  # Install demos and samples.
  cp -a demo %{buildroot}%{_jvmdir}/%{sdkdir}
  # enable short-circuit
  mkdir -p sample/rmi
  [ -f bin/java-rmi.cgi ] && mv bin/java-rmi.cgi sample/rmi
  cp -a sample %{buildroot}%{_jvmdir}/%{sdkdir}


%if %{with docs}

# Install Javadoc documentation.
install -d -m 755 %{buildroot}%{_javadocdir}
cp -a %{buildoutputdir}/docs %{buildroot}%{_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 %{buildroot}%{_datadir}/{applications,pixmaps}
for d in jconsole policytool; do
    cp $d.desktop $d-%{sdklnk}.desktop
    install -m 0644 $d-%{sdklnk}.desktop %{buildroot}/%{_datadir}/applications/
    %suse_update_desktop_file $d-%{sdklnk}
# Find JRE directories.
find %{buildroot}%{_jvmdir}/%{jredir} -type d \
  | grep -v jre/lib/security \
  | grep -v jconsole-%{sdklnk}.desktop \
  | sed 's|'%{buildroot}'|%dir |' \
  > %{name}.files
# Find JRE files.
find %{buildroot}%{_jvmdir}/%{jredir} -type f -o -type l \
  | grep -v jre/lib/security \
  | sed 's|'%{buildroot}'||' \
  >> %{name}.files
# Find demo directories.
find %{buildroot}%{_jvmdir}/%{sdkdir}/demo \
  %{buildroot}%{_jvmdir}/%{sdkdir}/sample -type d \
  | sed 's|'%{buildroot}'|%dir |' \
  > %{name}-demo.files
# Find non-documentation demo files.
find %{buildroot}%{_jvmdir}/%{sdkdir}/demo \
  %{buildroot}%{_jvmdir}/%{sdkdir}/sample \
  -type f -o -type l | sort \
  | grep -v README \
  | sed 's|'%{buildroot}'||' \
  >> %{name}-demo.files
# Find documentation demo files.
find %{buildroot}%{_jvmdir}/%{sdkdir}/demo \
  %{buildroot}%{_jvmdir}/%{sdkdir}/sample \
  -type f -o -type l | sort \
  | grep README \
  | sed 's|'%{buildroot}'||' \
  | sed 's|^|%doc |' \
  >> %{name}-demo.files

# Create links which leads to separately installed java-atk-bridge and allow configuration
# links points to java-atk-wrapper - an dependence
# mvyskocil: links are handled in post, lets make ghost files there
  touch %{buildroot}/%{_jvmdir}/%{jredir}/lib/%{archinstall}/
  touch %{buildroot}/%{_jvmdir}/%{jredir}/lib/ext/java-atk-wrapper.jar
  pushd %{buildroot}/%{_jvmdir}/%{jredir}/lib/
    echo "#Config file to  enable java-atk-wrapper" >
    echo "" >>
    echo "assistive_technologies=org.GNOME.Accessibility.AtkWrapper" >>
    echo "" >>

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

%fdupes -s %{buildroot}/%{_jvmdir}/%{sdkdir}/demo

%if %{with docs}

%fdupes -s %{buildroot}%{_javadocdir}/%{sdkname}


%if ! 0%{?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}" %{buildroot}/%{cacerts}) == "32" ]]; then
    echo "ERROR: Default keystore seems empty"
    exit 1


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}/pack200 pack200 %{jrebindir}/pack200 \
  --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 %{_bindir}/unpack200 unpack200 %{jrebindir}/unpack200 \
  --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/pack200.1$ext pack200.1$ext \
  %{_mandir}/man1/pack200-%{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 \
  %{_mandir}/man1/tnameserv-%{sdkname}.1$ext \
  --slave %{_mandir}/man1/unpack200.1$ext unpack200.1$ext \
  %{_mandir}/man1/unpack200-%{sdkname}.1$ext \
  --slave %{_datadir}/applications/policytool.desktop policytool.desktop\
  %{_datadir}/applications/policytool-%{sdklnk}.desktop \
  || :

update-alternatives \
  --install %{_jvmdir}/jre-openjdk \
  jre_openjdk %{_jvmdir}/%{jrelnk} %{priority} \
  --slave %{_jvmjardir}/jre-openjdk \
  jre_openjdk_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_openjdk %{_jvmdir}/%{jrelnk}
  update-alternatives --remove jre_%{javaver} %{_jvmdir}/%{jrelnk}

%if 0%{?suse_version} >= 1130
# if there's no java, certificates are not generated
if [ ! -f %{_localstatedir}/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 %{_localstatedir}/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}/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/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 \
  %{_mandir}/man1/xjc-%{sdkname}.1$ext \
  --slave %{_datadir}/applications/jconsole.desktop jconsole.desktop\
  %{_datadir}/applications/jconsole-%{sdklnk}.desktop \
  || :

update-alternatives \
  --install %{_jvmdir}/java-openjdk \
  java_sdk_openjdk %{_jvmdir}/%{sdklnk} %{priority} \
  --slave %{_jvmjardir}/java-openjdk \
  java_sdk_openjdk_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_openjdk %{_jvmdir}/%{sdklnk}
  update-alternatives --remove java_sdk_%{javaver} %{_jvmdir}/%{sdklnk}

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

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

%post accessibility
# create links to java-atk-wrapper
if [ ! -e %{_jvmdir}/%{jredir}/lib/%{archinstall}/ ]; then
    ln -sf %{_libdir}/java-atk-wrapper/  %{_jvmdir}/%{jredir}/lib/%{archinstall}/
if [ ! -e %{_jvmdir}/%{jredir}/lib/ext/java-atk-wrapper.jar ]; then
    ln -sf %{_libdir}/java-atk-wrapper/java-atk-wrapper.jar %{_jvmdir}/%{jredir}/lib/ext/java-atk-wrapper.jar

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

%dir %{_jvmdir}/%{sdkdir}
%dir %{_jvmdir}/%{jredir}/lib/security
%if 0%{?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/
# Using timezone info from the timezone-java package
%exclude %{_jvmdir}/%{jredir}/lib/zi

%dir %{_datadir}/icons/hicolor
#belongs to accessibility
%exclude %{_jvmdir}/%{jredir}/lib/%{archinstall}/
%exclude %{_jvmdir}/%{jredir}/lib/ext/java-atk-wrapper.jar
%exclude %{_jvmdir}/%{jredir}/lib/

%dir %{_jvmjardir}

%files devel
%doc %{buildoutputdir}/j2sdk-image/ASSEMBLY_EXCEPTION
%license %{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
# bnc#525097

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

%files src
#doc mauve_tests
#doc mauve-%{mauvedate}/mauve_output

%if %{with docs}
%files javadoc
%doc %{_javadocdir}/%{sdkname}


%files accessibility
%config(noreplace) %{_jvmdir}/%{jredir}/lib/
%ghost %{_jvmdir}/%{jredir}/lib/%{archinstall}/
%ghost %{_jvmdir}/%{jredir}/lib/ext/java-atk-wrapper.jar

openSUSE Build Service is sponsored by