Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 180966 - eselect rc broken with sys-apps/openrc
Summary: eselect rc broken with sys-apps/openrc
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: eselect (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo eselect Team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2007-06-05 14:20 UTC by Peter Alfredsen (RETIRED)
Modified: 2009-05-18 20:18 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
/usr/share/eselect/modules/rc.select patch for baselayout 2 (rc.eselect.patch,301 bytes, patch)
2008-08-16 17:32 UTC, Sebastian Günther
Details | Diff
/usr/share/eselect/modules/rc.select patch for baselayout 2 with use of API (rc.eselect.patch,1.52 KB, patch)
2009-04-19 20:01 UTC, Sebastian Günther
Details | Diff
/usr/share/eselect/modules/rc.select patch with use of API (rc.eselect.patch,1.65 KB, patch)
2009-04-20 12:20 UTC, Sebastian Günther
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Alfredsen (RETIRED) gentoo-dev 2007-06-05 14:20:08 UTC
Error occurs on eselect rc show:
loki ~ # eselect rc show
/usr/share/eselect//modules/rc.eselect: line 199: /var/lib/init.d//softlevel: No such file or directory
Status of init scripts in runlevel

I am not actually sure that this files is provided by baselayout, but since that seems to be the only delta relative to working systems that seemed relevant, I've guessed at who to blame for this.
P.S.
Happy honeymoon, UberLord.


Reproducible: Always

Steps to Reproduce:
Comment 1 Roy Marples (RETIRED) gentoo-dev 2007-06-26 08:34:41 UTC
Our state dir should *never* be referenced by programs other than baselayout - we provide an API for that. Something like this

. /etc/init.d/functions.sh

# baselayout-1 compat
[ -e "${svclib}"/sh/rc-services.sh ] && . "${svclib}"/sh/rc-services.sh

service_started foo && einfo "started"
Comment 2 Sebastian Günther 2008-08-12 08:56:19 UTC
Is there going to be a patched version anytime soon?

I can provide a patch if this is aprecoated.
Comment 3 Ronny Perinke 2008-08-13 15:09:38 UTC
I thought it worked yesterday but today I get the same error message.

(In reply to comment #2)
> Is there going to be a patched version anytime soon?
> 
> I can provide a patch if this is aprecoated.
> 

yes please do so
Comment 4 Sebastian Günther 2008-08-16 17:32:48 UTC
Created attachment 163061 [details, diff]
/usr/share/eselect/modules/rc.select patch for baselayout 2

This patch should be only applied to systems where baselayout 2 is running, because it just fixed the default RC_SVCDIR.

The usage of the API as suggested above is *not* possible with eselect, since /etc/init.d/functions.sh uses "eval", which is prohibited by core.bash.

BTW: Where is the f**king documentation of that API?
Comment 5 Ronny Perinke 2008-08-20 22:34:01 UTC
(In reply to comment #4)
> Created an attachment (id=163061) [edit]
> /usr/share/eselect/modules/rc.select patch for baselayout 2
> 
> This patch should be only applied to systems where baselayout 2 is running,
> because it just fixed the default RC_SVCDIR.

hm, "svcdir" in /etc/conf.d/rc needs to be changed too

from /usr/share/eselect/modules/rc.select
------
rc_svcdir() {
	local ret=$(load_config ${ROOT}/etc/conf.d/rc svcdir)
	echo ${ret:-${RC_SVCDIR}}
}
Comment 6 Sebastian Günther 2008-08-21 06:52:32 UTC
(In reply to comment #5)
> 
> hm, "svcdir" in /etc/conf.d/rc needs to be changed too
> 
This is no business of eselect.

I do not have such variable set there. on my machine using Baselayout 2 there isn't even a /etc/conf.d/rc.

If this varable is always set in /etc/conf.d/rc when using baselayout 1, then this patch is crude, but will work for both baselayouts.

> from /usr/share/eselect/modules/rc.select
> ------
> rc_svcdir() {
>         local ret=$(load_config ${ROOT}/etc/conf.d/rc svcdir)
>         echo ${ret:-${RC_SVCDIR}}
> }
> 

In fact: I would rather use the API and not mess with the direct path, but since bash.core prohibits the use of eval and functions.sh uses it, we're doomed at the moment.
Comment 7 Ulrich Müller gentoo-dev 2009-04-18 10:52:35 UTC
(In reply to comment #6)
> In fact: I would rather use the API and not mess with the direct path, but
> since bash.core prohibits the use of eval and functions.sh uses it, we're
> doomed at the moment.

Not really, since you can unset the function:

   local evil_eval=$(declare -f eval)
   unset -f eval
   ... do some work ...
   eval "${evil_eval}"

A patch using the API (as pointed out by Roy in comment #1) would really be appreciated.
Comment 8 Sebastian Günther 2009-04-19 20:01:48 UTC
Created attachment 188916 [details, diff]
/usr/share/eselect/modules/rc.select patch for baselayout 2 with use of API

OK, this is just tested on baselayout 2, since I do not have a baselayout 1 machine, could please someone check this.
Comment 9 Ulrich Müller gentoo-dev 2009-04-19 21:46:47 UTC
(In reply to comment #8)
> OK, this is just tested on baselayout 2, since I do not have a baselayout 1
> machine, could please someone check this.

Thanks.
Looks like we have two problems with baselayout-1:

+    local runlevel=$(/bin/rc-status -r)

rc-status of baselayout-1 has no -r option.

+    for x in hotplugged started starting stopping stopped inactive crashed; do
+        service_${x} ${script} && write_kv_list_entry ${script} "[${x}]"

baselayout-1 doesn't have service_hotplugged and service_crashed.
As far as I know, only the following 5 states are mutually exclusive: "stopped", "started", "stopping", "starting", and "inactive".

Questions to Roy (adding to CC): rc-status of OpenRC has also "scheduled".
Is this a 6th alternative? What is the reason that there is no "service_scheduled" command?
Comment 10 Roy Marples 2009-04-19 22:28:15 UTC
(In reply to comment #9)
> Looks like we have two problems with baselayout-1:
> 
> +    local runlevel=$(/bin/rc-status -r)
> 
> rc-status of baselayout-1 has no -r option.

baselayout-1 has no means of returning the currently runlevel beyond parsing the full rc-status output or by looking directly at the state data.

> 
> +    for x in hotplugged started starting stopping stopped inactive crashed; do
> +        service_${x} ${script} && write_kv_list_entry ${script} "[${x}]"
> 
> baselayout-1 doesn't have service_hotplugged and service_crashed.
> As far as I know, only the following 5 states are mutually exclusive:
> "stopped", "started", "stopping", "starting", and "inactive".

Correct

> Questions to Roy (adding to CC): rc-status of OpenRC has also "scheduled".
> Is this a 6th alternative? What is the reason that there is no
> "service_scheduled" command?

No, a stopped service can be scheduled to be started when another service starts.
It's status is both stopped and scheduled.
I didn't see a reason to add a service_scheduled command. If there is a need to add it, then there should also be a services_scheduled command, like so

# service_scheduled a
foo bar
# services_scheduled foo
a

If you feel a need for this, please file a request at http://roy.marples.name/projects/openrc/newticket
Comment 11 Ulrich Müller gentoo-dev 2009-04-19 23:33:35 UTC
(In reply to comment #10)
> > rc-status of baselayout-1 has no -r option.
> 
> baselayout-1 has no means of returning the currently runlevel beyond parsing
> the full rc-status output or by looking directly at the state data.

So I guess we have to do something like the following. Really ugly.

get_runlevel() {
    if type rc_runlevel &>/dev/null; then
        rc_runlevel
    else
        # baselayout-1 doesn't have rc_runlevel()
        local svcdir=$(load_config /etc/conf.d/rc svcdir)
        cat "${svcdir:-/var/lib/init.d}/softlevel"
    fi
}
Comment 12 Ulrich Müller gentoo-dev 2009-04-19 23:44:06 UTC
(In reply to comment #11)
>     else
>         # baselayout-1 doesn't have rc_runlevel()
>         local svcdir=$(load_config /etc/conf.d/rc svcdir)
>         cat "${svcdir:-/var/lib/init.d}/softlevel"

I just see that functions.sh of baselayout-1 exports the SOFTLEVEL variable, so probably this could be used in the "else" part.
Comment 13 Sebastian Günther 2009-04-20 12:20:36 UTC
Created attachment 188953 [details, diff]
 /usr/share/eselect/modules/rc.select patch with use of API

I change the patch according the annotations. I just removed crashed and hotplugged states and change the runlevel detection in the show function.

The detection of the current runlevel is only used in the show action, so I did not see the need for a function for the whole module and it need in fact the functions.sh to work proper. And because of the eval statement, I did not want to include it in the whole module.
Comment 14 Ulrich Müller gentoo-dev 2009-04-20 15:09:30 UTC
> I change the patch according the annotations. I just removed crashed and
> hotplugged states and change the runlevel detection in the show function.

Thank you again. Tested with OpenRC and baselayout-1 and works with both.

> The detection of the current runlevel is only used in the show action, so I
> did not see the need for a function for the whole module and it need in fact
> the functions.sh to work proper.

I think it's cleaner to move such things to their own function, but it's a matter of taste of course. ;-)

Committed to SVN (r476). I've also moved the sourcing of functions.sh into a subshell (and we don't have to restore "eval" then), and added some colours for the different states.

You may emerge app-admin/eselect-9999 for testing, or get the rc module from here: <http://sources.gentoo.org/viewcvs.py/eselect/trunk/modules/rc.eselect?view=markup>
Comment 15 Sebastian Günther 2009-04-20 16:52:56 UTC
(In reply to comment #14)
> > I change the patch according the annotations. I just removed crashed and
> > hotplugged states and change the runlevel detection in the show function.
> 
> Thank you again. Tested with OpenRC and baselayout-1 and works with both.
> 
> > The detection of the current runlevel is only used in the show action, so I
> > did not see the need for a function for the whole module and it need in fact
> > the functions.sh to work proper.
> 
> I think it's cleaner to move such things to their own function, but it's a
> matter of taste of course. ;-)

You should then make a comment that the $SOFTLEVEL is only defined if you call source_rc_functions before get_runlevel. Or later someone will change the ordering and keeps on wondering why it does not work anymore...


> 
> Committed to SVN (r476). I've also moved the sourcing of functions.sh into a
> subshell (and we don't have to restore "eval" then), and added some colours for
> the different states.
> 

Comment 16 Ulrich Müller gentoo-dev 2009-04-20 17:08:56 UTC
> You should then make a comment that the $SOFTLEVEL is only defined if you
> call source_rc_functions before get_runlevel.

Done.
Comment 17 Ulrich Müller gentoo-dev 2009-05-18 20:18:18 UTC
Fixed in eselect-1.1_rc1.