diff options
| author | Gluzskiy Alexandr <sss123next@list.ru> | 2017-01-24 22:33:23 +0300 |
|---|---|---|
| committer | Gluzskiy Alexandr <sss123next@list.ru> | 2017-01-24 22:33:23 +0300 |
| commit | 0d640bfbfabe7eb40b0bd5a5ee9aef7a2dc2f125 (patch) | |
| tree | 9c8802507e2d351889d022caf0dcd91a8f41f658 /app-emulation/lxc/files | |
| parent | d07d23880582ec68c76dd41f5b2f0542db24c3e8 (diff) | |
added lxc-scm
Diffstat (limited to 'app-emulation/lxc/files')
| -rw-r--r-- | app-emulation/lxc/files/lxc-2.0.5-omit-sysconfig.patch | 5 | ||||
| -rw-r--r-- | app-emulation/lxc/files/lxc-2.0.6-major.patch | 74 | ||||
| -rw-r--r-- | app-emulation/lxc/files/lxc-scm-bash-completion.patch | 27 | ||||
| -rw-r--r-- | app-emulation/lxc/files/lxc.initd.3 | 118 | ||||
| -rw-r--r-- | app-emulation/lxc/files/lxc.initd.5 | 119 | ||||
| -rw-r--r-- | app-emulation/lxc/files/lxc_at.service | 12 | ||||
| -rw-r--r-- | app-emulation/lxc/files/lxc_at.service.4 | 14 |
7 files changed, 369 insertions, 0 deletions
diff --git a/app-emulation/lxc/files/lxc-2.0.5-omit-sysconfig.patch b/app-emulation/lxc/files/lxc-2.0.5-omit-sysconfig.patch new file mode 100644 index 0000000..3ec8135 --- /dev/null +++ b/app-emulation/lxc/files/lxc-2.0.5-omit-sysconfig.patch @@ -0,0 +1,5 @@ +--- /config/Makefile.am.orig 2016-05-19 02:56:11.891113982 +0000 ++++ /config/Makefile.am 2016-05-19 02:56:32.596115476 +0000 +@@ -1 +1 @@ +-SUBDIRS = apparmor bash etc init selinux templates yum sysconfig ++SUBDIRS = apparmor bash etc init selinux templates yum diff --git a/app-emulation/lxc/files/lxc-2.0.6-major.patch b/app-emulation/lxc/files/lxc-2.0.6-major.patch new file mode 100644 index 0000000..beb379a --- /dev/null +++ b/app-emulation/lxc/files/lxc-2.0.6-major.patch @@ -0,0 +1,74 @@ +Adapt to future removal of major()/minor()/makedev() from <sys/types.h> + +Gentoo removed it in glibc-2.24. + +https://bugs.gentoo.org/575232 +https://bugs.gentoo.org/604360 +diff --git a/configure.ac b/configure.ac +index 4640c0d..71e6450 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -620,4 +620,7 @@ AC_CHECK_DECLS([PR_CAPBSET_DROP], [], [], [#include <sys/prctl.h>]) + AC_CHECK_HEADERS([sys/signalfd.h pty.h ifaddrs.h sys/capability.h sys/personality.h utmpx.h sys/timerfd.h]) + ++# lookup major()/minor()/makedev() ++AC_HEADER_MAJOR ++ + # Check for some syscalls functions + AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat]) +diff --git a/src/lxc/bdev/lxclvm.c b/src/lxc/bdev/lxclvm.c +index 3d41b10..419d1c2 100644 +--- a/src/lxc/bdev/lxclvm.c ++++ b/src/lxc/bdev/lxclvm.c +@@ -33,8 +33,17 @@ + + #include "bdev.h" ++#include "config.h" + #include "log.h" + #include "lxclvm.h" + #include "utils.h" + ++/* major()/minor() */ ++#ifdef MAJOR_IN_MKDEV ++# include <sys/mkdev.h> ++#endif ++#ifdef MAJOR_IN_SYSMACROS ++# include <sys/sysmacros.h> ++#endif ++ + lxc_log_define(lxclvm, lxc); + +diff --git a/src/lxc/conf.c b/src/lxc/conf.c +index c54ee41..9a00e7f 100644 +--- a/src/lxc/conf.c ++++ b/src/lxc/conf.c +@@ -40,4 +40,12 @@ + #include <time.h> + ++/* makedev() */ ++#ifdef MAJOR_IN_MKDEV ++# include <sys/mkdev.h> ++#endif ++#ifdef MAJOR_IN_SYSMACROS ++# include <sys/sysmacros.h> ++#endif ++ + #ifdef HAVE_STATVFS + #include <sys/statvfs.h> +diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c +index 3a9e1e3..fe75fcc 100644 +--- a/src/lxc/lxccontainer.c ++++ b/src/lxc/lxccontainer.c +@@ -62,4 +62,12 @@ + #include "version.h" + ++/* major()/minor() */ ++#ifdef MAJOR_IN_MKDEV ++# include <sys/mkdev.h> ++#endif ++#ifdef MAJOR_IN_SYSMACROS ++# include <sys/sysmacros.h> ++#endif ++ + #if HAVE_IFADDRS_H + #include <ifaddrs.h> diff --git a/app-emulation/lxc/files/lxc-scm-bash-completion.patch b/app-emulation/lxc/files/lxc-scm-bash-completion.patch new file mode 100644 index 0000000..6033e36 --- /dev/null +++ b/app-emulation/lxc/files/lxc-scm-bash-completion.patch @@ -0,0 +1,27 @@ +diff --git a/config/bash/lxc.in b/config/bash/lxc.in +index 7dcf302..5927fe2 100644 +--- a/config/bash/lxc.in ++++ b/config/bash/lxc.in +@@ -1,4 +1,3 @@ +-_have lxc-start && { + _lxc_names() { + COMPREPLY=( $( compgen -W "$( lxc-ls )" "$cur" ) ) + } +@@ -100,4 +99,3 @@ _have lxc-start && { + + complete -o default -F _lxc_generic_o lxc-copy + complete -o default -F _lxc_generic_o lxc-start-ephemeral +-} +diff --git a/configure.ac b/configure.ac +index 4640c0d..14ccdd3 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -478,7 +478,7 @@ AM_CONDITIONAL([ENABLE_BASH], [test "x$enable_bash" = "xyes"]) + AM_COND_IF([ENABLE_BASH], + [AC_MSG_CHECKING([bash completion directory]) + PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], , +- bashcompdir="${sysconfdir}/bash_completion.d") ++ bashcompdir="$datadir/bash-completion/completions") + AC_MSG_RESULT([$bashcompdir]) + AC_SUBST(bashcompdir) + ]) diff --git a/app-emulation/lxc/files/lxc.initd.3 b/app-emulation/lxc/files/lxc.initd.3 new file mode 100644 index 0000000..7f12438 --- /dev/null +++ b/app-emulation/lxc/files/lxc.initd.3 @@ -0,0 +1,118 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +CONTAINER=${SVCNAME#*.} + +LXC_PATH=`lxc-config lxc.lxcpath` + +lxc_get_configfile() { + if [ -f "${LXC_PATH}/${CONTAINER}.conf" ]; then + echo "${LXC_PATH}/${CONTAINER}.conf" + elif [ -f "${LXC_PATH}/${CONTAINER}/config" ]; then + echo "${LXC_PATH}/${CONTAINER}/config" + else + eerror "Unable to find a suitable configuration file." + eerror "If you set up the container in a non-standard" + eerror "location, please set the CONFIGFILE variable." + return 1 + fi +} + +[ $CONTAINER != $SVCNAME ] && CONFIGFILE=${CONFIGFILE:-$(lxc_get_configfile)} + +lxc_get_var() { + awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE} +} + +lxc_get_net_link_type() { + awk 'BEGIN { FS="[ \t]*=[ \t]*"; _link=""; _type="" } + $1 == "lxc.network.type" {_type=$2;} + $1 == "lxc.network.link" {_link=$2;} + {if(_link != "" && _type != ""){ + printf("%s:%s\n", _link, _type ); + _link=""; _type=""; + }; }' <${CONFIGFILE} +} + +checkconfig() { + if [ ${CONTAINER} = ${SVCNAME} ]; then + eerror "You have to create an init script for each container:" + eerror " ln -s lxc /etc/init.d/lxc.container" + return 1 + fi + + # no need to output anything, the function takes care of that. + [ -z "${CONFIGFILE}" ] && return 1 + + utsname=$(lxc_get_var lxc.utsname) + if [ ${CONTAINER} != ${utsname} ]; then + eerror "You should use the same name for the service and the" + eerror "container. Right now the container is called ${utsname}" + return 1 + fi +} + +depend() { + # be quiet, since we have to run depend() also for the + # non-muxed init script, unfortunately. + checkconfig 2>/dev/null || return 0 + + config ${CONFIGFILE} + need localmount + + local _x _if + for _x in $(lxc_get_net_link_type); do + _if=${_x%:*} + case "${_x##*:}" in + # when the network type is set to phys, we can make use of a + # network service (for instance to set it up before we disable + # the net_admin capability), but we might also not set it up + # at all on the host and leave the net_admin capable service + # to take care of it. + phys) use net.${_if} ;; + *) need net.${_if} ;; + esac + done +} + +start() { + checkconfig || return 1 + rm -f /var/log/lxc/${CONTAINER}.log + + rootpath=$(lxc_get_var lxc.rootfs) + + # Check the format of our init and the chroot's init, to see + # if we have to use linux32 or linux64; always use setarch + # when required, as that makes it easier to deal with + # x32-based containers. + case $(scanelf -BF '%a#f' ${rootpath}/sbin/init) in + EM_X86_64) setarch=linux64;; + EM_386) setarch=linux32;; + esac + + ebegin "Starting ${CONTAINER}" + env -i ${setarch} $(type -p lxc-start) -l WARN -n ${CONTAINER} -f ${CONFIGFILE} -d -o /var/log/lxc/${CONTAINER}.log + sleep 0.5 + + # lxc-start -d will _always_ report a correct startup, even if it + # failed, so rather than trust that, check that the cgroup exists. + [ -d /sys/fs/cgroup/cpuset/lxc/${CONTAINER} ] + eend $? +} + +stop() { + checkconfig || return 1 + + + if ! [ -d /sys/fs/cgroup/cpuset/lxc/${CONTAINER} ]; then + ewarn "${CONTAINER} doesn't seem to be started." + return 0 + fi + + # 10s should be enough to shut everything down + ebegin "Stopping ${CONTAINER}" + lxc-stop -t 10 -n ${CONTAINER} + eend $? +} diff --git a/app-emulation/lxc/files/lxc.initd.5 b/app-emulation/lxc/files/lxc.initd.5 new file mode 100644 index 0000000..e5a5236 --- /dev/null +++ b/app-emulation/lxc/files/lxc.initd.5 @@ -0,0 +1,119 @@ +#!/sbin/openrc-run +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +CONTAINER=${SVCNAME#*.} + +LXC_PATH=`lxc-config lxc.lxcpath` + +lxc_get_configfile() { + if [ -f "${LXC_PATH}/${CONTAINER}.conf" ]; then + echo "${LXC_PATH}/${CONTAINER}.conf" + elif [ -f "${LXC_PATH}/${CONTAINER}/config" ]; then + echo "${LXC_PATH}/${CONTAINER}/config" + else + eerror "Unable to find a suitable configuration file." + eerror "If you set up the container in a non-standard" + eerror "location, please set the CONFIGFILE variable." + return 1 + fi +} + +[ $CONTAINER != $SVCNAME ] && CONFIGFILE=${CONFIGFILE:-$(lxc_get_configfile)} + +lxc_get_var() { + awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE} +} + +lxc_get_net_link_type() { + awk 'BEGIN { FS="[ \t]*=[ \t]*"; _link=""; _type="" } + $1 == "lxc.network.type" {_type=$2;} + $1 == "lxc.network.link" {_link=$2;} + {if(_link != "" && _type != ""){ + printf("%s:%s\n", _link, _type ); + _link=""; _type=""; + }; }' <${CONFIGFILE} +} + +checkconfig() { + if [ ${CONTAINER} = ${SVCNAME} ]; then + eerror "You have to create an init script for each container:" + eerror " ln -s lxc /etc/init.d/lxc.container" + return 1 + fi + + # no need to output anything, the function takes care of that. + [ -z "${CONFIGFILE}" ] && return 1 + + utsname=$(lxc_get_var lxc.utsname) + if [ ${CONTAINER} != ${utsname} ]; then + eerror "You should use the same name for the service and the" + eerror "container. Right now the container is called ${utsname}" + return 1 + fi +} + +depend() { + # be quiet, since we have to run depend() also for the + # non-muxed init script, unfortunately. + checkconfig 2>/dev/null || return 0 + + config ${CONFIGFILE} + need localmount + use lxcfs + + local _x _if + for _x in $(lxc_get_net_link_type); do + _if=${_x%:*} + case "${_x##*:}" in + # when the network type is set to phys, we can make use of a + # network service (for instance to set it up before we disable + # the net_admin capability), but we might also not set it up + # at all on the host and leave the net_admin capable service + # to take care of it. + phys) use net.${_if} ;; + *) need net.${_if} ;; + esac + done +} + +start() { + checkconfig || return 1 + rm -f /var/log/lxc/${CONTAINER}.log + + rootpath=$(lxc_get_var lxc.rootfs) + + # Check the format of our init and the chroot's init, to see + # if we have to use linux32 or linux64; always use setarch + # when required, as that makes it easier to deal with + # x32-based containers. + case $(scanelf -BF '%a#f' ${rootpath}/sbin/init) in + EM_X86_64) setarch=linux64;; + EM_386) setarch=linux32;; + esac + + ebegin "Starting ${CONTAINER}" + env -i ${setarch} $(which lxc-start) -l WARN -n ${CONTAINER} -f ${CONFIGFILE} -d -o /var/log/lxc/${CONTAINER}.log + sleep 0.5 + + # lxc-start -d will _always_ report a correct startup, even if it + # failed, so rather than trust that, check that the cgroup exists. + [ -d /sys/fs/cgroup/cpuset/lxc/${CONTAINER} ] + eend $? +} + +stop() { + checkconfig || return 1 + + + if ! [ -d /sys/fs/cgroup/cpuset/lxc/${CONTAINER} ]; then + ewarn "${CONTAINER} doesn't seem to be started." + return 0 + fi + + # 10s should be enough to shut everything down + ebegin "Stopping ${CONTAINER}" + lxc-stop -t 10 -n ${CONTAINER} + eend $? +} diff --git a/app-emulation/lxc/files/lxc_at.service b/app-emulation/lxc/files/lxc_at.service new file mode 100644 index 0000000..1ef4497 --- /dev/null +++ b/app-emulation/lxc/files/lxc_at.service @@ -0,0 +1,12 @@ +[Unit] +Description=Linux Container %I +After=network.target + +[Service] +Restart=always +ExecStart=/usr/sbin/lxc-start -n %i +ExecReload=/usr/sbin/lxc-restart -n %i +ExecStop=/usr/sbin/lxc-stop -n %i + +[Install] +WantedBy=multi-user.target diff --git a/app-emulation/lxc/files/lxc_at.service.4 b/app-emulation/lxc/files/lxc_at.service.4 new file mode 100644 index 0000000..64ae745 --- /dev/null +++ b/app-emulation/lxc/files/lxc_at.service.4 @@ -0,0 +1,14 @@ +[Unit] +Description=Linux Container %I +After=network.target +Wants=lxcfs.service + +[Service] +Restart=always +ExecStart=/usr/bin/lxc-start -n %i -F +ExecReload=/usr/bin/lxc-restart -n %i +ExecStop=/usr/bin/lxc-stop -n %i +Delegate=yes + +[Install] +WantedBy=multi-user.target |
