File gridcoinresearch.spec of Package gridcoin

#
# spec file for package gridcoin
#
# Copyright (c) 2014-2015 Matthias Bach <marix@marix.org>
#
# 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/
#

Name:           gridcoinresearch
Version:        4.0.5.0.ddaaf8d5a
Release:        0
Summary:        P2P Digital Currency
License:        MIT
Group:          Productivity/Networking/Other
Url:            http://www.gridcoin.us
Source:         %{name}-%{version}.tar.xz
Source2:        %{name}d.service
Source3:        %{name}d.firewall
Source4:        %{name}d.conf
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
%if 0%{?suse_version} >= 1500
BuildRequires:  libboost_chrono-devel
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_iostreams-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
BuildRequires:  libboost_test-devel
%else
BuildRequires:  boost-devel
%endif
BuildRequires:  libcurl-devel
BuildRequires:  gcc-c++
BuildRequires:  git
BuildRequires:  libopenssl-devel
BuildRequires:  libdb-4_8-devel
BuildRequires:  libminiupnpc-devel
BuildRequires:  protobuf-devel
BuildRequires:  qrencode-devel
BuildRequires:  libQt5Concurrent-devel
BuildRequires:  libQt5DBus-devel
BuildRequires:  libQt5Network-devel
BuildRequires:  libQt5Test-devel
BuildRequires:  libQt5Widgets-devel
%if 0%{?suse_version} > 1320 || 0%{?fedora_version} >= 27
BuildRequires:  libQt5Charts5-devel
%endif
BuildRequires:  libqt5-linguist
BuildRequires:  hicolor-icon-theme
BuildRequires:  update-desktop-files
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{defined suse_version}
Recommends:     boinc-client
%endif

%description
Gridcoin is an open source peer-to-peer cryptocurrency using a BOINC based Proof
of Research instead of the more common Proof of Work for block generation.

%package -n gridcoinresearchd

Summary:        Headless daemon for the Gridcoin crypto-currency
License:        MIT
Group:          Productivity/Networking/Other
Requires(post): pwgen

%description -n gridcoinresearchd
Gridcoin is an open source peer-to-peer cryptocurrency using a BOINC based Proof
of Research instead of the more common Proof of Work for block generation

This package provides gridcoinresearchd, headless gridcoin daemon.

%package qt

Summary:        An end-user Qt GUI for the Gridcoin crypto-currency
License:        MIT
Group:          Productivity/Networking/Other
Requires:       hicolor-icon-theme

%description qt
Gridcoin is an open source peer-to-peer cryptocurrency using a BOINC based Proof
of Research instead of the more common Proof of Work for block generation

This package provides gridcoinresearch, a GUI for Gridcoin based on Qt.

%prep
%setup -q

%build
./autogen.sh
%configure --disable-bench --with-miniupnpc --with-qrencode --with-gui=qt5
make %{?_smp_mflags}

%install
%make_install

# The test is not supposed to be installed
rm %{buildroot}%{_bindir}/test_gridcoin
rm %{buildroot}%{_bindir}/test_gridcoin-qt

# Install man-pages
install -D -m 0644 doc/gridcoinresearch.1 %{buildroot}%{_mandir}/man1/gridcoinresearch.1
install -D -m 0644 doc/gridcoinresearchd.1 %{buildroot}%{_mandir}/man1/gridcoinresearchd.1

# Install the service definition
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
install -Dpm 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}d
mkdir %{buildroot}%{_sbindir}
ln -sv %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}d
install -Dpm 0644 %{SOURCE2} %{buildroot}/%{_unitdir}/%{name}d.service
install -Dpm 0644 %{SOURCE4} %{buildroot}/%{_tmpfilesdir}/%{name}d.conf
install -dpm 0755 %{buildroot}%{_sysconfdir}/%{name}
%check
VERBOSE=1 make check

%pre -n %{name}d
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{_localstatedir}/lib/%{name} -s /sbin/nologin -c "Gridcoin Research daemon" %{name}
%service_add_pre %{name}d.service

%post -n %{name}d
%service_add_post %{name}d.service
%tmpfiles_create %{_tmpfilesdir}/%{name}d.conf
test -f %{_sysconfdir}/%{name}/%{name}.conf || { echo -e "rpcuser=gridcoinrpc\nrpcpassword=$(pwgen -n 24)" > %{_sysconfdir}/%{name}/%{name}.conf && chown root:%{name} %{_sysconfdir}/%{name}/%{name}.conf && chmod 0640 %{_sysconfdir}/%{name}/%{name}.conf; }

%preun -n %{name}d
%service_del_preun %{name}d.service

%postun -n %{name}d
%service_del_postun %{name}d.service

%post qt
%desktop_database_post

%postun qt
%desktop_database_postun

%files -n %{name}d
%defattr(-,root,root)
%{_bindir}/%{name}d
%{_mandir}/man1/%{name}d.1*
%dir %attr(700,%{name},%{name}) %{_var}/lib/%{name}
%dir %attr(750,root,%{name}) %{_sysconfdir}/%{name}
%config %ghost %{_sysconfdir}/%{name}/%{name}.conf
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}d
%ghost %{_rundir}/%{name}
%{_unitdir}/%{name}d.service
%{_sbindir}/rc%{name}d
%{_tmpfilesdir}/%{name}d.conf

%files qt
%defattr(-,root,root)
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_mandir}/man1/%{name}.1*

%changelog