File bitcoinprivate.spec of Package bitcoinprivate

#
# spec file for package bitcoinprivate
#
# 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/
#


%define libsnark libsnark-20170131

Name:           bitcoinprivate
Version:        1.0.15
Release:        0
Summary:        P2P digital currency
License:        MIT
Group:          Productivity/Networking/Other
Url:            https://btcprivate.org/
Source0:        %{name}-%{version}.tar.xz
Source1:        %{libsnark}.tar.xz
Patch0:         %{name}-boost.patch
Patch1:         %{name}-configure.patch
Patch2:         %{name}-except.patch
Patch3:         %{name}-params.patch
ExclusiveArch:  x86_64
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_1_62-devel
%endif
BuildRequires:  fdupes
BuildRequires:  gmp-devel
BuildRequires:  help2man
BuildRequires:  libdb-6_2-devel
BuildRequires:  libevent-devel
BuildRequires:  libminiupnpc-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libsodium-devel >= 1.0.4
BuildRequires:  libtool
BuildRequires:  protobuf-devel
%if 0%{?suse_version} && 0%{?suse_version} > 1320
BuildRequires:  qpid-proton-devel
%endif
%if 0%{?suse_version} && 0%{?is_opensuse} && 0%{?suse_version} == 1315 && 0%{?sle_version} && 0%{?sle_version} >= 120100
BuildRequires:  shadow
%endif
BuildRequires:  zeromq-devel

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

%define libsnark_install_prefix %{_builddir}/%{name}-%{version}/%{libsnark}/.install
%define progname btcp
%define confname btcprivate
%define daemon_pname %{name}d

# set binary names
%define daemon_name %{progname}d
%define display_name Bitcoin Private
%define fparams_name %{progname}-fetch-params
%define cli_name %{progname}-cli
%define tx_name %{progname}-tx

# set ports
%define p2p_port 7933
%define rpc_port 7932

%define description_text BitCoin Private is a BitCoin and ZClassic fork which uses ZK-SNARK technology for privacy and fungibility.

%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 %{daemon_pname}
Summary:        Headless daemon for %{name} crypto-currency
Group:          Productivity/Networking/Other
Recommends:     ca-certificates

%description -n %{daemon_pname}
%{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 -b 1 -n %{libsnark}
%setup -q -b 0 -n %{name}-%{version}
mv ../%{libsnark} .
%if 0%{?suse_version} && 0%{?suse_version} > 1500
%patch0
%patch2
%endif
%patch1
%patch3

# 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 \\$#ExecStartPre=%{_bindir}/%{fparams_name}\nExecStart=%{_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=%{progname}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^Group=bitcoin$#Group=%{progname}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^TimeoutStartSec=2s$#TimeoutStartSec=5m#g' contrib/init/%{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" > %{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
CXXFLAGS="${CXXFLAGS} %{optflags} -fPIC -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" %{__make} -C %{libsnark} %{?_smp_mflags} lib CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT
%{__make} -C %{libsnark} install PREFIX=%{libsnark_install_prefix} CURVE=ALT_BN128 NO_SUPERCOP=1 STATIC=1
export CPPFLAGS="${CPPFLAGS} -I%{libsnark_install_prefix}/include"
export LDFLAGS="${LDFLAGS} -L%{libsnark_install_prefix}/lib"
./autogen.sh
%configure --docdir=%{_defaultdocdir}/%{name} --enable-wallet --enable-mining --enable-upnp-default --with-miniupnpc --without-qrencode --with-boost --with-utils --without-libs --with-daemon --with-gui=no --disable-tests --disable-rust --enable-hardening --enable-reduce-exports --disable-static CXXFLAGS="${CXXFLAGS} -DBUILD_SUFFIX=%{_host_vendor}"
%{__make} %{?_smp_mflags}
%{__strip} -s src/%{cli_name}
%{__strip} -s src/zcash-tx
%{__strip} -s src/%{daemon_name}

%install
%{__make} %{?_smp_mflags} install DESTDIR=%{buildroot}
%{__mv} %{buildroot}%{_bindir}/zcash-fetch-params %{buildroot}%{_bindir}/%{fparams_name}
%{__rm} %{buildroot}%{_bindir}/zcash-tx
%{__rm} %{buildroot}%{_mandir}/man1/zcash-*

# install daemon supplementary files
%{__install} -D -m 0644 contrib/debian/examples/%{confname}.conf  %{buildroot}%{_sysconfdir}/%{confname}.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

# generate missing man pages
help2man --version-string "v%{version}" -s 1 -N -o %{buildroot}%{_mandir}/man1/%{fparams_name}.1 %{buildroot}%{_bindir}/%{fparams_name}

# compress man pages
%{__gzip} %{buildroot}%{_mandir}/man1/%{cli_name}.1
%{__gzip} %{buildroot}%{_mandir}/man1/%{daemon_name}.1
%{__gzip} %{buildroot}%{_mandir}/man1/%{fparams_name}.1

# 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
%{__mv} doc/man .
%{__cp} -a doc %{buildroot}%{_defaultdocdir}/%{name}/
%{__mv} man doc/
%fdupes %{buildroot}%{_defaultdocdir}/%{name}

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

%pre -n %{daemon_pname}
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 %{daemon_pname}
%service_del_preun %{daemon_name}.service

%post -n %{daemon_pname}
%service_add_post %{daemon_name}.service
%if 0%{?suse_version} && ( 0%{?suse_version} > 1320 || ( 0%{?is_opensuse} && 0%{?suse_version} == 1315 ) )
%tmpfiles_create %{_tmpfilesdir}/%{progname}_rundir.conf
%else
systemd-tmpfiles --create %{_tmpfilesdir}/%{progname}_rundir.conf >/dev/null 2>&1 || :
%endif

%postun -n %{daemon_pname}
%service_del_postun %{daemon_name}.service

%files utils
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{cli_name}
%{_mandir}/man1/%{cli_name}.1%{?ext_man}

%files -n %{daemon_pname}
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{daemon_name}
%attr(755,root,root) %{_bindir}/%{fparams_name}
%{_sbindir}/rc%{daemon_name}
%{_unitdir}/%{daemon_name}.service
%config(noreplace) %{_sysconfdir}/%{confname}.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}
%dir %{_tmpfilesdir}
%{_tmpfilesdir}/%{progname}_rundir.conf
%{_mandir}/man1/%{daemon_name}.1%{?ext_man}
%{_mandir}/man1/%{fparams_name}.1%{?ext_man}

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

%changelog
openSUSE Build Service is sponsored by