lxc/lxc.spec

285 lines
7.6 KiB
RPMSpec

### XXX This package was mostly copypasted from OpenMandriva
# when upgrading very old lxc v2 to lxc v4 in ROSA 2019.1 (urpmi -> dnf)
# https://github.com/OpenMandrivaAssociation/lxc
# TODO:
# - get rid of network scripts crap
# - try to get rid of dnsmasq
# - rename distro from OpenMandriva to ROSA
# - check if distro script requires fixing
# - check if python bindings from an older version are needed and remove them
# - check what to do with templates from older version
%global _disable_rebuild_configure 0
# The python module doesn't link to libpython
%global _disable_ld_no_undefined 1
%define major 1
%define libname %mklibname lxc %{major}
%define develname %mklibname lxc -d
%define luaver 5.3
%define lualibdir %{_libdir}/lua/%{luaver}
%define luapkgdir %{_datadir}/lua/%{luaver}
%bcond_with lua
%bcond_without python
Name: lxc
Version: 4.0.5
Release: 1
Summary: Linux Containers
Group: System/Kernel and hardware
License: LGPLv2
Epoch: 1
URL: http://lxc.sourceforge.net
Source0: http://linuxcontainers.org/downloads/%{name}-%{version}.tar.gz
Source1: http://linuxcontainers.org/downloads/%{name}-templates-3.0.4.tar.gz
Source2: http://linuxcontainers.org/downloads/lua-%{name}-3.0.2.tar.gz
Source3: http://linuxcontainers.org/downloads/python3-%{name}-3.0.4.tar.gz
Source4: %{name}.sh
Source5: dnsmasq-rule
Source6: ifcfg-lxcbr0
Source7: sysctl-rule
Source100: lxc.rpmlintrc
Patch0: lxc-templates-openmandriva.patch
Patch4: lxc-3.1.0-python-linkage.patch
BuildRequires: docbook-utils
BuildRequires: kernel-headers
BuildRequires: cap-devel
BuildRequires: pkgconfig(libsystemd)
Buildrequires: docbook-dtd30-sgml
Buildrequires: docbook2x
BuildRequires: pkgconfig(bash-completion)
%if %{with lua}
Buildrequires: lua-devel
%endif
%if %{with python}
Buildrequires: pkgconfig(python3)
Buildrequires: python3-setuptools
%endif
# needed for lxc-busybox
#Requires: busybox
# needed for lxc-debian
#Requires: dpkg
# needed for lxc-debian, lxc-ubuntu:
#Requires: debootstrap
Requires: rsync
# needed for lxc-sshd
Recommends: openssh-server
# bridge
Requires: bridge-utils
# for lxcbr0, but allow to create it in other ways
Recommends: iptables
Recommends: dnsmasq
%description
The package "%{name}" provides the command lines to create and manage
containers. It contains a full featured container with the isolation
/ virtualization of the pids, the ipc, the utsname, the mount points,
/proc, /sys, the network and it takes into account the control groups.
It is very light, flexible, and provides a set of tools around the
container like the monitoring with asynchronous events notification,
or the freeze of the container. This package is useful to create
Virtual Private Server, or to run isolated applications like bash or
sshd.
%files
%doc %{_docdir}/%{name}
%{_datadir}/%{name}/config/common.conf.d/README
%{_sysconfdir}/default/%{name}
%{_bindir}/lxc-*
%{_sbindir}/init.lxc
%dir %{_libexecdir}/lxc
%{_libexecdir}/lxc/lxc-*
%dir %{_libexecdir}/lxc/hooks
%{_libexecdir}/lxc/hooks/unmount-namespace
%dir %{_datadir}/lxc
%dir %{_datadir}/lxc/config
%dir %{_datadir}/lxc/hooks
%dir %{_datadir}/lxc/templates
%dir %{_datadir}/lxc/selinux
%dir %{_datadir}/lxc/config/common.conf.d
%dir %{_libdir}/lxc/rootfs
%{_datadir}/lxc/templates/*
%{_datadir}/lxc/hooks/*
%{_datadir}/lxc/selinux/lxc.*
#{_datadir}/lxc/__pycache__
%{_libdir}/lxc/rootfs/README
%{_mandir}/man*/%{name}*
%{_mandir}/ja/man*/*
%{_datadir}/%{name}/config/*.seccomp
%{_datadir}/%{name}/config/*.conf
%{_datadir}/lxc/lxc-patch.py
/var/lib/%{name}
%{_datadir}/%{name}/%{name}.functions
%{_sysconfdir}/dnsmasq.d/lxc
%{_sysconfdir}/sysconfig/network-scripts/ifcfg-lxcbr0
%{_unitdir}/lxc.service
%{_unitdir}/lxc-net.service
%{_sysconfdir}/sysctl.d/99-lxc-oom.conf
%{_sysconfdir}/lxc
%{_unitdir}/lxc@.service
%{_datadir}/bash-completion/completions/lxc
%lang(ko) %{_mandir}/ko/*/*
#-----------------------------------------------------------------------
%package -n %{libname}
Summary: Library for LXC
Group: System/Libraries
%description -n %{libname}
Library for the Linux Kernel Containers.
%files -n %{libname}
%{_libdir}/lib%{name}.so.%{major}
%{_libdir}/lib%{name}.so.%{major}.*
#-----------------------------------------------------------------------
%package -n %{develname}
Summary: Development files for LXC
Group: Development/C
Requires: %{libname} = %{EVRD}
%description -n %{develname}
Developement files for the Linux Kernel Containers.
%files -n %{develname}
%{_includedir}/%{name}
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
#-----------------------------------------------------------------------
%if %{with lua}
%package -n lua-%{name}
Summary: Lua binding for %{name}
Group: System/Libraries
Requires: lua-filesystem
%description -n lua-%{name}
Linux Resource Containers provide process and resource isolation without the
overhead of full virtualization.
The lua-%{name} package contains the Lua binding for %{name}.
%files -n lua-%{name}
%{lualibdir}/%{name}
%{luapkgdir}/%{name}.lua
%endif
#-----------------------------------------------------------------------
%if %{with python}
%package -n python3-%{name}
Summary: Python binding for %{name}
Group: System/Libraries
%description -n python3-%{name}
Linux Resource Containers provide process and resource isolation without the
overhead of full virtualization.
The python3-%{name} package contains the Python3 binding for %{name}.
%files -n python3-%{name}
%{python3_sitearch}/*
%endif
#-----------------------------------------------------------------------
%prep
%setup -q -a 1 %{?_with_lua:-a 2} -a 3
%apply_patches
#autopatch -p1
# Some adaptation of OMV script
# TODO: name it as ROSA and test it properly
sed -i lxc-templates-*/templates/lxc-openmandriva.in \
-e 's,openmandriva.org,rosalinux.ru,g' \
-e 's,distro-release-repos,rosa-repos,g'
# Clang spews a few more warnings than gcc...
sed -i -e 's,-Werror,,g' configure*
%build
dir0="$PWD"
[ -e autogen.sh ] && ./autogen.sh || autoreconf -fi
cd "${dir0}"/lxc-templates-*
[ -e autogen.sh ] && ./autogen.sh || autoreconf -fi
%if %{with lua}
cd "${dir0}"/lua-lxc-*
[ -e autogen.sh ] && ./autogen.sh || autoreconf -fi
%endif
cd "$dir0"
%configure \
--disable-apparmor \
--with-init-script=systemd \
--with-distro=openmandriva \
%if %{with lua}
--enable-lua \
%else
--disable-lua \
%endif
%if %{with python}
--enable-python \
%endif
%make_build
cd "${dir0}"/lxc-templates-*
%configure
%make_build
%if %{with lua}
cd "${dir0}"/lua-lxc-*
%configure
%make_build
cd ..
%endif
%if %{with python}
export PKG_CONFIG_PATH=`pwd`
cd "${dir0}"/python3-lxc-*
%__python3 setup.py build
cd ..
%endif
%install
dir0="$PWD"
%make_install templatesdir=%{_datadir}/lxc/templates READMEdir=%{_libdir}/lxc/rootfs
cd "${dir0}"/lxc-templates-*
%make_install templatesdir=%{_datadir}/lxc/templates READMEdir=%{_libdir}/lxc/rootfs
cd ..
%if %{with lua}
cd "${dir0}"/lua-lxc-*
%make_install templatesdir=%{_datadir}/lxc/templates READMEdir=%{_libdir}/lxc/rootfs
cd ..
%endif
%if %{with python}
cd "${dir0}"/python3-lxc-*
%__python3 setup.py install --skip-build --root=%{buildroot} --single-version-externally-managed --record=INSTALLED_FILES --optimize=1
cd ..
%endif
mkdir -p %{buildroot}/var/lib/%{name}
mkdir -p %{buildroot}%{_sysconfdir}/dnsmasq.d/
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/
mkdir -p %{buildroot}%{_sysconfdir}/sysctl.d/
install %{SOURCE4} %{buildroot}%{_sysconfdir}/dnsmasq.d/lxc
install %{SOURCE5} %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifcfg-lxcbr0
install %{SOURCE6} %{buildroot}%{_sysconfdir}/sysctl.d/99-lxc-oom.conf
# Fix up bogus pkgconfig files
sed -i -e 's,\${prefix}//,/,g' %{buildroot}%{_libdir}/pkgconfig/*
# clean .a files
find %{buildroot} -type f -name "*.a" -exec rm -f {} \;