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