File libcgroup.spec of Package libcgroup

#
# spec file for package libcgroup
#
# Copyright (c) 2019 SUSE LINUX 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 https://bugs.opensuse.org/
#


Name:           libcgroup
%define lname	libcgroup1
Version:        0.41.rc1
Release:        0
Summary:        Control groups management tools
License:        LGPL-2.1-only
Group:          System/Management
Url:            http://sourceforge.net/projects/libcg/
Source:         http://sourceforge.net/projects/libcg/files/libcgroup/v0.41.rc/libcgroup-0.41.rc1.tar.bz2
Source3:        sysconfig.cgred
Source4:        cgconfig.service
Source99:       baselibs.conf
Patch6:         initd_cgred.patch
Patch9:         do-not-version-pam-module.patch
Patch10:        remove-initd_cgconfig.patch
Patch11:        0001-cgrulesengd-remove-umask-0.patch
Patch12:        0001-api.c-change-cgroup-of-every-thread-of-a-process.patch
Patch13:        0002-api.c-always-move-all-tasks-of-a-process-to-a-cgroup.patch
# 0001-cgrulesengd-Do-not-ignore-changes-of-short-lived-pro.patch (sent upstream)
Patch14:        0001-cgrulesengd-Do-not-ignore-changes-of-short-lived-pro.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  libtool
BuildRequires:  pam-devel
BuildRequires:  pkg-config
BuildRequires:  systemd-rpm-macros
Requires:       pam
%{?systemd_requires}

%description
Control groups, a new kernel feature in Linux 2.6.24 provides a file
system interface to manipulate and control the details on task grouping
including creation of new task groups (control groups), permission
handling and task assignment.

%package -n %lname
Summary:        Control groups management library
Group:          System/Libraries

%description -n %lname
Control groups, a new kernel feature in Linux 2.6.24 provides a file
system interface to manipulate and control the details on task grouping
including creation of new task groups (control groups), permission
handling and task assignment.

%package devel
Summary:        Control groups management tools devel package
Group:          Development/Libraries/C and C++
Requires:       %lname = %version

%description devel
Control groups, a new kernel feature in Linux 2.6.24 provides a file
system interface to manipulate and control the details on task grouping
including creation of new task groups (control groups), permission
handling and task assignment.

%package tools
Summary:        Control groups management tools
# Added for openSUSE 12.3 to aid the solver.
Group:          System/Management
Provides:       libcgroup1:/usr/bin/cgexec
Requires(post):	%insserv_prereq %fillup_prereq
Requires:       insserv

%description tools
Control groups, a new kernel feature in Linux 2.6.24 provides a file
system interface to manipulate and control the details on task grouping
including creation of new task groups (control groups), permission
handling and task assignment.

%prep
%setup -n libcgroup-%{version}
%patch6 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1

%build
# only for GIT builds
%if 0
aclocal
libtoolize -c
autoconf
autoheader
automake --foreign --add-missing --copy
%endif
# ==============

autoreconf -f -i
%configure --enable-pam-module-dir=/%{_lib}/security --enable-initscript-install
export V=1
make %{?_smp_mflags}

%install
%makeinstall INITSCRIPTDIR=%{buildroot}/%{_sysconfdir}/init.d/
find $RPM_BUILD_ROOT -type f -name '*.la' -exec rm -f {} ';'
rm -f $RPM_BUILD_ROOT/%{_lib}/security/*.so.* 
mkdir -p %{buildroot}/usr/share/fillup-templates/
install -m 644 %{SOURCE3} %{buildroot}/usr/share/fillup-templates/sysconfig.cgred
%__install -D -m 444 %{SOURCE4} %{buildroot}%{_unitdir}/cgconfig.service

ln -s %{_sysconfdir}/init.d/cgred %{buildroot}/%{_sbindir}/rccgred
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rccgconfig

# remove setuid
chmod u-s $RPM_BUILD_ROOT/%{_bindir}/cgexec

# move lib to rootfs
libcgso=$(basename $RPM_BUILD_ROOT/%{_libdir}/libcgroup.so.*.*.*)
mkdir -p $RPM_BUILD_ROOT/%{_lib}
mv -f $RPM_BUILD_ROOT/%{_libdir}/libcgroup.so.*.*.* $RPM_BUILD_ROOT/%{_lib}
rm -f $RPM_BUILD_ROOT/%{_libdir}/libcgroup.so.1
ln -sf $libcgso $RPM_BUILD_ROOT/%{_lib}/libcgroup.so.1
ln -sf ../../%{_lib}/$libcgso $RPM_BUILD_ROOT/%{_libdir}/libcgroup.so

%post -n %lname -p /sbin/ldconfig

%postun -n %lname -p /sbin/ldconfig

%preun tools
%stop_on_removal cgred 
%service_del_preun cgconfig.service

%pre tools
%service_add_pre cgconfig.service

%post tools
%service_add_post cgconfig.service
%{fillup_and_insserv -n cgred}
test ! -e /var/log/cgred || chmod go-w /var/log/cgred
echo "cgconfig: WARNING: this version doesn't create /sysdefault cgroup"

%postun tools
%service_del_postun cgconfig.service
%restart_on_update cgred
%insserv_cleanup

%files -n %lname
%defattr(-,root,root)
/%{_lib}/libcgroup.so.*

%files tools
%defattr(-,root,root)
%doc COPYING
%doc README
%doc README_daemon
%doc samples/cgconfig.conf
%doc samples/cgrules.conf
%{_unitdir}/cgconfig.service
%{_sysconfdir}/init.d/cgred
%{_bindir}/cg*
%{_bindir}/ls*
%{_sbindir}/cg*
%{_sbindir}/rccgred
%{_sbindir}/rccgconfig
/%{_lib}/security/pam_cgroup.so
/usr/share/fillup-templates/sysconfig.cgred
%{_mandir}/man[^3]/*

%files devel
%defattr(-,root,root)
%{_libdir}/libcgroup.so
%{_includedir}/libcgroup.h
%dir %{_includedir}/libcgroup
%{_includedir}/libcgroup/*.h
%{_libdir}/pkgconfig/libcgroup.pc

%changelog
openSUSE Build Service is sponsored by