diff options
Diffstat (limited to 'app-emulation')
-rw-r--r-- | app-emulation/lxc/ChangeLog | 11 | ||||
-rw-r--r-- | app-emulation/lxc/files/lxc.initd.2 | 119 | ||||
-rw-r--r-- | app-emulation/lxc/lxc-0.8.0_rc1.ebuild | 118 |
3 files changed, 246 insertions, 2 deletions
diff --git a/app-emulation/lxc/ChangeLog b/app-emulation/lxc/ChangeLog index 01e666fe8b5e..9d1df2c33c4b 100644 --- a/app-emulation/lxc/ChangeLog +++ b/app-emulation/lxc/ChangeLog @@ -1,6 +1,13 @@ # ChangeLog for app-emulation/lxc -# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/ChangeLog,v 1.29 2011/10/19 17:51:49 flameeyes Exp $ +# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/ChangeLog,v 1.30 2012/03/24 00:29:00 flameeyes Exp $ + +*lxc-0.8.0_rc1 (24 Mar 2012) + + 24 Mar 2012; Diego E. Pettenò <flameeyes@gentoo.org> +files/lxc.initd.2, + +lxc-0.8.0_rc1.ebuild: + Version bump; change init script as the path is changed. Assume a modern + OpenRC is used. *lxc-0.7.5-r3 (19 Oct 2011) diff --git a/app-emulation/lxc/files/lxc.initd.2 b/app-emulation/lxc/files/lxc.initd.2 new file mode 100644 index 000000000000..fb4edc62c340 --- /dev/null +++ b/app-emulation/lxc/files/lxc.initd.2 @@ -0,0 +1,119 @@ +#!/sbin/runscript +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd.2,v 1.1 2012/03/24 00:29:00 flameeyes Exp $ + +CONTAINER=${SVCNAME#*.} + +lxc_get_configfile() { + if [ -f "/etc/lxc/${CONTAINER}.conf" ]; then + echo "/etc/lxc/${CONTAINER}.conf" + elif [ -f "/etc/lxc/${CONTAINER}/config" ]; then + echo "/etc/lxc/${CONTAINER}/config" + else + eerror "Unable to find a suitable configuration file." + eerror "If you set up the contianer 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} +} + +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 + + # find out which network interface the container is linked to, + # and then require that to be enabled, so that the + # dependencies are correct. + netif=$(lxc_get_var lxc.network.link) + [ -n "${netif}" ] && use net.${netif} +} + +start() { + checkconfig || return 1 + rm /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... + case $(scanelf -BF '%M#f' /sbin/init ${rootpath}/sbin/init | tr '\n' ':') in + ELFCLASS64:ELFCLASS64:) setarch=;; + ELFCLASS32:ELFCLASS32:) setarch=;; + ELFCLASS32:ELFCLASS64:) setarch=linux64;; + ELFCLASS64:ELFCLASS32:) 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 + + init_pid=$(lxc-info -n ${CONTAINER} --pid | cut -d: -f 2) + + if [ "${init_pid}" = "-1" ]; then + ewarn "${CONTAINER} doesn't seem to be running." + return 0 + fi + + ebegin "Shutting down system in ${CONTAINER}" + kill -INT ${init_pid} + eend $? + + TIMEOUT=${TIMEOUT:-30} + i=0 + while [ -n "$(pgrep -P ${init_pid})" -a $i -lt ${TIMEOUT} ]; do + sleep 1 + i=$(expr $i + 1) + done + + if [ -n "${missingprocs}" ]; then + ewarn "Something failed to properly shut down in ${CONTAINER}" + fi + + ebegin "Stopping ${CONTAINER}" + lxc-stop -n ${CONTAINER} + eend $? +} diff --git a/app-emulation/lxc/lxc-0.8.0_rc1.ebuild b/app-emulation/lxc/lxc-0.8.0_rc1.ebuild new file mode 100644 index 000000000000..08dc87e50652 --- /dev/null +++ b/app-emulation/lxc/lxc-0.8.0_rc1.ebuild @@ -0,0 +1,118 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/lxc-0.8.0_rc1.ebuild,v 1.1 2012/03/24 00:29:00 flameeyes Exp $ + +EAPI="4" + +MY_P="${P/_/-}" + +inherit eutils linux-info versionator flag-o-matic + +DESCRIPTION="LinuX Containers userspace utilities" +HOMEPAGE="http://lxc.sourceforge.net/" +SRC_URI="http://lxc.sourceforge.net/download/lxc/${MY_P}.tar.gz" +S="${WORKDIR}/${MY_P}" + +KEYWORDS="~amd64 ~ppc64 ~x86" + +LICENSE="LGPL-3" +SLOT="0" +IUSE="examples vanilla" + +RDEPEND="sys-libs/libcap" + +DEPEND="${RDEPEND} + app-text/docbook-sgml-utils + >=sys-kernel/linux-headers-2.6.29" + +# For init script, so protect with vanilla, they are not strictly +# needed. +RDEPEND="${RDEPEND} + vanilla? ( + sys-apps/util-linux + app-misc/pax-utils + )" + +CONFIG_CHECK="~CGROUPS + ~CPUSETS ~CGROUP_CPUACCT + ~RESOURCE_COUNTERS ~CGROUP_MEM_RES_CTLR + ~CGROUP_SCHED + + ~NAMESPACES + ~IPC_NS ~USER_NS ~PID_NS + + ~DEVPTS_MULTIPLE_INSTANCES + ~CGROUP_FREEZER + ~UTS_NS ~NET_NS + ~VETH ~MACVLAN + + ~POSIX_MQUEUE + ~!NETPRIO_CGROUP" + +ERROR_DEVPTS_MULTIPLE_INSTANCES="CONFIG_DEVPTS_MULTIPLE_INSTANCES: needed for pts inside container" + +ERROR_CGROUP_FREEZER="CONFIG_CGROUP_FREEZER: needed to freeze containers" + +ERROR_UTS_NS="CONFIG_UTS_NS: needed to unshare hostnames and uname info" +ERROR_NET_NS="CONFIG_NET_NS: needed for unshared network" + +ERROR_VETH="CONFIG_VETH: needed for internal (host-to-container) networking" +ERROR_MACVLAN="CONFIG_MACVLAN: needed for internal (inter-container) networking" + +ERROR_POSIX_MQUEUE="CONFIG_POSIX_MQUEUE: needed for lxc-execute command" + +ERROR_NETPRIO_CGROUP="CONFIG_NETPRIO_CGROUP: as of kernel 3.3 and lxc 0.8.0_rc1 this causes LXCs to fail booting." + +DOCS=(AUTHORS CONTRIBUTING MAINTAINERS TODO README doc/FAQ.txt) + +src_configure() { + append-flags -fno-strict-aliasing + + econf \ + --localstatedir=/var \ + --bindir=/usr/sbin \ + --docdir=/usr/share/doc/${PF} \ + --with-config-path=/etc/lxc \ + --with-rootfs-path=/usr/lib/lxc/rootfs \ + --with-linuxdir="${KERNEL_DIR}" \ + --enable-doc \ + $(use_enable examples) +} + +src_install() { + default + + rm -r "${D}"/usr/sbin/lxc-{setcap,ls} \ + "${D}"/usr/share/man/man1/lxc-ls.1 \ + || die "unable to remove extraenous content" + + keepdir /etc/lxc /usr/lib/lxc/rootfs + + find "${D}" -name '*.la' -delete + + use vanilla && return 0 + + # Gentoo-specific additions! + newinitd "${FILESDIR}/${PN}.initd.2" ${PN} + keepdir /var/log/lxc +} + +pkg_postinst() { + if ! use vanilla; then + elog "There is an init script provided with the package now; no documentation" + elog "is currently available though, so please check out /etc/init.d/lxc ." + elog "You _should_ only need to symlink it to /etc/init.d/lxc.configname" + elog "to start the container defined into /etc/lxc/configname.conf ." + elog "For further information about LXC development see" + elog "http://blog.flameeyes.eu/tag/lxc" # remove once proper doc is available + elog "" + fi + ewarn "With version 0.7.4, the mountpoint syntax came back to the one used by 0.7.2" + ewarn "and previous versions. This means you'll have to use syntax like the following" + ewarn "" + ewarn " lxc.rootfs = /container" + ewarn " lxc.mount.entry = /usr/portage /container/usr/portage none bind 0 0" + ewarn "" + ewarn "To use the Fedora, Debian and (various) Ubuntu auto-configuration scripts, you" + ewarn "will need sys-apps/yum or dev-util/debootstrap." +} |