File logkeys.spec of Package logkeys

#
# spec file for package logkeys
#
# Copyright (c) 2017 SUSE LINUX Products 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:           logkeys
Version:	0.1.1c
Release:	0		
License:	GPL-3.0+ or WTFPL
Summary:	Simple Keylogger
Url:		https://github.com/kernc/logkeys
Group:		Productivity/Security
Source:		%name-%version.tar.gz
Source1:	%{name}d.conf
Source2:	%name.service
Patch0:		missing-call-to-setgroups-before-setuid.patch
Patch1:		disable-input-check.patch
BuildRequires:	gcc-c++
BuildRequires:	automake
BuildRequires:	procps
BuildRequires:	kbd
BuildRequires: systemd-rpm-macros
%{?systemd_requires}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
logkeys is a linux keylogger. It is no more advanced than other
available linux keyloggers, notably lkl and uberkey, but is a bit
newer, more up to date, it doesn't unreliably repeat keys and it
shouldn't crash your X. All in all, it just seems to work. It
relies on event interface of the Linux input subsystem.
Once completely set, it logs all common character and function keys,
while also being fully aware of Shift and AltGr key modifiers.

%prep
%setup -q
%patch0 -p3
%patch1 -p1

%build
#hack to pass osc tests
export CXXFLAGS="%optflags"
CXXFLAGS=$(%__sed 's/-D_FORTIFY_SOURCE=.//g' <<< $CXXFLAGS)
%configure

# fix cxxflags in Makefile
%__sed -i 's#^CXXFLAGS =.*#AM_CXXFLAGS = $(CXXFLAGS) -Wall -DSYS_CONF_DIR=\\"$(sysconfdir)\\"#' src/Makefile
%__make %{?_smp_mflags}

%install
%__install -Dm755 src/%name %buildroot%_bindir/%name

%__gzip -9 man/%name.8
%__install -Dm644 man/%name.8.gz %buildroot%_mandir/man8/%name.8.gz

%__install -Dm644 %{S:2} %buildroot%_unitdir/%name.service
%__install -Dm644 %{S:1} %buildroot%_sysconfdir/%{name}d

%__mkdir %buildroot%_sbindir
%__ln_s %_sbindir/service %buildroot%_sbindir/rc%name

cd keymaps
for filename in $(ls *.map); do
	%__install -Dm644 $filename %buildroot%_datadir/%name/${filename}
done

%files
%defattr(-,root,root)
%doc ChangeLog README COPYING
%_bindir/%name
%_mandir/man8/%name.8.gz
%config(noreplace) %_sysconfdir/%{name}d
%_unitdir/%name.service
%{_sbindir}/rc%name
%_datadir/%name/*.map
%dir %_datadir/%name

%pre
%service_add_pre %name.service

%post
%service_add_post %name.service

%preun
%service_del_preun %name.service

%postun
%service_del_postun %name.service

%changelog
* Wed Oct 11 2017 Simone Sclavi <darkhado@gmail.com> - 0.1.1c
- Initial build