summaryrefslogtreecommitdiff
blob: cbf184618d675466eb95af84ca81a021ee4dfdec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils flag-o-matic multilib

DESCRIPTION="OpenVZ VPS control utility"
HOMEPAGE="http://openvz.org/"
SRC_URI="http://download.openvz.org/utils/${PN}/${PV}/src/${P}.tar.bz2
	http://dev.gentoo.org/~phreak/distfiles/${PN}-patches-${PVR}.tar.bz2
	http://dev.gentoo.org/~hollow/distfiles/${PN}-patches-${PVR}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="udev"

RDEPEND="app-admin/logrotate
	sys-apps/ed
	net-firewall/iptables
	sys-fs/vzquota
	sys-apps/iproute2
	udev? ( sys-fs/udev )"

DEPEND="${RDEPEND}"

src_unpack() {
	unpack ${A}

	epatch "${WORKDIR}/patches"/*.patch
	if use amd64 ; then
		epatch "Applying ${P}-libdir64.patch"
		sed -i "s,LIBDIR = $(PREFIX)/lib/vzctl/lib,LIBDIR = $(PREFIX)/lib64,"
	fi

	if use x86 ; then
		epatch "Applying ${P}-libdir.patch"
		sed -i "s,LIBDIR = $(PREFIX)/lib/vzctl/lib,LIBDIR = $(PREFIX)/lib,"
	fi
}

src_compile() {
	append-flags -Wall -g2
	emake CFLAGS="${CFLAGS}" || die
}

src_install() {
#	make DESTDIR="${D}" LIBDIR="/usr/$(get_libdir)/vzctl" install || die "make install failed"
	make DESTDIR="${D}" install || die "make install failed"

	# the get_libdir in `make install' breaks src/Makefile's logic (and thus all
	# contained tools), so we have to create a env.d entry for vzctl's LDPATH.
	#dodir /etc/env.d
	#echo "LDPATH=\"/usr/$(get_libdir)/vzctl\"" > "${D}"/etc/env.d/05vzctl

	# setup udev rules for /dev/vzctl
	if use udev; then
		dodir /etc/udev/rules.d
		echo 'KERNEL="vzctl", NAME="%k", MODE="0600"' > "${D}"/etc/udev/rules.d/60-vzctl.rules
	fi

	# Provide a symlink for vz.conf (fixing #138462)
	dosym /etc/vz/vz.conf /etc/conf.d/vz

	# Remove cruftie sysconfig entries
	# We can get rid of that once ovz #254 is solved
	rm -rf "${D}"/etc/sysconfig

	# Install gentoo specific init script
	rm -f "${D}"/etc/init.d/*
	newinitd "${WORKDIR}"/init.d/vz.initd vz

#	dodoc "${WORKDIR}/patches/000_README"
}

pkg_postinst() {
	if has_version "<3.0.10"; then
		ewarn
		ewarn "The location of some vzctl files have changed. Most notably,"
		ewarn "VE configuration files and samples directory has changed from"
		ewarn "/etc/vz to /etc/vz/conf. In order to be able to work with"
		ewarn "your VEs, please do the following:"
		ewarn
		ewarn "bash# mv /etc/vz/[0-9]*.conf /etc/vz/conf/"
		ewarn
	fi
}