%define debug_package %{nil}
Name:    tezos-baker-Proxford
Version: 20.3
Release: 1
Epoch: 1
Summary: Daemon for baking
License: MIT
BuildArch: x86_64 aarch64
Source0: tezos-baker-Proxford-20.3.tar.gz
Source1: https://gitlab.com/tezos/tezos/tree/v20.3/
BuildRequires: make cmake m4 perl pkg-config wget unzip rsync gcc cargo opam git autoconf coreutils libev-devel gmp-devel hidapi-devel libffi-devel zlib-devel libpq-devel protobuf-compiler protobuf-devel sqlite-devel systemd systemd-rpm-macros
Requires: libev-devel gmp-devel hidapi-devel libffi-devel zlib-devel libpq-devel protobuf-compiler protobuf-devel sqlite-devel, tezos-sapling-params, tezos-client, acl, udev
%description
Daemon for baking
Maintainer: Serokell <hi@serokell.io>
%prep
%setup -q
%build
%install
make octez-baker-Proxford
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 octez-baker-Proxford %{buildroot}/%{_bindir}
ln -s %{_bindir}/octez-baker-Proxford %{buildroot}/%{_bindir}/tezos-baker-Proxford



mkdir -p %{buildroot}/%{_unitdir}
install -m 644 tezos-baker-proxford.service %{buildroot}/%{_unitdir}
install -m 644 tezos-baker-proxford@.service %{buildroot}/%{_unitdir}

mkdir -p %{buildroot}/%{_sysconfdir}/default
install -m 644 tezos-baker-proxford.default %{buildroot}/%{_sysconfdir}/default/tezos-baker-proxford

install -m 0755 tezos-baker-proxford-start %{buildroot}/%{_bindir}


%files
%license LICENSE

%{_bindir}/octez-baker-Proxford
%{_bindir}/tezos-baker-Proxford

%{_bindir}/tezos-baker-proxford-start

%{_unitdir}/tezos-baker-proxford.service
%{_unitdir}/tezos-baker-proxford@.service

%{_sysconfdir}/default/tezos-baker-proxford



%post
%systemd_post tezos-baker-proxford.service
%systemd_post tezos-baker-proxford@.service


if [ -z $(getent passwd tezos) ]; then
    useradd -r -s /bin/false -m -d /var/lib/tezos tezos
    chmod 0755 /var/lib/tezos
fi

mkdir -p /var/lib/tezos/.tezos-client
chown -R tezos:tezos /var/lib/tezos/.tezos-client


%preun
%systemd_preun tezos-baker-proxford.service
%systemd_preun tezos-baker-proxford@.service


%postun
%systemd_postun_with_restart tezos-baker-proxford.service
%systemd_postun_with_restart tezos-baker-proxford@.service