summaryrefslogtreecommitdiff
blob: 1592368f60e934499cb59ac740b8abd24bf26ae4 (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
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-fs/multipath-tools/multipath-tools-0.4.8-r2.ebuild,v 1.1 2009/11/05 04:15:09 robbat2 Exp $

EAPI=2
inherit eutils toolchain-funcs

DESCRIPTION="Device mapper target autoconfig"
HOMEPAGE="http://christophe.varoqui.free.fr/"
SRC_URI="http://christophe.varoqui.free.fr/${PN}/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86"
IUSE=""

RDEPEND="|| (
		>=sys-fs/lvm2-2.02.45
		>=sys-fs/device-mapper-1.00.19-r1
	)
	>=sys-fs/udev-124
	sys-fs/sysfsutils
	dev-libs/libaio"
DEPEND="${RDEPEND}"

src_prepare() {
	epatch "${FILESDIR}"/${PN}-0.4.8-build.patch
	epatch "${FILESDIR}"/${PN}-0.4.8-udev-scsi_id-changes.patch
	# Patch per upstream tree for 1GiB limit of kpartx
	epatch "${FILESDIR}"/${PN}-0.4.8-r1-kpartx.patch
	# CVE-2009-0115, world writable socket
	epatch "${FILESDIR}"/${PN}-0.4.8-socket-cve-2009-0115.patch
	# kpartx fails on extended partitions
	epatch "${FILESDIR}"/${PN}-0.4.8-kparted-ext-partitions.patch
}

src_compile() {
	# The -j1 is NOT a joke. The 0.4.8-era upstream code rebuilds several object
	# files with different compiler defines. The upstream git, as yet unreleased
	# moves to proper automake, but it's a large jump and is not being
	# backported to 0.4.8.
	emake -j1 CC="$(tc-getCC)" || die "emake failed"
}

src_install() {
	dodir /sbin /usr/share/man/man8
	make DESTDIR="${D}" install || die "install failed"

	insinto /etc
	newins "${S}"/multipath.conf.annotated multipath.conf
	fperms 644 /etc/udev/rules.d/65-multipath.rules
	fperms 644 /etc/udev/rules.d/66-kpartx.rules
	# This is the monitoring daemon
	newinitd "${FILESDIR}"/rc-multipathd multipathd
	# This is the init script that fires the multipath addon for baselayout2
	newinitd "${FILESDIR}"/init.d-multipath-0.4.8-r1 multipath
	# Handle early-boot startup as well as shutdown of multipath devices
	insinto /lib/rcscripts/addons
	doins "${FILESDIR}"/multipath-start.sh
	doins "${FILESDIR}"/multipath-stop.sh

	dodoc multipath.conf.*
	dodoc AUTHOR ChangeLog FAQ README TODO
	docinto kpartx; dodoc kpartx/ChangeLog kpartx/README
}

pkg_preinst() {
	# The dev.d script was previously wrong and is now removed (the udev rules
	# file does the job instead), but it won't be removed from live systems due
	# to cfgprotect.
	# This should help out a little...
	if [[ -e ${ROOT}/etc/dev.d/block/multipath.dev ]] ; then
		mkdir -p "${D}"/etc/dev.d/block
		echo "# Please delete this file. It is obsoleted by /etc/udev/rules.d/65-multipath.rules" \
			> "${D}"/etc/dev.d/block/multipath.dev
	fi
}
pkg_postinst() {
	elog "If you need multipath on your system, you should ensure that a"
	elog "'multipath' entry is present in your RC_VOLUME_ORDER variable!"
	elog "If you use baselayout2, you must add 'multipath' into"
	elog "your boot runlevel!"
}