%global project vsmartcard

Name:		virtualsmartcard
Version:	0.9
Release:	2%{?dist}
Summary:	Virtual Smart Card

License:	GPLv3
URL:		https://github.com/frankmorgner/%{project}/tree/master/%{name}
Source0:	https://github.com/frankmorgner/%{project}/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz
Patch0:		%{name}-0.7-prefix.patch

BuildRequires:	pcsc-lite-devel
BuildRequires:	help2man
BuildRequires:	check
BuildRequires:	python3-devel
BuildRequires:	gcc
BuildRequires:	autoconf
BuildRequires:	automake
BuildRequires:	libtool
# The main package needs vpcd, but vpcd can work with other tools
Requires: vpcd = %{version}-%{release}


%description
Virtual Smart Card emulates a smart card and makes it accessible through PC/SC.

%package -n vpcd
Summary: Virtual smart card reader.

%description -n vpcd
Virtual smart card reader to be used for smart card emulation vith
virtualsmartcard (vicc).

%prep
%setup -q  -n %{name}-%{version}
# The deprecated patchN is needed for RHEL 7 compatibility
%patch0 -p1 -b .prefix
# Inconsistent indentation
#sed -i 's/\t/        /g' src/vpicc/virtualsmartcard/CardGenerator.py


%build
%if 0%{?rhel} == 7
sed -i -e 's/vpicc//g' src/Makefile.am
%endif

# This is outdated and does not work in c10s
# https://github.com/frankmorgner/vsmartcard/issues/274
rm py-compile
autoreconf -vis
autoconf
%configure --enable-serialconfdir=/etc/reader.conf.d
make %{?_smp_mflags}

%if 0%{?rhel} != 7
# shebang ...
sed -ie 's|^#! /usr/bin/python$|#! /usr/bin/python3|' src/vpicc/vicc
%endif

%install
%make_install V=1


%files
%if 0%{?rhel} != 7
%{_bindir}/vicc
%{python3_sitelib}/%{name}/*
%{_mandir}/man1/vicc.1*
%endif

%files -n vpcd
%license COPYING
%{_bindir}/vpcd-config
%{_libdir}/pcsc/drivers/serial/libifdvpcd.so
%{_libdir}/pcsc/drivers/serial/libifdvpcd.so.0.*
%config(noreplace) %{_sysconfdir}/reader.conf.d/vpcd




%changelog
* Thu Apr 25 2024 Jakub Jelen <jjelen@redhat.com> - 0.9-2
- Remove and reinstall py-compile to avoid issues on c10s with new python

* Tue Apr 16 2024 Jakub Jelen <jjelen@redhat.com> - 0.9-1
- New upstream release

* Wed Apr 19 2023 Jakub Jelen <jjelen@redhat.com> - 0.8-5
- Rebuild

* Wed Jun 01 2022 Jakub Jelen <jjelen@redhat.com> - 0.8-4
- RHEL 7 compatibility

* Tue Dec 21 2021 Jakub Jelen <jjelen@redhat.com> - 0.8-3
- Rebuild for EPEL9

* Mon Oct 11 2021 Jakub Jelen <jjelen@redhat.com> - 0.8-2
- Python rebuild

* Sat May 01 2021 Jakub Jelen <jjelen@redhat.com> - 0.8-1
- Finally new upstream release

* Thu May 14 2020 Jakub Jelen <jjelen@redhat.com> - 0.7-2
- Separate python subpackage to avoid Python 2 dependency on reader installation

* Tue Jan 29 2019 Jakub Jelen <jjelen@redhat.com> - 0.7-1
- Initial release