File libcap-ng.spec of Package libcap-ng

#
# spec file for package libcap-ng
#
# Copyright (c) 2024 SUSE LLC
#
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%define sover  0
%define ambient_sover 0

Name:           libcap-ng
Version:        0.9.1
Release:        0
Summary:        An alternate Linux/POSIX capabilities library
License:        LGPL-2.1-or-later
Group:          Development/Libraries/C and C++
URL:            https://people.redhat.com/sgrubb/libcap-ng
Source0:        %{name}-%{version}.tar.gz
Source1:        baselibs.conf
BuildRequires:  autoconf automake libtool
BuildRequires:  kernel-headers >= 2.6.11
BuildRequires:  pkgconfig
# Для netcap может потребоваться libpcap-devel (добавьте при необходимости)
# BuildRequires:  libpcap-devel

%description
libcap-ng is a library providing an alternate mechanism to libcap to
make use of Linux process and file capabilities.

%package -n %{name}%{sover}
Summary:        An alternate Linux/POSIX capabilities library
Group:          System/Libraries

%description -n %{name}%{sover}
libcap-ng is a library providing an alternate mechanism to libcap to
inspect and set Linux process and file capabilities (modeled upon a
withdrawn POSIX.1e draft).

%package devel
Summary:        Header files for the libcap-ng library
Group:          Development/Libraries/C and C++
Requires:       %{name}%{sover} = %{version}
Requires:       kernel-headers >= 2.6.11
Requires:       pkgconfig

%description devel
The libcap-ng-devel package contains the files needed for developing
applications that need to use the libcap-ng library.

%package utils
Summary:        Utilities for analysing and setting file capabilities
License:        GPL-2.0-or-later
Group:          System/Base

%description utils
The libcap-ng-utils package contains applications to analyse the
Linux process capabilities of programs running on a system. It also
lets you set the filesystem-based capabilities.

%package -n libdrop_ambient%{ambient_sover}
Summary:        Library for dropping ambient capabilities
Requires:       %{name}%{sover} = %{version}

%description -n libdrop_ambient%{ambient_sover}
This library can be used via LD_PRELOAD to force an application started with ambient capabilities to drop them.

%package -n libdrop_ambient-devel
Summary:        Devel package for libdrop_ambient%{ambient_sover}
Requires:       libdrop_ambient%{ambient_sover}

%description -n libdrop_ambient-devel
This package contains the files needed for developing
applications that need to use the libdrop_ambient library.

%prep
%setup -q

%build
export LDFLAGS="$LDFLAGS -lpthread"

# Генерация configure из исходников GitHub
if [ -f ./autogen.sh ]; then
    echo "Found autogen.sh, running it..."
    ./autogen.sh
elif [ ! -f configure ]; then
    echo "autogen.sh not found and configure missing, running autoreconf -fi..."
    autoreconf -fi
else
    echo "configure already exists, skipping regeneration."
fi

%configure \
	--disable-static \
	--without-python
make %{?_smp_mflags}

%install
%make_install
find %{buildroot} -type f -name "*.la" -delete -print

# Диагностика установленных утилит
echo "--------------------------------------------------------"
echo "Installed files in /usr/bin and /usr/sbin:"
ls -la %{buildroot}%{_bindir}/ %{buildroot}%{_sbindir}/ 2>/dev/null || echo "Directories are empty"
echo "--------------------------------------------------------"

%post -n %{name}%{sover} -p /sbin/ldconfig
%postun -n %{name}%{sover} -p /sbin/ldconfig

%post -n libdrop_ambient%{ambient_sover} -p /sbin/ldconfig
%postun -n libdrop_ambient%{ambient_sover} -p /sbin/ldconfig

%files -n %{name}%{sover}
%license COPYING.LIB
%{_libdir}/%{name}.so.%{sover}
%{_libdir}/%{name}.so.%{sover}.*

%files -n libdrop_ambient%{ambient_sover}
%{_libdir}/libdrop_ambient.so.%{ambient_sover}
%{_libdir}/libdrop_ambient.so.%{ambient_sover}.*

%files -n libdrop_ambient-devel
%{_libdir}/libdrop_ambient.so
%{_mandir}/man7/libdrop_ambient.7%{ext_man}

%files devel
%{_mandir}/man3/*.3%{ext_man}
%{_includedir}/cap-ng.h
%{_libdir}/%{name}.so
%dir %{_datadir}/aclocal
%{_datadir}/aclocal/cap-ng.m4
%{_libdir}/pkgconfig/%{name}.pc

%files utils
%license COPYING
%{_bindir}/filecap
%{_bindir}/netcap
%{_bindir}/pscap
%{_mandir}/man8/*.8%{ext_man}

%changelog
openSUSE Build Service is sponsored by