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

Summary: Library for getting and setting POSIX.1e capabilities
Summary(ja): POSIX.1e ケーパビリティを取得・設定するためのライブラリ
Name: libcap
Version: 2.27
Release: 1%{?_dist_release}

License: LGPLv2
Group: System Environment/Libraries

Vendor: Project Vine
Distribution: Vine Linux

Source: https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/libcap2/%{name}-%{version}.tar.xz
Source1: getpcaps.8


# Patch0: libcap-2.16-headerfix.patch
Patch1: %{name}-2.25-buildflags.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: libattr-devel
BuildRequires: pam-devel

%description
libcap is a library for getting and setting POSIX.1e (formerly POSIX 6)
draft 15 capabilities.

%package devel
Summary: Development files for libcap
Summary(ja): libcap の開発用ファイル
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
Development files (Headers, libraries for static linking, etc) for libcap.

libcap is a library for getting and setting POSIX.1e (formerly POSIX 6)
draft 15 capabilities.

Install libcap-devel if you want to develop or compile applications using
libcap.

%package static
Summary: static library of libcap
Summary(ja): libcap のスタティックライブラリ
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}

%description static
This package includes the static library of libpcap

# compat32
%package -n compat32-%{name}
Summary: Library for getting and setting POSIX.1e capabilities
Summary(ja): POSIX.1e ケーパビリティを取得・設定するためのライブラリ
Group: System Environment/Libraries

%description -n compat32-%{name}
libcap is a library for getting and setting POSIX.1e (formerly POSIX 6)
draft 15 capabilities.

%package -n compat32-%{name}-devel
Summary: Development files for libcap
Summary(ja): libcap の開発用ファイル
Group: Development/Libraries
Requires: compat32-%{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}-%{release}

%description -n compat32-%{name}-devel
Development files (Headers, libraries for static linking, etc) for libcap.

libcap is a library for getting and setting POSIX.1e (formerly POSIX 6)
draft 15 capabilities.

Install libcap-devel if you want to develop or compile applications using
libcap.

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

%build
# libcap can not be build with _smp_mflags:
make PREFIX=%{_prefix} LIBDIR=%{_libdir} SBINDIR=%{_sbindir} \
     INCDIR=%{_includedir} MANDIR=%{_mandir} COPTFLAG="$RPM_OPT_FLAGS"

%install
rm -rf $RPM_BUILD_ROOT
make install RAISE_SETFCAP=no \
	     DESTDIR=${RPM_BUILD_ROOT} \
             LIBDIR=/%{_lib} \
             SBINDIR=%{_sbindir} \
             INCDIR=%{_includedir} \
             MANDIR=%{_mandir}/ \
             PKGCONFIGDIR=%{_libdir}/pkgconfig/ \
	     COPTFLAG="$RPM_OPT_FLAGS"
mkdir -p ${RPM_BUILD_ROOT}/%{_mandir}/man{2,3,8}
#mv -f doc/*.2 ${RPM_BUILD_ROOT}/%{_mandir}/man2/
mv -f doc/*.3 ${RPM_BUILD_ROOT}/%{_mandir}/man3/

chmod +x $RPM_BUILD_ROOT/%{_lib}/*.so.*

# need to build init.lxc.static
mv %{buildroot}/%{_lib}/libcap.a %{buildroot}/%{_libdir}/libcap.a

cp -f %{SOURCE1} %{buildroot}/%{_mandir}/man8/

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%post -n compat32-%{name} -p /sbin/ldconfig

%postun -n compat32-%{name} -p /sbin/ldconfig

%files
%defattr(-,root,root)
%license License
%doc doc/capability.notes
/%{_lib}/*.so.*
%{_sbindir}/*
%{_mandir}/man1/*
%{_mandir}/man8/*
/%{_lib}/security/pam_cap.so

%files devel
%defattr(-,root,root)
%{_includedir}/*
/%{_lib}/*.so
%{_libdir}/pkgconfig/*
%{_mandir}/man3/*

%files static
%defattr(-,root,root)
%{_libdir}/*.a

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

%files -n compat32-%{name}-devel
%defattr(-,root,root)
/%{_lib}/*.so
%endif

%changelog
* Mon Sep 23 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.27-1
- new upstream release.

* Sun Jun 26 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.25-1
- new upstream release.
- added Source1.
- added libcap-static.

* Thu Jul  9 2015 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.24-1
- new upstream release
- change tarfile format
- change flags in install section
- add patch1, drop patch0 (patch1 from fedora)

* Tue Dec 31 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.16-4
- rebuild with VineSeed environment

* Tue Jun 07 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.16-3
- add BuildRequires: pam-devel

* Sat Apr 16 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.16-2
- rebuilt with current VineSeed

* Wed Jul 15 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.16-1
- new upstream release
- remove compat library (libpcap-1.10)

* Sun May 10 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.06-2
- added compat32 package for x86_64 arch support

* Fri Jun 20 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.06-1
- source updated
- built with libattr 2.4.41

* Mon Mar 13 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 1.10-22vl2
- rebuilt

* Sun Mar 20 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.10-22vl1
- initial build for Vine Linux based on FC package

* Wed Mar 02 2005 Karsten Hopp <karsten@redhat.de> 1.10-22
- build with gcc-4

* Wed Feb 09 2005 Karsten Hopp <karsten@redhat.de> 1.10-21
- rebuilt

* Tue Aug 31 2004 Phil Knirsch <pknirsch@redhat.com> 1.10-20
- Fix wrong typedef in userland patch (#98801)

* Tue Jun 15 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Tue Mar 02 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Tue Jan 27 2004 Karsten Hopp <karsten@redhat.de> 1.10-17
- use _manpath

* Wed Jun 04 2003 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
- rebuilt

* Sat Jan  4 2003 Jeff Johnson <jbj@redhat.com> 1.10-14
- set execute bits on library so that requires are generated.

* Thu Nov 21 2002 Mike A. Harris <mharris@redhat.com> 1.10-13
- Removed %%name macro sillyness from package Summary, description text, etc.
- Removed archaic Prefix: tag
- lib64 fixes everywhere to use _lib, _libdir, etc
- Removed deletion of RPM_BUILD_DIR from %%clean section
- Added -q flag to setup macro
- Severely cleaned up spec file, and removed usage of perl

* Fri Jul 19 2002 Jakub Jelinek <jakub@redhat.com> 1.10-12
- CFLAGS was using COPTFLAG variable, not COPTFLAGS
- build with -fpic
- apply the IA-64 patch everywhere, use capget/capset from glibc,
  not directly as _syscall (as it is broken on IA-32 with -fpic)
- reenable alpha

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Wed May 29 2002 Bernhard Rosenkraenzer <bero@redhat.com> 1.10-10
- Exclude alpha for now, apparent gcc bug.

* Fri Nov  9 2001 Bernhard Rosenkraenzer <bero@redhat.com> 1.10-6
- Fix sys/capabilities.h header (#55727)
- Move to /lib, some applications seem to be using this rather early
  (#55733)

* Mon Jul 16 2001 Trond Eivind Glomsr藷?<teg@redhat.com>
- Add post,postun scripts

* Tue Jul 10 2001 Jakub Jelinek <jakub@redhat.com>
- don't build libcap.so.1 with ld -shared, but gcc -shared

* Wed Jun 20 2001 Trond Eivind Glomsr藷?<teg@redhat.com>
- Rebuild - it was missing for alpha

* Wed Jun 06 2001 Florian La Roche <Florian.LaRoche@redhat.de>
- add s390/s390x support

* Thu May 17 2001 Bernhard Rosenkraenzer <bero@redhat.com> 1.10-1
- initial RPM
- fix build on ia64
