File lxc.spec of Package lxc

#
# spec file for package lxc
#
# Copyright (c) 2016 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 http://bugs.opensuse.org/
#


%define		shlib_version 1
Name:           lxc
Version:        2.0.7
Release:        0
Url:            http://linuxcontainers.org/
Summary:        Userspace tools for Linux kernel containers
License:        LGPL-2.1+
Group:          System/Management
Source:         http://linuxcontainers.org/downloads/%{name}-%{version}.tar.gz
Source1:        lxc-createconfig.in
Source2:        README.SUSE
Source3:        openSUSE_apparmor_mount.conf
%if 0%{?suse_version} > 1315
Patch0:         0001-tree-wide-include-sys-sysmacros.h-directly.patch
Patch1:         0002-tree-wide-include-sys-sysmacros.h-directly.patch
%endif
Patch2:         0003-CVE-2017-5985-Ensure-target-netns-is-caller-owned.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires:  docbook-utils
BuildRequires:  docbook2x
BuildRequires:  fdupes
BuildRequires:  git
BuildRequires:  libapparmor-devel
BuildRequires:  libcap-devel
%ifarch %ix86 x86_64
BuildRequires:  libseccomp-devel
%endif
BuildRequires:  libxslt
BuildRequires:  linux-glibc-devel
BuildRequires:  lsb-release
BuildRequires:  pkg-config
BuildRequires:  python3-devel

%if 0%{?suse_version} >= 1210
BuildRequires:  systemd
%endif

Requires:       /usr/sbin/setcap
Requires:       lxcfs
Requires:       rsync

%{?systemd_requires}
# needed to create openSUSE containers using template
Recommends:     build
Recommends:     criu >= 2.0

%description
LXC provides commands to create and manage containers. Current LXC uses the
following kernel features to contain processes:
- Kernel namespaces (ipc, uts, mount, pid, network and user)
- Apparmor and SELinux profiles
- Seccomp policies
- Chroots (using pivot_root)
- Kernel capabilities
- CGroups (control groups)
LXC containers are often considered as something in the middle between a chroot
and a full fledged virtual machine. The goal of LXC is to create an environment
as close as possible to a standard Linux installation but without the need for a
separate kernel.

%package -n liblxc%{shlib_version}
Summary:        LXC container runtime library
License:        LGPL-2.1
Group:          System/Libraries

%description -n liblxc%{shlib_version}
Provides the LXC container runtime library.

%package -n liblxc-devel
Summary:        LXC container runtime library development files
License:        LGPL-2.1
Group:          Development/Libraries/C and C++
Requires:       liblxc%{shlib_version} = %version

%description -n liblxc-devel
Provides the LXC container runtime library development files

%prep
%setup
%if 0%{?suse_version} > 1315
%patch0 -p1
%patch1 -p1
%endif
%patch2 -p1

%build
chmod 755 configure
%configure --disable-examples \
	--disable-rpath \
	--with-init-script=systemd \
	--with-systemdsystemunitdir=%{_unitdir}
make %{?_smp_mflags}
cp %{SOURCE2} .
cp %{SOURCE3} .
rm -rf .doc
mkdir -p .doc/examples
cp doc/examples/*.conf .doc/examples

%install
%make_install
install -d -m 755 %{buildroot}/var/lib/lxc
find %buildroot -type f -name '*.la' -delete
chmod u-s %{buildroot}/%{_libexecdir}/%{name}/lxc-user-nic
./config.status --file=%{buildroot}%{_bindir}/lxc-createconfig:%{S:1}
chmod a+x %{buildroot}%{_bindir}/lxc-createconfig
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rclxc
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rclxc-net
cp %{SOURCE3} %{buildroot}/usr/share/lxc/config/common.conf.d/
%fdupes %{buildroot}/%{_datadir}/%{name}/config/

%pre
%service_add_pre lxc@.service lxc.service lxc-net.service

%post
%service_add_post lxc@.service lxc.service lxc-net.service

%preun
%service_del_preun lxc@.service lxc.service lxc-net.service

%postun
%service_del_postun lxc@.service lxc.service lxc-net.service

%post   -n liblxc%{shlib_version} -p /sbin/ldconfig
%postun -n liblxc%{shlib_version} -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc README doc/FAQ.txt
%doc README.SUSE
%dir %{_sysconfdir}/%{name}/
%config %{_sysconfdir}/%{name}/default.conf
%config(noreplace) %{_sysconfdir}/default/%{name}

# On non 64bit versions of SUSE  {_libdir} will be /usr/lib and thus equivalent
# to {_libexecdir}. Hence, the next directive would install everything in
# /usr/lib but we want to exclude some files because they get installed
# together with the liblxc subpackage on which lxc depends.
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/rootfs

%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/hooks
%{_libexecdir}/%{name}/lxc-containers
%{_libexecdir}/%{name}/lxc-net
%exclude %{_libexecdir}/%{name}/lxc-apparmor-load
%exclude %{_libexecdir}/%{name}/lxc-monitord
%exclude %{_libexecdir}/%{name}/lxc-user-nic

%{_datadir}/%{name}
%dir /var/lib/lxc
%{_bindir}/%{name}-*
%{_sbindir}/init.lxc
%{_sbindir}/rclxc
%{_sbindir}/rclxc-net
%{_mandir}/man[^3]/*
%_unitdir/%{name}.service
%_unitdir/%{name}-net.service
%_unitdir/%{name}@.service
%python3_sitearch/%{name}/
%python3_sitearch/_%{name}*
%config %{_sysconfdir}/bash_completion.d/%{name}

%files -n liblxc%{shlib_version}
%defattr(-,root,root)
%{_libdir}/lib%{name}.so.*
%doc AUTHORS MAINTAINERS COPYING
%doc .doc/examples
%dir  %{_sysconfdir}/apparmor.d
%dir  %{_sysconfdir}/apparmor.d/abstractions
%dir  %{_sysconfdir}/apparmor.d/abstractions/lxc
%config %{_sysconfdir}/apparmor.d/abstractions/lxc/container-base
%config %{_sysconfdir}/apparmor.d/abstractions/lxc/start-container
%config %{_sysconfdir}/apparmor.d/lxc-containers
%dir  %{_sysconfdir}/apparmor.d/lxc
%config %{_sysconfdir}/apparmor.d/lxc/lxc-default
%config %{_sysconfdir}/apparmor.d/lxc/lxc-default-cgns
%config %{_sysconfdir}/apparmor.d/lxc/lxc-default-with-mounting
%config %{_sysconfdir}/apparmor.d/lxc/lxc-default-with-nesting
%config %{_sysconfdir}/apparmor.d/usr.bin.lxc-start
%{_libexecdir}/%{name}/lxc-apparmor-load
%{_libexecdir}/%{name}/lxc-monitord
%{_libexecdir}/%{name}/lxc-user-nic

%files -n liblxc-devel
%defattr(-,root,root)
%{_libdir}/lib%{name}.so
%{_includedir}/%name
%{_libdir}/pkgconfig/%{name}.pc

%changelog
openSUSE Build Service is sponsored by