# SPDX-FileCopyrightText: 2022 stenc authors
#
# SPDX-License-Identifier: GPL-2.0-or-later

%global commit 4b0b7e15755dca3f2c0e861ca6f6d01d5d90963b
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           stenc
Version:        2.0.0
Release:        2%{?dist}
Summary:        SCSI Tape Encryption Manager

License:        GPL-2.0-or-later
URL:            https://github.com/scsitape/stenc
Source0:        https://github.com/scsitape/stenc/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
Source1:        stenc-keygen.sh

BuildRequires:  gcc-c++
BuildRequires:  make
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  pkgconfig(bash-completion)
BuildRequires:  pandoc

%description
SCSI Tape Encryption Manager - Manages encryption on LTO 4 and newer tape
drives with hardware-based encryption

%prep
%autosetup -p1 -n %{name}-%{commit}

%build
./autogen.sh
%configure
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot}
%{__install} -Dm0755 %{SOURCE1} -t %{buildroot}%{_bindir}

%files
%license LICENSES/GPL-2.0-or-later.txt
%doc README.md AUTHORS.md
%caps(cap_sys_rawio=ep) %{_bindir}/stenc
%{_mandir}/man1/stenc.1*
%{_datadir}/bash-completion/completions/stenc
# CentOS 8 doesn't support this macro 
#%%{bash_completions_dir}/stenc


%package -n %{name}-keygen
Summary: Stenc key generator
BuildArch: noarch
Requires: openssl
Requires: bash
Recommends: stenc

%description -n %{name}-keygen
A simple tool to generate a key for stenc.

%files -n %{name}-keygen
%{_bindir}/stenc-keygen.sh

%changelog
* Mon Mar 18 2024 Paweł Marciniak <sunwire+repo@gmail.com> - 2.0.0-2
- BuildRequires fix for bash-completion

* Sat Jun 03 2023 Paweł Marciniak <sunwire+repo@gmail.com> - 2.0.0-1
- Release 2.0.0

* Tue May 2 2023 Paweł Marciniak <sunwire+repo@gmail.com> - 2.0.0_rc2-1
- Release candidate  2.0.0

* Mon Apr 25 2022 Paweł Marciniak <sunwire+repo@gmail.com> - 1.1.1-1
- Release 1.1.1

* Fri Apr 22 2022 Paweł Marciniak <sunwire+repo@gmail.com> - 1.1.0-1
- Release 1.1.0

* Wed Apr 20 2022 Paweł Marciniak <sunwire+repo@gmail.com> - 1.0.9-1
- Release 1.0.9

* Sat Jul 4 2020 Paweł Marciniak <sunwire+repo@gmail.com> 1.0.8-1
- Initial SPEC file