File novacoin.spec of Package novacoin
#
# spec file for package novacoin
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
Name: novacoin
Version: 0.5.10
Release: 0
Summary: P2P digital currency
License: MIT
Group: Productivity/Networking/Other
URL: https://%{name}.org/
Source0: %{name}-%{version}.tar.xz
Patch0: %{name}-cmake.patch
ExclusiveArch: x86_64
%if 0%{?suse_version} && 0%{?suse_version} > 1320
BuildRequires: libboost_atomic-devel
BuildRequires: libboost_chrono-devel
BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_program_options-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_thread-devel
%else
BuildRequires: boost-devel
%endif
BuildRequires: cmake >= 3.9
BuildRequires: dos2unix
BuildRequires: libdb-4_8-devel
BuildRequires: libdeflate-devel
BuildRequires: libopenssl-devel
BuildRequires: libpng-devel
BuildRequires: libqt5-qtbase-devel
BuildRequires: libqt5-qtdeclarative-devel
BuildRequires: libqt5-qttools-devel
%if 0%{?suse_version} && 0%{?is_opensuse} && 0%{?suse_version} == 1315 && 0%{?sle_version} && 0%{?sle_version} >= 120200
BuildRequires: shadow
%endif
BuildRequires: update-desktop-files
%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif
%global qt5_version qt5
%define qt_version %{qt5_version}
# set binary names
%define daemon_name %{name}d
%define display_name NovaCoin
%define gui_name %{name}-qt
# set ports
%define p2p_port 7777
%define rpc_port 8344
%define description_text_1 NovaCoin - a hybrid scrypt PoW + PoS based cryptocurrency.
%define description_text_3 - 10 minutes stake spacing
%define description_text_4 - 30 minutes PoW spacing
%define description_text_5 - Balanced PoW blocks and stakes weighting
%define description_text_6 - The PoW subsidy halves every x64 multiply of PoW difficulty
%define description_text_7 - The PoS interest halves every x64 multiply of PoS difficulty
%define description_text_8 - Maximum PoS reward is 10 coins
%define description_text_9 - ~ 2 billion total coins
%description
%{description_text_1}
%{description_text_3}
%{description_text_4}
%{description_text_5}
%{description_text_6}
%{description_text_7}
%{description_text_8}
%{description_text_9}
%package %{qt_version}
Summary: GUI for the %{display_name} crypto-currency
Group: Productivity/Networking/Other
Obsoletes: %{name}-%{qt_version_obsolete}
%description %{qt_version}
%{description_text_1}
%{description_text_3}
%{description_text_4}
%{description_text_5}
%{description_text_6}
%{description_text_7}
%{description_text_8}
%{description_text_9}
This package provides %{display_name}-Qt, a GUI for %{display_name} based on Qt.
%package -n %{daemon_name}
Summary: Headless daemon for %{name} crypto-currency
Group: Productivity/Networking/Other
%description -n %{daemon_name}
%{description_text_1}
%{description_text_3}
%{description_text_4}
%{description_text_5}
%{description_text_6}
%{description_text_7}
%{description_text_8}
%{description_text_9}
This package provides %{daemon_name}, a headless %{name} daemon.
%package doc
Summary: Documentation for %{name}
Group: Documentation/Man
BuildArch: noarch
%description doc
%{description_text_1}
%{description_text_3}
%{description_text_4}
%{description_text_5}
%{description_text_6}
%{description_text_7}
%{description_text_8}
%{description_text_9}
%prep
%setup -q
%patch0
/usr/bin/dos2unix -k doc/README_windows.txt
# setup systemd service
%{__sed} -i 's#^Description=Novacoin daemon serivce$#Description=%{display_name} Daemon#g' contrib/initscripts/systemd/%{daemon_name}.service
%{__sed} -i 's#^ExecStart=/opt/novacoin/novacoind$#\nType=forking\nPIDFile=%{_rundir}/%{name}/%{daemon_name}.pid\nExecStart=%{_bindir}/%{daemon_name} -daemon -pid=%{_rundir}/%{name}/%{daemon_name}.pid -conf=%{_sysconfdir}/%{name}.conf -datadir=%{_localstatedir}/lib/%{name} -disablewallet\nExecReload=/bin/kill -HUP \$MAINPID\n\nRestart=always\nPrivateTmp=true\nTimeoutStopSec=60s\nTimeoutStartSec=2s\nStartLimitInterval=120s\nStartLimitBurst=5#g' contrib/initscripts/systemd/%{daemon_name}.service
%{__sed} -i 's#^User=novacoin$#Group=%{name}#g' contrib/initscripts/systemd/%{daemon_name}.service
%{__sed} -i 's#^Type=simple$#User=%{name}#g' contrib/initscripts/systemd/%{daemon_name}.service
# setup firewall config
%if 0%{?suse_version} && ( 0%{?suse_version} < 1500 || ( 0%{?is_opensuse} && 0%{?suse_version} == 1500 && 0%{?sle_version} && 0%{?sle_version} <= 150200 ) )
echo "## Name: %{display_name} Daemon" > %{name}.firewall
echo "## Description: Opens ports for %{daemon_name} in order to allow remote connections." >> %{name}.firewall
echo -e "\nTCP=\"%{p2p_port} %{rpc_port}\"" >> %{name}.firewall
%endif
# setup run folder
echo "d %{_rundir}/%{name} 0770 root %{name}" > rundir.conf
# compress man pages
%{__gzip} contrib/debian/manpages/%{daemon_name}.1
%{__gzip} contrib/debian/manpages/%{name}.conf.5
# fix cmake for oS 1520 and before
%if 0%{?suse_version} && ( 0%{?suse_version} < 1500 || ( 0%{?is_opensuse} && 0%{?suse_version} == 1500 && 0%{?sle_version} && 0%{?sle_version} <= 150200 ) )
%{__sed} -i 's#\${CMAKE_INSTALL_LIBDIR}#%{_lib}#g' CMakeLists.txt
%{__sed} -i 's#\${CMAKE_INSTALL_LIBDIR}#%{_lib}#g' src/CMakeLists.txt
%endif
%build
%cmake -DWITH_TOOLS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS="${CXXFLAGS} -DBUILD_SUFFIX=%{_host_vendor}"
%cmake_build
%{__strip} -s %{gui_name}
cd ../src
%cmake -DCMAKE_CXX_FLAGS="${CXXFLAGS} -DBUILD_SUFFIX=%{_host_vendor}"
%cmake_build
%{__strip} -s %{daemon_name}
%install
%{__install} -dm 0755 %{buildroot}%{_bindir}
%{__install} -m 0755 build/%{gui_name} %{buildroot}%{_bindir}
%{__install} -m 0755 src/build/%{daemon_name} %{buildroot}%{_bindir}
# install daemon supplementary files
%{__install} -D -m 0644 contrib/debian/examples/%{name}.conf %{buildroot}%{_sysconfdir}/%{name}.conf
%{__install} -D -m 0644 contrib/initscripts/systemd/%{daemon_name}.service %{buildroot}%{_unitdir}/%{daemon_name}.service
%{__mkdir_p} %{buildroot}%{_localstatedir}/lib/%{name}
%{__install} -d -m 0755 %{buildroot}%{_sbindir}
%{__ln_s} %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{daemon_name}
# install firewall config file
%if 0%{?suse_version} && ( 0%{?suse_version} < 1500 || ( 0%{?is_opensuse} && 0%{?suse_version} == 1500 && 0%{?sle_version} && 0%{?sle_version} <= 150200 ) )
%{__install} -D -m 644 %{name}.firewall %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{daemon_name}
%endif
# install desktop file
%{__install} -D -m 0644 src/qt/res/icons/novacoin-128.png %{buildroot}%{_datadir}/pixmaps/%{name}.png
%suse_update_desktop_file -c %{gui_name} %{display_name} "%{display_name} Wallet" %{gui_name} %{name} Office Finance
# install run folder configuration
%{__install} -D -m 0644 rundir.conf %{buildroot}/%{_tmpfilesdir}/%{name}_rundir.conf
# install man pages
%{__install} -D -m 0644 -p contrib/debian/manpages/%{daemon_name}.1%{?ext_man} %{buildroot}%{_mandir}/man1/%{daemon_name}.1%{?ext_man}
%{__install} -D -m 0644 -p contrib/debian/manpages/%{name}.conf.5%{?ext_man} %{buildroot}%{_mandir}/man5/%{name}.conf.5%{?ext_man}
# install documentation
%{__install} -d -m 0755 %{buildroot}%{_defaultdocdir}/%{name}
%{__install} -m 0644 -p -t %{buildroot}%{_defaultdocdir}/%{name} README.md
%{__install} -d -m 0755 %{buildroot}%{_defaultlicensedir}/%{name}
%{__install} -m 0644 -p -t %{buildroot}%{_defaultlicensedir}/%{name} COPYING LICENSE
%{__cp} -a doc %{buildroot}%{_defaultdocdir}/%{name}/
%{__rm} -fr %{buildroot}%{_defaultdocdir}/%{name}/obsolete
%pre -n %{daemon_name}
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 "%{name} daemon" %{name}
%service_add_pre %{daemon_name}.service
%preun -n %{daemon_name}
%service_del_preun %{daemon_name}.service
%post -n %{daemon_name}
%service_add_post %{daemon_name}.service
%if 0%{?suse_version} && ( 0%{?suse_version} > 1320 || ( 0%{?is_opensuse} && 0%{?suse_version} == 1315 && 0%{?sle_version} && 0%{?sle_version} >= 120100 ) )
%tmpfiles_create %{_tmpfilesdir}/%{name}_rundir.conf
%else
systemd-tmpfiles --create %{_tmpfilesdir}/%{name}_rundir.conf >/dev/null 2>&1 || :
%endif
%if 0%{?suse_version} && 0%{?suse_version} < 1500
%post %{qt_version}
%desktop_database_post
%postun %{qt_version}
%desktop_database_postun
%endif
%postun -n %{daemon_name}
%service_del_postun %{daemon_name}.service
%files %{qt_version}
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{gui_name}
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/applications/%{gui_name}.desktop
%files -n %{daemon_name}
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{daemon_name}
%{_sbindir}/rc%{daemon_name}
%{_unitdir}/%{daemon_name}.service
%config(noreplace) %{_sysconfdir}/%{name}.conf
%if 0%{?suse_version} && ( 0%{?suse_version} < 1500 || ( 0%{?is_opensuse} && 0%{?suse_version} == 1500 && 0%{?sle_version} && 0%{?sle_version} <= 150200 ) )
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{daemon_name}
%endif
%dir %attr(700,%{name},%{name}) %{_localstatedir}/lib/%{name}
%ghost %{_rundir}/%{name}
%{_tmpfilesdir}/%{name}_rundir.conf
%{_mandir}/man1/%{daemon_name}.1%{?ext_man}
%{_mandir}/man5/%{name}.conf.5%{?ext_man}
%files doc
%defattr(-,root,root,-)
%{_defaultdocdir}/%{name}/
%{_defaultlicensedir}/%{name}/
%changelog