Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] eselect r476 - in trunk: . modules
Date: Mon, 20 Apr 2009 15:00:36
Message-Id: E1Lvuz4-0004Iy-4n@stork.gentoo.org
1 Author: ulm
2 Date: 2009-04-20 15:00:33 +0000 (Mon, 20 Apr 2009)
3 New Revision: 476
4
5 Modified:
6 trunk/ChangeLog
7 trunk/NEWS
8 trunk/modules/rc.eselect
9 Log:
10 Make rc module work with OpenRC, fixes bug 180966.
11
12 Modified: trunk/ChangeLog
13 ===================================================================
14 --- trunk/ChangeLog 2009-04-20 12:51:42 UTC (rev 475)
15 +++ trunk/ChangeLog 2009-04-20 15:00:33 UTC (rev 476)
16 @@ -1,5 +1,12 @@
17 2009-04-20 Ulrich Mueller <ulm@g.o>
18
19 + * modules/rc.eselect (source_rc_functions, get_runlevel):
20 + New functions for OpenRC (and baselayout-1) support.
21 + (RC_SVCDIR, rc_svcdir): Removed.
22 + (do_show): Function completely rewritten; use the common API
23 + of baselayout-1 and OpenRC. Thanks to Sebastian Günther
24 + <samson@××××××××××××××××.de> in bug 180966.
25 +
26 * libs/editor-variable.bash.in:
27 * modules/editor.eselect:
28 * modules/visual.eselect:
29
30 Modified: trunk/NEWS
31 ===================================================================
32 --- trunk/NEWS 2009-04-20 12:51:42 UTC (rev 475)
33 +++ trunk/NEWS 2009-04-20 15:00:33 UTC (rev 476)
34 @@ -5,6 +5,7 @@
35 Bug fixes:
36 - Fixed bug #155814: Clear aliases and shell functions.
37 - Fixed bug #156866: Handle missing scripts in rc module.
38 + - Fixed bug #180966: Make rc module work with OpenRC.
39 - Various improvements in opengl module.
40
41 New features:
42
43 Modified: trunk/modules/rc.eselect
44 ===================================================================
45 --- trunk/modules/rc.eselect 2009-04-20 12:51:42 UTC (rev 475)
46 +++ trunk/modules/rc.eselect 2009-04-20 15:00:33 UTC (rev 476)
47 @@ -9,13 +9,28 @@
48 SVN_DATE='$Date$'
49 VERSION=$(svn_date_to_version "${SVN_DATE}")
50
51 -# default setting
52 -RC_SVCDIR=/var/lib/init.d/
53 +# source_rc_functions PRIVATE
54 +# API for OpenRC or baselayout-1
55 +source_rc_functions() {
56 + [[ ${RC_GOT_FUNCTIONS} = yes ]] && return
57 + source /etc/init.d/functions.sh || die "Failed to source functions.sh"
58 + # baselayout-1 compatibility
59 + if [[ -e ${svclib}/sh/rc-services.sh ]]; then
60 + source "${svclib}/sh/rc-services.sh" \
61 + || die "Failed to source rc-services.sh"
62 + fi
63 +}
64
65 -# return actual rc service directory
66 -rc_svcdir() {
67 - local ret=$(load_config ${ROOT}/etc/conf.d/rc svcdir)
68 - echo ${ret:-${RC_SVCDIR}}
69 +# get_runlevel PRIVATE
70 +# determine the current runlevel
71 +get_runlevel() {
72 + if type rc_runlevel &>/dev/null; then
73 + rc_runlevel || die "rc_runlevel failed"
74 + elif [[ -n ${SOFTLEVEL} ]]; then
75 + echo "${SOFTLEVEL}"
76 + else
77 + die "Cannot determine runlevel"
78 + fi
79 }
80
81 # list_runlevels PRIVATE
82 @@ -194,19 +209,36 @@
83 }
84
85 do_show() {
86 - local softlevel=$(< "$(rc_svcdir)"/softlevel) script stopped
87 - local runlevel=${1:-${softlevel}}
88 - write_list_start "Status of init scripts in runlevel $(highlight ${runlevel})"
89 - for script in $(find_scripts ${ROOT}/etc/runlevels/${runlevel}) ; do
90 - stopped=true
91 - for x in started starting stopping failed broken ; do
92 - if [[ -L ${ROOT}/$(rc_svcdir)/${x}/${script} ]] ; then
93 - write_kv_list_entry ${script} "[${x}]"
94 - stopped=false
95 - fi
96 + # subshell to avoid pollution of caller's environment
97 + (
98 + # core.bash redefines eval; unset it because OpenRC's
99 + # functions.sh needs the bash builtin
100 + unset -f eval
101 + source_rc_functions
102 + runlevel=$(get_runlevel)
103 + write_list_start \
104 + "Status of init scripts in runlevel \"${runlevel}\""
105 + for script in $(find_scripts "${ROOT}/etc/runlevels/${runlevel}"); do
106 + for x in stopping starting inactive started stopped; do
107 + if service_${x} ${script}; then
108 + case ${x} in
109 + starting|inactive)
110 + write_kv_list_entry ${script} \
111 + "$(highlight_warning [${x}])"
112 + ;;
113 + started)
114 + write_kv_list_entry ${script} "$(highlight [${x}])"
115 + ;;
116 + *)
117 + write_kv_list_entry ${script} [${x}]
118 + ;;
119 + esac
120 + continue 2
121 + fi
122 + done
123 + write_kv_list_entry ${script} "$(highlight_warning [unknown])"
124 done
125 - [[ ${stopped} == true ]] && write_kv_list_entry ${script} "[stopped]"
126 - done
127 + )
128 }
129
130 ### start action