all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd'.
@ 2016-01-24 15:33 Alex Kost
  2016-01-24 15:33 ` [PATCH 1/5] service: Rename 'services' variable to '%services' Alex Kost
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Alex Kost @ 2016-01-24 15:33 UTC (permalink / raw)
  To: guix-devel

As discussed in a parallel thread, this patchset is for renaming 'dmd'
service to 'root' service (which also provides 'shepherd' name).

Actually, patches 1, 2 and 4 are not related, I just made some changes
that I noticed and I believe should be made :-)

Patches:

[PATCH 1/5] service: Rename 'services' variable to '%services'.
[PATCH 2/5] service: Improve style of 'for-each-service'.

[PATCH 3/5] service: 'service-list' returns unique services.

Without this change, if the root service provides 2 names, 'herd status'
would display:

Started: (root root)
Stopped: ()

[PATCH 4/5] service: Add docstring to 'lookup-services'.
[PATCH 5/5] Rename 'dmd' service to 'root'.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/5] service: Rename 'services' variable to '%services'.
  2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
@ 2016-01-24 15:33 ` Alex Kost
  2016-01-24 15:33 ` [PATCH 2/5] service: Improve style of 'for-each-service' Alex Kost
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Alex Kost @ 2016-01-24 15:33 UTC (permalink / raw)
  To: guix-devel

* modules/shepherd/service.scm (services): Rename to...
(%services): ... this.
(for-each-service, service-list, find-service, lookup-services,
register-services, deregister-service): Adjust accordingly.
---
 modules/shepherd/service.scm | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 64d56ef..808372c 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -806,7 +806,7 @@ given USER and/or GROUP to run COMMAND."
 ;;; Registered services.
 
 ;; All registered services.
-(define services (make-hash-table 75))
+(define %services (make-hash-table 75))
 
 ;;; Perform actions with services:
 
@@ -816,14 +816,14 @@ given USER and/or GROUP to run COMMAND."
 	       (and (eq? key (canonical-name (car value)))
 		    (proc (car value))))
 	     #f ;; Unused
-	     services))
+	     %services))
 
 (define (service-list)
   "Return the list of services currently defined."
   (hash-fold (lambda (key services result)
                (append services result))
              '()
-             services))
+             %services))
 
 (define (find-service pred)
   "Return the first service that matches PRED, or #f if none was found."
@@ -833,13 +833,13 @@ given USER and/or GROUP to run COMMAND."
                   (and=> (find pred services)
                          return))
                 #f
-                services)
+                %services)
      #f)))
 
 ;; Lookup the services that provide NAME.  Returns a (possibly empty)
 ;; list of those.
 (define (lookup-services name)
-  (hashq-ref services name '()))
+  (hashq-ref %services name '()))
 
 (define waitpid*
   (let ((waitpid (EINTR-safe waitpid)))
@@ -931,7 +931,7 @@ otherwise by updating its state."
     (for-each (lambda (name)
 		(let ((old (lookup-services name)))
 		  ;; Actually add the new service now.
-		  (hashq-set! services name (cons new old))))
+		  (hashq-set! %services name (cons new old))))
 	      (provided-by new)))
 
   (for-each register-single-service new-services))
@@ -953,9 +953,9 @@ requested to be removed."
        (let ((old (lookup-services name)))
          (if (= 1 (length old))
              ;; Only service provides this service; remove it.
-             (hashq-remove! services name)
+             (hashq-remove! %services name)
              ;; ELSE: remove service from providing services.
-             (hashq-set! services name
+             (hashq-set! %services name
                          (remove
                           (lambda (lk-service)
                             (eq? (canonical-name service)
@@ -973,7 +973,7 @@ requested to be removed."
                        (not (eq? key 'dmd))
                        (cons key service)))
                  (_ #f)))               ; all other cases: #f.
-             services)))
+             %services)))
 
   (let ((name (string->symbol service-name)))
     (cond ((eq? name 'all)
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] service: Improve style of 'for-each-service'.
  2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
  2016-01-24 15:33 ` [PATCH 1/5] service: Rename 'services' variable to '%services' Alex Kost
@ 2016-01-24 15:33 ` Alex Kost
  2016-01-24 15:33 ` [PATCH 3/5] service: 'service-list' returns unique services Alex Kost
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Alex Kost @ 2016-01-24 15:33 UTC (permalink / raw)
  To: guix-devel

* modules/shepherd/service.scm (lookup-canonical-service): New procedure.
(for-each-service): Use it.  Use 'hash-for-each' instead of 'hash-fold'.
---
 modules/shepherd/service.scm | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 808372c..7cf557f 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -2,6 +2,7 @@
 ;; Copyright (C) 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;; Copyright (C) 2002, 2003 Wolfgang Järling <wolfgang@pro-linux.de>
 ;; Copyright (C) 2014 Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
+;; Copyright (C) 2016 Alex Kost <alezost@gmail.com>
 ;;
 ;; This file is part of the GNU Shepherd.
 ;;
@@ -810,13 +811,19 @@ given USER and/or GROUP to run COMMAND."
 
 ;;; Perform actions with services:
 
-;; Call PROC once for each registered service.
+(define (lookup-canonical-service name services)
+  "Return service with canonical NAME from SERVICES list.
+Return #f if service is not found."
+  (find (lambda (service)
+          (eq? name (canonical-name service)))
+        services))
+
 (define (for-each-service proc)
-  (hash-fold (lambda (key value unused)
-	       (and (eq? key (canonical-name (car value)))
-		    (proc (car value))))
-	     #f ;; Unused
-	     %services))
+  "Call PROC for each registered service."
+  (hash-for-each (lambda (name services)
+                   (and=> (lookup-canonical-service name services)
+                          proc))
+                 %services))
 
 (define (service-list)
   "Return the list of services currently defined."
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] service: 'service-list' returns unique services.
  2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
  2016-01-24 15:33 ` [PATCH 1/5] service: Rename 'services' variable to '%services' Alex Kost
  2016-01-24 15:33 ` [PATCH 2/5] service: Improve style of 'for-each-service' Alex Kost
@ 2016-01-24 15:33 ` Alex Kost
  2016-01-24 15:33 ` [PATCH 4/5] service: Add docstring to 'lookup-services' Alex Kost
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Alex Kost @ 2016-01-24 15:33 UTC (permalink / raw)
  To: guix-devel

* modules/shepherd/service.scm (service-list): Remove duplicates from
  the final list.
---
 modules/shepherd/service.scm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 7cf557f..0a13626 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -827,10 +827,12 @@ Return #f if service is not found."
 
 (define (service-list)
   "Return the list of services currently defined."
-  (hash-fold (lambda (key services result)
-               (append services result))
-             '()
-             %services))
+  (delete-duplicates
+   (hash-fold (lambda (key services result)
+                (append services result))
+              '()
+              %services)
+   eq?))
 
 (define (find-service pred)
   "Return the first service that matches PRED, or #f if none was found."
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] service: Add docstring to 'lookup-services'.
  2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
                   ` (2 preceding siblings ...)
  2016-01-24 15:33 ` [PATCH 3/5] service: 'service-list' returns unique services Alex Kost
@ 2016-01-24 15:33 ` Alex Kost
  2016-01-24 15:33 ` [PATCH 5/5] Rename 'dmd' service to 'root' Alex Kost
  2016-01-24 21:20 ` [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Ludovic Courtès
  5 siblings, 0 replies; 14+ messages in thread
From: Alex Kost @ 2016-01-24 15:33 UTC (permalink / raw)
  To: guix-devel

* modules/shepherd/service.scm (lookup-services): Use docstring instead
  of a comment.
---
 modules/shepherd/service.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 0a13626..fd9c7e2 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -845,9 +845,8 @@ Return #f if service is not found."
                 %services)
      #f)))
 
-;; Lookup the services that provide NAME.  Returns a (possibly empty)
-;; list of those.
 (define (lookup-services name)
+  "Return a (possibly empty) list of services that provide NAME."
   (hashq-ref %services name '()))
 
 (define waitpid*
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] Rename 'dmd' service to 'root'.
  2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
                   ` (3 preceding siblings ...)
  2016-01-24 15:33 ` [PATCH 4/5] service: Add docstring to 'lookup-services' Alex Kost
@ 2016-01-24 15:33 ` Alex Kost
  2016-01-25  8:55   ` Alex Kost
  2016-01-24 21:20 ` [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Ludovic Courtès
  5 siblings, 1 reply; 14+ messages in thread
From: Alex Kost @ 2016-01-24 15:33 UTC (permalink / raw)
  To: guix-devel

* modules/shepherd/service.scm (dmd-service): Rename to...
(shepherd-service): ... this.  Provide both 'root' and 'shepherd' names.
Adjust the rest file accordingly.
* modules/shepherd.scm: Likewise.
* modules/herd.scm: Likewise.
* modules/halt.scm: Likewise.
* modules/reboot.scm: Likewise.
* modules/shepherd/support.scm (make-bare-init-file): Likewise.
* shepherd.texi: Likewise.
* tests/basic.sh: Likewise.
* tests/no-home.sh: Likewise.
* tests/status-sexp.sh: Likewise.
---
 modules/herd.scm             | 12 ++++++----
 modules/shepherd.scm         | 10 ++++----
 modules/shepherd/service.scm | 46 +++++++++++++++++------------------
 modules/shepherd/support.scm |  4 ++--
 shepherd.texi                | 57 ++++++++++++++++++++++----------------------
 tests/basic.sh               | 28 +++++++++++-----------
 tests/no-home.sh             |  4 ++--
 tests/respawn.sh             |  2 +-
 tests/status-sexp.sh         | 19 ++++++++-------
 9 files changed, 93 insertions(+), 89 deletions(-)

diff --git a/modules/herd.scm b/modules/herd.scm
index c2cca85..a5e6c16 100644
--- a/modules/herd.scm
+++ b/modules/herd.scm
@@ -88,7 +88,8 @@ of pairs."
 the daemon via SOCKET-FILE."
   (with-system-error-handling
    (let ((sock    (open-connection socket-file))
-         (action* (if (and (eq? service 'dmd) (eq? action 'detailed-status))
+         (action* (if (and (eq? action 'detailed-status)
+                           (memq service '(root shepherd)))
                       'status
                       action)))
      ;; Send the command.
@@ -110,9 +111,9 @@ the daemon via SOCKET-FILE."
 
         ;; Then interpret the result
         (match (list action service)
-          (('status 'dmd)
+          (('status (or 'root 'shepherd))
            (display-status-summary (first result)))
-          (('detailed-status 'dmd)
+          (('detailed-status (or 'root 'shepherd))
            (display-detailed-status (first result)))
           (('status _)
            ;; We get a list of statuses, in case several services have the
@@ -135,7 +136,8 @@ the daemon via SOCKET-FILE."
        ((? eof-object?)
         ;; When stopping shepherd, we may get an EOF in lieu of a real reply,
         ;; and that's fine.  In other cases, a premature EOF is an error.
-        (unless (and (eq? action 'stop) (eq? service 'dmd))
+        (unless (and (eq? action 'stop)
+                     (memq service '(root shepherd)))
           (report-error (l10n "premature end-of-file while \
 talking to shepherd"))
           (exit 1))))
@@ -167,7 +169,7 @@ talking to shepherd"))
 
       (match (reverse command-args)
         (((and action (or "status" "detailed-status"))) ;one argument
-         (run-command socket-file (string->symbol action) 'dmd '()))
+         (run-command socket-file (string->symbol action) 'root '()))
         ((action service args ...)
          (run-command socket-file
                       (string->symbol action)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index ce24513..5e26b4f 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -140,8 +140,8 @@
     ;; Send output to log and clients.
     (set-current-output-port shepherd-output-port)
 
-    ;; Start the dmd service.
-    (start dmd-service)
+    ;; Start the 'root' service.
+    (start root-service)
     ;; This _must_ succeed.  (We could also put the `catch' around
     ;; `main', but it is often useful to get the backtrace, and
     ;; `caught-error' does not do this yet.)
@@ -175,7 +175,7 @@
     ;; ctrlaltdel(8).
     (sigaction SIGINT
       (lambda _
-        (stop dmd-service)))
+        (stop root-service)))
 
     ;; Ignore SIGPIPE so that we don't die if a client closes the connection
     ;; prematurely.
@@ -267,7 +267,7 @@
                           port))))
        (lambda (key)
          ;; Most likely we're receiving 'quit' from the 'stop' method of
-         ;; DMD-SERVICE.  So, if we're running as 'root', just reboot.
+         ;; ROOT-SERVICE.  So, if we're running as 'root', just reboot.
          (if (zero? (getuid))
              (begin
                (local-output "Rebooting...")
@@ -283,7 +283,7 @@ would write them on the 'herd' command line."
     (if (eof-object? line)
 
         ;; Exit on `C-d'.
-        (stop dmd-service)
+        (stop root-service)
 
         (begin
           (match (string-tokenize line)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index fd9c7e2..1c280aa 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -70,7 +70,7 @@
             make-system-destructor
             make-init.d-service
 
-            dmd-service
+            root-service
             make-actions
 
             &service-error
@@ -344,8 +344,8 @@ wire."
                           (slot-ref obj 'running)
                           args))
                  (lambda (key . args)
-                   ;; Special case: `dmd' may quit.
-                   (and (eq? dmd-service obj)
+                   ;; Special case: 'root' may quit.
+                   (and (eq? root-service obj)
                         (eq? key 'quit)
                         (apply quit args))
                    (caught-error key args)))
@@ -405,8 +405,8 @@ wire."
              (lambda ()
                (apply proc (slot-ref obj 'running) args))
              (lambda (key . args)
-               ;; Special case: `dmd' may quit.
-               (and (eq? dmd-service obj)
+               ;; Special case: 'root' may quit.
+               (and (eq? root-service obj)
                     (eq? key 'quit)
                     (apply quit args))
                (report-exception the-action obj key args)))))))
@@ -441,7 +441,7 @@ wire."
 		     (action-list obj)))
       (else
        ;; FIXME: Implement doc-help.
-       (local-output "Unknown keyword.  Try `doc dmd help'.")))))
+       (local-output "Unknown keyword.  Try 'doc root help'.")))))
 
 ;; Return a list of canonical names of the services that conflict with
 ;; OBJ.
@@ -947,7 +947,7 @@ otherwise by updating its state."
 (define (deregister-service service-name)
   "For each string in SERVICE-NAME, stop the associated service if
 necessary and remove it from the services table.  If SERVICE-NAME is
-the special string 'all', remove all services except for dmd.
+the special string 'all', remove all services except of 'root'.
 
 This will remove a service either if it is identified by its canonical
 name, or if it is the only service providing the service that is
@@ -978,7 +978,7 @@ requested to be removed."
                (match value
                  ((service)     ; only one service associated with KEY
                   (and (eq? key (canonical-name service))
-                       (not (eq? key 'dmd))
+                       (not (memq key '(root shepherd)))
                        (cons key service)))
                  (_ #f)))               ; all other cases: #f.
              %services)))
@@ -1029,7 +1029,7 @@ requested to be removed."
 
 \f
 
-;; The `dmd' service.
+;; The 'root' service.
 
 (define (shutdown-services)
   "Shut down all the currently running services; update the persistent state
@@ -1049,10 +1049,10 @@ file when persistence is enabled."
         (lambda (p)
           (format p "~{~a ~}~%" running-services))))))
 
-(define dmd-service
+(define root-service
   (make <service>
-    #:docstring "The dmd service is used to operate on dmd itself."
-    #:provides '(dmd)
+    #:docstring "The root service is used to operate on shepherd itself."
+    #:provides '(root shepherd)
     #:requires '()
     #:respawn #f
     #:start (lambda args
@@ -1060,9 +1060,9 @@ file when persistence is enabled."
                 (display-version))
 	      #t)
     #:stop (lambda (unused . args)
-	     (local-output "Exiting dmd...")
+	     (local-output "Exiting shepherd...")
 	     ;; Prevent that we try to stop ourself again.
-	     (slot-set! dmd-service 'running #f)
+	     (slot-set! root-service 'running #f)
              (shutdown-services)
 	     (quit))
     ;; All actions here need to take care that they do not invoke any
@@ -1082,7 +1082,7 @@ Clients such as 'herd' can read it and format it in a human-readable way."
       "Halt the system."
       (lambda (running)
         (catch 'quit
-          (cut stop dmd-service)
+          (cut stop root-service)
           (lambda (key)
             (local-output "Halting...")
             (halt)))))
@@ -1091,25 +1091,25 @@ Clients such as 'herd' can read it and format it in a human-readable way."
       "Halt the system and turn it off."
       (lambda (running)
         (catch 'quit
-          (cut stop dmd-service)
+          (cut stop root-service)
           (lambda (key)
             (local-output "Shutting down...")
             (power-off)))))
      ;; Load a configuration file.
      (load
-      "Load the Scheme code from FILE into dmd.  This is potentially
+      "Load the Scheme code from FILE into shepherd.  This is potentially
 dangerous.  You have been warned."
       (lambda (running file-name)
         (load-config file-name)))
      ;; Unload a service
      (unload
       "Unload the service identified by SERVICE-NAME or all services
-except for dmd if SERVICE-NAME is 'all'.  Stop services before
+except for 'root' if SERVICE-NAME is 'all'.  Stop services before
 removing them if needed."
       (lambda (running service-name)
         (deregister-service service-name)))
      (reload
-      "Unload all services, then load from FILE-NAME into dmd.  This
+      "Unload all services, then load from FILE-NAME into shepherd.  This
 is potentialy dangerous.  You have been warned."
       (lambda (running file-name)
         (and (deregister-service "all") ; unload all services
@@ -1117,7 +1117,7 @@ is potentialy dangerous.  You have been warned."
      ;; Go into the background.
      (daemonize
       "Go into the background.  Be careful, this means that a new
-process will be created, so dmd will not get SIGCHLD signals anymore
+process will be created, so shepherd will not get SIGCHLD signals anymore
 if previously spawned childs terminate.  Therefore, this action should
 usually only be used (if at all) *before* childs get spawned for which
 we want to receive these signals."
@@ -1143,7 +1143,7 @@ name as argument that will be used to store the status."
       (lambda (running)
 	(set! persistency #f)))
      (cd
-      "Change the working directory of dmd.  This only makes sense
+      "Change the working directory of shepherd.  This only makes sense
 when in interactive mode, i.e. with `--socket=none'."
       (lambda (running dir)
 	(chdir dir)))
@@ -1151,8 +1151,8 @@ when in interactive mode, i.e. with `--socket=none'."
      ;; we're better off by implementing it due to the
      ;; default action.
      (restart
-      "This does not work for dmd."
+      "This does not work for the 'root' service."
       (lambda (running)
 	(local-output "You must be kidding."))))))
 
-(register-services dmd-service)
+(register-services root-service)
diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index fbc7b3a..9bfb050 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -247,8 +247,8 @@ TARGET should be a string representing a filepath + name."
 ;; providing them as arguments to 'register-services'.
 ""(register-services)
 
-;; Send dmd into the background
-""(action 'dmd 'daemonize)
+;; Send shepherd into the background
+""(action 'shepherd 'daemonize)
 
 ;; Services to start when dmd starts:
 ;; Add the name of each service that should be started to the list
diff --git a/shepherd.texi b/shepherd.texi
index 105155f..ef1d9da 100644
--- a/shepherd.texi
+++ b/shepherd.texi
@@ -278,19 +278,19 @@ of the additional actions a service provides; obviously, it can also
 be called when the service is not running.  Services cannot provide
 their own implementation of @code{list-actions}.
 
-A special service is @code{dmd}, which is used for controlling the Shepherd
-itself.  It implements various actions.  For example, the
-@code{status} action displays which services are started and which
-ones are stopped, whereas @code{detailed-status} has the effect of
-applying the default implementation of @code{status} to all services
-one after another.  The @code{load}
-action is unusual insofar as it shows a feature that is actually
-available to all services, but which we have not seen yet: It takes an
-additional argument.  You can use @code{load} to load arbitrary code
-into the Shepherd at runtime, like this:
+A special service is @code{root}, which is used for controlling the
+Shepherd itself.  You can also reference to this service as
+@code{shepherd}.  It implements various actions.  For example, the
+@code{status} action displays which services are started and which ones
+are stopped, whereas @code{detailed-status} has the effect of applying
+the default implementation of @code{status} to all services one after
+another.  The @code{load} action is unusual insofar as it shows a
+feature that is actually available to all services, but which we have
+not seen yet: It takes an additional argument.  You can use @code{load}
+to load arbitrary code into the Shepherd at runtime, like this:
 
 @example
-herd load dmd ~/additional-services.scm
+herd load shepherd ~/additional-services.scm
 @end example
 
 This is enough now about the @command{herd} and @command{shepherd} programs, we
@@ -322,7 +322,8 @@ You can display the status of a service, even if the service does not
 provide a specific implementation for this action.  The same is true
 for restarting.
 @item
-The @code{dmd} service is used to control @command{shepherd} itself.
+The @code{root}/@code{shepherd} service is used to control
+@command{shepherd} itself.
 @end itemize
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -446,11 +447,11 @@ herd [@var{option}@dots{}] @var{action} [@var{service} [@var{arg}@dots{}]]
 
 It causes the @var{action} of the @var{service} to be invoked.  When
 @var{service} is omitted and @var{action} is @code{status} or
-@code{detailed-status}, the @code{dmd} service is used@footnote{This
+@code{detailed-status}, the @code{root} service is used@footnote{This
 shorthand does not work for other actions such as @code{stop}, because
 inadvertently typing @code{herd stop} would stop all the services, which
-could be pretty annoying.} (@pxref{The dmd and unknown services}, for
-more information on the @code{dmd} service.)
+could be pretty annoying.} (@pxref{The root and unknown services}, for
+more information on the @code{root} service.)
 
 For each action, you should pass the appropriate @var{arg}s.  Actions
 that are available for every service are @code{start}, @code{stop},
@@ -492,8 +493,8 @@ reboot the system.  It has the following synopsis:
 reboot [@var{option}@dots{}]
 @end example
 
-It is equivalent to running @command{herd stop dmd}.  The @code{reboot}
-command understands the following option:
+It is equivalent to running @command{herd stop shepherd}.  The
+@code{reboot} command understands the following option:
 
 @table @samp
 
@@ -518,8 +519,8 @@ off the system.  It has the following synopsis:
 halt [@var{option}@dots{}]
 @end example
 
-It is equivalent to running @command{herd power-off dmd}.  As usual, the
-@code{halt} command understands the following option:
+It is equivalent to running @command{herd power-off shepherd}.  As
+usual, the @code{halt} command understands the following option:
 
 @table @samp
 
@@ -555,7 +556,7 @@ defined in the @code{(shepherd service)} module.
 * Service De- and Constructors:: Commonly used ways of starting and
                                    stopping services.
 * Service Examples::             Examples that show how services are used.
-* The dmd and unknown services:: Special services in the Shepherd.
+* The root and unknown services:: Special services in the Shepherd.
 @end menu
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -749,7 +750,7 @@ terminates.
 Display status information about @var{obj}.  This method is called
 when the user performs the action @code{status} on @var{obj}, but
 there is no specific implementation given for it.  It is also called
-when @code{detailed-status} is applied on @code{dmd}.
+when @code{detailed-status} is applied on the @code{root} service.
 @end deffn
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ -917,15 +918,15 @@ also specifies some more initial values for the slots:
 
 @c @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
-@node The dmd and unknown services
-@section The @code{dmd} and @code{unknown} services
+@node The root and unknown services
+@section The @code{root} and @code{unknown} services
 
-@cindex dmd service
+@cindex root service
 @cindex special services
-The service @code{dmd} is special, because it is used to control the Shepherd
-itself.  It provides the following actions (in addition to
-@code{enable}, @code{disable} and @code{restart} which do not make
-sense here).
+The service @code{root} is special, because it is used to control the
+Shepherd itself.  It has an alias @code{shepherd}.  It provides the
+following actions (in addition to @code{enable}, @code{disable} and
+@code{restart} which do not make sense here).
 
 @table @code
 @item status
diff --git a/tests/basic.sh b/tests/basic.sh
index 462f8ad..a20e9dc 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -67,8 +67,8 @@ dmd_pid="`cat $pid`"
 
 kill -0 $dmd_pid
 test -S "$socket"
-pristine_status=`$herd status dmd` # Prep for 'reload' test.
-echo $pristine_status | grep -E '(Start.*dmd|Stop.*test)'
+pristine_status=`$herd status root` # Prep for 'reload' test.
+echo $pristine_status | grep -E '(Start.*root|Stop.*test)'
 
 $herd start test
 test -f "$stamp"
@@ -97,35 +97,35 @@ do
     $herd $action does-not-exist 2>&1 | grep "does-not-exist.*not.*found"
 done
 
-if $herd an-action-that-does-not-exist dmd
+if $herd an-action-that-does-not-exist root
 then false; else true; fi
 
 # Wrong number of arguments for an action.
-if $herd status dmd foo bar baz;
+if $herd status root foo bar baz;
 then false; else true; fi
 
 # Asking for the doc of specific actions.
-$herd doc dmd action status
-if $herd doc dmd action an-action-that-does-not-exist
+$herd doc root action status
+if $herd doc root action an-action-that-does-not-exist
 then false; else true; fi
 
 # Loading nonexistent file.
-if $herd load dmd /does/not/exist.scm;
+if $herd load root /does/not/exist.scm;
 then false; else true; fi
 
 # Unload one service, make sure the other it still around.
-$herd unload dmd test
+$herd unload root test
 $herd status | grep "Stopped: (test-2)"
 
-$herd reload dmd "$conf"
+$herd reload root "$conf"
 test "`$herd status`" == "$pristine_status"
 
-# Unload everything and make sure only 'dmd' is left.
-$herd unload dmd all
+# Unload everything and make sure only 'root' is left.
+$herd unload root all
 $herd status | grep "Stopped: ()"
-$herd status | grep "Started: (dmd)"
+$herd status | grep "Started: (root)"
 
-$herd stop dmd
+$herd stop root
 ! kill -0 $dmd_pid
 
 test -f "$log"
@@ -154,7 +154,7 @@ $herd stop test
 
 dmd_pid="`cat $pid`"
 
-$herd stop dmd
+$herd stop root
 ! kill -0 $dmd_pid
 
 rm -rf $confdir
diff --git a/tests/no-home.sh b/tests/no-home.sh
index 5f8d752..5af51e6 100644
--- a/tests/no-home.sh
+++ b/tests/no-home.sh
@@ -43,8 +43,8 @@ dmd_pid="$!"
 while ! test -f "$pid" ; do kill -0 "$dmd_pid" ; sleep 0.3 ; done
 
 kill -0 `cat "$pid"`
-$herd status dmd
-$herd stop dmd
+$herd status root
+$herd stop root
 
 if kill `cat "$pid"`
 then
diff --git a/tests/respawn.sh b/tests/respawn.sh
index 695d536..057c3ea 100644
--- a/tests/respawn.sh
+++ b/tests/respawn.sh
@@ -122,4 +122,4 @@ $herd status test1 | grep stopped
 ! kill -0 "$pid"
 
 cat $service2_pid
-$herd stop dmd
+$herd stop root
diff --git a/tests/status-sexp.sh b/tests/status-sexp.sh
index 02bba3d..3452a15 100644
--- a/tests/status-sexp.sh
+++ b/tests/status-sexp.sh
@@ -62,14 +62,15 @@ test -S "$socket"
 # Code to fetch service status info.
 fetch_status="
   (let ((sock (open-connection \"$socket\")))
-    (write-command (shepherd-command 'status 'dmd) sock)
+    (write-command (shepherd-command 'status 'root) sock)
     (read sock))"
 
-dmd_service_sexp="
+root_service_sexp="
    (service (version 0)
-      (provides (dmd)) (requires ())
+      (provides (root shepherd))
+      (requires ())
       (respawn? #f)
-      (docstring \"The dmd service is used to operate on dmd itself.\")
+      (docstring \"The root service is used to operate on shepherd itself.\")
       (enabled? #t) (running #t) (last-respawns ()))"
 
 "$GUILE" -c "
@@ -80,7 +81,7 @@ dmd_service_sexp="
    (('reply _ ('result (services)) ('error #f) ('messages ()))
     (lset= equal?
             services
-	   '($dmd_service_sexp
+	   '($root_service_sexp
 	     (service (version 0)
 	       (provides (foo)) (requires ())
 	       (respawn? #t) (docstring \"Foo!\")
@@ -108,8 +109,8 @@ dmd_service_sexp="
    (pk 'wrong x)
    (exit 1)))"
 
-# Unload everything and make sure only 'dmd' is left.
-$herd unload dmd all
+# Unload everything and make sure only 'root' is left.
+$herd unload root all
 
 "$GUILE" -c "
 (use-modules (shepherd comm))
@@ -118,10 +119,10 @@ $herd unload dmd all
   (equal? $fetch_status
           '(reply
             (version 0)
-            (result (($dmd_service_sexp)))
+            (result (($root_service_sexp)))
             (error #f) (messages ()))))"
 
-$herd stop dmd
+$herd stop root
 ! kill -0 $dmd_pid
 
 test -f "$log"
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd'.
  2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
                   ` (4 preceding siblings ...)
  2016-01-24 15:33 ` [PATCH 5/5] Rename 'dmd' service to 'root' Alex Kost
@ 2016-01-24 21:20 ` Ludovic Courtès
  2016-01-24 21:45   ` Mathieu Lirzin
  2016-01-25  8:39   ` [SHEPHERD] [PATCH] service: Improve 'service-list' Alex Kost
  5 siblings, 2 replies; 14+ messages in thread
From: Ludovic Courtès @ 2016-01-24 21:20 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> As discussed in a parallel thread, this patchset is for renaming 'dmd'
> service to 'root' service (which also provides 'shepherd' name).
>
> Actually, patches 1, 2 and 4 are not related, I just made some changes
> that I noticed and I believe should be made :-)

Indeed, there are occasionally stylistic issues.  :-)

> Patches:
>
> [PATCH 1/5] service: Rename 'services' variable to '%services'.
> [PATCH 2/5] service: Improve style of 'for-each-service'.
>
> [PATCH 3/5] service: 'service-list' returns unique services.
>
> Without this change, if the root service provides 2 names, 'herd status'
> would display:
>
> Started: (root root)
> Stopped: ()
>
> [PATCH 4/5] service: Add docstring to 'lookup-services'.
> [PATCH 5/5] Rename 'dmd' service to 'root'.

Excellent!  I’ve pushed all 5 patches.

While I was at it, I’ve added Mathieu and you as committers.

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd'.
  2016-01-24 21:20 ` [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Ludovic Courtès
@ 2016-01-24 21:45   ` Mathieu Lirzin
  2016-01-25  8:39   ` [SHEPHERD] [PATCH] service: Improve 'service-list' Alex Kost
  1 sibling, 0 replies; 14+ messages in thread
From: Mathieu Lirzin @ 2016-01-24 21:45 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel, Alex Kost

ludo@gnu.org (Ludovic Courtès) writes:

> Excellent!  I’ve pushed all 5 patches.
>
> While I was at it, I’ve added Mathieu and you as committers.

Thanks!

--
Mathieu Lirzin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [SHEPHERD] [PATCH] service: Improve 'service-list'.
  2016-01-24 21:20 ` [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Ludovic Courtès
  2016-01-24 21:45   ` Mathieu Lirzin
@ 2016-01-25  8:39   ` Alex Kost
  2016-01-25 15:06     ` Ludovic Courtès
  1 sibling, 1 reply; 14+ messages in thread
From: Alex Kost @ 2016-01-25  8:39 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

Ludovic Courtès (2016-01-25 00:20 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
[...]
>> [PATCH 1/5] service: Rename 'services' variable to '%services'.
>> [PATCH 2/5] service: Improve style of 'for-each-service'.
>>
>> [PATCH 3/5] service: 'service-list' returns unique services.
>>
>> Without this change, if the root service provides 2 names, 'herd status'
>> would display:
>>
>> Started: (root root)
>> Stopped: ()
>>
>> [PATCH 4/5] service: Add docstring to 'lookup-services'.
>> [PATCH 5/5] Rename 'dmd' service to 'root'.
>
> Excellent!  I’ve pushed all 5 patches.

Ah, I'm late :-) I suddenly realized that for the 3rd patch it would be
better to use 'lookup-canonical-service' instead of 'delete-duplicates'.
It is guaranteed that there will be no duplicates since services have a
single canonical name, so for each name from %services hash-table there
will be either zero or one service with this canonical name.

(Hm, I probably didn't describe it well, but I hope it's clear enough)

So would it be OK to push the attached patch?

> While I was at it, I’ve added Mathieu and you as committers.

Thank you!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-service-Improve-service-list.patch --]
[-- Type: text/x-patch, Size: 1305 bytes --]

From f3d21e3ec8a100a966153d03264639ebe48e8872 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Mon, 25 Jan 2016 11:18:00 +0300
Subject: [PATCH] service: Improve 'service-list'.

* modules/shepherd/service.scm (service-list): Use
  'lookup-canonical-service' on each name instead of removing duplicates
  from the final list.
---
 modules/shepherd/service.scm | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index f84d1dd..94f2aae 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -871,12 +871,13 @@ Return #f if service is not found."
 
 (define (service-list)
   "Return the list of services currently defined."
-  (delete-duplicates
-   (hash-fold (lambda (key services result)
-                (append services result))
-              '()
-              %services)
-   eq?))
+  (hash-fold (lambda (name services result)
+               (let ((service (lookup-canonical-service name services)))
+                 (if service
+                     (cons service result)
+                     result)))
+             '()
+             %services))
 
 (define (find-service pred)
   "Return the first service that matches PRED, or #f if none was found."
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] Rename 'dmd' service to 'root'.
  2016-01-24 15:33 ` [PATCH 5/5] Rename 'dmd' service to 'root' Alex Kost
@ 2016-01-25  8:55   ` Alex Kost
  0 siblings, 0 replies; 14+ messages in thread
From: Alex Kost @ 2016-01-25  8:55 UTC (permalink / raw)
  To: guix-devel

Alex Kost (2016-01-24 18:33 +0300) wrote:

> * modules/shepherd/service.scm (dmd-service): Rename to...
> (shepherd-service): ... this.  Provide both 'root' and 'shepherd' names.
> Adjust the rest file accordingly.
> * modules/shepherd.scm: Likewise.
> * modules/herd.scm: Likewise.
> * modules/halt.scm: Likewise.
> * modules/reboot.scm: Likewise.
> * modules/shepherd/support.scm (make-bare-init-file): Likewise.
> * shepherd.texi: Likewise.
> * tests/basic.sh: Likewise.
> * tests/no-home.sh: Likewise.
> * tests/status-sexp.sh: Likewise.

Somehow I missed to adjust "halt.scm" and "reboot.scm", sorry :)
Fixed in commit c3c4487.

-- 
Alex

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [SHEPHERD] [PATCH] service: Improve 'service-list'.
  2016-01-25  8:39   ` [SHEPHERD] [PATCH] service: Improve 'service-list' Alex Kost
@ 2016-01-25 15:06     ` Ludovic Courtès
  2016-01-25 15:57       ` Alex Kost
  0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2016-01-25 15:06 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From f3d21e3ec8a100a966153d03264639ebe48e8872 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Mon, 25 Jan 2016 11:18:00 +0300
> Subject: [PATCH] service: Improve 'service-list'.
>
> * modules/shepherd/service.scm (service-list): Use
>   'lookup-canonical-service' on each name instead of removing duplicates
>   from the final list.

[...]

> diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
> index f84d1dd..94f2aae 100644
> --- a/modules/shepherd/service.scm
> +++ b/modules/shepherd/service.scm
> @@ -871,12 +871,13 @@ Return #f if service is not found."
>  
>  (define (service-list)
>    "Return the list of services currently defined."
> -  (delete-duplicates
> -   (hash-fold (lambda (key services result)
> -                (append services result))
> -              '()
> -              %services)
> -   eq?))
> +  (hash-fold (lambda (name services result)
> +               (let ((service (lookup-canonical-service name services)))
> +                 (if service
> +                     (cons service result)
> +                     result)))
> +             '()
> +             %services))

OK, except that we know that SERVICE is necessarily true, because the
canonical service for NAME is necessarily among SERVICES.

So I would remove the ‘if’ and add a comment explaining the above.

OK with this change?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [SHEPHERD] [PATCH] service: Improve 'service-list'.
  2016-01-25 15:06     ` Ludovic Courtès
@ 2016-01-25 15:57       ` Alex Kost
  2016-01-25 21:49         ` Ludovic Courtès
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Kost @ 2016-01-25 15:57 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2016-01-25 18:06 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> From f3d21e3ec8a100a966153d03264639ebe48e8872 Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Mon, 25 Jan 2016 11:18:00 +0300
>> Subject: [PATCH] service: Improve 'service-list'.
>>
>> * modules/shepherd/service.scm (service-list): Use
>>   'lookup-canonical-service' on each name instead of removing duplicates
>>   from the final list.
>
> [...]
>
>> diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
>> index f84d1dd..94f2aae 100644
>> --- a/modules/shepherd/service.scm
>> +++ b/modules/shepherd/service.scm
>> @@ -871,12 +871,13 @@ Return #f if service is not found."
>>  
>>  (define (service-list)
>>    "Return the list of services currently defined."
>> -  (delete-duplicates
>> -   (hash-fold (lambda (key services result)
>> -                (append services result))
>> -              '()
>> -              %services)
>> -   eq?))
>> +  (hash-fold (lambda (name services result)
>> +               (let ((service (lookup-canonical-service name services)))
>> +                 (if service
>> +                     (cons service result)
>> +                     result)))
>> +             '()
>> +             %services))
>
> OK, except that we know that SERVICE is necessarily true, because the
> canonical service for NAME is necessarily among SERVICES.
>
> So I would remove the ‘if’ and add a comment explaining the above.
>
> OK with this change?

No, the service is not necessarily true.  When a service has several
names (e.g., "root" and "shepherd"), then %services table will contain 2
entries (with 'root' and 'shepherd' keys and the same (#<<service> …>)
value).  So for one of the hash-table entries:

  (lookup-canonical-service 'root (list root-service))

returns #t, and for the other:

  (lookup-canonical-service 'shepherd (list root-service))

it returns #f.

-- 
Alex

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [SHEPHERD] [PATCH] service: Improve 'service-list'.
  2016-01-25 15:57       ` Alex Kost
@ 2016-01-25 21:49         ` Ludovic Courtès
  2016-01-26  9:42           ` Alex Kost
  0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2016-01-25 21:49 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2016-01-25 18:06 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> From f3d21e3ec8a100a966153d03264639ebe48e8872 Mon Sep 17 00:00:00 2001
>>> From: Alex Kost <alezost@gmail.com>
>>> Date: Mon, 25 Jan 2016 11:18:00 +0300
>>> Subject: [PATCH] service: Improve 'service-list'.
>>>
>>> * modules/shepherd/service.scm (service-list): Use
>>>   'lookup-canonical-service' on each name instead of removing duplicates
>>>   from the final list.
>>
>> [...]
>>
>>> diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
>>> index f84d1dd..94f2aae 100644
>>> --- a/modules/shepherd/service.scm
>>> +++ b/modules/shepherd/service.scm
>>> @@ -871,12 +871,13 @@ Return #f if service is not found."
>>>  
>>>  (define (service-list)
>>>    "Return the list of services currently defined."
>>> -  (delete-duplicates
>>> -   (hash-fold (lambda (key services result)
>>> -                (append services result))
>>> -              '()
>>> -              %services)
>>> -   eq?))
>>> +  (hash-fold (lambda (name services result)
>>> +               (let ((service (lookup-canonical-service name services)))
>>> +                 (if service
>>> +                     (cons service result)
>>> +                     result)))
>>> +             '()
>>> +             %services))
>>
>> OK, except that we know that SERVICE is necessarily true, because the
>> canonical service for NAME is necessarily among SERVICES.
>>
>> So I would remove the ‘if’ and add a comment explaining the above.
>>
>> OK with this change?
>
> No, the service is not necessarily true.  When a service has several
> names (e.g., "root" and "shepherd"), then %services table will contain 2
> entries (with 'root' and 'shepherd' keys and the same (#<<service> …>)
> value).  So for one of the hash-table entries:
>
>   (lookup-canonical-service 'root (list root-service))
>
> returns #t, and for the other:
>
>   (lookup-canonical-service 'shepherd (list root-service))
>
> it returns #f.

Indeed, my bad.

Then OK to push, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [SHEPHERD] [PATCH] service: Improve 'service-list'.
  2016-01-25 21:49         ` Ludovic Courtès
@ 2016-01-26  9:42           ` Alex Kost
  0 siblings, 0 replies; 14+ messages in thread
From: Alex Kost @ 2016-01-26  9:42 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2016-01-26 00:49 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2016-01-25 18:06 +0300) wrote:
>>
>>> Alex Kost <alezost@gmail.com> skribis:
>>>
>>>> From f3d21e3ec8a100a966153d03264639ebe48e8872 Mon Sep 17 00:00:00 2001
>>>> From: Alex Kost <alezost@gmail.com>
>>>> Date: Mon, 25 Jan 2016 11:18:00 +0300
>>>> Subject: [PATCH] service: Improve 'service-list'.
>>>>
>>>> * modules/shepherd/service.scm (service-list): Use
>>>>   'lookup-canonical-service' on each name instead of removing duplicates
>>>>   from the final list.
>>>
>>> [...]
>>>
>>>> diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
>>>> index f84d1dd..94f2aae 100644
>>>> --- a/modules/shepherd/service.scm
>>>> +++ b/modules/shepherd/service.scm
>>>> @@ -871,12 +871,13 @@ Return #f if service is not found."
>>>>  
>>>>  (define (service-list)
>>>>    "Return the list of services currently defined."
>>>> -  (delete-duplicates
>>>> -   (hash-fold (lambda (key services result)
>>>> -                (append services result))
>>>> -              '()
>>>> -              %services)
>>>> -   eq?))
>>>> +  (hash-fold (lambda (name services result)
>>>> +               (let ((service (lookup-canonical-service name services)))
>>>> +                 (if service
>>>> +                     (cons service result)
>>>> +                     result)))
>>>> +             '()
>>>> +             %services))
>>>
>>> OK, except that we know that SERVICE is necessarily true, because the
>>> canonical service for NAME is necessarily among SERVICES.
>>>
>>> So I would remove the ‘if’ and add a comment explaining the above.
>>>
>>> OK with this change?
>>
>> No, the service is not necessarily true.  When a service has several
>> names (e.g., "root" and "shepherd"), then %services table will contain 2
>> entries (with 'root' and 'shepherd' keys and the same (#<<service> …>)
>> value).  So for one of the hash-table entries:
>>
>>   (lookup-canonical-service 'root (list root-service))
>>
>> returns #t, and for the other:
>>
>>   (lookup-canonical-service 'shepherd (list root-service))
>>
>> it returns #f.
>
> Indeed, my bad.
>
> Then OK to push, thanks!

Pushed, thanks!

-- 
Alex

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-01-26  9:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
2016-01-24 15:33 ` [PATCH 1/5] service: Rename 'services' variable to '%services' Alex Kost
2016-01-24 15:33 ` [PATCH 2/5] service: Improve style of 'for-each-service' Alex Kost
2016-01-24 15:33 ` [PATCH 3/5] service: 'service-list' returns unique services Alex Kost
2016-01-24 15:33 ` [PATCH 4/5] service: Add docstring to 'lookup-services' Alex Kost
2016-01-24 15:33 ` [PATCH 5/5] Rename 'dmd' service to 'root' Alex Kost
2016-01-25  8:55   ` Alex Kost
2016-01-24 21:20 ` [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Ludovic Courtès
2016-01-24 21:45   ` Mathieu Lirzin
2016-01-25  8:39   ` [SHEPHERD] [PATCH] service: Improve 'service-list' Alex Kost
2016-01-25 15:06     ` Ludovic Courtès
2016-01-25 15:57       ` Alex Kost
2016-01-25 21:49         ` Ludovic Courtès
2016-01-26  9:42           ` Alex Kost

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.