commit:     f0f2d3fca5674eb4eee592d8d97a3bd896268f22
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 22 05:45:48 2025 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sat Mar 22 05:45:48 2025 +0000
URL:        https://gitweb.gentoo.org/proj/eselect.git/commit/?id=f0f2d3fc

Warn about deprecation of the rc module

* modules/rc.eselect (module_load_hook): New function; warn about
the module being deprecated.
* libs/core.bash.in (do_action): Call the module_load_hook
function if it exists.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 ChangeLog          | 5 +++++
 libs/core.bash.in  | 5 ++++-
 modules/rc.eselect | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f3343c6..e8579f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2025-03-22  Ulrich Müller  <[email protected]>
 
+       * modules/rc.eselect (module_load_hook): New function; warn about
+       the module being deprecated.
+       * libs/core.bash.in (do_action): Call the module_load_hook
+       function if it exists.
+
        * modules/rc.eselect (show_script_status): Add /usr/libexec/rc/bin
        to PATH. Display the correct status. Bug 951499.
 

diff --git a/libs/core.bash.in b/libs/core.bash.in
index 2800cc5..ea45fbd 100644
--- a/libs/core.bash.in
+++ b/libs/core.bash.in
@@ -1,5 +1,5 @@
 # -*-eselect-*-  vim: ft=eselect
-# Copyright (c) 2005-2023 Gentoo Authors
+# Copyright (c) 2005-2025 Gentoo Authors
 #
 # This file is part of the 'eselect' tools framework.
 #
@@ -106,6 +106,9 @@ do_action() {
                        || die "Couldn't source ${ESELECT_DEFAULT_ACTIONS}"
                source "${modfile}" 2>/dev/null \
                        || die "Couldn't source ${modfile}"
+               if is_function module_load_hook; then
+                       module_load_hook || die -q "Module load hook failed"
+               fi
                if [[ -z ${subaction} ]]; then
                        check_do "do_${DEFAULT_ACTION:-usage}" "$@"
                else

diff --git a/modules/rc.eselect b/modules/rc.eselect
index 2e6efa9..6e96811 100644
--- a/modules/rc.eselect
+++ b/modules/rc.eselect
@@ -7,6 +7,13 @@ inherit config
 DESCRIPTION="Manage /etc/init.d scripts in runlevels"
 MAINTAINER="[email protected]"
 
+module_load_hook() {
+       [[ -n ${I_KNOW_WHAT_I_AM_DOING} ]] && return
+       write_warning_msg "\"${ESELECT_COMMAND}\" is deprecated"
+       write_warning_msg "Use rc-update, rc-service or rc-status instead"
+       echo >&2
+}
+
 # get_runlevel PRIVATE
 # determine the current runlevel
 get_runlevel() {

Reply via email to