bouncycastle/bouncycastle.spec

188 lines
5.8 KiB
RPMSpec

#
# spec file for package bouncycastle
#
# Copyright (c) 2012 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/
#
%define ver 1.46
%define archivever jdk16-%(echo %{ver}|sed 's|\\\.||')
%define classname org.bouncycastle.jce.provider.BouncyCastleProvider
%define _mavenpomdir %{_datadir}/maven2/poms
Summary: Bouncy Castle Crypto Package for Java
License: MIT
Group: Development/Libraries/Java
Name: bouncycastle
Version: %{ver}
Release: 0
Url: http://www.%{name}.org/
# Original source http://www.bouncycastle.org/download/bcprov-%{archivever}.tar.gz
# is modified to
# bcprov-%{archivever}-FEDORA.tar.gz with patented algorithms removed.
# Specifically: IDEA algorithms got removed.
Source0: bcprov-%{archivever}-FEDORA.tar.gz
#Source1: http://repo2.maven.org/maven2/org/bouncycastle/bcprov-jdk16/%{version}/bcprov-jdk16-%{version}.pom
Source1: bcprov-jdk16-%{version}.pom
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: jpackage-utils >= 1.5
Requires(post): jpackage-utils >= 1.7
Requires(postun): jpackage-utils >= 1.7
BuildArch: noarch
BuildRequires: java-devel
BuildRequires: unzip
Requires: java
BuildRequires: junit4
Provides: bcprov = %{version}-%{release}
%description
The Bouncy Castle Crypto package is a Java implementation of cryptographic
algorithms. The package is organised so that it contains a light-weight API
suitable for use in any environment (including the newly released J2ME) with
the additional infrastructure to conform the algorithms to the JCE framework.
%package javadoc
Summary: Javadoc for %{name}
Group: Development/Libraries/Java
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
Requires: jpackage-utils
%description javadoc
API documentation for the %{name} package.
%prep
%setup -q -n bcprov-%{archivever}
# Remove provided binaries
find . -type f -name "*.class" -exec rm -f {} \;
find . -type f -name "*.jar" -exec rm -f {} \;
mkdir src
unzip -qq src.zip -d src/
%build
pushd src
export CLASSPATH=$(build-classpath junit4)
%javac -g -target 1.5 -encoding UTF-8 $(find . -type f -name "*.java")
jarfile="../bcprov-%{version}.jar"
# Exclude all */test/* files except org.bouncycastle.util.test, cf. upstream
files="$(find . -type f \( -name '*.class' -o -name '*.properties' \) -not -path '*/test/*')"
files="$files $(find . -type f -path '*/org/bouncycastle/util/test/*.class')"
files="$files $(find . -type f -path '*/org/bouncycastle/jce/provider/test/*.class')"
files="$files $(find . -type f -path '*/org/bouncycastle/ocsp/test/*.class')"
test ! -d classes && mf="" \
|| mf="`find classes/ -type f -name "*.mf" 2>/dev/null`"
test -n "$mf" && jar cvfm $jarfile $mf $files \
|| %jar cvf $jarfile $files
popd
%install
install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/java/security/security.d
touch $RPM_BUILD_ROOT%{_sysconfdir}/java/security/security.d/2000-%{classname}
# install bouncy castle provider
install -dm 755 $RPM_BUILD_ROOT%{_javadir}
install -pm 644 bcprov-%{version}.jar \
$RPM_BUILD_ROOT%{_javadir}/bcprov-%{version}.jar
pushd $RPM_BUILD_ROOT%{_javadir}
ln -sf bcprov-%{version}.jar bcprov.jar
popd
# javadoc
mkdir -p $RPM_BUILD_ROOT%{_javadocdir}/%{name}
cp -pr docs/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}
# maven pom
install -dm 755 $RPM_BUILD_ROOT%{_mavenpomdir}
install -pm 644 %{SOURCE1} $RPM_BUILD_ROOT%{_mavenpomdir}/JPP-bcprov.pom
%add_to_maven_depmap org.bouncycastle bcprov-jdk16 %{version} JPP bcprov
%check
pushd src
export CLASSPATH=$PWD:$(build-classpath junit4)
for test in $(find . -name AllTests.class) ; do
test=${test#./} ; test=${test%.class} ; test=${test//\//.}
# TODO: failures; get them fixed and remove || :
%java org.junit.runner.JUnitCore $test || :
done
popd
%post
{
# Rebuild the list of security providers in classpath.security
suffix=security/classpath.security
secfiles="/usr/lib/$suffix /usr/lib64/$suffix"
for secfile in $secfiles
do
# check if this classpath.security file exists
[ -f "$secfile" ] || continue
sed -i '/^security\.provider\./d' "$secfile"
count=0
for provider in $(ls /etc/java/security/security.d)
do
count=$((count + 1))
echo "security.provider.${count}=${provider#*-}" >> "$secfile"
done
done
} || :
%update_maven_depmap
%postun
if [ $1 -eq 0 ] ; then
{
# Rebuild the list of security providers in classpath.security
suffix=security/classpath.security
secfiles="/usr/lib/$suffix /usr/lib64/$suffix"
for secfile in $secfiles
do
# check if this classpath.security file exists
[ -f "$secfile" ] || continue
sed -i '/^security\.provider\./d' "$secfile"
count=0
for provider in $(ls /etc/java/security/security.d)
do
count=$((count + 1))
echo "security.provider.${count}=${provider#*-}" >> "$secfile"
done
done
} || :
fi
%update_maven_depmap
%files
%defattr(0644,root,root,0755)
%doc *.html
%{_javadir}/bcprov.jar
%{_javadir}/bcprov-%{version}.jar
%{_javadir}/*
%{_sysconfdir}/java/*
%{_mavenpomdir}/JPP-bcprov.pom
%config %{_mavendepmapfragdir}/%{name}
%dir /usr/share/maven2
%files javadoc
%defattr(0644,root,root,0755)
%{_javadocdir}/%{name}/
%changelog