Blob Blame Raw
%global commit 19796b19b3f1eff5513e2299cf8dfe918f93eb56
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           openstv
Version:        1.7
Release:        14%{?dist}
Summary:        Single transferable vote and instant runoff voting software

License:        GPLv2+
URL:            https://github.com/OpenTechStrategies/%{name}
Source0:        https://github.com/OpenTechStrategies/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz
Source1:        openstv
Source2:        openstv-run-election
Source3:        openstv.1
Source4:        openstv-run-election.1
Source5:        openstv.desktop
Source6:        openstv.appdata.xml
# Install icons, image and HTML documentation used by the application
Patch0:	        openstv-1.7-setup-package-data.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1185599
Patch1:	        openstv-1.7-wxpython3.0.patch

BuildArch:      noarch
BuildRequires:  desktop-file-utils
BuildRequires:  icoutils
BuildRequires:  python2-devel
BuildRequires:  /usr/bin/appstream-util
Requires:       hicolor-icon-theme
Requires:       wxPython

%description
OpenSTV is an open-source software for implementing the single transferable
vote and other voting methods such as instant runoff voting, Condorcet voting,
and approval voting. OpenSTV is the only open-source software that implements
the single transferable vote exactly as used by governments, including Scotland
and the City of Cambridge, Massachusetts. These methods have been extensively
verified against other software and/or actual election results.

Organizations can use OpenSTV to implement their own elections. First, the
organization must adopt a voting method. Second, the organization must conduct
the vote, and this will most likely be done with paper ballots. Third, the
ballots must be entered into the OpenSTV program. Finally, you can use OpenSTV
to count the votes and determine the winners of the election.

%prep
%setup -q -n %{name}-%{commit}
sed -i 's:#!/usr/bin/env python:# Run openstv instead:' openstv/OpenSTV.py
sed -i 's:#!/usr/bin/env python:# Run openstv-run-election instead:' openstv/runElection.py
%patch0 -p1
%patch1 -p1
icotool --extract --index=7 openstv/Icons/pie.ico
mv pie_7_48x48x32.png %{name}.png


%build
%{__python2} setup.py build


%install
%{__python2} setup.py install --root=%{buildroot}
install -Dpm 0755 %{SOURCE1} %{buildroot}%{_bindir}/openstv
install -pm 0755 %{SOURCE2} %{buildroot}%{_bindir}/openstv-run-election
install -Dpm 0644 %{SOURCE3} %{buildroot}%{_mandir}/man1/openstv.1
install -pm 0644 %{SOURCE4} %{buildroot}%{_mandir}/man1/openstv-run-election.1
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE5}
install -Dpm 0644 %{name}.png %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
install -Dpm 0644 %{SOURCE6} %{buildroot}%{_datadir}/appdata/%{name}.appdata.xml
ln -sf %{python2_sitelib}/%{name}/License.html License.html


%check
appstream-util validate-relax --nonet %{buildroot}/%{_datadir}/appdata/%{name}.appdata.xml

%files
%doc CHANGELOG.txt License.html README.md
%{_bindir}/%{name}*
%{python2_sitelib}/%{name}/
%{python2_sitelib}/OpenSTV-%{version}-*.egg-info
%{_mandir}/man1/%{name}*.1*
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/48x48/apps/%{name}.png



%changelog
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Wed Feb 13 2019 David King <amigadave@amigadave.com> - 1.7-13
- Use python2 in shebangs (#1675591)

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-7
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sun Jan 25 2015 David King <amigadave@amigadave.com> - 1.7-4
- Apply patch from Debian to run with wxPython 3.0 (#1185599)

* Thu Jan 08 2015 David King <amigadave@amigadave.com> - 1.7-3
- Validate AppData in check
- Update man page glob in files section

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Mon May 19 2014 David King <amigadave@amigadave.com> - 1.7-1
- Initial import (#1076186)