File superbitcoin.spec of Package superbitcoin
#
# spec file for package superbitcoin
#
# Copyright (c) 2018 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 http://bugs.opensuse.org/
#
Name: superbitcoin
Version: 0.17.7
Release: 0
Summary: P2P digital currency
License: MIT
Group: Productivity/Networking/Other
Url: http://superbtc.org/
Source0: %{name}-%{version}.tar.xz
Source1: leveldb_helpers.tar.xz
Patch0: %{name}-boost.patch
Patch1: %{name}-cmake.patch
Patch2: %{name}-crypto.patch
Patch3: %{name}-debug.patch
Patch4: %{name}-leveldb.patch
Patch5: %{name}-util.patch
%if 0%{?suse_version} && 0%{?suse_version} > 1320
BuildRequires: libboost_chrono-devel
BuildRequires: libboost_context-devel
BuildRequires: libboost_coroutine-devel
BuildRequires: libboost_date_time-devel
BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_locale-devel
BuildRequires: libboost_program_options-devel
BuildRequires: libboost_random-devel
BuildRequires: libboost_serialization-devel
BuildRequires: libboost_signals-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_test-devel
BuildRequires: libboost_thread-devel
%else
BuildRequires: boost-devel
%endif
BuildRequires: cmake >= 3.9
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: libdb-4_8-devel
BuildRequires: libevent-devel
BuildRequires: libleveldb-devel
BuildRequires: libminiupnpc-devel
BuildRequires: libopenssl-devel
BuildRequires: libsecp256k1-devel
BuildRequires: log4cpp-devel
%if 0%{?suse_version} && 0%{?is_opensuse} && 0%{?suse_version} == 1315 && 0%{?sle_version} && 0%{?sle_version} >= 120200
BuildRequires: shadow
%endif
%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif
# set progam base name
%define progname sbtc
# set binary names
%define display_name SuperBitCoin
%define daemon_name %{progname}d
%define gui_name %{progname}-qt
%define cli_name %{progname}-cli
%define tx_name %{progname}-tx
# set ports
%define p2p_port 8334
%define rpc_port 8333
%define description_text Super Bitcoin is an experimental hard fork of Bitcoin, which is also an experimental digital currency. Super Bitcoin tries to implement, test, improve, and innovate features that Bitcoin society members have long proposed or requested, the results of which could in turn be valuable to Bitcoin itself.
%description
%{description_text}
%package utils
Summary: Utils for the %{display_name} crypto-currency
Group: Productivity/Networking/Other
%description utils
%{description_text}
This package provides %{display_name}-CLI and %{display_name}-TX, a command line interface for %{display_name}.
%package -n %{name}d
Summary: Headless daemon for %{name} crypto-currency
Group: Productivity/Networking/Other
%description -n %{name}d
%{description_text}
This package provides %{daemon_name}, a headless %{name} daemon.
%package doc
Summary: Documentation for %{name}
Group: Documentation/Man
BuildArch: noarch
%description doc
%{description_text}
This package contains the documentation for %{name}.
%prep
%setup -q
%patch0
%patch1
%patch2
%patch3
%patch4
%patch5
%{__rm} src/CMakeCache.txt
%{__rm} src/utils/crypto/ctaes/bench.c
%{__rm} src/utils/crypto/ctaes/test.c
%{__tar} -C src/utils -xf %{S:1}
/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#^Description=Bitcoin.s distributed currency daemon$#Description=%{display_name} Daemon#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^PIDFile=/var/lib/bitcoind/bitcoind.pid$#PIDFile=%{_rundir}/%{progname}/%{daemon_name}.pid#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^ExecStart=/usr/bin/bitcoind -daemon -pid=/var/lib/bitcoind/bitcoind.pid \\$#ExecStart=%{_bindir}/%{daemon_name} -daemon -pid=%{_rundir}/%{progname}/%{daemon_name}.pid -conf=%{_sysconfdir}/%{progname}.conf -datadir=%{_localstatedir}/lib/%{progname} -disablewallet#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^-conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind -disablewallet$#ExecReload=/bin/kill -HUP \$MAINPID#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 contrib/debian/examples/bitcoin.conf contrib/debian/examples/%{progname}.conf
%{__sed} -i 's#bitcoin#%{progname}#g' contrib/debian/examples/%{progname}.conf
%{__sed} -i 's#Bitcoin-QT#%{gui_name}#g' contrib/debian/examples/%{progname}.conf
%{__sed} -i 's#Bitcoin#%{progname}#g' contrib/debian/examples/%{progname}.conf
# 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" > %{progname}.firewall
echo "## Description: Opens ports for %{daemon_name} in order to allow remote connections." >> %{progname}.firewall
echo -e "\nTCP=\"%{rpc_port}:%{p2p_port}\"" >> %{progname}.firewall
%endif
# setup run folder
echo "d %{_rundir}/%{progname} 0770 root %{progname}" > rundir.conf
%build
%cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC_FLAG=OFF -DHAVE_CONFIG_H=OFF -DHAVE_SYS_SELECT_H=OFF -DENABLE_WALLET=ON -DTESTS=OFF -DENABLE_ZMQ_FLAG=OFF -DREVISIVE_FLAG=OFF -DCMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS} -llog4cpp"
%make_jobs
%{__strip} -s src/%{cli_name}/%{cli_name}
%{__strip} -s src/%{tx_name}/%{tx_name}
%{__strip} -s src/%{daemon_name}/%{daemon_name}
%install
%{__install} -D -m 0755 -t %{buildroot}%{_bindir} build/src/%{cli_name}/%{cli_name} build/src/%{tx_name}/%{tx_name} build/src/%{daemon_name}/%{daemon_name}
# install daemon supplementary files
%{__install} -D -m 0644 contrib/debian/examples/%{progname}.conf %{buildroot}%{_sysconfdir}/%{progname}.conf
%{__install} -D -m 0644 contrib/init/%{daemon_name}.service %{buildroot}%{_unitdir}/%{daemon_name}.service
%{__mkdir_p} %{buildroot}%{_localstatedir}/lib/%{progname}
%{__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 %{progname}.firewall %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{daemon_name}
%endif
# install run folder configuration
%{__install} -D -m 0644 rundir.conf %{buildroot}/%{_tmpfilesdir}/%{progname}_rundir.conf
# install documentation
%{__install} -d -m 0755 %{buildroot}%{_defaultdocdir}/%{name}
%{__install} -m 0644 -p -t %{buildroot}%{_defaultdocdir}/%{name} CONTRIBUTING.md README.md
%{__install} -d -m 0755 %{buildroot}%{_defaultlicensedir}/%{name}
%{__install} -m 0644 -p -t %{buildroot}%{_defaultlicensedir}/%{name} COPYING
%{__cp} -a doc %{buildroot}%{_defaultdocdir}/%{name}/
%{__rm} -fr %{buildroot}%{_defaultdocdir}/%{name}/doc/man
%fdupes %{buildroot}%{_defaultdocdir}/%{name}
# no rpath check
export NO_BRP_CHECK_RPATH=true
%pre -n %{name}d
getent group %{progname} > /dev/null || groupadd -r %{progname}
getent passwd %{progname} > /dev/null || useradd -r -g %{progname} -d %{_localstatedir}/lib/%{progname} -s /sbin/nologin -c "%{progname} daemon" %{progname}
%service_add_pre %{daemon_name}.service
%preun -n %{name}d
%service_del_preun %{daemon_name}.service
%post -n %{name}d
%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}/%{progname}_rundir.conf
%else
systemd-tmpfiles --create %{_tmpfilesdir}/%{progname}_rundir.conf >/dev/null 2>&1 || :
%endif
%postun -n %{name}d
%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}
%files -n %{name}d
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{daemon_name}
%{_sbindir}/rc%{daemon_name}
%{_unitdir}/%{daemon_name}.service
%config(noreplace) %{_sysconfdir}/%{progname}.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,%{progname},%{progname}) %{_localstatedir}/lib/%{progname}
%ghost %{_rundir}/%{progname}
%{_tmpfilesdir}/%{progname}_rundir.conf
%files doc
%defattr(-,root,root,-)
%{_defaultdocdir}/%{name}/
%{_defaultlicensedir}/%{name}/
%changelog