File openCryptoki.spec of Package openCryptoki

#
# spec file for package openCryptoki (Version 2.2.6)
#
# Copyright (c) 2010 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

%define openCryptoki_32bit_arch %ix86 s390 ppc %arm
# support in the workings for: ppc64
# no support in sight for: ia64
%define openCryptoki_64bit_arch s390x ppc64 x86_64
# autobuild:/work/cd/lib/misc/group
#   openCryptoki    pkcs11:x:64:
%define pkcs11_group_id 64
%define oc_cvs_tag opencryptoki-%{version}

Name:           openCryptoki
BuildRequires:  gcc-c++ libica openssl-devel pwdutils
Summary:        An Implementation of PKCS#11 (Cryptoki) v2.11 for IBM Cryptographic Hardware
Version:        2.2.6
Release:        17
License:        IBM PL
Group:          Productivity/Security
# :pserver:anonymous@cvs.sourceforge.net:/cvsroot/opencryptoki
# cvs co -r openCryptoki-2-1-5 -d openCryptoki-2-1-5 .
Source:         %{oc_cvs_tag}.tar.bz2
Source1:        openCryptoki.pkcsslotd
Source2:        openCryptoki-TFAQ.html
Patch1:         ocki-2.2.6-PIN-backspace.patch
Url:            http://oss.software.ibm.com/developerworks/opensource/opencryptoki
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         /usr/sbin/groupadd /usr/bin/id /usr/sbin/usermod /bin/sed
# IBM maintains openCryptoki on these architectures:
ExclusiveArch:  %openCryptoki_32bit_arch %openCryptoki_64bit_arch
#

%description
The PKCS#11 version 2.11 API implemented for the IBM cryptographic
cards. This package includes support for the IBM 4758 cryptographic
coprocessor (with the PKCS#11 firmware loaded) and the IBM eServer
Cryptographic Accelerator (FC 4960 on pSeries).



%package devel
License:        IBM PL
Summary:        An Implementation of PKCS#11 (Cryptoki) v2.01 for IBM Cryptographic Hardware
Group:          Development/Languages/C and C++
Requires:       openCryptoki = %{version}-%{release}, glibc-devel, openssl-devel

%description devel
The PKCS#11 version 2.01 API implemented for the IBM cryptographic
cards. This package includes support for the IBM 4758 cryptographic
co-processor (with the PKCS#11 firmware loaded) and the IBM eServer
Cryptographic Accelerator (FC 4960 on pSeries).



%ifarch %openCryptoki_32bit_arch

%package 32bit
License:        IBM PL
Summary:        An Implementation of PKCS#11 (Cryptoki) v2.11 for IBM Cryptographic Hardware
Group:          Productivity/Security
# this is needed to make sure the pkcs11 group exists before
# installation:
PreReq:         openCryptoki
ExclusiveArch:  %openCryptoki_32bit_arch

%description 32bit
This is a re-packaged binary rpm. For the package source, please look
for the source of the package without the "32bit" ending

The PKCS#11 version 2.11 API implemented for the IBM cryptographic
cards. This package includes support for the IBM 4758 cryptographic
coprocessor (with the PKCS#11 firmware loaded) and the IBM eServer
Cryptographic Accelerator (FC 4960 on pSeries).



%endif
%ifarch %openCryptoki_64bit_arch

%package 64bit
License:        IBM PL
Summary:        An Implementation of PKCS#11 (Cryptoki) v2.11 for IBM Cryptographic Hardware
Group:          Productivity/Security
# this is needed to make sure the pkcs11 group exists before
# installation:
PreReq:         openCryptoki
ExclusiveArch:  %openCryptoki_64bit_arch

%description 64bit
This is a re-packaged binary rpm. For the package source, please look
for the source of the package without the "64bit" ending

The PKCS#11 version 2.11 API implemented for the IBM cryptographic
cards. This package includes support for the IBM 4758 cryptographic
coprocessor (with the PKCS#11 firmware loaded) and the IBM eServer
Cryptographic Accelerator (FC 4960 on pSeries).



%endif

%prep
%setup -q -n %{oc_cvs_tag}
cp %{SOURCE2} .
%patch1

%build
autoreconf --force --install
CFLAGS="$RPM_OPT_FLAGS -D__USE_BSD" ./configure --prefix=/usr --libdir=%{_libdir} --enable-tpmtok
make

%install
make install DESTDIR=$RPM_BUILD_ROOT INSROOT=$RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT/usr/include
install -d $RPM_BUILD_ROOT/var/lib/opencryptoki
install -d $RPM_BUILD_ROOT/etc/init.d
install -d $RPM_BUILD_ROOT/usr/sbin
install -m 544 %{S:1} $RPM_BUILD_ROOT/etc/init.d/pkcsslotd
ln -sfv ../../etc/init.d/pkcsslotd $RPM_BUILD_ROOT/usr/sbin/rcpkcsslotd
rm -rf $RPM_BUILD_ROOT/tmp
# Remove all development files
rm -f $RPM_BUILD_ROOT${_libdir}/opencryptoki/libopencryptoki.la
rm -f $RPM_BUILD_ROOT/%_libdir/opencryptoki/methods

%pre
# autobuild:/work/cd/lib/misc/group
# openCryptoki    pkcs11:x:64:
/usr/sbin/groupadd -g %pkcs11_group_id -o -r pkcs11 2>/dev/null || true
# add root to group pkcs11 to enable root to run pkcsconf
/usr/sbin/usermod -G $(/usr/bin/id --groups --name root | /bin/sed \
-e 's/root//' -e '
# add the pkcs group if it is missing
/(^| )pkcs11( |$)/!s/$/ pkcs11/
# replace spaces by commas
y/ /,/
'),pkcs11  root

%post
# Symlink from /var/lib/opencryptoki to /etc/pkcs11
if [ ! -L %{_sysconfdir}/pkcs11 ] ; then
	if [ -e %{_sysconfdir}/pkcs11/pk_config_data ] ; then
		mv %{_sysconfdir}/pkcs11/* %{_localstatedir}/lib/opencryptoki
		cd %{_sysconfdir} && rm -rf pkcs11 && \
			ln -sf %{_localstatedir}/lib/opencryptoki pkcs11
	fi
fi
/sbin/ldconfig

%postun
if [ -L %{_sysconfdir}/pkcs11 ] ; then
	rm %{_sysconfdir}/pkcs11
fi
%ifarch %openCryptoki_32bit_arch

%postun 32bit
# remove the openCryptoki start script
%{insserv_cleanup}

%post 32bit
# Old library name links
cd %{_libdir}/opencryptoki && ln -sf ./libopencryptoki.so PKCS11_API.so
ln -sf %{_sbindir} %{_libdir}/opencryptoki/methods
rm -rf %{_libdir}/pkcs11/stdll
if [ -d %{_libdir}/pkcs11 ] ; then
    cd %{_libdir}/pkcs11
    ln -sf ../opencryptoki/stdll stdll
    cd stdll
    [ -f libpkcs11_ica.so ] && ln -sf ./libpkcs11_ica.so PKCS11_ICA.so || true
    [ -f libpkcs11_sw.so ] && ln -sf ./libpkcs11_sw.so PKCS11_SW.so || true
fi
/sbin/ldconfig
%endif
%ifarch %openCryptoki_64bit_arch

%post 64bit
# Old library name for 64bit libs were under /usr/lib/pkcs11. For migration purposes only.
test -d /usr/lib/pkcs11 || mkdir -p /usr/lib/pkcs11
ln -sf %{_libdir}/opencryptoki/libopencryptoki.so /usr/lib/pkcs11/PKCS11_API.so64
/sbin/ldconfig
%endif

%files
%defattr(-,root,root)
%doc openCryptoki-TFAQ.html
  # configuration directory
%dir %attr(755,root,pkcs11) /var/lib/opencryptoki
/etc/init.d/pkcsslotd
/usr/sbin/rcpkcsslotd
  # utilities
/usr/sbin/pkcsslotd
/usr/sbin/pkcs11_startup
/usr/sbin/pkcsconf
/usr/sbin/pkcs_slot
%dir %{_libdir}/opencryptoki
%dir %{_libdir}/opencryptoki/stdll
%{_mandir}/man*/*

%files devel
%defattr(-,root,root)
%dir %{_libdir}/opencryptoki
%dir %{_libdir}/opencryptoki/stdll
%{_libdir}/opencryptoki/*.la
%{_libdir}/opencryptoki/stdll/*.la
%{_includedir}/opencryptoki
%ifarch %openCryptoki_32bit_arch

%files 32bit
%defattr(-,root,root)
  # these don't conflict because they only exist as 64bit binaries if
  # there is no 32bit version of them usable
%{_libdir}/opencryptoki/libopencryptoki.so
%ghost %{_libdir}/opencryptoki/PKCS11_API.so
%{_libdir}/opencryptoki/*.0
%ifnarch s390 s390x
%{_libdir}/opencryptoki/stdll/libpkcs11_sw.so
%ghost %{_libdir}/opencryptoki/stdll/PKCS11_SW.so
%else
%{_libdir}/opencryptoki/stdll/libpkcs11_ica.so
%ghost %{_libdir}/opencryptoki/stdll/PKCS11_ICA.so
%endif
%{_libdir}/opencryptoki/stdll/*.0
%dir %{_libdir}/pkcs11
%ghost %{_libdir}/pkcs11/stdll
%ghost %{_libdir}/pkcs11/methods
%{_libdir}/pkcs11/*.so
# %{_libdir}/libopencryptoki.so
# %{_libdir}/libopencryptoki.so.0
%{_sysconfdir}/ld.so.conf.d/*
%endif
%ifarch %openCryptoki_64bit_arch

%files 64bit
%defattr(-,root,root)
%dir %_libdir/opencryptoki
%{_libdir}/opencryptoki/*.so
%{_libdir}/opencryptoki/*.0
%dir %_libdir/opencryptoki/stdll
%{_libdir}/opencryptoki/stdll/*.so
%{_libdir}/opencryptoki/stdll/*.0
%{_libdir}/pkcs11
# %{_libdir}/libopencryptoki.so
# %{_libdir}/libopencryptoki.so.0
%{_sysconfdir}/ld.so.conf.d/*
%{_mandir}/man*/*
%endif

%changelog
openSUSE Build Service is sponsored by