Gentoo Archives: gentoo-commits

From: Marc Schiffbauer <mschiff@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/lvm2/files/, sys-fs/lvm2/
Date: Mon, 13 Feb 2017 20:09:32
Message-Id: 1487016537.513cc0319dca99422e0a6f6f52dc37c281d05234.mschiff@gentoo
1 commit: 513cc0319dca99422e0a6f6f52dc37c281d05234
2 Author: Marc Schiffbauer <mschiff <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 13 20:08:57 2017 +0000
4 Commit: Marc Schiffbauer <mschiff <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 13 20:08:57 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=513cc031
7
8 sys-fs/lvm2: Add sanlock USE flag for lvmlockd, fixes #604334
9
10 Package-Manager: Portage-2.3.3, Repoman-2.3.1
11
12 sys-fs/lvm2/files/lvm.rc-2.02.166-r1 | 135 ++++++++++++
13 sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1 | 18 ++
14 sys-fs/lvm2/lvm2-2.02.166-r1.ebuild | 298 +++++++++++++++++++++++++++
15 sys-fs/lvm2/metadata.xml | 1 +
16 4 files changed, 452 insertions(+)
17
18 diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.166-r1 b/sys-fs/lvm2/files/lvm.rc-2.02.166-r1
19 new file mode 100644
20 index 0000000000..e779d2fb09
21 --- /dev/null
22 +++ b/sys-fs/lvm2/files/lvm.rc-2.02.166-r1
23 @@ -0,0 +1,135 @@
24 +#!/sbin/openrc-run
25 +# Copyright 1999-2017 Gentoo Foundation
26 +# Distributed under the terms of the GNU General Public License v2
27 +# $Id$
28 +
29 +_get_lvm_path() {
30 + local lvm_path=
31 + for lvm_path in /bin/lvm /sbin/lvm ; do
32 + [ -x "$lvm_path" ] && break
33 + done
34 + echo "${lvm_path}"
35 +}
36 +
37 +_need_lvmetad()
38 +{
39 + local lvm_path="$(_get_lvm_path)"
40 + [ ! -x "${lvm_path}" ] && return 1
41 + ${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmetad=1'
42 +}
43 +
44 +depend() {
45 + before checkfs fsck
46 + after modules device-mapper
47 + # We may use lvmetad based on the configuration. If we added lvmetad
48 + # support while lvm2 is running then we aren't dependent on it. For the
49 + # more common case, if its disabled in the config we aren't dependent
50 + # on it.
51 + config /etc/lvm/lvm.conf
52 + local _need=
53 + if service_started; then
54 + _need=$(service_get_value need)
55 + else
56 + if _need_lvmetad; then
57 + _need="${_need} lvmetad"
58 + fi
59 + fi
60 + need sysfs ${_need}
61 +}
62 +
63 +config='global { locking_dir = "/run/lock/lvm" }'
64 +
65 +dm_in_proc() {
66 + local retval=0
67 + for x in devices misc ; do
68 + grep -qs 'device-mapper' /proc/${x}
69 + retval=$((${retval} + $?))
70 + done
71 + return ${retval}
72 +}
73 +
74 +start() {
75 + # LVM support for /usr, /home, /opt ....
76 + # This should be done *before* checking local
77 + # volumes, or they never get checked.
78 +
79 + # NOTE: Add needed modules for LVM or RAID, etc
80 + # to /etc/modules.autoload if needed
81 + lvm_path="$(_get_lvm_path)"
82 + for lvm_path in /bin/lvm /sbin/lvm ; do
83 + [ -x "$lvm_path" ] && break
84 + done
85 + if [ ! -x "$lvm_path" ]; then
86 + eerror "Cannot find lvm binary in /sbin or /bin!"
87 + return 1
88 + fi
89 + if [ -z "${CDBOOT}" ] ; then
90 + if [ -e /proc/modules ] && ! dm_in_proc ; then
91 + modprobe dm-mod 2>/dev/null
92 + fi
93 + if [ -d /proc/lvm ] || dm_in_proc ; then
94 + ebegin "Setting up the Logical Volume Manager"
95 + #still echo stderr for debugging
96 + lvm_commands="#! ${lvm_path} --config '${config}'\n"
97 + # Extra PV find pass because some devices might not have been available until very recently
98 + lvm_commands="${lvm_commands}pvscan\n"
99 + # Now make the nodes
100 + lvm_commands="${lvm_commands}vgscan --mknodes\n"
101 + # And turn them on!
102 + lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
103 + # Start lockd VGs as required
104 + lvm_commands="${lvm_commands}vgchange --lock-start --lock-opt auto\n"
105 + # Order of this is important, have to work around dash and LVM readline
106 + printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
107 + eend $? "Failed to setup the LVM"
108 + fi
109 + fi
110 +}
111 +
112 +start_post()
113 +{
114 + # Save if we needed lvmetad
115 + if _need_lvmetad; then
116 + service_set_value need lvmetad
117 + fi
118 +}
119 +
120 +stop() {
121 + for lvm_path in /bin/lvm /sbin/lvm ; do
122 + [ -x "$lvm_path" ] && break
123 + done
124 + if [ ! -x "$lvm_path" ]; then
125 + eerror "Cannot find lvm binary in /sbin or /bin!"
126 + return 1
127 + fi
128 +# Stop LVM2
129 +if [ -x /sbin/vgs ] && \
130 + [ -x /sbin/vgchange ] && \
131 + [ -x /sbin/lvchange ] && \
132 + [ -f /etc/lvmtab -o -d /etc/lvm ] && \
133 + [ -d /proc/lvm -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
134 +then
135 + einfo "Shutting down the Logical Volume Manager"
136 +
137 + VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
138 +
139 + if [ "$VGS" ]
140 + then
141 + ebegin " Shutting Down LVs & VGs"
142 + #still echo stderr for debugging
143 + lvm_commands="#! ${lvm_path} --config '${config}'\n"
144 + # Extra PV find pass because some devices might not have been available until very recently
145 + lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
146 + # Now make the nodes
147 + lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
148 + # Order of this is important, have to work around dash and LVM readline
149 + printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
150 + eend $? "Failed (possibly some LVs still needed for /usr or root)"
151 + fi
152 +
153 + einfo "Finished shutting down the Logical Volume Manager"
154 + return 0
155 +fi
156 +}
157 +
158 +# vim:ts=4
159
160 diff --git a/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1 b/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1
161 new file mode 100644
162 index 0000000000..bf3292a797
163 --- /dev/null
164 +++ b/sys-fs/lvm2/files/lvmlockd.initd-2.02.166-r1
165 @@ -0,0 +1,18 @@
166 +#!/sbin/openrc-run
167 +# Copyright 1999-2017 Gentoo Foundation
168 +# Distributed under the terms of the GNU General Public License v2
169 +# $Id$
170 +
171 +pidfile="/run/lvmlockd.pid"
172 +command="/sbin/lvmlockd"
173 +command_args="${LVMLOCKD_OPTS:--p ${pidfile}} ${LVMLOCKD_TYPE:--g sanlock}"
174 +start_stop_daemon_args="--pidfile ${pidfile}"
175 +
176 +depend() {
177 + before sanlock
178 +}
179 +
180 +start_pre()
181 +{
182 + checkpath --directory /run/lvm || return 1
183 +}
184
185 diff --git a/sys-fs/lvm2/lvm2-2.02.166-r1.ebuild b/sys-fs/lvm2/lvm2-2.02.166-r1.ebuild
186 new file mode 100644
187 index 0000000000..8be6acbd8f
188 --- /dev/null
189 +++ b/sys-fs/lvm2/lvm2-2.02.166-r1.ebuild
190 @@ -0,0 +1,298 @@
191 +# Copyright 1999-2017 Gentoo Foundation
192 +# Distributed under the terms of the GNU General Public License v2
193 +# $Id$
194 +
195 +EAPI=6
196 +inherit autotools eutils linux-info multilib systemd toolchain-funcs udev flag-o-matic
197 +
198 +DESCRIPTION="User-land utilities for LVM2 (device-mapper) software"
199 +HOMEPAGE="https://sourceware.org/lvm2/"
200 +SRC_URI="ftp://sourceware.org/pub/lvm2/${PN/lvm/LVM}.${PV}.tgz
201 + ftp://sourceware.org/pub/lvm2/old/${PN/lvm/LVM}.${PV}.tgz"
202 +
203 +LICENSE="GPL-2"
204 +SLOT="0"
205 +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
206 +IUSE="readline static static-libs systemd clvm cman corosync lvm1 lvm2create_initrd openais sanlock selinux +udev +thin device-mapper-only"
207 +REQUIRED_USE="device-mapper-only? ( !clvm !cman !corosync !lvm1 !lvm2create_initrd !openais !sanlock !thin )
208 + systemd? ( udev )
209 + clvm? ( !systemd )"
210 +
211 +DEPEND_COMMON="
212 + clvm? (
213 + cman? ( =sys-cluster/cman-3* )
214 + corosync? ( sys-cluster/corosync )
215 + openais? ( sys-cluster/openais )
216 + =sys-cluster/libdlm-3*
217 + )
218 +
219 + readline? ( sys-libs/readline:0= )
220 + sanlock? ( sys-cluster/sanlock )
221 + systemd? ( >=sys-apps/systemd-205:0= )
222 + udev? ( >=virtual/libudev-208:=[static-libs?] )"
223 +# /run is now required for locking during early boot. /var cannot be assumed to
224 +# be available -- thus, pull in recent enough baselayout for /run.
225 +# This version of LVM is incompatible with cryptsetup <1.1.2.
226 +RDEPEND="${DEPEND_COMMON}
227 + >=sys-apps/baselayout-2.2
228 + !<sys-apps/openrc-0.11
229 + !<sys-fs/cryptsetup-1.1.2
230 + !!sys-fs/clvm
231 + !!sys-fs/lvm-user
232 + >=sys-apps/util-linux-2.16
233 + lvm2create_initrd? ( sys-apps/makedev )
234 + thin? ( >=sys-block/thin-provisioning-tools-0.3.0 )"
235 +# note: thin- 0.3.0 is required to avoid --disable-thin_check_needs_check
236 +# USE 'static' currently only works with eudev, bug 520450
237 +DEPEND="${DEPEND_COMMON}
238 + virtual/pkgconfig
239 + >=sys-devel/binutils-2.20.1-r1
240 + sys-devel/autoconf-archive
241 + static? (
242 + selinux? ( sys-libs/libselinux[static-libs] )
243 + udev? ( >=sys-fs/eudev-3.1.2[static-libs] )
244 + >=sys-apps/util-linux-2.16[static-libs]
245 + )"
246 +
247 +S=${WORKDIR}/${PN/lvm/LVM}.${PV}
248 +
249 +PATCHES=(
250 + # Gentoo specific modification(s):
251 + "${FILESDIR}"/${PN}-2.02.129-example.conf.in.patch
252 +
253 + # For upstream -- review and forward:
254 + "${FILESDIR}"/${PN}-2.02.63-always-make-static-libdm.patch
255 + "${FILESDIR}"/${PN}-2.02.56-lvm2create_initrd.patch
256 + "${FILESDIR}"/${PN}-2.02.67-createinitrd.patch #301331
257 + "${FILESDIR}"/${PN}-2.02.99-locale-muck.patch #330373
258 + "${FILESDIR}"/${PN}-2.02.70-asneeded.patch # -Wl,--as-needed
259 + "${FILESDIR}"/${PN}-2.02.139-dynamic-static-ldflags.patch #332905
260 + "${FILESDIR}"/${PN}-2.02.129-static-pkgconfig-libs.patch #370217, #439414 + blkid
261 + "${FILESDIR}"/${PN}-2.02.130-pthread-pkgconfig.patch #492450
262 + #"${FILESDIR}"/${PN}-2.02.145-mkdev.patch #580062 # Merged upstream
263 +)
264 +
265 +pkg_setup() {
266 + local CONFIG_CHECK="~SYSVIPC"
267 +
268 + if use udev; then
269 + local WARNING_SYSVIPC="CONFIG_SYSVIPC:\tis not set (required for udev sync)\n"
270 + if linux_config_exists; then
271 + local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
272 + if [ -n "${uevent_helper_path}" ] && [ "${uevent_helper_path}" != '""' ]; then
273 + ewarn "It's recommended to set an empty value to the following kernel config option:"
274 + ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
275 + fi
276 + fi
277 + fi
278 +
279 + check_extra_config
280 +
281 + # 1. Genkernel no longer copies /sbin/lvm blindly.
282 + if use static; then
283 + elog "Warning, we no longer overwrite /sbin/lvm and /sbin/dmsetup with"
284 + elog "their static versions. If you need the static binaries,"
285 + elog "you must append .static to the filename!"
286 + fi
287 +}
288 +
289 +src_prepare() {
290 + default
291 +
292 + sed -i \
293 + -e "1iAR = $(tc-getAR)" \
294 + -e "s:CC ?= @CC@:CC = $(tc-getCC):" \
295 + make.tmpl.in || die #444082
296 +
297 + sed -i -e '/FLAG/s:-O2::' configure{.in,} || die #480212
298 +
299 + if use udev && ! use device-mapper-only; then
300 + sed -i -e '/use_lvmetad =/s:0:1:' conf/example.conf.in || die #514196
301 + elog "Notice that \"use_lvmetad\" setting is enabled with USE=\"udev\" in"
302 + elog "/etc/lvm/lvm.conf, which will require restart of udev, lvm, and lvmetad"
303 + elog "if it was previously disabled."
304 + fi
305 +
306 + sed -i -e "s:/usr/bin/true:$(type -P true):" scripts/blk_availability_systemd_red_hat.service.in || die #517514
307 +
308 + # Without thin-privision-tools, there is nothing to install for target install_man7:
309 + use thin || { sed -i -e '/^install_lvm2/s:install_man7::' man/Makefile.in || die; }
310 +
311 + eautoreconf
312 +}
313 +
314 +src_configure() {
315 + filter-flags -flto
316 + local myconf=()
317 + local buildmode
318 +
319 + myconf+=( $(use_enable !device-mapper-only dmeventd) )
320 + myconf+=( $(use_enable !device-mapper-only cmdlib) )
321 + myconf+=( $(use_enable !device-mapper-only applib) )
322 + myconf+=( $(use_enable !device-mapper-only fsadm) )
323 + myconf+=( $(use_enable !device-mapper-only lvmetad) )
324 + use device-mapper-only && myconf+=( --disable-udev-systemd-background-jobs )
325 +
326 + # Most of this package does weird stuff.
327 + # The build options are tristate, and --without is NOT supported
328 + # options: 'none', 'internal', 'shared'
329 + if use static; then
330 + buildmode="internal"
331 + # This only causes the .static versions to become available
332 + myconf+=( --enable-static_link )
333 + else
334 + buildmode="shared"
335 + fi
336 + dmbuildmode=$(use !device-mapper-only && echo internal || echo none)
337 +
338 + # dmeventd requires mirrors to be internal, and snapshot available
339 + # so we cannot disable them
340 + myconf+=( --with-mirrors=${dmbuildmode} )
341 + myconf+=( --with-snapshots=${dmbuildmode} )
342 + if use thin; then
343 + myconf+=( --with-thin=internal --with-cache=internal )
344 + local texec
345 + for texec in check dump repair restore; do
346 + myconf+=( --with-thin-${texec}="${EPREFIX}"/sbin/thin_${texec} )
347 + myconf+=( --with-cache-${texec}="${EPREFIX}"/sbin/cache_${texec} )
348 + done
349 + else
350 + myconf+=( --with-thin=none --with-cache=none )
351 + fi
352 +
353 + if use lvm1; then
354 + myconf+=( --with-lvm1=${buildmode} )
355 + else
356 + myconf+=( --with-lvm1=none )
357 + fi
358 +
359 + # disable O_DIRECT support on hppa, breaks pv detection (#99532)
360 + use hppa && myconf+=( --disable-o_direct )
361 +
362 + if use clvm; then
363 + myconf+=( --with-cluster=${buildmode} )
364 + # 4-state! Make sure we get it right, per bug 210879
365 + # Valid options are: none, cman, gulm, all
366 + #
367 + # 2009/02:
368 + # gulm is removed now, now dual-state:
369 + # cman, none
370 + # all still exists, but is not needed
371 + #
372 + # 2009/07:
373 + # TODO: add corosync and re-enable ALL
374 + local clvmd=""
375 + use cman && clvmd="cman"
376 + #clvmd="${clvmd/cmangulm/all}"
377 + use corosync && clvmd="${clvmd:+$clvmd,}corosync"
378 + use openais && clvmd="${clvmd:+$clvmd,}openais"
379 + [ -z "${clvmd}" ] && clvmd="none"
380 + myconf+=( --with-clvmd=${clvmd} )
381 + myconf+=( --with-pool=${buildmode} )
382 +
383 + else
384 + myconf+=( --with-clvmd=none --with-cluster=none )
385 + fi
386 +
387 + econf \
388 + $(use_enable readline) \
389 + $(use_enable selinux) \
390 + --enable-pkgconfig \
391 + --with-confdir="${EPREFIX}"/etc \
392 + --exec-prefix="${EPREFIX}" \
393 + --sbindir="${EPREFIX}/sbin" \
394 + --with-staticdir="${EPREFIX}"/sbin \
395 + --libdir="${EPREFIX}/$(get_libdir)" \
396 + --with-usrlibdir="${EPREFIX}/usr/$(get_libdir)" \
397 + --with-default-dm-run-dir=/run \
398 + --with-default-run-dir=/run/lvm \
399 + --with-default-locking-dir=/run/lock/lvm \
400 + --with-default-pid-dir=/run \
401 + $(use_enable udev udev_rules) \
402 + $(use_enable udev udev_sync) \
403 + $(use_with udev udevdir "$(get_udevdir)"/rules.d) \
404 + $(use_enable sanlock lockd-sanlock) \
405 + $(use_enable systemd udev-systemd-background-jobs) \
406 + --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
407 + ${myconf[@]} \
408 + CLDFLAGS="${LDFLAGS}"
409 +}
410 +
411 +src_compile() {
412 + pushd include >/dev/null
413 + emake
414 + popd >/dev/null
415 +
416 + if use device-mapper-only ; then
417 + emake device-mapper
418 + else
419 + emake
420 + emake CC="$(tc-getCC)" -C scripts lvm2_activation_generator_systemd_red_hat
421 + fi
422 +}
423 +
424 +src_install() {
425 + local inst
426 + INSTALL_TARGETS="install install_tmpfiles_configuration"
427 + # install systemd related files only when requested, bug #522430
428 + use systemd && INSTALL_TARGETS="${INSTALL_TARGETS} install_systemd_units install_systemd_generators"
429 + use device-mapper-only && INSTALL_TARGETS="install_device-mapper"
430 + for inst in ${INSTALL_TARGETS}; do
431 + emake DESTDIR="${D}" ${inst}
432 + done
433 +
434 + newinitd "${FILESDIR}"/device-mapper.rc-2.02.105-r2 device-mapper
435 + newconfd "${FILESDIR}"/device-mapper.conf-1.02.22-r3 device-mapper
436 +
437 + if use !device-mapper-only ; then
438 + newinitd "${FILESDIR}"/dmeventd.initd-2.02.67-r1 dmeventd
439 + newinitd "${FILESDIR}"/lvm.rc-2.02.166-r1 lvm
440 + newconfd "${FILESDIR}"/lvm.confd-2.02.28-r2 lvm
441 +
442 + newinitd "${FILESDIR}"/lvm-monitoring.initd-2.02.105-r2 lvm-monitoring
443 + newinitd "${FILESDIR}"/lvmetad.initd-2.02.116-r3 lvmetad
444 + fi
445 +
446 + if use sanlock; then
447 + newinitd "${FILESDIR}"/lvmlockd.initd-2.02.166-r1 lvmlockd
448 + fi
449 +
450 + if use clvm; then
451 + newinitd "${FILESDIR}"/clvmd.rc-2.02.39 clvmd
452 + newconfd "${FILESDIR}"/clvmd.confd-2.02.39 clvmd
453 + fi
454 +
455 + if use static-libs; then
456 + dolib.a libdm/ioctl/libdevmapper.a
457 + dolib.a libdaemon/client/libdaemonclient.a #462908
458 + #gen_usr_ldscript libdevmapper.so
459 + dolib.a daemons/dmeventd/libdevmapper-event.a
460 + #gen_usr_ldscript libdevmapper-event.so
461 + else
462 + rm -f "${ED}"usr/$(get_libdir)/{libdevmapper-event,liblvm2cmd,liblvm2app,libdevmapper}.a
463 + fi
464 +
465 + if use lvm2create_initrd; then
466 + dosbin scripts/lvm2create_initrd/lvm2create_initrd
467 + doman scripts/lvm2create_initrd/lvm2create_initrd.8
468 + newdoc scripts/lvm2create_initrd/README README.lvm2create_initrd
469 + fi
470 +
471 + insinto /etc
472 + doins "${FILESDIR}"/dmtab
473 +
474 + dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
475 +}
476 +
477 +pkg_postinst() {
478 + ewarn "Make sure the \"lvm\" init script is in the runlevels:"
479 + ewarn "# rc-update add lvm boot"
480 + ewarn
481 + ewarn "Make sure to enable lvmetad in /etc/lvm/lvm.conf if you want"
482 + ewarn "to enable lvm autoactivation and metadata caching."
483 +}
484 +
485 +src_test() {
486 + einfo "Tests are disabled because of device-node mucking, if you want to"
487 + einfo "run tests, compile the package and see ${S}/tests"
488 +}
489
490 diff --git a/sys-fs/lvm2/metadata.xml b/sys-fs/lvm2/metadata.xml
491 index 33079b1d9c..cca547ca5c 100644
492 --- a/sys-fs/lvm2/metadata.xml
493 +++ b/sys-fs/lvm2/metadata.xml
494 @@ -24,6 +24,7 @@
495 <flag name="openais">Openais support for clustered lvm</flag>
496 <flag name="thin">Support for thin volumes</flag>
497 <flag name="device-mapper-only">Build only device-mapper and not the rest of LVM2 (UNSUPPORTED)</flag>
498 + <flag name="sanlock">Enable lvmlockd with support for sanlock</flag>
499 </use>
500 <upstream>
501 <remote-id type="cpe">cpe:/a:heinz_mauelshagen:lvm2</remote-id>