Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@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, 28 Dec 2015 00:30:19
Message-Id: 1451262541.ef66b97c3c1778c3c8e9f96d80057ad7a1a3e2f4.robbat2@gentoo
1 commit: ef66b97c3c1778c3c8e9f96d80057ad7a1a3e2f4
2 Author: Doug Goldstein <cardoe <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 24 23:28:35 2015 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Mon Dec 28 00:29:01 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ef66b97c
7
8 sys-fs/lvm2: conditionally depend on lvmetad
9
10 If the user has configured their system to be dependent on lvmetad in
11 /etc/lvm/lvm.conf then we need to depend on lvmetad starting up.
12 Otherwise it shouldn't be necessary and won't be started.
13
14 Gentoo-Bug: 503016
15 Gentoo-Bug: 525614
16 Gentoo-Bug: 554918
17 Gentoo-Bug: 565154
18 Signed-off-by: Doug Goldstein <cardoe <AT> gentoo.org>
19 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
20
21 sys-fs/lvm2/files/lvm.rc-2.02.116-r3 | 134 +++++++++++++++++++++++++++++++++++
22 sys-fs/lvm2/lvm2-2.02.116-r3.ebuild | 2 +-
23 2 files changed, 135 insertions(+), 1 deletion(-)
24
25 diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.116-r3 b/sys-fs/lvm2/files/lvm.rc-2.02.116-r3
26 new file mode 100644
27 index 0000000..059e880
28 --- /dev/null
29 +++ b/sys-fs/lvm2/files/lvm.rc-2.02.116-r3
30 @@ -0,0 +1,134 @@
31 +#!/sbin/runscript
32 +# Copyright 1999-2014 Gentoo Foundation
33 +# Distributed under the terms of the GNU General Public License v2
34 +# $Id$
35 +
36 +_get_lvm_path() {
37 + local lvm_path=
38 + for lvm_path in /bin/lvm /sbin/lvm ; do
39 + [ -x "$lvm_path" ] && break
40 + done
41 + echo "${lvm_path}"
42 +}
43 +
44 +_need_lvmetad()
45 +{
46 + local lvm_path="$(_get_lvm_path)"
47 + [ ! -x "${lvm_path}" ] && return 1
48 + ${lvm_path} dumpconfig global | grep -q 'use_lvmetad=1'
49 +}
50 +
51 +depend() {
52 + before checkfs fsck
53 + after modules device-mapper
54 + need lvmetad sysfs
55 + # We may use lvmetad based on the configuration. If we added lvmetad
56 + # support while lvm2 is running then we aren't dependent on it. For the
57 + # more common case, if its disabled in the config we aren't dependent
58 + # on it.
59 + config /etc/lvm/lvm.conf
60 + local _need=
61 + if service_started; then
62 + _need=$(service_get_value need)
63 + else
64 + if _need_lvmetad; then
65 + _need="${_need} lvmetad"
66 + fi
67 + fi
68 + need ${_need}
69 +}
70 +
71 +config='global { locking_dir = "/run/lock/lvm" }'
72 +
73 +dm_in_proc() {
74 + local retval=0
75 + for x in devices misc ; do
76 + grep -qs 'device-mapper' /proc/${x}
77 + retval=$((${retval} + $?))
78 + done
79 + return ${retval}
80 +}
81 +
82 +start() {
83 + # LVM support for /usr, /home, /opt ....
84 + # This should be done *before* checking local
85 + # volumes, or they never get checked.
86 +
87 + # NOTE: Add needed modules for LVM or RAID, etc
88 + # to /etc/modules.autoload if needed
89 + lvm_path="$(_get_lvm_path)"
90 + for lvm_path in /bin/lvm /sbin/lvm ; do
91 + [ -x "$lvm_path" ] && break
92 + done
93 + if [ ! -x "$lvm_path" ]; then
94 + eerror "Cannot find lvm binary in /sbin or /bin!"
95 + return 1
96 + fi
97 + if [ -z "${CDBOOT}" ] ; then
98 + if [ -e /proc/modules ] && ! dm_in_proc ; then
99 + modprobe dm-mod 2>/dev/null
100 + fi
101 + if [ -d /proc/lvm ] || dm_in_proc ; then
102 + ebegin "Setting up the Logical Volume Manager"
103 + #still echo stderr for debugging
104 + lvm_commands="#! ${lvm_path} --config '${config}'\n"
105 + # Extra PV find pass because some devices might not have been available until very recently
106 + lvm_commands="${lvm_commands}pvscan\n"
107 + # Now make the nodes
108 + lvm_commands="${lvm_commands}vgscan --mknodes\n"
109 + # And turn them on!
110 + lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
111 + # Order of this is important, have to work around dash and LVM readline
112 + printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
113 + eend $? "Failed to setup the LVM"
114 + fi
115 + fi
116 +}
117 +
118 +start_post()
119 +{
120 + # Save if we needed lvmetad
121 + if _need_lvmetad; then
122 + service_set_value need lvmetad
123 + fi
124 +}
125 +
126 +stop() {
127 + for lvm_path in /bin/lvm /sbin/lvm ; do
128 + [ -x "$lvm_path" ] && break
129 + done
130 + if [ ! -x "$lvm_path" ]; then
131 + eerror "Cannot find lvm binary in /sbin or /bin!"
132 + return 1
133 + fi
134 +# Stop LVM2
135 +if [ -x /sbin/vgs ] && \
136 + [ -x /sbin/vgchange ] && \
137 + [ -x /sbin/lvchange ] && \
138 + [ -f /etc/lvmtab -o -d /etc/lvm ] && \
139 + [ -d /proc/lvm -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
140 +then
141 + einfo "Shutting down the Logical Volume Manager"
142 +
143 + VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
144 +
145 + if [ "$VGS" ]
146 + then
147 + ebegin " Shutting Down LVs & VGs"
148 + #still echo stderr for debugging
149 + lvm_commands="#! ${lvm_path} --config '${config}'\n"
150 + # Extra PV find pass because some devices might not have been available until very recently
151 + lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
152 + # Now make the nodes
153 + lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
154 + # Order of this is important, have to work around dash and LVM readline
155 + printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
156 + eend $? "Failed (possibly some LVs still needed for /usr or root)"
157 + fi
158 +
159 + einfo "Finished shutting down the Logical Volume Manager"
160 + return 0
161 +fi
162 +}
163 +
164 +# vim:ts=4
165
166 diff --git a/sys-fs/lvm2/lvm2-2.02.116-r3.ebuild b/sys-fs/lvm2/lvm2-2.02.116-r3.ebuild
167 index 3146e3c..e62a3b6 100644
168 --- a/sys-fs/lvm2/lvm2-2.02.116-r3.ebuild
169 +++ b/sys-fs/lvm2/lvm2-2.02.116-r3.ebuild
170 @@ -227,7 +227,7 @@ src_install() {
171
172 if use !device-mapper-only ; then
173 newinitd "${FILESDIR}"/dmeventd.initd-2.02.67-r1 dmeventd
174 - newinitd "${FILESDIR}"/lvm.rc-2.02.105-r2 lvm
175 + newinitd "${FILESDIR}"/lvm.rc-2.02.116-r3 lvm
176 newconfd "${FILESDIR}"/lvm.confd-2.02.28-r2 lvm
177
178 newinitd "${FILESDIR}"/lvm-monitoring.initd-2.02.105-r2 lvm-monitoring