%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

%define vermajor 1
%define verminor 6
%define version %{vermajor}.%{verminor}
%define libapivermajor 1
%define libapiversion %{libapivermajor}.6

%define libdir /%{_lib}
%define usrlibdir %{_prefix}/%{_lib}

Summary: Linux Key Management Utilities
Summary(ja): Linux 鍵管理ユーティリティ
Name: keyutils
Version: %{version}
Release: 1%{?_dist_release}
Group: System Environment/Base
License: GPLv2+ and LGPLv2+
Distribution: Vine Linux
Vendor: Project Vine

URL: http://people.redhat.com/~dhowells/keyutils/
Source0: http://people.redhat.com/~dhowells/keyutils/keyutils-%{version}.tar.bz2

ExclusiveOS: Linux
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: glibc-kernheaders >= 2.4-9.1.92
Requires: %{name}-libs = %{version}-%{release}


%description
Utilities to control the kernel key management facility and to provide
a mechanism by which the kernel call back to userspace to get a key
instantiated.

%package libs
Summary: Key utilities library
Summary(ja): 鍵管理ユーティリティのライブラリ
Group: System Environment/Libraries

%description libs
This package provides a wrapper library for the key management facility system
calls.

%package libs-devel
Summary: Development package for building linux key management utilities
Summary(ja): Linux 鍵管理ユーティリティの開発ファイル
Group: Development/Libraries
Requires: %{name}-libs = %{version}-%{release}

%description libs-devel
This package provides headers and libraries for building key utilities.

%package -n compat32-%{name}-libs
Summary: Key utilities library
Summary(ja): 鍵管理ユーティリティのライブラリ
Group: System Environment/Libraries
Requires: %{name}-libs = %{version}-%{release}

%description -n compat32-%{name}-libs
This package provides a wrapper library for the key management facility system
calls.

%package -n compat32-%{name}-libs-devel
Summary: Development package for building linux key management utilities
Summary(ja): Linux 鍵管理ユーティリティの開発ファイル
Group: Development/Libraries
Requires: compat32-%{name}-libs = %{version}-%{release}
Requires: %{name}-libs-devel = %{version}-%{release}

%description -n compat32-%{name}-libs-devel
This package provides headers and libraries for building key utilities.

%prep
%setup -q

%build
make \
	NO_ARLIB=1 \
	LIBDIR=%{libdir} \
	USRLIBDIR=%{usrlibdir} \
	BINDIR=%{_bindir} \
	SBINDIR=%{_sbindir} \
	RELEASE=.%{release} \
	NO_GLIBC_KEYERR=1 \
	CFLAGS="-Wall $RPM_OPT_FLAGS -Werror"

%install
rm -rf $RPM_BUILD_ROOT
make \
	NO_ARLIB=1 \
	DESTDIR=$RPM_BUILD_ROOT \
	LIBDIR=%{libdir} \
	USRLIBDIR=%{usrlibdir} \
	BINDIR=%{_bindir} \
	SBINDIR=%{_sbindir} \
	install

mkdir -p %{buildroot}%{_libdir}
mv -f %{buildroot}/%{_lib}/pkgconfig %{buildroot}%{_libdir}

%clean
rm -rf $RPM_BUILD_ROOT

%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig

%if %{build_compat32}
%post -n compat32-%{name}-libs -p /sbin/ldconfig
%postun -n compat32-%{name}-libs -p /sbin/ldconfig

%endif

%files
%defattr(-,root,root,-)
%license LICENCE.GPL
%doc README
%{_sbindir}/*
%{_bindir}/*
%{_datadir}/keyutils
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man8/*
%config(noreplace) %{_sysconfdir}/*

%files libs
%defattr(-,root,root,-)
%license LICENCE.LGPL
%{_mandir}/man7/*
%{libdir}/libkeyutils.so.*

%files libs-devel
%defattr(-,root,root,-)
%{usrlibdir}/libkeyutils.so
%{usrlibdir}/pkgconfig/*
%{_includedir}/*
%{_mandir}/man3/*

# compat32
%if %{build_compat32}
%files -n compat32-%{name}-libs
%defattr(-,root,root,-)
%{libdir}/libkeyutils.so.*

%files -n compat32-%{name}-libs-devel
%defattr(-,root,root,-)
%{usrlibdir}/libkeyutils.so
%{usrlibdir}/pkgconfig/*
%endif

%changelog
* Wed Mar 18 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.6-1
- new upstream release.

* Mon Dec 22 2014 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.5.9-1
- updated to 1.5.9
- rebuilt on current VineSeed

* Thu Mar 24 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2-4
- rebuilt with new toolchains

* Sun Jun 28 2009 NAKAMURA Kenta <kenta@vinelinux.org> 1.2-3
- added compat32 package for x86_64 arch support

* Sat Feb 14 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2-2
- changed libs subpackage's Group to System Environment/Libraries
- changed devel subpackage's Group to Development/Libraries

* Thu Oct 02 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2-1
- initial build for Vine Linux

* Mon Feb 18 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 1.2-3
- Autorebuild for GCC 4.3

* Tue Aug 22 2006 David Howells <dhowells@redhat.com> - 1.2-1
- Remove syscall manual pages (section 2) to man-pages package [BZ 203582]
- Don't write to serial port in debugging script

* Mon Jun 5 2006 David Howells <dhowells@redhat.com> - 1.1-4
- Call ldconfig during (un)installation.

* Fri May 5 2006 David Howells <dhowells@redhat.com> - 1.1-3
- Don't include the release number in the shared library filename
- Don't build static library

* Fri May 5 2006 David Howells <dhowells@redhat.com> - 1.1-2
- More bug fixes from Fedora reviewer.

* Thu May 4 2006 David Howells <dhowells@redhat.com> - 1.1-1
- Fix rpmlint errors

* Mon Dec 5 2005 David Howells <dhowells@redhat.com> - 1.0-2
- Add build dependency on glibc-kernheaders with key management syscall numbers

* Tue Nov 29 2005 David Howells <dhowells@redhat.com> - 1.0-1
- Add data pipe-in facility for keyctl request2

* Mon Nov 28 2005 David Howells <dhowells@redhat.com> - 1.0-1
- Rename library and header file "keyutil" -> "keyutils" for consistency
- Fix shared library version naming to same way as glibc.
- Add versioning for shared library symbols
- Create new keyutils-libs package and install library and main symlink there
- Install base library symlink in /usr/lib and place in devel package
- Added a keyutils archive library
- Shorten displayed key permissions list to just those we actually have

* Thu Nov 24 2005 David Howells <dhowells@redhat.com> - 0.3-4
- Add data pipe-in facilities for keyctl add, update and instantiate

* Fri Nov 18 2005 David Howells <dhowells@redhat.com> - 0.3-3
- Added stdint.h inclusion in keyutils.h
- Made request-key.c use request_key() rather than keyctl_search()
- Added piping facility to request-key

* Thu Nov 17 2005 David Howells <dhowells@redhat.com> - 0.3-2
- Added timeout keyctl option
- request_key auth keys must now be assumed
- Fix keyctl argument ordering for debug negate line in request-key.conf

* Thu Jul 28 2005 David Howells <dhowells@redhat.com> - 0.3-1
- Must invoke initialisation from perror() override in libkeyutils
- Minor UI changes

* Wed Jul 20 2005 David Howells <dhowells@redhat.com> - 0.2-2
- Bump version to permit building in main repositories.

* Tue Jul 12 2005 David Howells <dhowells@redhat.com> - 0.2-1
- Don't attempt to define the error codes in the header file.
- Pass the release ID through to the makefile to affect the shared library name.

* Tue Jul 12 2005 David Howells <dhowells@redhat.com> - 0.1-3
- Build in the perror() override to get the key error strings displayed.

* Tue Jul 12 2005 David Howells <dhowells@redhat.com> - 0.1-2
- Need a defattr directive after each files directive.

* Tue Jul 12 2005 David Howells <dhowells@redhat.com> - 0.1-1
- Package creation.
