File java-1_8_0-openjdk-plugin.spec of Package icedtea-web

#
# spec file for package java-1_8_0-openjdk-plugin
#
# Copyright (c) 2017 SUSE LINUX 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/
#


%define priority        18020
%define javaver         1.8.0
%define java_name       java-1_8_0-openjdk
# use a same name of alternatives as Sun/IBM Java
%define javaplugin      javaplugin
%define pluginsdir      %{_libdir}/browser-plugins
%define sdkdir          java-%{javaver}-openjdk-%{javaver}
%define pluginpath      %{_libdir}/%{name}/lib
%define pluginname      IcedTeaPlugin.so
Name:           %{java_name}-plugin
Version:        1.6.2
Release:        0
Summary:        Java Web Start and plugin implementation
License:        GPL-2.0-with-classpath-exception
Group:          Development/Languages/Java
Url:            http://icedtea.classpath.org
Source0:        http://icedtea.classpath.org/download/source/icedtea-web-%{version}.tar.gz
Patch1000:      icedtea-web-suse-desktop-files.patch
BuildRequires:  %{java_name}-devel >= %{javaver}
# IcedTeaPlugin build requirements.
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  glib2-devel
BuildRequires:  npapi-sdk
BuildRequires:  pkgconfig >= 0.9.0
BuildRequires:  procps
BuildRequires:  rhino
BuildRequires:  update-desktop-files
BuildRequires:  zip
BuildRequires:  zlib-devel
# to make sure the new package is installed in time of post
Requires(post): %{java_name}
# Post requires alternatives to install tool alternatives.
Requires(post): update-alternatives
# Postun requires alternatives to uninstall tool alternatives.
Requires(postun): update-alternatives
Suggests:       icedtea-web-javadoc
# bnc#737105/FATE#313084/bsc#929464
Supplements:    packageand(browser(npapi):%{java_name})
Provides:       icedtea-web = %{version}-%{release}
Provides:       java-plugin = %{javaver}
Obsoletes:      icedtea-web < %{version}-%{release}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} <= 1130
BuildRequires:  xorg-x11-devel
%else
BuildRequires:  libX11-devel
%endif
# owns javadocdir
# javapackages-tools now includes jpackage-utils
%if 0%{?suse_version} > 1230
BuildRequires:  javapackages-tools
%else
BuildRequires:  jpackage-utils
%endif

%description
The IcedTea-Web project provides a Free Software web browser plugin running
applets written in the Java programming language and an implementation of Java
Web Start, originally based on the NetX project.

%prep
%setup -q -n icedtea-web-%{version}
%patch1000 -p1

%build
autoreconf -fi
%configure \
	--with-jdk-home=%{_jvmdir}/%{sdkdir} \
	--with-jre-home=%{_jvmdir}/%{sdkdir}/jre \
	--prefix=%{_libdir}/%{name} \
	--bindir=%{_libdir}/%{name}/bin \
	--libdir=%{_libdir}/%{name}/lib \
	--datadir=%{_libdir}/%{name}/share \
	--mandir=%{_libdir}/%{name}/share/man \
	--disable-docs \
	--with-pkgversion=suse-%{version}-%{_arch}

make %{?_smp_mflags} V=1

%install
make %{?_smp_mflags} DESTDIR=%{buildroot} install

# Install desktop files.
install -d -m 755 %{buildroot}%{_libdir}/%{name}/share/{applications,pixmaps}
cp javaws.png %{buildroot}%{_libdir}/%{name}/share/pixmaps
for d in javaws itweb-settings policyeditor; do
   install -m 0644 $d.desktop %{buildroot}/%{_libdir}/%{name}/share/applications/
    %suse_update_desktop_file $d
done

# Compress manpages
for i in %{buildroot}%{_libdir}/%{name}/share/man/man1/*.1; do
   gzip -9 -n $i
done

%fdupes -s %{buildroot}

# needs for sle-11-sp1 and openSUSE evergreen
export NO_BRP_CHECK_BYTECODE_VERSION=true

# Create the alternatives files
mkdir -p %{buildroot}%{_sysconfdir}/alternatives/
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_datadir}/applications/
mkdir -p %{buildroot}%{_datadir}/pixmaps/
mkdir -p %{buildroot}%{_mandir}/man1/
mkdir -p %{buildroot}%{pluginsdir}
touch %{buildroot}%{_sysconfdir}/alternatives/javaplugin.so
touch %{buildroot}%{_sysconfdir}/alternatives/javaws
touch %{buildroot}%{_sysconfdir}/alternatives/javaws.desktop
touch %{buildroot}%{_sysconfdir}/alternatives/javaws.png
touch %{buildroot}%{_sysconfdir}/alternatives/itweb-settings
touch %{buildroot}%{_sysconfdir}/alternatives/itweb-settings.desktop
touch %{buildroot}%{_sysconfdir}/alternatives/policyeditor
touch %{buildroot}%{_sysconfdir}/alternatives/itweb-settings.1.gz
touch %{buildroot}%{_sysconfdir}/alternatives/javaws.1.gz
touch %{buildroot}%{_sysconfdir}/alternatives/policyeditor.1.gz
touch %{buildroot}%{_sysconfdir}/alternatives/policyeditor.desktop
ln -sf %{_sysconfdir}/alternatives/javaplugin.so %{buildroot}%{pluginsdir}/javaplugin.so
ln -sf %{_sysconfdir}/alternatives/javaws %{buildroot}%{_bindir}/javaws
ln -sf %{_sysconfdir}/alternatives/javaws.desktop %{buildroot}%{_datadir}/applications/javaws.desktop
ln -sf %{_sysconfdir}/alternatives/javaws.png %{buildroot}%{_datadir}/pixmaps/javaws.png
ln -sf %{_sysconfdir}/alternatives/itweb-settings %{buildroot}%{_bindir}/itweb-settings
ln -sf %{_sysconfdir}/alternatives/itweb-settings.desktop %{buildroot}%{_datadir}/applications/itweb-settings.desktop
ln -sf %{_sysconfdir}/alternatives/policyeditor %{buildroot}%{_bindir}/policyeditor
ln -sf %{_sysconfdir}/alternatives/javaws.1.gz %{buildroot}%{_mandir}/man1/javaws.1.gz
ln -sf %{_sysconfdir}/alternatives/itweb-settings.1.gz %{buildroot}%{_mandir}/man1/itweb-settings.1.gz
ln -sf %{_sysconfdir}/alternatives/policyeditor.desktop %{buildroot}%{_datadir}/applications/policyeditor.desktop
ln -sf %{_sysconfdir}/alternatives/policyeditor.1.gz %{buildroot}%{_mandir}/man1/policyeditor.1.gz

%post
update-alternatives \
  --install %{pluginsdir}/javaplugin.so %{javaplugin} \
  %{pluginpath}/%{pluginname} %{priority} \
  --slave %{_bindir}/javaws javaws %{_libdir}/%{name}/bin/javaws \
  --slave %{_datadir}/applications/javaws.desktop javaws.desktop \
  %{_libdir}/%{name}/share/applications/javaws.desktop \
  --slave %{_datadir}/pixmaps/javaws.png javaws.png \
  %{_libdir}/%{name}/share/pixmaps/javaws.png \
  --slave %{_bindir}/itweb-settings itweb-settings %{_libdir}/%{name}/bin/itweb-settings \
  --slave %{_datadir}/applications/itweb-settings.desktop itweb-settings.desktop \
  %{_libdir}/%{name}/share/applications/itweb-settings.desktop \
  --slave %{_bindir}/policyeditor policyeditor %{_libdir}/%{name}/bin/policyeditor \
  --slave %{_datadir}/applications/policyeditor.desktop policyeditor.desktop \
  %{_libdir}/%{name}/share/applications/policyeditor.desktop \
  --slave %{_mandir}/man1/javaws.1.gz javaws.1.gz \
  %{_libdir}/%{name}/share/man/man1/javaws.1.gz \
  --slave %{_mandir}/man1/itweb-settings.1.gz itweb-settings.1.gz \
  %{_libdir}/%{name}/share/man/man1/itweb-settings.1.gz \
  --slave %{_mandir}/man1/policyeditor.1.gz policyeditor.1.gz \
  %{_libdir}/%{name}/share/man/man1/policyeditor.1.gz

%postun
if [ $1 -eq 0 ]; then
update-alternatives --remove %{javaplugin} \
    %{pluginpath}/%{pluginname}
fi

%files
%defattr(-,root,root,-)
%doc NEWS README COPYING
%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/bin
%dir %{_libdir}/%{name}/lib
%dir %{_libdir}/%{name}/share
%dir %{_libdir}/%{name}/share/applications
%dir %{_libdir}/%{name}/share/icedtea-web
%dir %{_libdir}/%{name}/share/man
%dir %{_libdir}/%{name}/share/man/man1
%dir %{_libdir}/%{name}/share/pixmaps
%ghost %{_sysconfdir}/alternatives/javaplugin.so
%ghost %{_sysconfdir}/alternatives/javaws
%ghost %{_sysconfdir}/alternatives/javaws.desktop
%ghost %{_sysconfdir}/alternatives/javaws.png
%ghost %{_sysconfdir}/alternatives/itweb-settings
%ghost %{_sysconfdir}/alternatives/itweb-settings.desktop
%ghost %{_sysconfdir}/alternatives/policyeditor
%ghost %{_sysconfdir}/alternatives/itweb-settings.1.gz
%ghost %{_sysconfdir}/alternatives/javaws.1.gz
%ghost %{_sysconfdir}/alternatives/policyeditor.1.gz
%ghost %{_sysconfdir}/alternatives/policyeditor.desktop
%{_bindir}/itweb-settings
%{_bindir}/javaws
%{_bindir}/policyeditor
%{pluginsdir}/javaplugin.so
%{_datadir}/applications/itweb-settings.desktop
%{_datadir}/applications/javaws.desktop
%{_datadir}/applications/policyeditor.desktop
%{_datadir}/pixmaps/javaws.png
%{_mandir}/man1/itweb-settings.1.gz
%{_mandir}/man1/javaws.1.gz
%{_mandir}/man1/policyeditor.1.gz
%{_libdir}/%{name}/bin/itweb-settings
%{_libdir}/%{name}/bin/javaws
%{_libdir}/%{name}/bin/policyeditor
%{pluginpath}/%{pluginname}
%{_libdir}/%{name}/share/applications/itweb-settings.desktop
%{_libdir}/%{name}/share/applications/javaws.desktop
%{_libdir}/%{name}/share/applications/policyeditor.desktop
%{_libdir}/%{name}/share/pixmaps/javaws.png
%{_libdir}/%{name}/share/icedtea-web/javaws_splash.png
%{_libdir}/%{name}/share/icedtea-web/netx.jar
%{_libdir}/%{name}/share/icedtea-web/plugin.jar
%{_libdir}/%{name}/share/man/man1/*.1*
%exclude %{_libdir}/%{name}/share/man/*/man1

%changelog