File openct.spec of Package openct

#
# spec file for package openct (Version 0.6.17)
#
# Copyright (c) 2009 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:           openct
Version:        0.6.17
Release:        2
BuildRequires:  db-devel doxygen krb5-devel libusb-devel licenses openldap2-devel pcsc-lite-devel pkg-config
# NOTE: We prefer multiple RPM directory ownership here, because
# dependency on hal increases bootstrap build time.
#BuildRequires:  hal
PreReq:         %insserv_prereq %fillup_prereq
Group:          Productivity/Security
License:        BSD 3-clause (or similar) ; LGPL v2.1 or later
Url:            http://www.opensc-project.org/openct/
Summary:        OpenCT Tools for Smart Card Readers
Source:         %{name}-%{version}.tar.bz2
Source2:        README.SUSE
Patch1:         %{name}-init.patch
Patch5:         %{name}-old-hal.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       licenses
# bug437293
%ifarch ppc64
Obsoletes:      openct-64bit
%endif
## Only for directory ownership:
#Requires:       hal
# Existed up to 10.2, maintained in SLES9:
Provides:       pcsc-etoken <= 0.3.2
Obsoletes:      pcsc-etoken <= 0.3.2
%define ifddir %(pkg-config libpcsclite --variable=usbdropdir)
%define USER	scard
%define GROUP	scard
%define LBRACE (
%define RBRACE )
%define QUOTE "
%define BACKSLASH \\
%define USBDRIVERS %(set -x ; bunzip2 <%{S:0} | sed -n 's/^ENV{MODALIAS}==%{QUOTE}%{BACKSLASH}%{LBRACE}usb:[^{QUOTE}]*%{BACKSLASH}%{RBRACE}%{BACKSLASH}*%{QUOTE}.*$/modalias%{LBRACE}%{BACKSLASH}1d*dc*dsc*dp*ic*isc*ip*%{RBRACE}/p' | tr '%{BACKSLASH}n' ' ')
# We are not using Supplements here. User may want to choose between openct and pcsc-lite:
Enhances:       %USBDRIVERS
# Generic CCID devices:
Enhances:       modalias(usb:*ic0Bisc00d*dc*dsc*dp*ic*isc*ip*)

%description
OpenCT is a set of library and tools to talk to smart card readers.
OpenCT is used by the OpenSC Smart Card library.

For a list of supported readers, please read documentation in
/usr/share/doc/packages/openct/wiki/index.html - some readers may be
supported only with particular firmware or particular connection type.

There are other packages that may support your reader in a different
way. Name of all these packages starts with "pcsc-".



Authors:
--------
    Olaf Kirch <okir@suse.de>
    Andreas Jellinghaus <aj@dungeon.inka.de>

%package -n libopenct1
License:        BSD 3-clause (or similar) ; LGPL v2.1 or later
Group:          System/Libraries
Summary:        OpenCT Library for Smart Card Readers
# bug437293
%ifarch ppc64
Obsoletes:      openct-64bit
%endif

%description -n libopenct1
OpenCT is a set of library and tools to talk to smart card readers.
OpenCT is used by the OpenSC Smart Card library.

For a list of supported readers, please read documentation in
/usr/share/doc/packages/openct/wiki/index.html - some readers may be
supported only with particular firmware or particular connection type.

There are other packages that may support your reader in a different
way. Name of all these packages starts with "pcsc-".



Authors:
--------
    Olaf Kirch <okir@suse.de>
    Andreas Jellinghaus <aj@dungeon.inka.de>

%package -n pcsc-openct
License:        BSD 3-clause (or similar) ; LGPL v2.1 or later
Group:          Productivity/Security
Summary:        PC/SC IFD Handler for OpenCT Smart Card Drivers

%description -n pcsc-openct
PC/SC Connector for OpenCT. It allows to use any of OpenCT Smart Card
drivers with the PCSC-Lite daemon from the pcsc-lite package.

OpenCT is a set of library and tools to talk to smart card readers.
OpenCT is used by the OpenSC Smart Card library.

For a list of supported readers, please read documentation in
/usr/share/doc/packages/openct/wiki/index.html - some readers may be
supported only with particular firmware or particular connection type.

There are other packages that may support your reader in a different
way. Name of all these packages starts with "pcsc-".



Authors:
--------
    Olaf Kirch <okir@suse.de>
    Andreas Jellinghaus <aj@dungeon.inka.de>

%package devel
License:        BSD 3-clause (or similar) ; LGPL v2.1 or later
Group:          Development/Libraries/C and C++
Summary:        OpenCT Library for Smart Card Readers
Requires:       libopenct1 = %{version} glibc-devel
# bug437293
%ifarch ppc64
Obsoletes:      openct-devel-64bit
%endif
#

%description devel
OpenCT is a set of library and tools to talk to smart card readers.
OpenCT is used by the OpenSC Smart Card library.

For a list of supported readers, please read documentation in
/usr/share/doc/packages/openct/wiki/index.html - some readers may be
supported only with particular firmware or particular connection type.

There are other packages that may support your reader in a different
way. Name of all these packages starts with "pcsc-".



Authors:
--------
    Olaf Kirch <okir@suse.de>
    Andreas Jellinghaus <aj@dungeon.inka.de>

%prep
%setup -q -n %{name}-%{version}
cp -a %{S:2} .
%patch1
%if %suse_version <= 1030
# Patch and sed script converts fdi file to the new hal syntax:
%patch5
%endif
sed -i 's/@USER@/%{USER}/g;s/@GROUP@/%{GROUP}/g' etc/openct.hald.in etc/init-script.in

%build
%if %suse_version > 1110
ACLOCAL="aclocal -I m4" autoreconf -f -i
%endif
%configure\
	--docdir=%{_docdir}/%{name}\
	--disable-static\
	--enable-doc\
	--enable-api-doc\
	--enable-usb\
	--enable-pcsc\
	--enable-non-privileged\
	--with-daemon-user=%{USER}\
	--with-daemon-groups=%{GROUP}\
	--with-bundle=%{ifddir}\
	--with-ifddir=%{ifddir}
# FIXME: Fix PCMCIA and serial readers hotplug.
# udev scripts are outdated, HAL rules don't exist yet:
# --with-udev=%{_sysconfdir}/udev/rules.d\
make %{?jobs:-j%jobs}

%install
%makeinstall
#
# HAL stuff
mkdir -p $RPM_BUILD_ROOT%{_datadir}/hal/fdi/information/10freedesktop
mkdir -p $RPM_BUILD_ROOT%{_datadir}/hal/fdi/policy/10osvendor
cp etc/openct.fdi $RPM_BUILD_ROOT%{_datadir}/hal/fdi/information/10freedesktop/10-usb-openct.fdi
cp etc/openct-policy.fdi $RPM_BUILD_ROOT%{_datadir}/hal/fdi/policy/10osvendor/10-usb-openct.fdi
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/hal
install etc/openct.hald $RPM_BUILD_ROOT%{_libexecdir}/hal/hald-addon-openct
#
# Create directory
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/openct
# NOTE: Example in the source recommends 750, but this value allows
# access only to dedicated users and root.
chmod 0755 $RPM_BUILD_ROOT%{_localstatedir}/run/openct
#
# Install init script
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d
install etc/init-script $RPM_BUILD_ROOT%{_sysconfdir}/init.d/openct
ln -s ../..%{_sysconfdir}/init.d/openct $RPM_BUILD_ROOT%{_sbindir}/rcopenct
#
# Copy the rest of documentation
cp LGPL-2.1 README.SUSE TODO doc/nonpersistent/ChangeLog etc/openct-disable.fdi $RPM_BUILD_ROOT%{_docdir}/%{name}
# And remove pointless .la file
rm $RPM_BUILD_ROOT%{_libdir}/libopenct.la

%pre
usr/sbin/groupadd -r -o %{GROUP} 2>/dev/null || :
usr/sbin/useradd -r -o -g %{GROUP} -s /bin/false -c "Smart Card Reader" -d /sbin %{USER} 2>/dev/null || :

%preun
%{stop_on_removal openct}

%post
# Remove possible orphans created by openct<=0.6.15 before openct-status-lock-orphans.patch (openSUSE <= 11.1, SLE <= 11):
rm -f %{_localstatedir}/run/openct/status.lock.*
# Fix possible old ownership (openSUSE <= 11.1, SLE <= 11):
chown -R %{USER}:%{GROUP} %{_localstatedir}/run/openct
# Fix possible bad permissions (openSUSE < 11.1, SLE < 11):
chmod 0755 %{_localstatedir}/run/openct
%{fillup_and_insserv -y openct}

%postun
%{restart_on_update openct}
%{insserv_cleanup}

%post -n libopenct1 -p /sbin/ldconfig

%postun -n libopenct1 -p /sbin/ldconfig

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc %dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/ChangeLog
%doc %{_docdir}/%{name}/LGPL-2.1
%doc %{_docdir}/%{name}/NEWS
%doc %{_docdir}/%{name}/README
%doc %{_docdir}/%{name}/README.SUSE
%doc %{_docdir}/%{name}/TODO
%doc %{_docdir}/%{name}/openct-disable.fdi
%doc %{_docdir}/%{name}/wiki
%{_bindir}/*
%{_datadir}/hal/fdi/information/10freedesktop/10-usb-openct.fdi
%{_datadir}/hal/fdi/policy/10osvendor/10-usb-openct.fdi
%dir %attr(-,%{USER},%{GROUP}) %{_localstatedir}/run/openct
%{_libexecdir}/hal/hald-addon-*
%doc %{_mandir}/man?/*.*
%{_sbindir}/*
%{_sysconfdir}/init.d/openct
%config(noreplace) %{_sysconfdir}/openct.conf
# NOTE: These directories logically belong to hal.
# To prevent dependency on hal, add it to the file list.
%dir %{_datadir}/hal
%dir %{_datadir}/hal/fdi
%dir %{_datadir}/hal/fdi/information
%dir %{_datadir}/hal/fdi/information/10freedesktop
%dir %{_libexecdir}/hal

%files -n libopenct1
%defattr(-,root,root)
%{_libdir}/*.so.*

%files -n pcsc-openct
%defattr(-,root,root)
%{ifddir}/openct-ifd.bundle

%files devel
%defattr(-,root,root)
%doc %{_docdir}/%{name}/api
%{_includedir}/openct
%{_libdir}/*.so
%{_libdir}/*.*a
%{_libdir}/pkgconfig/libopenct.pc

%changelog
openSUSE Build Service is sponsored by