File libcgroup.spec of Package libcgroup

#
# spec file for package libcgroup
#
# Copyright (c) 2015 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/
#


%define lname	libcgroup1
Name:           libcgroup
Version:        0.41
Release:        0
Summary:        Control groups management tools
License:        LGPL-2.1
Group:          System/Management
Url:            http://sourceforge.net/projects/libcg/
Source:         http://sourceforge.net/projects/libcg/files/%{name}/v%{version}/%{name}-%{version}.tar.bz2
Source3:        sysconfig.cgred
Source99:       baselibs.conf
Patch5:         initd_cgconfig.patch
Patch6:         initd_cgred.patch
Patch9:         do-not-version-pam-module.patch
Patch10:        cgconfig-Do-not-overwrite-defaultcgroup-configuratio.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  libtool
BuildRequires:  pam-devel
BuildRequires:  pkg-config
Requires:       insserv
Requires(post):	%insserv_prereq %fillup_prereq
Requires:       pam
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%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
Group:          System/Management
Requires(post): %fillup_prereq
Requires(post): %insserv_prereq
# Added for openSUSE 12.3 to aid the solver.
Provides:       libcgroup1:%{_bindir}/cgexec

%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 -q
%patch5 -p1
%patch6 -p1
%patch9 -p1
%patch10 -p1
autoreconf -fvi

%build
%configure \
    --disable-silent-rules \
    --enable-pam-module-dir=/%{_lib}/security \
    --enable-initscript-install
make %{?_smp_mflags}

%install
make DESTDIR=%{buildroot} install %{?_smp_mflags} INITSCRIPTDIR=%{buildroot}/%{_sysconfdir}/init.d/
find %{buildroot} -type f -name "*.la" -delete -print
rm -f %{buildroot}/%{_lib}/security/*.so.*
mkdir -p %{buildroot}/%{_localstatedir}/adm/fillup-templates/
install -m 644 %{SOURCE3} %{buildroot}/%{_localstatedir}/adm/fillup-templates/sysconfig.cgred

# FIXME: migrate to systemd
ln -s %{_sysconfdir}/init.d/cgred %{buildroot}/%{_sbindir}/rccgred
ln -s %{_sysconfdir}/init.d/cgconfig %{buildroot}/%{_sbindir}/rccgconfig

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

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

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

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

%preun tools
%stop_on_removal cgred cgconfig

%post tools
%{fillup_and_insserv -f cgconfig}
%{fillup_and_insserv -n cgred}

%postun tools
%restart_on_update cgconfig 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
%{_sysconfdir}/init.d/cgconfig
%{_sysconfdir}/init.d/cgred
%{_bindir}/cg*
%{_bindir}/ls*
%{_sbindir}/cg*
%{_sbindir}/rccgred
%{_sbindir}/rccgconfig
/%{_lib}/security/pam_cgroup.so
%{_localstatedir}/adm/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