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

#
# spec file for package java-1_6_0-sun (Version 1.6.0.u23)
#
# 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 http://bugs.opensuse.org/
#

# norootforbuild


Name:           java-1_6_0-sun
BuildRequires:  fdupes jpackage-utils unzip update-alternatives update-desktop-files
%define section         non-free
%define origin          sun
%define priority        1617
%define javamajver      1.6.0
%define javaminver      45
%define toplevel_dir    jdk%{javamajver}_%{javaminver}
%define suse_release    %{nil}
%define javaver         %{javamajver}.u%{javaminver}%{suse_release}
%define cvsver          1_6_0
%define buildver        1
%define cvsversion	%{cvsver}_%{buildver}
#define cvsversion	%{cvsver}
%define javaws_ver      %{javaver}
%define javaws_version  %{cvsversion}
%define sdklnk          java-%{javamajver}-%{origin}
%define jrelnk          jre-%{javamajver}-%{origin}
%define sdkdir          java-%{javamajver}-%{origin}-%{javamajver}
%define demodir         %{_jvmdir}/%{sdkdir}/demo
%define sampledir      %{_jvmdir}/%{sdkdir}/sample
%define jredir          %{sdkdir}/jre
%define sdkbindir       %{_jvmdir}/%{sdklnk}/bin
%define sdklibdir       %{_jvmdir}/%{sdklnk}/lib
%define jrebindir       %{_jvmdir}/%{jrelnk}/bin
%define jvmjardir       %{_jvmjardir}/java-%{javamajver}-%{origin}-%{javamajver}
%define x11bindir       %{_prefix}/X11R6/bin
%define x11encdir       %{_prefix}/X11R6/lib/X11/fonts/encodings
%define fontconfigdir   %{_sysconfdir}/fonts
%define fontdir         %{_datadir}/fonts/java
%define xsldir          %{_datadir}/xml/%{name}-%{javamajver}
%define pluginsdir      %{_libdir}/browser-plugins
%ifarch %ix86
%define pluginpath      %{_jvmdir}/%{jredir}/lib/i386
%else 
%define pluginpath      %{_jvmdir}/%{jredir}/lib/amd64
%endif
%define pluginname      libnpjp2.so
# The old plugin for Seamonkey bnc#476397
%ifarch %ix86
%define pluginsdir_seamonkey %{_libdir}/seamonkey/plugins
%define pluginsdir_opera     %{_libdir}/opera/plugins
%define pluginpath_legacy       %{_jvmdir}/%{jredir}/plugin/i386/ns7/
%define pluginname_legacy       libjavaplugin_oji.so
%endif
%define cgibindir       %{_var}/www/cgi-bin
# Avoid RPM 4.2+'s internal dep generator, it may produce bogus
# Provides/Requires here.
Version:        1.6.0.u45
Release:        1
Summary:        Java(TM) 6 Runtime Environment
License:        NON-OSI-COMPLIANT(royalties)
Group:          Development/Languages/Java
Url:            https://jdk-distros.dev.java.net/developer.html
Source0:        jdk-6u%{javaminver}-linux-i586.bin
NoSource:       0
Source1:        jdk-6u%{javaminver}-linux-x64.bin
NoSource:       1
#Source1:        %{name}-register-java-fonts.xsl
#Source2:        %{name}-unregister-java-fonts.xsl
Source3:        fontconfig.SuSE.properties
Source4:        README.SUSE.EARLY_RELEASE
Source5:        wrapper-script
%define tzversion 2_0_0-2015a
Source100:      tzupdater-%{tzversion}.zip
NoSource:       100
%define         tzupdate false
Source1000:     java-1_6_0-sun-rpmlintrc
Provides:       jre-%{javamajver}-%{origin} = %{version}-%{release}
Provides:       jre-%{origin} = %{version}-%{release}
Provides:       jre-%{javamajver}, java-%{javamajver}, jre = %{javaver}
Provides:       java-%{origin} = %{version}-%{release}
Provides:       java = %{javaver}
Requires:       update-alternatives
Requires:       jpackage-utils >= 1.7.0
Conflicts:      kaffe
ExclusiveArch:  %ix86 x86_64
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:       javaws = %{javaws_ver}
Provides:       jndi = %{javaver}, jndi-ldap = %{javaver}
Provides:       jndi-cos = %{javaver}, jndi-rmi = %{javaver}
Provides:       jndi-dns = %{javaver}
Provides:       jaas = %{javaver}
Provides:       jsse = %{javaver}
Provides:       jce = %{javaver}
Provides:       jdbc-stdext = 3.0, jdbc-stdext = %{javaver}
Provides:       java-sasl = %{javaver}
Provides:       jre1.1.x jre1.2.x jre1.3.x jre1.4.x jre1.5.x jre1.6.x
# 32-bit versus 64-bit specific provides:
%ifarch %ix86 ppc s390
%define bits 32
%endif
%ifarch x86_64 ia64 s390x
%define bits 64
%endif
Provides:       jre-%{javamajver}-%{origin}-%{bits} = %{version}-%{release}
Provides:       jre-%{origin}-%{bits} = %{version}-%{release}
Provides:       jre-%{javamajver}-%{bits}, java-%{javamajver}-%{bits}
Provides:       jre-%{bits} = %{javaver}
Provides:       java-%{origin}-%{bits} = %{version}-%{release}
Provides:       java-%{bits} = %{javaver}
Provides:       jndi-%{bits}, jdbc-stdext-%{bits}
Obsoletes:      java2-jre < 1.4.2-150
Provides:       java2-jre = 1.6.0
PreReq:         update-alternatives
%ifarch %ix86
Obsoletes:      javaws-menu
%endif
Provides:       j2re = 1.6.0

%description
Java(TM) 6 Runtime Environment

The Java(TM) 6 Runtime Environment contains the Java virtual machine,
runtime class libraries, and 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-sun-devel package.

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



%package        devel
License:        NON-OSI-COMPLIANT(royalties)
Summary:        Java(TM) 6 SDK, Standard Edition
Group:          Development/Languages/Java
Requires:       update-alternatives
Provides:       java-sdk-%{javamajver}-%{origin} = %{version}-%{release}
Provides:       java-sdk-%{origin} = %{version}-%{release}
Provides:       java-sdk-%{javamajver}, java-sdk = %{javaver}
Provides:       java-devel-%{origin} = %{version}-%{release}
Provides:       java-%{javamajver}-devel, java-devel = %{javaver}
Requires:       %{name} = %{version}-%{release}
Requires:       jre-%{javamajver}-%{origin}-%{bits} = %{version}-%{release}
Provides:       j2sdk = 1.6.0

%description    devel
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        src
License:        NON-OSI-COMPLIANT(royalties)
Summary:        Source files for java-1_6_0-sun
Group:          Development/Languages/Java
Requires:       %{name} = %{version}-%{release}
Requires:       jre-%{javamajver}-%{origin}-%{bits} = %{version}-%{release}

%description    src
This package contains the sources of all classes that make up the Java
6 Standard Edition API, as provided by Sun.



%package        demo
License:        NON-OSI-COMPLIANT(royalties)
Summary:        Demonstration files for java-1_6_0-sun
Group:          Development/Languages/Java
Requires:       %{name} = %{version}-%{release}
Requires:       jre-%{javamajver}-%{origin}-%{bits} = %{version}-%{release}
# Without this a requirement on libjava_crw_demo_g.so is added which
# is not in the main java package. libjava_crw_demo.so is but not "_g".
AutoReq:        0

%description    demo
This package contains demonstration files for java-1_6_0-sun.



%package        plugin
License:        NON-OSI-COMPLIANT(royalties)
Summary:        Browser plugin files for java-1_6_0-sun
Group:          Development/Languages/Java
Requires:       %{name} = %{version}-%{release}
Requires:       jre-%{javamajver}-%{origin}-%{bits} = %{version}-%{release}
Requires:       %{_bindir}/find, sed
Provides:       java-plugin = %{javaver}, java-%{javamajver}-plugin = %{version}
Conflicts:      java-%{javamajver}-ibm-plugin, java-%{javamajver}-blackdown-plugin
Conflicts:      java-%{javamajver}-bea-plugin
Obsoletes:      java-1.3.1-plugin, java-1.4.0-plugin, java-1.4.1-plugin, java-1.4.2-plugin,
Provides:       java-1.3.1-plugin, java-1.4.0-plugin, java-1.4.1-plugin, java-1.4.2-plugin, java-1.6.0-plugin
Requires(post): update-alternatives
Conflicts:      MozillaFirefox <= 2

%description    plugin
This package contains browser plugin files for java-1_6_0-sun. Note:
this package supports browsers built with GCC 3.2 and later



%package        alsa
License:        NON-OSI-COMPLIANT(royalties)
Summary:        ALSA support for java-1_6_0-sun
Group:          Development/Languages/Java
Requires:       %{name} = %{version}-%{release}
Requires:       jre-%{javamajver}-%{origin}-%{bits} = %{version}-%{release}

%description    alsa
This package contains Advanced Linux Sound Architecture (ALSA) support
libraries for java-1_6_0-sun.



%package        jdbc
License:        NON-OSI-COMPLIANT(royalties)
Summary:        JDBC/ODBC bridge driver for java-1_6_0-sun
Group:          Development/Languages/Java
AutoReq:        0
Requires:       %{name} = %{version}-%{release}
Requires:       jre-%{javamajver}-%{origin}-%{bits} = %{version}-%{release}
Requires:       unixODBC
Provides:       java-jdbc = %{version}

%description    jdbc
This package contains the JDBC/ODBC bridge driver for java-1_6_0-sun.



%prep
rm -rf $RPM_BUILD_DIR/%{toplevel_dir}
export MORE=10000
%ifarch %ix86
sh %{SOURCE0} --accept-license --unpack
%endif
%ifarch x86_64
sh %{SOURCE1} --accept-license --unpack
%endif
%setup -T -D -n %{toplevel_dir}
chmod -R go=u-w *
chmod -R u+w *
cp %{SOURCE4} .
if [ "%tzupdate" = "true" ]
then
%define tzname %(echo %{tzversion} | sed 's/_/./g')
  unzip %{SOURCE100}
  ./bin/java -jar tzupdater-%{tzname}/tzupdater.jar -v -u
fi

%build
# Nope.

%install
export NO_BRP_CHECK_BYTECODE_VERSION="true"
# the Sun bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6532373 is already fixed
# and combination of fdupes and those symlinks should be dangerous - bnc#473952
#for file in jre/bin/java bin/java jre/bin/ControlPanel bin/appletviewer
#do
#  if [ -e $file ] 
#  then
#    cp $file{,.bin}
#    cp %{SOURCE5} $file
#  fi
#done
# fix up ControlPanel APPHOME and bin locations
perl -p -i -e 's|APPHOME=.*|APPHOME=%{_jvmdir}/%{jredir}|' jre/bin/ControlPanel
perl -p -i -e 's|/usr/bin/||g' jre/bin/ControlPanel
# fix up (create new) HtmlConverter
cat > bin/HtmlConverter << EOF
%{jrebindir}/java -jar %{sdklibdir}/htmlconverter.jar $*
EOF
# fix up java-rmi.cgi PATH
perl -p -i -e 's|PATH=.*|PATH=%{jrebindir}|' bin/java-rmi.cgi
# XXX: what's that?
# install java-rmi-cgi
#install -D -m 755 bin/java-rmi.cgi $RPM_BUILD_ROOT%{cgibindir}/java-rmi-%{version}.cgi
# main files
install -d -m 755 $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
cp -a bin include lib $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
cp -a src.zip $RPM_BUILD_ROOT%{_jvmdir}/%{sdkdir}
install -d -m 755 $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}
# extensions handling
install -d -m 755 $RPM_BUILD_ROOT%{jvmjardir}
pushd $RPM_BUILD_ROOT%{jvmjardir}
   ln -s %{_jvmdir}/%{jredir}/lib/jsse.jar jsse-%{version}.jar
   ln -s %{_jvmdir}/%{jredir}/lib/jce.jar jce-%{version}.jar
   ln -s %{_jvmdir}/%{jredir}/lib/rt.jar jndi-%{version}.jar
   ln -s %{_jvmdir}/%{jredir}/lib/rt.jar jndi-ldap-%{version}.jar
   ln -s %{_jvmdir}/%{jredir}/lib/rt.jar jndi-cos-%{version}.jar
   ln -s %{_jvmdir}/%{jredir}/lib/rt.jar jndi-rmi-%{version}.jar
   ln -s %{_jvmdir}/%{jredir}/lib/rt.jar jaas-%{version}.jar
   ln -s %{_jvmdir}/%{jredir}/lib/rt.jar jdbc-stdext-%{version}.jar
   ln -s jdbc-stdext-%{version}.jar jdbc-stdext-3.0.jar
   ln -s %{_jvmdir}/%{jredir}/lib/rt.jar sasl-%{version}.jar
   for jar in *-%{version}.jar ; do
      if [ x%{version} != x%{javaver} ]; then
         ln -fs ${jar} $(echo $jar | sed "s|-%{version}.jar|-%{javaver}.jar|g")
      fi
      ln -fs ${jar} $(echo $jar | sed "s|-%{version}.jar|.jar|g")
   done
popd
# rest of the jre
cp -a jre/bin jre/lib $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}/lib
cp -a jre/javaws jre/plugin $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}
install -d -m 755 $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}/lib/endorsed
# jce policy file handling
install -d -m 755 $RPM_BUILD_ROOT%{_jvmprivdir}/%{name}/jce/vanilla
for file in local_policy.jar US_export_policy.jar; do
  mv $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}/lib/security/$file \
    $RPM_BUILD_ROOT%{_jvmprivdir}/%{name}/jce/vanilla
  # for ghosts
  touch $RPM_BUILD_ROOT%{_jvmdir}/%{jredir}/lib/security/$file
done
# versionless symlinks
pushd $RPM_BUILD_ROOT%{_jvmdir}
ln -s %{jredir} %{jrelnk}
ln -s %{sdkdir} %{sdklnk}
popd
pushd $RPM_BUILD_ROOT%{_jvmjardir}
ln -s %{sdkdir} %{jrelnk}
ln -s %{sdkdir} %{sdklnk}
popd
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/applications
install -Dpm 644 jre/plugin/desktop/sun_java.png \
  $RPM_BUILD_ROOT%{_datadir}/pixmaps/sun-java-%{version}-%{release}.png
cat <<EOF > $RPM_BUILD_ROOT%{_datadir}/applications/jpackage-%{name}-ControlPanel.desktop
[Desktop Entry]
Name=Sun Java %{version} Java Plug-in Control Panel
GenericName=Java Plugin Control Panel
Comment=Sun Java %{version} Java Plug-in Control Panel
Exec=%{_jvmdir}/%{jredir}/bin/ControlPanel
Icon=sun-java-%{version}-%{release}
Terminal=false
Type=Application
EOF
%suse_update_desktop_file -r $RPM_BUILD_ROOT%{_datadir}/applications/jpackage-%{name}-ControlPanel.desktop Java System SystemSetup
# menu entry for web start (reuse plugin control panel icon)
cat <<EOF > $RPM_BUILD_ROOT%{_datadir}/applications/jpackage-%{name}-webstart.desktop
[Desktop Entry]
Name=Sun Java %{version} Java Web Start
GenericName=Java Web Start
Comment=Java Web Start Application Manager
Exec=%{_jvmdir}/%{jredir}/javaws/javaws -viewer
Icon=sun-java-%{version}-%{release}
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Application;System;Java;X-JPackage;
EOF
chmod 644 $RPM_BUILD_ROOT%{_datadir}/applications/jpackage-%{name}-webstart.desktop
%suse_update_desktop_file -r $RPM_BUILD_ROOT%{_datadir}/applications/jpackage-%{name}-webstart.desktop Java System Monitor 
# man pages
install -d -m 755 $RPM_BUILD_ROOT%{_mandir}/man1
for manpage in man/man1/*; do
  install -m 644 -p $manpage $RPM_BUILD_ROOT%{_mandir}/man1/`basename $manpage .1`-%{name}.1
done
# demo
#install -d -m 755 $RPM_BUILD_ROOT%{demodir}
#cp -a demo/*      $RPM_BUILD_ROOT%{demodir}
# samples bnc#496489
#install -d -m 755 $RPM_BUILD_ROOT%{sampledir}
#cp -a sample/*   $RPM_BUILD_ROOT%{sampledir}
# Most of this shamelessly stolen from redhat's kdebase-2.2.2 specfile
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
grep plugin  %{name}-%{version}-all.files | sort \
  > %{name}-%{version}-plugin.files
grep Jdbc    %{name}-%{version}-all.files | sort \
  > %{name}-%{version}-jdbc.files
grep -F alsa.so %{name}-%{version}-all.files | sort \
  > %{name}-%{version}-alsa.files
cat %{name}-%{version}-all.files \
  | grep -v plugin \
  | grep -v Jdbc \
  | grep -v lib/fonts \
  | grep -v "\/demo\/" \
  | grep -vF alsa.so \
  | grep -v jre/lib/security \
  | grep -v %{pluginname} \
  > %{name}-%{version}.files
# hardlink duplicates:
# fdupes links the files from JDK to JRE, so it breaks a JRE
# use it carefully :))
%fdupes -s $RPM_BUILD_ROOT/%{_jvmdir}/%{jredir}/
%fdupes -s $RPM_BUILD_ROOT/%{_jvmdir}/%{sdkdir}/demo
%fdupes -s $RPM_BUILD_ROOT%{_javadocdir}/%{sdkname}
# see bnc#331680
# JAR_EXECUTABLE=$(readlink -f $(find %{_builddir} -name "jar"))
# find $RPM_BUILD_ROOT \( -name "*.jar" -a -type f -a ! -empty \) -exec $JAR_EXECUTABLE -i {} \;
# bnc#394974
install -d -m 0755 $RPM_BUILD_ROOT/%{_jvmdir}/%{jredir}/.systemPrefs
touch $RPM_BUILD_ROOT/%{_jvmdir}/%{jredir}/.systemPrefs/.systemRootModFile
# The old plugin for Seamonkey bnc#476397
%ifarch %ix86
install -d -m 0755 $RPM_BUILD_ROOT/%{pluginsdir_seamonkey}
install -d -m 0755 $RPM_BUILD_ROOT/%{pluginsdir_opera}
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /bin/bash
# set link to javaws ... remove old link, if older versions dont point to alternative
if [ "$(readlink /usr/bin/javaws)" != "/etc/alternatives/javaws" ]
then
  rm -f /usr/bin/javaws
fi
ext=
[ -f %{_mandir}/man1/java-%{name}.1.bz2 ] && ext=".bz2"
[ -f %{_mandir}/man1/java-%{name}.1.gz ] && ext=".gz"
update-alternatives --install %{_bindir}/java java %{jrebindir}/java %{priority} \
--slave %{_bindir}/ControlPanel            ControlPanel                %{jrebindir}/ControlPanel \
--slave %{_bindir}/javaws                  javaws                      %{jrebindir}/javaws \
--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-%{name}.1$ext \
--slave %{_mandir}/man1/keytool.1$ext      keytool.1$ext               %{_mandir}/man1/keytool-%{name}.1$ext \
--slave %{_mandir}/man1/orbd.1$ext         orbd.1$ext                  %{_mandir}/man1/orbd-%{name}.1$ext \
--slave %{_mandir}/man1/policytool.1$ext   policytool.1$ext            %{_mandir}/man1/policytool-%{name}.1$ext \
--slave %{_mandir}/man1/rmid.1$ext         rmid.1$ext                  %{_mandir}/man1/rmid-%{name}.1$ext \
--slave %{_mandir}/man1/rmiregistry.1$ext  rmiregistry.1$ext           %{_mandir}/man1/rmiregistry-%{name}.1$ext \
--slave %{_mandir}/man1/servertool.1$ext   servertool.1$ext            %{_mandir}/man1/servertool-%{name}.1$ext \
--slave %{_mandir}/man1/tnameserv.1$ext    tnameserv.1$ext             %{_mandir}/man1/tnameserv-%{name}.1$ext \
--slave %{_mandir}/man1/javaws.1$ext       javaws.1$ext                %{_mandir}/man1/javaws-%{name}.1$ext
#--slave %{_mandir}/man1/kinit.1$ext        kinit.1$ext                 %{_mandir}/man1/kinit-%{name}.1$ext \
#--slave %{_mandir}/man1/klist.1$ext        klist.1$ext                 %{_mandir}/man1/klist-%{name}.1$ext \
#--slave %{_mandir}/man1/ktab.1$ext         ktab.1$ext                  %{_mandir}/man1/ktab-%{name}.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-%{javamajver} jre_%{javamajver} %{_jvmdir}/%{jrelnk} %{priority} \
--slave %{_jvmjardir}/jre-%{javamajver}       jre_%{javamajver}_exports      %{_jvmjardir}/%{jrelnk}
# bnc#355868
# 1.) the local_policy and US_export_policy link has to be there, if not
# then move alternatives status back to auto
if [ ! -e %{_jvmdir}/%{jrelnk}/lib/security/local_policy.jar -o \
     ! -e %{_jvmdir}/%{jrelnk}/lib/security/US_export_policy ]; then
    update-alternatives --auto jce_%{javamajver}_%{origin}_local_policy
fi
# 2.) The call can simply fails, when the link target already exists, because user
# should modify it
update-alternatives \
  --install \
    %{_jvmdir}/%{jrelnk}/lib/security/local_policy.jar \
    jce_%{javamajver}_%{origin}_local_policy \
    %{_jvmprivdir}/%{name}/jce/vanilla/local_policy.jar \
    %{priority} \
  --slave \
    %{_jvmdir}/%{jrelnk}/lib/security/US_export_policy.jar \
    jce_%{javamajver}_%{origin}_us_export_policy \
    %{_jvmprivdir}/%{name}/jce/vanilla/US_export_policy.jar 2>/dev/null || :

if [ -f %{_sysconfdir}/mime.types ]; then
   perl -p -i -e 's|application/x-java-jnlp-file.*||g' %{_sysconfdir}/mailcap.bak 2>/dev/null
   echo "type=application/x-java-jnlp-file; description=\"Java Web Start\"; exts=\"jnlp\"" >> %{_sysconfdir}/mailcap 2>/dev/null
   perl -p -i -e 's|application/x-java-jnlp-file.*||g' %{_sysconfdir}/mime.types 2>/dev/null
   echo "application/x-java-jnlp-file      jnlp" >> %{_sysconfdir}/mime.types 2>/dev/null
fi
### bad symlinks workaround ###
%ifarch %ix86
for ALT in java jre_%{origin} jre-%{javaver} jce_%{javaver}_%{origin}_local_policy; do
   if [[ $(update-alternatives --display ${ALT} | head -n 1 | grep manual) && 
         $(readlink /etc/alternatives/${ALT} | grep "1\.6\.0\.u[23]") ]]; then
        update-alternatives --auto ${ALT}
   fi
done
%endif
### bad symlinks workaround ###

%post devel -p /bin/bash
ext=
[ -f %{_mandir}/man1/javac-%{name}.1.bz2 ] && ext=".bz2"
[ -f %{_mandir}/man1/javac-%{name}.1.gz ] && ext=".gz"
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}/appletviewer             appletviewer                %{sdkbindir}/appletviewer \
--slave %{_bindir}/extcheck                 extcheck                    %{sdkbindir}/extcheck \
--slave %{_bindir}/idlj                     idlj                        %{sdkbindir}/idlj \
--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}/jdb                      jdb                         %{sdkbindir}/jdb \
--slave %{_bindir}/native2ascii             native2ascii                %{sdkbindir}/native2ascii \
--slave %{_bindir}/rmic                     rmic                        %{sdkbindir}/rmic \
--slave %{_bindir}/serialver                serialver                   %{sdkbindir}/serialver \
--slave %{_bindir}/jconsole                 jconsole                    %{sdkbindir}/jconsole \
--slave %{_bindir}/pack200                  pack200                     %{sdkbindir}/pack200 \
--slave %{_bindir}/unpack200                unpack200                   %{sdkbindir}/unpack200 \
--slave %{_bindir}/HtmlConverter            HtmlConverter               %{sdkbindir}/HtmlConverter \
--slave %{_bindir}/apt                      apt                         %{sdkbindir}/apt \
--slave %{_bindir}/jinfo                    jinfo                       %{sdkbindir}/jinfo \
--slave %{_bindir}/jmap                     jmap                        %{sdkbindir}/jmap \
--slave %{_bindir}/jps                      jps                         %{sdkbindir}/jps \
--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}/jvisualvm                jvisualvm                   %{sdkbindir}/jvisualvm \
--slave %{_mandir}/man1/appletviewer.1$ext  appletviewer.1$ext          %{_mandir}/man1/appletviewer-%{name}.1$ext \
--slave %{_mandir}/man1/extcheck.1$ext      extcheck.1$ext              %{_mandir}/man1/extcheck-%{name}.1$ext \
--slave %{_mandir}/man1/idlj.1$ext          idlj.1$ext                  %{_mandir}/man1/idlj-%{name}.1$ext \
--slave %{_mandir}/man1/jar.1$ext           jar.1$ext                   %{_mandir}/man1/jar-%{name}.1$ext \
--slave %{_mandir}/man1/jarsigner.1$ext     jarsigner.1$ext             %{_mandir}/man1/jarsigner-%{name}.1$ext \
--slave %{_mandir}/man1/javac.1$ext         javac.1$ext                 %{_mandir}/man1/javac-%{name}.1$ext \
--slave %{_mandir}/man1/javadoc.1$ext       javadoc.1$ext               %{_mandir}/man1/javadoc-%{name}.1$ext \
--slave %{_mandir}/man1/javah.1$ext         javah.1$ext                 %{_mandir}/man1/javah-%{name}.1$ext \
--slave %{_mandir}/man1/javap.1$ext         javap.1$ext                 %{_mandir}/man1/javap-%{name}.1$ext \
--slave %{_mandir}/man1/jdb.1$ext           jdb.1$ext                   %{_mandir}/man1/jdb-%{name}.1$ext \
--slave %{_mandir}/man1/jvisualvm.1$ext     jvisualvm.1$ext             %{_mandir}/man1/jvisualvm-%{name}.1$ext \
--slave %{_mandir}/man1/native2ascii.1$ext  native2ascii.1$ext          %{_mandir}/man1/native2ascii-%{name}.1$ext \
--slave %{_mandir}/man1/rmic.1$ext          rmic.1$ext                  %{_mandir}/man1/rmic-%{name}.1$ext \
--slave %{_mandir}/man1/serialver.1$ext     serialver.1$ext             %{_mandir}/man1/serialver-%{name}.1$ext \
--slave %{_mandir}/man1/jconsole.1$ext      jconsole.1$ext              %{_mandir}/man1/jconsole-%{name}.1$ext \
--slave %{_mandir}/man1/pack200.1$ext       pack200.1$ext               %{_mandir}/man1/pack200-%{name}.1$ext \
--slave %{_mandir}/man1/unpack200.1$ext     unpack200.1$ext             %{_mandir}/man1/unpack200-%{name}.1$ext \
--slave %{_mandir}/man1/apt.1$ext           apt.1$ext                   %{_mandir}/man1/apt-%{name}.1$ext \
--slave %{_mandir}/man1/jinfo.1$ext         jinfo.1$ext                 %{_mandir}/man1/jinfo-%{name}.1$ext \
--slave %{_mandir}/man1/jmap.1$ext          jmap.1$ext                  %{_mandir}/man1/jmap-%{name}.1$ext \
--slave %{_mandir}/man1/jps.1$ext           jps.1$ext                   %{_mandir}/man1/jps-%{name}.1$ext \
--slave %{_mandir}/man1/jsadebugd.1$ext     jsadebugd.1$ext             %{_mandir}/man1/jsadebugd-%{name}.1$ext \
--slave %{_mandir}/man1/jstack.1$ext        jstack.1$ext                %{_mandir}/man1/jstack-%{name}.1$ext \
--slave %{_mandir}/man1/jstat.1$ext         jstat.1$ext                 %{_mandir}/man1/jstat-%{name}.1$ext \
--slave %{_mandir}/man1/jstatd.1$ext        jstatd.1$ext                %{_mandir}/man1/jstatd-%{name}.1$ext 
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-%{javamajver} java_sdk_%{javamajver} %{_jvmdir}/%{sdklnk} %{priority} \
--slave %{_jvmjardir}/java-%{javamajver}       java_sdk_%{javamajver}_exports      %{_jvmjardir}/%{sdklnk}
### bad symlinks workaround ###
%ifarch %ix86
for ALT in javac java_sdk_%{origin} java_sdk_%{javaver}; do
   if [[ $(update-alternatives --display ${ALT} | head -n 1 | grep manual) && 
         $(readlink /etc/alternatives/${ALT} | grep "1\.6\.0\.u[23]") ]]; then
        update-alternatives --auto ${ALT}
   fi
done
%endif
### bad symlinks workaround ###

%post plugin -p /bin/bash
  # set link to plugin lib
  cd %{pluginsdir}
  JAVAPLUGINS=$(ls -1 | grep "\(java\|gcj\)" | grep -v javaplugin.so || true)
  if [ -n "$JAVAPLUGINS" ]
  then
    rm -rf $JAVAPLUGINS || true
  fi
  /usr/sbin/update-alternatives --install %{pluginsdir}/javaplugin.so javaplugin %{pluginpath}/%{pluginname} %{priority}
# The old plugin for Seamonkey bnc#476397
%ifarch %ix86
/usr/sbin/update-alternatives --install %{pluginsdir_seamonkey}/libjavaplugin_oji.so javaplugin_seamonkey %{pluginpath_legacy}/%{pluginname_legacy} %{priority}
/usr/sbin/update-alternatives --install %{pluginsdir_opera}/libjavaplugin_oji.so javaplugin_opera %{pluginpath_legacy}/%{pluginname_legacy} %{priority}
%endif
### bad symlinks workaround ###
%ifarch %ix86
for ALT in javaplugin; do
   if [[ $(update-alternatives --display ${ALT} | head -n 1 | grep manual) && 
         $(readlink /etc/alternatives/${ALT} | grep "1\.6\.0\.u[23]") ]]; then
        update-alternatives --auto ${ALT}
   fi
done
%endif
### bad symlinks workaround ###

%preun plugin -p /bin/bash
  if [ "$1" = "0" ] ; then
  /usr/sbin/update-alternatives --remove javaplugin %{pluginpath}/%{pluginname}
# The old plugin for Seamonkey bnc#476397
%ifarch %ix86
/usr/sbin/update-alternatives --remove javaplugin_seamonkey %{pluginpath_legacy}/%{pluginname_legacy}
/usr/sbin/update-alternatives --remove javaplugin_opera %{pluginpath_legacy}/%{pluginname_legacy}
%endif
  fi

%postun -p /bin/bash
if [ $1 -eq 0 ]; then
  update-alternatives --remove java %{jrebindir}/java
  update-alternatives --remove \
    jce_%{javamajver}_%{origin}_local_policy \
    %{_jvmprivdir}/%{name}/jce/vanilla/local_policy.jar
  update-alternatives --remove jre_%{origin}  %{_jvmdir}/%{jrelnk}
  update-alternatives --remove jre_%{javamajver} %{_jvmdir}/%{jrelnk}
fi

%postun devel -p /bin/bash
if [ $1 -eq 0 ]; then
  update-alternatives --remove javac %{sdkbindir}/javac
  update-alternatives --remove java_sdk_%{origin}  %{_jvmdir}/%{sdklnk}
  update-alternatives --remove java_sdk_%{javamajver} %{_jvmdir}/%{sdklnk}
fi

%files -f %{name}-%{version}.files
%defattr(-,root,root,-)
%{_datadir}/applications/jpackage-%{name}-webstart.desktop
%{_datadir}/pixmaps/sun-java-%{version}-%{release}.png
%doc  jre/COPYRIGHT jre/LICENSE jre/README README.SUSE.EARLY_RELEASE
%doc jre/Welcome.html
%dir %{_jvmdir}/%{sdkdir}
%{jvmjardir}
%{_jvmdir}/%{jredir}/lib/fonts
%dir %{_jvmdir}/%{jredir}/lib/security
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/cacerts
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/java.policy
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/java.security
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/javaws.policy
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/blacklist
%config(noreplace) %{_jvmdir}/%{jredir}/lib/security/trusted.libraries
%ghost %{_jvmdir}/%{jredir}/lib/security/local_policy.jar
%ghost %{_jvmdir}/%{jredir}/lib/security/US_export_policy.jar
%{_jvmdir}/%{jrelnk}
%{_jvmjardir}/%{jrelnk}
%dir %{_jvmprivdir}/%{name}
%dir %{_jvmprivdir}/%{name}/jce
%dir %{_jvmprivdir}/%{name}/jce/vanilla
%config(noreplace) %{_jvmprivdir}/%{name}/jce/vanilla/*_policy.jar
%{_mandir}/man1/java-%{name}.1*
%{_mandir}/man1/keytool-%{name}.1*
%{_mandir}/man1/orbd-%{name}.1*
%{_mandir}/man1/policytool-%{name}.1*
%{_mandir}/man1/rmid-%{name}.1*
%{_mandir}/man1/rmiregistry-%{name}.1*
%{_mandir}/man1/servertool-%{name}.1*
%{_mandir}/man1/tnameserv-%{name}.1*
%{_mandir}/man1/javaws-%{name}.1*
%{_mandir}/man1/jhat-java-1_6_0-sun.1.gz
%{_mandir}/man1/jrunscript-java-1_6_0-sun.1.gz
%{_mandir}/man1/schemagen-java-1_6_0-sun.1.gz
%{_mandir}/man1/wsgen-java-1_6_0-sun.1.gz
%{_mandir}/man1/wsimport-java-1_6_0-sun.1.gz
%{_mandir}/man1/xjc-java-1_6_0-sun.1.gz
#%{_mandir}/man1/kinit-%{name}.1*
#%{_mandir}/man1/klist-%{name}.1*
#%{_mandir}/man1/ktab-%{name}.1*
%{_jvmdir}/%{jredir}/.systemPrefs

%files devel
%defattr(-,root,root,-)
%doc COPYRIGHT LICENSE README.html
%dir %{_jvmdir}/%{sdkdir}/bin
%dir %{_jvmdir}/%{sdkdir}/include
%dir %{_jvmdir}/%{sdkdir}/lib
%{_jvmdir}/%{sdkdir}/bin/*
%{_jvmdir}/%{sdkdir}/include/*
%{_jvmdir}/%{sdkdir}/lib/*
%{_jvmdir}/%{sdklnk}
%{_jvmjardir}/%{sdklnk}
%{_mandir}/man1/appletviewer-%{name}.1*
%{_mandir}/man1/extcheck-%{name}.1*
%{_mandir}/man1/idlj-%{name}.1*
%{_mandir}/man1/jar-%{name}.1*
%{_mandir}/man1/jarsigner-%{name}.1*
%{_mandir}/man1/javac-%{name}.1*
%{_mandir}/man1/javadoc-%{name}.1*
%{_mandir}/man1/javah-%{name}.1*
%{_mandir}/man1/javap-%{name}.1*
%{_mandir}/man1/jdb-%{name}.1*
%{_mandir}/man1/native2ascii-%{name}.1*
%{_mandir}/man1/rmic-%{name}.1*
%{_mandir}/man1/serialver-%{name}.1*
%{_mandir}/man1/jconsole-%{name}.1*
%{_mandir}/man1/pack200-%{name}.1*
%{_mandir}/man1/unpack200-%{name}.1*
%{_mandir}/man1/apt-%{name}.1*
%{_mandir}/man1/jinfo-%{name}.1*
%{_mandir}/man1/jmap-%{name}.1*
%{_mandir}/man1/jps-%{name}.1*
%{_mandir}/man1/jsadebugd-%{name}.1*
%{_mandir}/man1/jstack-%{name}.1*
%{_mandir}/man1/jstat-%{name}.1*
%{_mandir}/man1/jstatd-%{name}.1*
%{_mandir}/man1/jvisualvm-%{name}.1*
%ifarch %ix86
#%{cgibindir}/java-rmi-%{version}.cgi
%endif

%files src
%defattr(-,root,root,-)
%{_jvmdir}/%{sdkdir}/src.zip

#%files demo
#%defattr(-,root,root,-)
#%{demodir}
#%{sampledir}

%files alsa -f %{name}-%{version}-alsa.files
%defattr(-,root,root,-)

%files jdbc -f %{name}-%{version}-jdbc.files
%defattr(-,root,root,-)

%files plugin -f %{name}-%{version}-plugin.files
%defattr(-,root,root,-)
%{_datadir}/applications/jpackage-%{name}-ControlPanel.desktop
%{pluginpath}/%{pluginname}
# The old plugin for Seamonkey bnc#476397
%ifarch %ix86
%dir %{_libdir}/seamonkey/
%dir %{_libdir}/seamonkey/plugins
%dir %{_libdir}/opera/
%dir %{_libdir}/opera/plugins
%endif

%changelog