File cgminer-zeus.spec of Package cgminer-zeus

#
# spec file for package cgminer-zeus
#
# 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:           cgminer-zeus
Summary:        A BitCoin miner for zeus hardware
License:        GPL-3.0+
Group:          Productivity/Other
%define common_name cgminer
Version:        3.11v140620
Release:        0
Url:            https://github.com/zeusminer/cgminer_zeus/
Source0:        %{name}-%{version}.tar.xz
Source1:        start_cgminer.in
Source2:        cgminer.service.in
BuildRequires:  automake
BuildRequires:  libcurl-devel
BuildRequires:  libjansson-devel >= 2.5
BuildRequires:  libusb-devel
BuildRequires:  ncurses-devel
BuildRequires:  pkg-config
BuildRequires:  shadow
BuildRequires:  systemd
Conflicts:      cgminer
Conflicts:      cgminer-ants1
Conflicts:      cgminer-ants2
Conflicts:      cgminer-bab
Conflicts:      cgminer-bitmine_A1
Conflicts:      cgminer-knc
Conflicts:      cgminer-minion
Conflicts:      cgminer-sp10
Conflicts:      cgminer-sp30

%define packagename_daemon %{name}-daemon
%define plugdev_gid 46
%define plugdev_gname plugdev

%package -n %{packagename_daemon}
Summary:        Daemon for %{name}
Group:          Productivity/Other
BuildArch:      noarch
Requires:       %{name} = %{version}
%{?systemd_requires}
Recommends:     logrotate

%description
The zeus version of cgminer based on cgminer 3.11.

%description -n %{packagename_daemon}
This package contains a systemd daemon for %{name}.

%prep
%setup -q
%{__sed} 's#^__SETTINGS__$#cgminer_bin=%{_bindir}/%{common_name}\ncgminer_conf=%{_sysconfdir}/%{common_name}.conf\ncgminer_log=%{_localstatedir}/log/%{common_name}/%{common_name}.log\ncgminer_run=%{_localstatedir}/run/%{common_name}.pid#g' %{S:1} > start_%{common_name}
%{__sed} 's#^__SETTINGS__$#ExecStart=%{_sbindir}/start_%{common_name} start\nExecStop=%{_sbindir}/start_%{common_name} stop#g' %{S:2} > %{common_name}.service

%build
autoreconf -fvi
%{__chmod} 0755 configure
%configure --docdir=%{_defaultdocdir}/%{name} --disable-opencl --disable-adl --disable-bflsc --disable-bitforce --disable-icarus --disable-avalon --disable-modminer --disable-ztex --enable-scrypt --enable-zeus
%{__make} %{?_smp_mflags}

%install
%{__make} install DESTDIR=%{buildroot}
%{__mkdir_p} %{buildroot}%{_sbindir}
%{__mkdir_p} %{buildroot}%{_localstatedir}/log/%{common_name}
%{__mkdir_p} %{buildroot}%{_sysconfdir}/logrotate.d
%{__mkdir_p} %{buildroot}%{_unitdir}
%{__install} -m 0755 -p -t %{buildroot}%{_sbindir} start_%{common_name}
%{__install} -m 0644 -p -t %{buildroot}%{_unitdir} %{common_name}.service
%{__cp} -a example.conf %{common_name}.conf
%{__install} -m 0644 -p -t %{buildroot}%{_sysconfdir} %{common_name}.conf
%{__rm} %{buildroot}%{_bindir}/*.cl

# generate logrotate configuration
echo "%{_localstatedir}/log/%{common_name}/%{common_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
getent group %{plugdev_gname} > /dev/null || groupadd -g %{plugdev_gid} %{plugdev_gname}

%pre -n %{packagename_daemon}
%service_add_pre %{common_name}.service

%post -n %{packagename_daemon}
%service_add_post %{common_name}.service

%preun -n %{packagename_daemon}
%service_del_preun %{common_name}.service

%postun -n %{packagename_daemon}
%service_del_postun %{common_name}.service

%files
%defattr(644,root,root,-)
%attr(755,root,root) %{_bindir}/%{common_name}
%doc NEWS *README

%files -n %{packagename_daemon}
%defattr(-,root,root,-)
%attr(755,root,root) %{_sbindir}/start_%{common_name}
%config(noreplace) %attr(644,root,root) %{_sysconfdir}/%{common_name}.conf
%attr(750,root,root) %dir %{_localstatedir}/log/%{common_name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{packagename_daemon}
%{_unitdir}/

%changelog
openSUSE Build Service is sponsored by