public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Ulrich Mueller (ulm)" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo commit in xml/htdocs/proj/en/eselect: dev-guide.xml
Date: Thu,  1 Sep 2011 21:04:25 +0000 (UTC)	[thread overview]
Message-ID: <20110901210425.7E4A82004C@flycatcher.gentoo.org> (raw)

ulm         11/09/01 21:04:25

  Modified:             dev-guide.xml
  Log:
  Update from developer-guide.txt.

Revision  Changes    Path
1.14                 xml/htdocs/proj/en/eselect/dev-guide.xml

file : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml?rev=1.14&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml?rev=1.14&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml?r1=1.13&r2=1.14

Index: dev-guide.xml
===================================================================
RCS file: /var/cvsroot/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- dev-guide.xml	7 Nov 2009 17:20:29 -0000	1.13
+++ dev-guide.xml	1 Sep 2011 21:04:25 -0000	1.14
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding="UTF-8"?>
-<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml,v 1.13 2009/11/07 17:20:29 ulm Exp $ -->
+<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/eselect/dev-guide.xml,v 1.14 2011/09/01 21:04:25 ulm Exp $ -->
 
 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
 
@@ -27,8 +27,8 @@
 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
 <license/>
 
-<version>1.2.6</version>
-<date>2009-11-07</date>
+<version>1.2.17</version>
+<date>2011-09-01</date>
 
 <chapter>
 <title>Introduction</title>
@@ -76,88 +76,115 @@
 <body>
 
 <p>
-  It's easiest to illustrate by example. Here's a simple module, named
-  <c>cow.eselect</c>. It has two actions, <c>moo</c> and <c>think</c>, plus
-  the standard <c>help</c>, <c>usage</c> and <c>version</c> actions, and is
-  installed to <path>$(datadir)/eselect/modules/</path>.
+  It's easiest to illustrate by example. Here's a simplified version of
+  the <c>kernel.eselect</c> module. It has three actions, <c>show</c>,
+  <c>list</c>, and <c>set</c>, plus the standard <c>help</c>, <c>usage</c>
+  and <c>version</c> actions, and is installed to
+  <path>$(datadir)/eselect/modules/</path>.
 </p>
 
-<pre caption="cow.eselect code">
+<pre caption="kernel.eselect code">
 # -*-eselect-*-  vim: ft=eselect
-# Copyright 1999-2005 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
+# Copyright 2005-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2 or later
 # &#36;Id: &#36;
 
-DESCRIPTION="Do things to a cow"
-MAINTAINER="foo@gentoo.org"
+DESCRIPTION="Manage the /usr/src/linux symlink"
+MAINTAINER="eselect@gentoo.org"
 SVN_DATE='&#36;Date: &#36;'
 VERSION=$(svn_date_to_version "${SVN_DATE}")
 
-### moo action
+# find a list of kernel symlink targets
+find_targets() {
+    local f
+    for f in "${EROOT}"/usr/src/linux-[[:digit:]]*; do
+        [[ -d ${f} ]] &amp;&amp; basename "${f}"
+    done
+}
 
-describe_moo() {
-    echo "Say moo"
+# remove the kernel symlink
+remove_symlink() {
+    rm "${EROOT}/usr/src/linux"
 }
 
-describe_moo_parameters() {
-    echo "&lt;text&gt;"
+# set the kernel symlink
+set_symlink() {
+    local target=$1
+
+    if is_number "${target}"; then
+        local targets=( $(find_targets) )
+        target=${targets[target-1]}
+    fi
+
+    [[ -z ${target} || ! -d ${EROOT}/usr/src/${target} ]] \
+        &amp;&amp; die -q "Target \"$1\" doesn't appear to be valid!"
+
+    ln -s "${target}" "${EROOT}/usr/src/linux"
 }
 
-describe_moo_options() {
-    echo "text : Text to display (optional)"
-    echo "--dead : Use a dead cow"
-    echo "--borg : Use a borged cow"
+### show action ###
+
+describe_show() {
+    echo "Show the current kernel symlink"
 }
 
+do_show() {
+    write_list_start "Current kernel symlink:"
+    if [[ -L ${EROOT}/usr/src/linux ]]; then
+        local kernel=$(canonicalise "${EROOT}/usr/src/linux")
+        write_kv_list_entry "${kernel%/}" ""
+    else
+        write_kv_list_entry "(unset)" ""
+    fi
+}
 
-do_moo() {
-    local params=
-    while [[ ${1#--} != ${1} ]] ; do
-        if [[ "--dead" == ${1} ]] ; then
-            shift
-            params="${params} -d"
-        elif [[ "--borg" == "${1}" ]] ; then
-            shift
-            params="${params} -b"
-        elif [[ "--" == "${1}" ]] ; then
-            break
-        else
-            die -q "Unknown parameter ${1}"
-        fi
-    done
+### list action ###
 
-    echo "${@:-I am a cow}" | cowsay ${params}
+describe_list() {
+    echo "List available kernel symlink targets"
 }
 
-### think action
+do_list() {
+    local i targets=( $(find_targets) )
 
-describe_think() {
-    echo "Show a pensive cow"
+    write_list_start "Available kernel symlink targets:"
+    for (( i = 0; i &lt; ${#targets[@]}; i++ )); do
+        # highlight the target where the symlink is pointing to
+        [[ ${targets[i]} = \
+            $(basename "$(canonicalise "${EROOT}/usr/src/linux")") ]] \
+            &amp;&amp; targets[i]=$(highlight_marker "${targets[i]}")
+    done
+    write_numbered_list -m "(none found)" "${targets[@]}"
 }
 
-describe_think_parameters() {
-    echo "&lt;text&gt;"
+### set action ###
+
+describe_set() {
+    echo "Set a new kernel symlink target"
 }
 
-describe_think_options() {
-    echo "text : Text to display"
-    echo "--sheep : Use a sheep rather than a cow"
+describe_set_parameters() {
+    echo "&lt;target&gt;"
 }
 
-do_think() {
-    local params=
-    while [[ ${1#--} != ${1} ]] ; do
-        if [[ "--sheep" == ${1} ]] ; then
-            shift
-            params="${params} -f sheep"
-        elif [[ "--" == "${1}" ]] ; then
-            break
-        else
-            die -q "Unknown parameter ${1}"
-        fi
-    done
+describe_set_options() {
+    echo "target : Target name or number (from 'list' action)"
+}
 
-    echo "${@:-Am I a cow?}" | cowthink ${params}
+do_set() {
+    [[ -z $1 ]] &amp;&amp; die -q "You didn't tell me what to set the symlink to"
+    [[ $# -gt 1 ]] &amp;&amp; die -q "Too many parameters"
+
+    if [[ -L ${EROOT}/usr/src/linux ]]; then
+        # existing symlink
+        remove_symlink || die -q "Couldn't remove existing symlink"
+        set_symlink "$1" || die -q "Couldn't set a new symlink"
+    elif [[ -e ${EROOT}/usr/src/linux ]]; then
+        # we have something strange
+        die -q "${EROOT}/usr/src/linux exists but is not a symlink"
+    else
+        set_symlink "$1" || die -q "Couldn't set a new symlink"
+    fi
 }
 </pre>
 
@@ -187,9 +214,16 @@
   functions are optional.
 </p>
 
+<p>
+  All eselect modules are required to support the ROOT variable. For prefix
+  support, variables EPREFIX and EROOT are also defined and have the same
+  meaning as in ebuilds.
+  (These two variables appeared in eselect-1.2.)
+</p>
+
 <note>
-  If eselect is invoked as <c>cow-config</c> or <c>cow-update</c> (for
-  example, via a symlink), it will automatically select the cow module.
+  If eselect is invoked as <c>foo-config</c> or <c>foo-update</c> (for
+  example, via a symlink), it will automatically execute the foo module.
 </note>
 
 </body>
@@ -203,8 +237,7 @@
   The following list contains suggested allowed names for actions. If there is
   no suitable name on the list for your task, it is best to ask for the list
   to be updated – for consistency, it would be nice to have a standardised
-  list of action names. (The cow module, being a silly demonstration module,
-  is exempt.)
+  list of action names.
 </p>
 
 <dl>






             reply	other threads:[~2011-09-01 21:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 21:04 Ulrich Mueller (ulm) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-01-21 23:57 [gentoo-commits] gentoo commit in xml/htdocs/proj/en/eselect: dev-guide.xml Ulrich Mueller (ulm)
2011-09-01 21:25 Ulrich Mueller (ulm)
2011-09-01 21:10 Ulrich Mueller (ulm)
2009-11-07 17:20 Ulrich Mueller (ulm)
2009-11-07 17:05 Ulrich Mueller (ulm)
2009-11-07 16:41 Ulrich Mueller (ulm)
2009-09-20 10:47 Ulrich Mueller (ulm)
2009-09-20 10:19 Ulrich Mueller (ulm)
2009-09-20  9:31 Ulrich Mueller (ulm)
2009-09-20  9:04 Ulrich Mueller (ulm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110901210425.7E4A82004C@flycatcher.gentoo.org \
    --to=ulm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox