File bfgminer.spec of Package bfgminer
#
# spec file for package bfgminer
#
# 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: bfgminer
Version: 5.5.0
Release: 0
Summary: A BitCoin miner
License: GPL-3.0
Group: Productivity/Other
Url: https://github.com/luke-jr/%{name}
Source0: %{name}-%{version}.tar.xz
Source1: start_bfgminer.in
Source2: bfgminer.service.in
Patch0: %{name}-configure.patch
Patch1: %{name}-i2c.patch
Patch2: %{name}-i2c-legacy.patch
Patch3: %{name}-microhttpd.patch
BuildRequires: automake
BuildRequires: libbase58-devel
BuildRequires: libblkmaker-devel >= 0.5.3
BuildRequires: libcurl-devel
BuildRequires: libevent-devel
BuildRequires: libgcrypt-devel
BuildRequires: libhidapi-devel
%if 0%{?suse_version} && 0%{?suse_version} > 1320
BuildRequires: libi2c0-devel
%else
BuildRequires: i2c-tools
%endif
BuildRequires: libjansson-devel
BuildRequires: libmicrohttpd-devel
BuildRequires: libsensors4-devel
BuildRequires: libtool
BuildRequires: libudev-devel
BuildRequires: libusb-devel
BuildRequires: ncurses-devel
BuildRequires: pkg-config
BuildRequires: systemd
BuildRequires: uthash-devel
BuildRequires: yasm
BuildRequires: zlib-devel
Recommends: libOpenCL1
%define packagename_daemon %{name}-daemon
%package -n %{packagename_daemon}
Summary: Daemon for %{name}
Group: Productivity/Other
BuildArch: noarch
Requires: %{name} = %{version}
%{?systemd_requires}
Recommends: logrotate
%description
This is a multi-threaded multi-pool FPGA, GPU and CPU miner with ATI GPU monitoring, (over)clocking and fanspeed support for bitcoin and derivative coins.
%description -n %{packagename_daemon}
This package contains a systemd daemon for %{name}.
%prep
%setup -q
%if 0%{?suse_version} && ( 0%{?suse_version} == 1315 || 0%{?suse_version} > 1320 )
%patch -P 0
%if 0%{?suse_version} && 0%{?suse_version} > 1320
%patch -P 1
%else
%patch -P 2
%endif
%endif
%if 0%{?suse_version} && 0%{?suse_version} >= 1600
%patch -P 3
%endif
%{__sed} 's#^__SETTINGS__$#bfgminer_bin=%{_bindir}/%{name}\nbfgminer_conf=%{_sysconfdir}/%{name}.conf\nbfgminer_log=%{_localstatedir}/log/%{name}/%{name}.log\nbfgminer_run=%{_localstatedir}/run/%{name}.pid#g' %{S:1} > start_%{name}
%{__sed} 's#^__SETTINGS__$#ExecStart=%{_sbindir}/start_%{name} start\nExecStop=%{_sbindir}/start_%{name} stop#g' %{S:2} > %{name}.service
%build
%if 0%{?suse_version} && 0%{?suse_version} > 1320
export CFLAGS="${CFLAGS} %{optflags} -fPIC -DNEED_LINUX_I2C_H"
export LIBS="${LIBS} -li2c"
%endif
%if 0%{?suse_version} && 0%{?suse_version} > 1500
export CFLAGS="${CFLAGS} -fcommon"
%endif
NOSUBMODULES=yes ./autogen.sh
%configure --enable-silent-rules --with-system-libbase58 --with-system-libblkmaker --with-udevrulesdir=%{_usr}/lib/udev/rules.d --docdir=%{_defaultdocdir}/%{name} --enable-alchemist --enable-bfsb --enable-bitmain --enable-cpumining --enable-jingtian --enable-knc --enable-kncasic --enable-metabank --enable-minergate --enable-minion --enable-opencl --enable-titan --enable-keccak --enable-scrypt
%{__make} %{?_smp_mflags}
%{__strip} -s %{name}
%{__strip} -s %{name}-rpc
%install
%{__make} install DESTDIR=%{buildroot}
%{__install} -d -m 0755 %{buildroot}%{_sbindir}
%{__install} -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d
%{__install} -d -m 0755 %{buildroot}%{_unitdir}
%{__install} -m 0755 -p -t %{buildroot}%{_sbindir} start_%{name}
%{__install} -m 0644 -p -t %{buildroot}%{_unitdir} %{name}.service
%{__cp} -a example.conf %{name}.conf
%{__install} -m 0644 -p -t %{buildroot}%{_sysconfdir} %{name}.conf
%{__ln_s} %{_sbindir}/service %{buildroot}%{_sbindir}/rcstart_%{name}
# generate logrotate configuration
echo "%{_localstatedir}/log/%{name}/%{name}.log {" > %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " compress" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " dateext" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " daily" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " rotate 90" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " notifempty" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " missingok" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " copytruncate" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo " create 644" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
echo "}" >> %{buildroot}%{_sysconfdir}/logrotate.d/%{packagename_daemon}
%check
%pre -n %{packagename_daemon}
%service_add_pre %{name}.service
%post -n %{packagename_daemon}
%service_add_post %{name}.service
%preun -n %{packagename_daemon}
%service_del_preun %{name}.service
%postun -n %{packagename_daemon}
%service_del_postun %{name}.service
%files
%defattr(-,root,root,-)
%attr(755,root,root) %{_bindir}/*
%attr(755,root,root) %{_sbindir}/setup-*
%{_datadir}/%{name}/
%{_usr}/lib/udev/rules.d/
%{_defaultdocdir}/%{name}/
%files -n %{packagename_daemon}
%defattr(-,root,root,-)
%attr(755,root,root) %{_sbindir}/start_%{name}
%{_sbindir}/rcstart_%{name}
%config(noreplace) %attr(644,root,root) %{_sysconfdir}/%{name}.conf
%attr(750,root,root) %dir %{_localstatedir}/log/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{packagename_daemon}
%{_unitdir}/
%changelog