commit:     793e2d209234d2e90ca28f37f5474d619b455f9f
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 15 15:10:34 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 15:12:24 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=793e2d20

sys-fs/lvm2: add pkg_postinst warning for USE=lvm -> USE=-lvm

I was reluctant to do this because we already published a news item
(and it's the critical news item mechanism for a reason) but if it saves
someone some pain, it's worth it, and it's cheap to do.

Show a warning for USE=-lvm -> USE=lvm or for fresh installs with USE=-lvm
as a one-off.

But warnings are not a substitute for reading news items, so this is mostly
for the benefit of new users who might be confused about how to get the tools
they're familiar with.

Bug: https://bugs.gentoo.org/718910
Bug: https://bugs.gentoo.org/890254
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...m2-2.03.17-r1.ebuild => lvm2-2.03.17-r2.ebuild} | 39 ++++++++++++++++------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/sys-fs/lvm2/lvm2-2.03.17-r1.ebuild 
b/sys-fs/lvm2/lvm2-2.03.17-r2.ebuild
similarity index 90%
rename from sys-fs/lvm2/lvm2-2.03.17-r1.ebuild
rename to sys-fs/lvm2/lvm2-2.03.17-r2.ebuild
index f0470c0a4165..27f458ee325f 100644
--- a/sys-fs/lvm2/lvm2-2.03.17-r1.ebuild
+++ b/sys-fs/lvm2/lvm2-2.03.17-r2.ebuild
@@ -263,20 +263,37 @@ src_install() {
        dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
 }
 
-pkg_postinst() {
-       use lvm && tmpfiles_process lvm2.conf
+pkg_preinst() {
+       HAD_LVM=0
 
-       if use udev; then
-               udev_reload
+       if has_version 'sys-fs/lvm2[lvm(+)]' ; then
+               HAD_LVM=1
        fi
+}
 
+pkg_postinst() {
+       use lvm && tmpfiles_process lvm2.conf
+       use udev && udev_reload
+
+       # This is a new installation
        if [[ -z "${REPLACING_VERSIONS}" ]]; then
-               # This is a new installation
-               ewarn "Make sure the \"lvm\" init script is in the runlevels:"
-               ewarn "# rc-update add lvm boot"
-               ewarn
-               ewarn "Make sure to enable lvmetad in /etc/lvm/lvm.conf if you 
want"
-               ewarn "to enable lvm autoactivation and metadata caching."
+               if use lvm ; then
+                       ewarn "Make sure the \"lvm\" init script is in the 
runlevels:"
+                       ewarn "# rc-update add lvm boot"
+                       ewarn
+                       ewarn "Make sure to enable lvmetad in 
${EROOT}/etc/lvm/lvm.conf if you want"
+                       ewarn "to enable lvm autoactivation and metadata 
caching."
+               else
+                       ewarn "Please enable USE=lvm if you need the LVM daemon 
and"
+                       ewarn "tools like 'lvchange', 'vgchange', etc!"
+               fi
+       else
+               if ! use lvm && [[ ${HAD_LVM} -eq 1 ]] ; then
+                       ewarn "LVM was previously enabled but is now disabled."
+                       ewarn "Please enable USE=lvm if you need the LVM daemon 
and"
+                       ewarn "tools like 'lvchange', 'vgchange', etc!"
+                       ewarn "See the 2022-11-19-lvm2-default-USE-flags news 
item for more details."
+               fi
        fi
 
        if use udev && [[ -d /run ]] ; then
@@ -291,7 +308,7 @@ pkg_postinst() {
                        ewarn ""
                        ewarn "    ${permission_run_expected} /run"
                        ewarn ""
-                       ewarn "This is known to be causing problems for 
UDEV-enabled LVM services."
+                       ewarn "This is known to cause problems for udev-enabled 
LVM services."
                fi
        fi
 }

Reply via email to