File feathercoin.spec of Package feathercoin

#
# spec file for package feathercoin
#
# Copyright (c) 2019 SUSE LINUX 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 https://bugs.opensuse.org/
#


Name:           feathercoin
Version:        0.18.1
Release:        0
Summary:        P2P digital currency
License:        MIT
Group:          Productivity/Networking/Other
Url:            https://%{name}.com/
Source0:        %{name}-%{version}.tar.xz
BuildRequires:  automake
%if 0%{?suse_version} && 0%{?suse_version} > 1320
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
%else
BuildRequires:  boost-devel
%endif
BuildRequires:  dos2unix
BuildRequires:  fdupes
BuildRequires:  libdb-4_8-devel
BuildRequires:  libevent-devel
BuildRequires:  libminiupnpc-devel
BuildRequires:  libtool
BuildRequires:  qrencode-devel
%if 0%{?suse_version} && 0%{?suse_version} >= 1315
%if 0%{?suse_version} && 0%{?suse_version} > 1320
BuildRequires:  libopenssl-1_0_0-devel
%else
BuildRequires:  libopenssl-devel
%endif
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libqt5-qttools-devel
%else
BuildRequires:  libqt4-devel
%endif
BuildRequires:  libunivalue-devel
BuildRequires:  protobuf-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
BuildRequires:  zeromq-devel

%if 0%{?suse_version} && 0%{?suse_version} <= 1320
%define use_asm "--enable-asm"
%endif

%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif

%global qt4_version qt
%global qt5_version qt5
%global qt4c_version qt4

%if 0%{?suse_version} && 0%{?suse_version} >= 1315
%define qt_version %{qt5_version}
%define qt_version_obsolete %{qt4_version}
%define qt_config %{qt5_version}
%else
%define qt_version %{qt4_version}
%define qt_version_obsolete %{qt5_version}
%define qt_config %{qt4c_version}
%endif

# set binary names
%define daemon_name %{name}d
%define display_name FeatherCoin
%define cli_name %{name}-cli
%define tx_name %{name}-tx
%define wallet_name %{name}-wallet
%define gui_name %{name}-qt

# set ports
%define p2p_port 9336
%define rpc_port 9337

%define description_text_1 FeatherCoin bypasses the old banking system by using peer-to-peer technology. Payments are borderless and can be processed by anyone with affordable computer hardware using free software. This work is rewarded with new FeatherCoins which are issued by the network.
%define description_text_3 - 1 minute block targets
%define description_text_4 - 80 coins per block
%define description_text_5 - NeoScrypt hashing algorithm
%define description_text_6 - Retarget every block
%define description_text_7 - Retarget with average of 15, 120 and 480 block averages and .25 damping
%define description_text_8 - Subsidy halves every ~4 years
%define description_text_9 - ~336 million 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 utils
Summary:        Utils for the %{display_name} crypto-currency
Group:          Productivity/Networking/Other
Obsoletes:      %{cli_name}

%description utils
%{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}-CLI, a command line interface for %{display_name}.

%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}

This package contains the documentation for %{name}.

%prep
%setup -q
/usr/bin/dos2unix -k doc/README_windows.txt

# setup systemd service
%{__cp} -a contrib/init/bitcoind.service contrib/init/%{daemon_name}.service
%{__sed} -i 's#^\# \$ systemctl edit bitcoind.service$#\# $ systemctl edit %{daemon_name}.service#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^\# /etc/bitcoin/bitcoin.conf#\# %{_sysconfdir}/%{name}/%{name}.conf#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^Description=Bitcoin daemon$#Description=%{display_name} Daemon#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^PIDFile=/run/bitcoind/bitcoind.pid$#PIDFile=%{_rundir}/%{name}/%{daemon_name}.pid#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^ExecStart=/usr/bin/bitcoind -daemon \\$#ExecStart=%{_bindir}/%{daemon_name} -daemon \\#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#-pid=/run/bitcoind/bitcoind.pid \\$#-pid=%{_rundir}/%{name}/%{daemon_name}.pid \\#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#-conf=/etc/bitcoin/bitcoin.conf \\$#-conf=%{_sysconfdir}/%{name}/%{name}.conf \\#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#-datadir=/var/lib/bitcoind$#-datadir=%{_localstatedir}/lib/%{name} \\\n                            -disablewallet\nExecReload=/bin/kill -HUP \$MAINPID#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^\# /run/bitcoind$#\# %{_rundir}/%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^RuntimeDirectory=bitcoind$#RuntimeDirectory=%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^\# /etc/bitcoin$#\# %{_sysconfdir}/%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^ConfigurationDirectory=bitcoin$#ConfigurationDirectory=%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^\# /var/lib/bitcoind$#\# %{_localstatedir}/lib/%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^StateDirectory=bitcoind$#StateDirectory=%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^User=bitcoin$#User=%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^Group=bitcoin$#Group=%{name}#g' contrib/init/%{daemon_name}.service

# setup default config file
%{__cp} -a share/examples/bitcoin.conf share/examples/%{name}.conf
%{__sed} -i 's#bitcoin#%{name}#g' share/examples/%{name}.conf
%{__sed} -i 's#Bitcoin-QT#%{gui_name}#g' share/examples/%{name}.conf
%{__sed} -i 's#Bitcoin#%{name}#g' share/examples/%{name}.conf

# setup firewall config
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

# setup run folder
echo "d %{_rundir}/%{name} 0770 root %{name}" > rundir.conf

%build
./autogen.sh
%configure --docdir=%{_defaultdocdir}/%{name} %{?use_asm} --enable-silent-rules --enable-hardening --enable-reduce-exports --disable-bench --disable-tests --enable-man --enable-zmq --enable-wallet --enable-upnp-default --enable-util-cli --enable-util-tx --enable-util-wallet --with-miniupnpc --with-qrcode --with-boost --with-utils --with-daemon --without-libs --with-gui=%{qt_config} --with-qtdbus --with-system-univalue --disable-static CXXFLAGS="${CXXFLAGS} -DBUILD_SUFFIX=%{_host_vendor}"
%if 0%{?suse_version} && 0%{?suse_version} >= 1500
%make_build
%else
%{__make} %{?_smp_mflags}
%endif
%{__strip} -s src/%{cli_name}
%{__strip} -s src/%{tx_name}
%{__strip} -s src/%{wallet_name}
%{__strip} -s src/qt/%{gui_name}
%{__strip} -s src/%{daemon_name}

%install
%if 0%{?suse_version} && 0%{?suse_version} >= 1500
%make_install
%else
%{__make} %{?_smp_mflags} install DESTDIR=%{buildroot}
%endif

# install daemon supplementary files
%{__install} -D -m 0644 share/examples/%{name}.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
%{__install} -D -m 0644 contrib/init/%{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
%{__install} -D -m 644 %{name}.firewall %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{daemon_name}

# install desktop file
%{__install} -D -m 0644 src/qt/res/icons/bitcoin.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 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
%{__install} -d -m 0755 %{buildroot}%{_defaultdocdir}/%{name}/doc
%{__cp} -a -t %{buildroot}%{_defaultdocdir}/%{name}/doc doc/*.md doc/*.txt doc/release-notes
%fdupes %{buildroot}%{_defaultdocdir}/%{name}

%check
%{__make} %{?_smp_mflags} check

%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 utils
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{cli_name}
%attr(755,root,root) %{_bindir}/%{tx_name}
%attr(755,root,root) %{_bindir}/%{wallet_name}
%{_mandir}/man1/%{cli_name}.1%{?ext_man}
%{_mandir}/man1/%{tx_name}.1%{?ext_man}
%{_mandir}/man1/%{wallet_name}.1%{?ext_man}

%files %{qt_version}
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{gui_name}
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/applications/%{gui_name}.desktop
%{_mandir}/man1/%{gui_name}.1%{?ext_man}

%files -n %{daemon_name}
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{daemon_name}
%{_sbindir}/rc%{daemon_name}
%{_unitdir}/%{daemon_name}.service
%dir %attr(710,root,%{name}) %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{daemon_name}
%dir %attr(700,%{name},%{name}) %{_localstatedir}/lib/%{name}
%ghost %{_rundir}/%{name}
%{_tmpfilesdir}/%{name}_rundir.conf
%{_mandir}/man1/%{daemon_name}.1%{?ext_man}

%files doc
%defattr(-,root,root,-)
%{_defaultdocdir}/%{name}/
%{_defaultlicensedir}/%{name}/

%changelog