File bitcoindiamond.spec of Package bitcoindiamond
#
# spec file for package bitcoindiamond
#
# 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/
#
# program names
%define progname bitcoindiamond
%define specname_core %{progname}
%define libname_core_ext %{nil}
# program base names
%define progbase %{progname}
# settings for bitcoin core
%define specname %{specname_core}
%define specurl http://btcd.io/
%define currency_name BitcoinDiamond
%define display_name BitCoin Diamond
%define libname_ext %{?libname_core_ext}
%define icon_src share/pixmaps/bitcoin256.png
# options
%define with_bench no
%define with_gui yes
%define with_libs no
%define with_man no
%define with_tests no
%define with_checks yes
%define with_bash_support no
Name: %{specname}
Version: 1.3.0rc1
Release: 0
Summary: P2P digital currency
License: MIT
Group: Productivity/Networking/Other
Url: %{specurl}
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
%if %{with_tests} == yes
BuildRequires: libboost_test-devel
%endif
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
BuildRequires: libopenssl-devel
BuildRequires: libqt5-qtbase-devel
BuildRequires: libqt5-qttools-devel
%else
BuildRequires: libqt4-devel
%endif
BuildRequires: libunivalue-devel
BuildRequires: protobuf-devel
BuildRequires: python3
%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 ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif
%define soname 0
%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 %{progbase}d
%define cli_name %{progbase}-cli
%define tx_name %{progbase}-tx
%define bench_name bench_%{progbase}
%define gui_name %{progbase}-qt
%define lib_name lib%{progbase}consensus%{soname}
%define test_name test_%{progbase}
%define test_gui_name test_%{gui_name}
# set ports
%define p2p_port 7117
%define rpc_port 7116
# set package names
%define daemon_packname %{name}d
%define lib_packname %{lib_name}%{?libname_ext}
# set configuration options
%if %{with_bench} == yes
%define conf_bench enable
%else
%define conf_bench disable
%endif
%if %{with_gui} == no
%define qt_config no
%endif
%if %{with_libs} == yes
%define conf_libs with
%else
%define conf_libs without
%endif
%if %{with_man} == yes
%define conf_man enable
%else
%define conf_man disable
%endif
%if %{with_tests} == yes
%define conf_tests enable
%else
%define conf_tests disable
%endif
# set description
%define description_text BitCoin Diamond (BCD) is a fork of BitCoin that occurs at the predetermined height of block 495866 and therewith a new chain will be generated as the BCD. BitCoin Diamond miners will begin creating blocks with a new proof-of-work algorithm, and will consecutively develop and enhance the protection for account transfer and privacy based on original features of BTC. This will cause a bifurcation of the BitCoin blockchain. The original BitCoin blockchain will continue on unaltered, but a new branch of the blockchain will split off from the original chain. It shares the same transaction history with Bitcoin until it starts branching and coming into a unique block from which it diverges. As a result of this process, a new cryptocurrency was created which we call BitCoin Diamond.
%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}.
%if %{with_gui} == yes
%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}
This package provides %{display_name} Qt, a GUI for %{display_name} based on Qt.
%endif
%package -n %{daemon_packname}
Summary: Headless daemon for %{name} crypto-currency
Group: Productivity/Networking/Other
%{?systemd_requires}
%description -n %{daemon_packname}
%{description_text}
This package provides %{daemon_name}, a headless %{name} daemon.
%if %{with_tests} == yes
%package test
Summary: Automated tests for %{name} client
Group: Productivity/Networking/Other
%if %{with_bench} == yes
Obsoletes: %{name}-bench
%endif
%description test
%{description_text}
%if %{with_bench} == yes
This package provides automated tests and benchmarks for %{gui_name} and %{daemon_name}.
%else
This package provides automated tests for %{gui_name} and %{daemon_name}.
%endif
%endif
%if %{with_libs} == yes
%package -n %{lib_packname}
Summary: Implementation of getblocktemplate protocol
Group: System/Libraries
%description -n %{lib_packname}
%{description_text}
This package provides shared libraries for %{name}.
%package -n %{lib_packname}-devel
Summary: Development files for %{lib_name}
Group: Development/Libraries/C and C++
Requires: %{lib_packname} = %{version}
%description -n %{lib_packname}-devel
%{description_text}
The %{lib_name}-devel package contains libraries and header files for developing applications that use %{lib_name}.
%endif
%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
/usr/bin/dos2unix -k doc/README_windows.txt
%{__chmod} 644 COPYING *.md
%{__chmod} 644 doc/*.md doc/*.txt doc/release-notes/*.md
# setup systemd service
%{__cp} -a contrib/init/bitcoind.service contrib/init/%{daemon_name}.service
%{__sed} -i 's#^Bitcoindiamond daemon$#Description=%{display_name} Daemon#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^PIDFile=/run/bitcoindiamondd/bitcoindiamondd.pid$#PIDFile=%{_rundir}/%{name}/%{daemon_name}.pid#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^ExecStart=/usr/local/bin/bitcoindiamondd -daemon -conf=/home/bcd-root/.bitcoindiamond/bitcoin.conf -pid=/run/bitcoindiamondd/bitcoindiamondd.pid$#ExecStart=%{_bindir}/%{daemon_name} -daemon -pid=%{_rundir}/%{name}/%{daemon_name}.pid -conf=%{_sysconfdir}/%{name}.conf -datadir=%{_localstatedir}/lib/%{name} -disablewallet#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^\# Creates /run/bitcoindiamondd owned by bitcoindiamondd$#ExecReload=/bin/kill -HUP \$MAINPID#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^RuntimeDirectory=bitcoindiamondd$#RuntimeDirectory=%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^User=bcd-root$#User=%{name}#g' contrib/init/%{daemon_name}.service
%{__sed} -i 's#^Group=bcd-root$#Group=%{name}#g' 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#^\# /home/bcd-root/.bitcoindiamond/bitcoin.conf$#\# %{_sysconfdir}/%{name}.conf#g' contrib/init/%{daemon_name}.service
# setup default config file
%{__cp} -a share/examples/bitcoin.conf share/examples/%{progname}.conf
%{__sed} -i 's#Bitcoin-Qt#%{gui_name}#g' share/examples/%{progbase}.conf
%{__sed} -i 's#bitcoin#%{progbase}#g' share/examples/%{progbase}.conf
%{__sed} -i 's#Bitcoin#%{progbase}#g' share/examples/%{progbase}.conf
# setup firewall config
echo "## Name: %{display_name} Daemon" > %{progbase}.firewall
echo "## Description: Opens ports for %{daemon_name} in order to allow remote connections." >> %{progbase}.firewall
echo -e "\nTCP=\"%{rpc_port}:%{p2p_port}\"" >> %{progbase}.firewall
# setup run folder
echo "d %{_rundir}/%{progbase} 0770 root %{progbase}" > rundir.conf
%build
./autogen.sh
%configure --docdir=%{_defaultdocdir}/%{name} --enable-silent-rules --enable-wallet --enable-upnp-default --%{conf_bench}-bench --%{conf_tests}-tests --%{conf_man}-man --enable-hardening --enable-reduce-exports --with-miniupnpc --with-qrencode --with-boost --with-utils --%{conf_libs}-libs --with-daemon --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}
%if %{with_bench} == yes
%{__strip} -s src/bench/%{bench_name}
%endif
%if %{with_gui} == yes
%{__strip} -s src/qt/%{gui_name}
%endif
%{__strip} -s src/%{daemon_name}
%if %{with_tests} == yes
%if %{with_gui} == yes
%{__strip} -s src/qt/test/%{test_gui_name}
%endif
%{__strip} -s src/test/%{test_name}
%endif
%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/%{progbase}.conf %{buildroot}%{_sysconfdir}/%{progbase}.conf
%{__install} -D -m 0644 contrib/init/%{daemon_name}.service %{buildroot}%{_unitdir}/%{daemon_name}.service
%if %{with_bash_support} == yes
%{__install} -D -m 0644 contrib/%{daemon_name}.bash-completion %{buildroot}%{_sysconfdir}/bash_completion.d/%{daemon_name}.bash-completion
%{__install} -D -m 0644 contrib/%{cli_name}.bash-completion %{buildroot}%{_sysconfdir}/bash_completion.d/%{cli_name}.bash-completion
%{__install} -D -m 0644 contrib/%{tx_name}.bash-completion %{buildroot}%{_sysconfdir}/bash_completion.d/%{tx_name}.bash-completion
%endif
%{__mkdir_p} %{buildroot}%{_localstatedir}/lib/%{progbase}
%{__install} -d -m 0755 %{buildroot}%{_sbindir}
%{__ln_s} %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{daemon_name}
# install firewall config file
%{__install} -D -m 644 %{progbase}.firewall %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{daemon_name}
# install desktop file
%if %{with_gui} == yes
%{__install} -D -m 0644 %{icon_src} %{buildroot}%{_datadir}/pixmaps/%{name}.png
%suse_update_desktop_file -c %{gui_name} "%{display_name}" "%{display_name} Wallet" %{gui_name} %{name} Office Finance
%endif
# install run folder configuration
%{__install} -D -m 0644 rundir.conf %{buildroot}/%{_tmpfilesdir}/%{progbase}_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
%{__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}
# eliminate files that do not go into the package
%if %{with_libs} == yes
find %{buildroot} -name '*.la' -exec %{__rm} -f {} ';'
%endif
# no rpath check on arm architectures
%ifarch %arm
export NO_BRP_CHECK_RPATH=true
%endif
%if %{with_checks} == yes
%check
%{__make} %{?_smp_mflags} check
%endif
%pre -n %{daemon_packname}
getent group %{progbase} > /dev/null || groupadd -r %{progbase}
getent passwd %{progbase} > /dev/null || useradd -r -g %{progbase} -d %{_localstatedir}/lib/%{progbase} -s /sbin/nologin -c "%{progbase} daemon" %{progbase}
%service_add_pre %{daemon_name}.service
%preun -n %{daemon_packname}
%service_del_preun %{daemon_name}.service
%if %{with_gui} == yes
%if 0%{?suse_version} && 0%{?suse_version} < 1500
%post %{qt_version}
%desktop_database_post
%postun %{qt_version}
%desktop_database_postun
%endif
%endif
%post -n %{daemon_packname}
%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}/%{progbase}_rundir.conf
%else
systemd-tmpfiles --create %{_tmpfilesdir}/%{progbase}_rundir.conf >/dev/null 2>&1 || :
%endif
%postun -n %{daemon_packname}
%service_del_postun %{daemon_name}.service
%if %{with_libs} == yes
%post -n %{lib_packname}
/sbin/ldconfig
%postun -n %{lib_packname}
/sbin/ldconfig
%endif
%files utils
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{cli_name}
%attr(755,root,root) %{_bindir}/%{tx_name}
%if %{with_man} == yes
%{_mandir}/man1/%{cli_name}.1%{?ext_man}
%{_mandir}/man1/%{tx_name}.1%{?ext_man}
%endif
%if %{with_gui} == yes
%files %{qt_version}
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{gui_name}
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/applications/%{gui_name}.desktop
%if %{with_man} == yes
%{_mandir}/man1/%{gui_name}.1%{?ext_man}
%endif
%endif
%files -n %{daemon_packname}
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{daemon_name}
%{_sbindir}/rc%{daemon_name}
%{_unitdir}/%{daemon_name}.service
%config(noreplace) %{_sysconfdir}/%{progbase}.conf
%if %{with_bash_support} == yes
%config %{_sysconfdir}/bash_completion.d/%{daemon_name}.bash-completion
%config %{_sysconfdir}/bash_completion.d/%{cli_name}.bash-completion
%config %{_sysconfdir}/bash_completion.d/%{tx_name}.bash-completion
%endif
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{daemon_name}
%dir %attr(700,%{progbase},%{progbase}) %{_localstatedir}/lib/%{progbase}
%ghost %{_rundir}/%{progbase}
%{_tmpfilesdir}/%{progbase}_rundir.conf
%if %{with_man} == yes
%{_mandir}/man1/%{daemon_name}.1%{?ext_man}
%endif
%if %{with_bench} == yes
%files bench
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/%{bench_name}
%endif
%if %{with_tests} == yes
%files test
%defattr(-,root,root,-)
%if %{with_bench} == yes
%attr(755,root,root) %{_bindir}/%{bench_name}
%endif
%attr(755,root,root) %{_bindir}/%{test_name}
%attr(755,root,root) %{_bindir}/%{test_gui_name}
%endif
%if %{with_libs} == yes
%files -n %{lib_packname}
%defattr(-,root,root,-)
%{_libdir}/*.so.*
%files -n %{lib_packname}-devel
%defattr(-,root,root,-)
%{_includedir}/*.h
%{_libdir}/pkgconfig/
%{_libdir}/*.so
%endif
%files doc
%defattr(-,root,root,-)
%{_defaultdocdir}/%{name}/
%{_defaultlicensedir}/%{name}/
%changelog