File howdy.spec of Package howdy

#
# spec file for package howdy
#
# Copyright (c) 2021 Dmitriy O. Afanasyev, <dmafanasyev@gmail.com>.
#
# 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.

%if 0%{suse_version} < 1650
%define py_minor_ver 11
%endif
Name:           howdy
Version:        2.6.1
Release:        0
Summary:        Windows Hello™ style authentication for Linux
License:        MIT
Url:            https://github.com/boltgolt/howdy
Group:          System/Base
Source0:        %{url}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# SECTION trained dlib models, see _service file
Source1:        dlib_face_recognition_resnet_model_v1.dat.bz2
Source2:        mmod_human_face_detector.dat.bz2
Source3:        shape_predictor_5_face_landmarks.dat.bz2
# /SECTION
Patch1:         howdy-cli-py-getuid.patch
# PATCH-FEATURE-OPENSUSE howdy-pam-python3.patch badshah400@gmail.com -- Update configparser usage to use pam-python3 instead of pam-python(2)
Patch2:         howdy-pam-python3.patch
# PATCH-FEATURE-OPENSUSE howdy-nano-bindir.patch badshah400@gmail.com -- Correct installed bindir where howdy looks for nano text editor
Patch3:         howdy-nano-bindir.patch
# PATCH-FIX-UPSTREAM howdy-use-correct-python-exec.patch -- Use the correct python executable path instead of hard-coding it to /usr/bin/python3
Patch4:         howdy-use-correct-python-exec.patch
BuildRequires:  wget
BuildRequires:  python-rpm-macros
Requires:       pam-python3
Requires:       python3%{?py_minor_ver}-opencv3
Requires:       ffmpeg
Requires:       python3%{?py_minor_ver}-numpy
Requires:       python3%{?py_minor_ver}-dlib

%description
Windows Hello™ style authentication for Linux. Use your built-in IR emitters
and camera in combination with face recognition to prove who you are.

%prep
%autosetup -p1
( cd src/dlib-data/ ; ln %{_sourcedir}/*.bz2 . ; bzip2 -d -f *.bz2 )
sed -Ei "1{s@^#!/usr/bin/env python3\$@#!/usr/bin/python3%{?py_minor_ver:.%py_minor_ver}@}" src/cli.py

%build
# nothing to build

%install
rm -rf 
mkdir -p %{buildroot}%{_libdir}/security/%{name}
rm -fr src/*~
cp -pr src/* %{buildroot}%{_libdir}/security/%{name}

# Delete some files from src/dlib-data
rm -fr %{buildroot}%{_libdir}/security/%{name}/dlib-data/{Readme.md,install.sh,.gitignore}

#Add bash completion
mkdir -p %{buildroot}%{_datadir}/bash-completion/completions
install -Dm 644 autocomplete/%{name} %{buildroot}%{_datadir}/bash-completion/completions

# Create an executable
mkdir -p %{buildroot}%{_bindir}
chmod +x %{buildroot}%{_libdir}/security/%{name}/cli.py
ln -s %{_libdir}/security/%{name}/cli.py %{buildroot}%{_bindir}/%{name}

%post
echo "See https://en.opensuse.org/SDB:Facial_authentication for configuration manual"

%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
%dir %{_libdir}/security
%{_libdir}/security/%{name}
%{_datadir}/bash-completion/completions/%{name}
%config(noreplace) %{_libdir}/security/%{name}/config.ini

%changelog
openSUSE Build Service is sponsored by