Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in xml/htdocs/proj/en/eselect: dev-guide.xml
Date: Thu, 01 Sep 2011 21:04:35
Message-Id: 20110901210425.7E4A82004C@flycatcher.gentoo.org
1 ulm 11/09/01 21:04:25
2
3 Modified: dev-guide.xml
4 Log:
5 Update from developer-guide.txt.
6
7 Revision Changes Path
8 1.14 xml/htdocs/proj/en/eselect/dev-guide.xml
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml?rev=1.14&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml?rev=1.14&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml?r1=1.13&r2=1.14
13
14 Index: dev-guide.xml
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml,v
17 retrieving revision 1.13
18 retrieving revision 1.14
19 diff -u -r1.13 -r1.14
20 --- dev-guide.xml 7 Nov 2009 17:20:29 -0000 1.13
21 +++ dev-guide.xml 1 Sep 2011 21:04:25 -0000 1.14
22 @@ -1,5 +1,5 @@
23 <?xml version='1.0' encoding="UTF-8"?>
24 -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml,v 1.13 2009/11/07 17:20:29 ulm Exp $ -->
25 +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml,v 1.14 2011/09/01 21:04:25 ulm Exp $ -->
26
27 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
28
29 @@ -27,8 +27,8 @@
30 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
31 <license/>
32
33 -<version>1.2.6</version>
34 -<date>2009-11-07</date>
35 +<version>1.2.17</version>
36 +<date>2011-09-01</date>
37
38 <chapter>
39 <title>Introduction</title>
40 @@ -76,88 +76,115 @@
41 <body>
42
43 <p>
44 - It's easiest to illustrate by example. Here's a simple module, named
45 - <c>cow.eselect</c>. It has two actions, <c>moo</c> and <c>think</c>, plus
46 - the standard <c>help</c>, <c>usage</c> and <c>version</c> actions, and is
47 - installed to <path>$(datadir)/eselect/modules/</path>.
48 + It's easiest to illustrate by example. Here's a simplified version of
49 + the <c>kernel.eselect</c> module. It has three actions, <c>show</c>,
50 + <c>list</c>, and <c>set</c>, plus the standard <c>help</c>, <c>usage</c>
51 + and <c>version</c> actions, and is installed to
52 + <path>$(datadir)/eselect/modules/</path>.
53 </p>
54
55 -<pre caption="cow.eselect code">
56 +<pre caption="kernel.eselect code">
57 # -*-eselect-*- vim: ft=eselect
58 -# Copyright 1999-2005 Gentoo Foundation
59 -# Distributed under the terms of the GNU General Public License v2
60 +# Copyright 2005-2011 Gentoo Foundation
61 +# Distributed under the terms of the GNU General Public License v2 or later
62 # &#36;Id: &#36;
63
64 -DESCRIPTION="Do things to a cow"
65 -MAINTAINER="foo@g.o"
66 +DESCRIPTION="Manage the /usr/src/linux symlink"
67 +MAINTAINER="eselect@g.o"
68 SVN_DATE='&#36;Date: &#36;'
69 VERSION=$(svn_date_to_version "${SVN_DATE}")
70
71 -### moo action
72 +# find a list of kernel symlink targets
73 +find_targets() {
74 + local f
75 + for f in "${EROOT}"/usr/src/linux-[[:digit:]]*; do
76 + [[ -d ${f} ]] &amp;&amp; basename "${f}"
77 + done
78 +}
79
80 -describe_moo() {
81 - echo "Say moo"
82 +# remove the kernel symlink
83 +remove_symlink() {
84 + rm "${EROOT}/usr/src/linux"
85 }
86
87 -describe_moo_parameters() {
88 - echo "&lt;text&gt;"
89 +# set the kernel symlink
90 +set_symlink() {
91 + local target=$1
92 +
93 + if is_number "${target}"; then
94 + local targets=( $(find_targets) )
95 + target=${targets[target-1]}
96 + fi
97 +
98 + [[ -z ${target} || ! -d ${EROOT}/usr/src/${target} ]] \
99 + &amp;&amp; die -q "Target \"$1\" doesn't appear to be valid!"
100 +
101 + ln -s "${target}" "${EROOT}/usr/src/linux"
102 }
103
104 -describe_moo_options() {
105 - echo "text : Text to display (optional)"
106 - echo "--dead : Use a dead cow"
107 - echo "--borg : Use a borged cow"
108 +### show action ###
109 +
110 +describe_show() {
111 + echo "Show the current kernel symlink"
112 }
113
114 +do_show() {
115 + write_list_start "Current kernel symlink:"
116 + if [[ -L ${EROOT}/usr/src/linux ]]; then
117 + local kernel=$(canonicalise "${EROOT}/usr/src/linux")
118 + write_kv_list_entry "${kernel%/}" ""
119 + else
120 + write_kv_list_entry "(unset)" ""
121 + fi
122 +}
123
124 -do_moo() {
125 - local params=
126 - while [[ ${1#--} != ${1} ]] ; do
127 - if [[ "--dead" == ${1} ]] ; then
128 - shift
129 - params="${params} -d"
130 - elif [[ "--borg" == "${1}" ]] ; then
131 - shift
132 - params="${params} -b"
133 - elif [[ "--" == "${1}" ]] ; then
134 - break
135 - else
136 - die -q "Unknown parameter ${1}"
137 - fi
138 - done
139 +### list action ###
140
141 - echo "${@:-I am a cow}" | cowsay ${params}
142 +describe_list() {
143 + echo "List available kernel symlink targets"
144 }
145
146 -### think action
147 +do_list() {
148 + local i targets=( $(find_targets) )
149
150 -describe_think() {
151 - echo "Show a pensive cow"
152 + write_list_start "Available kernel symlink targets:"
153 + for (( i = 0; i &lt; ${#targets[@]}; i++ )); do
154 + # highlight the target where the symlink is pointing to
155 + [[ ${targets[i]} = \
156 + $(basename "$(canonicalise "${EROOT}/usr/src/linux")") ]] \
157 + &amp;&amp; targets[i]=$(highlight_marker "${targets[i]}")
158 + done
159 + write_numbered_list -m "(none found)" "${targets[@]}"
160 }
161
162 -describe_think_parameters() {
163 - echo "&lt;text&gt;"
164 +### set action ###
165 +
166 +describe_set() {
167 + echo "Set a new kernel symlink target"
168 }
169
170 -describe_think_options() {
171 - echo "text : Text to display"
172 - echo "--sheep : Use a sheep rather than a cow"
173 +describe_set_parameters() {
174 + echo "&lt;target&gt;"
175 }
176
177 -do_think() {
178 - local params=
179 - while [[ ${1#--} != ${1} ]] ; do
180 - if [[ "--sheep" == ${1} ]] ; then
181 - shift
182 - params="${params} -f sheep"
183 - elif [[ "--" == "${1}" ]] ; then
184 - break
185 - else
186 - die -q "Unknown parameter ${1}"
187 - fi
188 - done
189 +describe_set_options() {
190 + echo "target : Target name or number (from 'list' action)"
191 +}
192
193 - echo "${@:-Am I a cow?}" | cowthink ${params}
194 +do_set() {
195 + [[ -z $1 ]] &amp;&amp; die -q "You didn't tell me what to set the symlink to"
196 + [[ $# -gt 1 ]] &amp;&amp; die -q "Too many parameters"
197 +
198 + if [[ -L ${EROOT}/usr/src/linux ]]; then
199 + # existing symlink
200 + remove_symlink || die -q "Couldn't remove existing symlink"
201 + set_symlink "$1" || die -q "Couldn't set a new symlink"
202 + elif [[ -e ${EROOT}/usr/src/linux ]]; then
203 + # we have something strange
204 + die -q "${EROOT}/usr/src/linux exists but is not a symlink"
205 + else
206 + set_symlink "$1" || die -q "Couldn't set a new symlink"
207 + fi
208 }
209 </pre>
210
211 @@ -187,9 +214,16 @@
212 functions are optional.
213 </p>
214
215 +<p>
216 + All eselect modules are required to support the ROOT variable. For prefix
217 + support, variables EPREFIX and EROOT are also defined and have the same
218 + meaning as in ebuilds.
219 + (These two variables appeared in eselect-1.2.)
220 +</p>
221 +
222 <note>
223 - If eselect is invoked as <c>cow-config</c> or <c>cow-update</c> (for
224 - example, via a symlink), it will automatically select the cow module.
225 + If eselect is invoked as <c>foo-config</c> or <c>foo-update</c> (for
226 + example, via a symlink), it will automatically execute the foo module.
227 </note>
228
229 </body>
230 @@ -203,8 +237,7 @@
231 The following list contains suggested allowed names for actions. If there is
232 no suitable name on the list for your task, it is best to ask for the list
233 to be updated – for consistency, it would be nice to have a standardised
234 - list of action names. (The cow module, being a silly demonstration module,
235 - is exempt.)
236 + list of action names.
237 </p>
238
239 <dl>