summaryrefslogtreecommitdiff
blob: 91dc06ac1d5b977bd993e82879a0a9af6fdf4c6c (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6

PYTHON_COMPAT=( python3_{6,7,8} )
inherit linux-info python-r1 systemd

DESCRIPTION="shared storage lock manager"
HOMEPAGE="https://pagure.io/sanlock"
SRC_URI="https://releases.pagure.org/${PN}/${P}.tar.gz"

LICENSE="LGPL-2+ GPL-2 GPL-2+"
SLOT="0"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~riscv s390 sparc x86"
IUSE="python"

REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"

DEPEND="
	acct-user/${PN}
	acct-group/${PN}
	dev-libs/libaio
	sys-apps/util-linux
	python? ( ${PYTHON_DEPS} )
"
RDEPEND="${DEPEND}"

PATCHES=(
	${FILESDIR}/sanlock-fence_sanlock-LDFLAGS.patch
)

pkg_setup() {
	local warning="You need to have CONFIG_SOFT_WATCHDOG enabled in your kernel for wdmd"
	if linux_config_exists; then
		if ! linux_chkconfig_present SOFT_WATCHDOG; then
			ewarn ""
			ewarn "$warning"
			ewarn ""
		fi
	else
		ewarn ""
		ewarn "Could not be checked automatically: $warning"
		ewarn ""
	fi
}

src_compile() {
	for d in wdmd src fence_sanlock reset; do
		cd $d; emake; cd ..
	done
	if use python; then
		cd python; python_foreach_impl emake; cd ..
	fi
}

src_install() {
	for d in wdmd src fence_sanlock reset; do
		cd $d; emake DESTDIR="${D}" LIBDIR="${EROOT}usr/$(get_libdir)" install; cd ..
	done
	if use python; then
		cd python; python_foreach_impl emake DESTDIR="${D}" install; cd ..
	fi

	# config
	dodir /etc/wdmd.d
	dodir /etc/sanlock
	insinto /etc/sanlock
	doins src/sanlock.conf

	# init
	newconfd init.d/sanlock.sysconfig sanlock
	newconfd init.d/wdmd.sysconfig wdmd
	newinitd "${FILESDIR}"/sanlock.initd sanlock
	newinitd "${FILESDIR}"/wdmd.initd wdmd
	#doinitd ${FILESDIR}/sanlk-resetd.initd
	#doinitd ${FILESDIR}/fence_sanlockd.initd

	# systemd
	systemd_newunit init.d/sanlock.service.native sanlock.service
	sed -i 's,^ExecStartPre=,#ExecStartPre=,' init.d/wdmd.service.native
	systemd_newunit init.d/wdmd.service.native wdmd.service
	systemd_dounit init.d/sanlk-resetd.service
	#systemd_dounit ${FILESDIR}/fence_sanlockd.service
}