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