guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/03: gnu: shepherd: 'herd status' now sorts the result.


From: Mark H. Weaver
Subject: 02/03: gnu: shepherd: 'herd status' now sorts the result.
Date: Wed, 14 Feb 2018 03:43:36 -0500 (EST)

mhw pushed a commit to branch core-updates
in repository guix.

commit 02843215d871c501ec5515d5b2589297d8d4a923
Author: Mark H Weaver <address@hidden>
Date:   Wed Feb 14 02:06:21 2018 -0500

    gnu: shepherd: 'herd status' now sorts the result.
    
    Add a patch by Ludovic Courtès <address@hidden> from the upstream
    shepherd repository to partially fix <https://bugs.gnu.org/30299>.
    
    * gnu/packages/patches/shepherd-herd-status-sorted.patch: New file.
    * gnu/local.mk (dist_patch_DATA): Add it.
    * gnu/packages/admin.scm (shepherd)[source]: Add patch.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/admin.scm                             |  5 +-
 .../patches/shepherd-herd-status-sorted.patch      | 79 ++++++++++++++++++++++
 3 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 19fc361..d923a52 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1072,6 +1072,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/sdl-libx11-1.6.patch                    \
   %D%/packages/patches/seq24-rename-mutex.patch                        \
   %D%/packages/patches/shepherd-close-fds.patch                        \
+  %D%/packages/patches/shepherd-herd-status-sorted.patch       \
   %D%/packages/patches/shishi-fix-libgcrypt-detection.patch    \
   %D%/packages/patches/slim-session.patch                      \
   %D%/packages/patches/slim-config.patch                       \
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 61ab965..e636b2a 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès 
<address@hidden>
 ;;; Copyright © 2013 Cyril Roelandt <address@hidden>
-;;; Copyright © 2014, 2015, 2016 Mark H Weaver <address@hidden>
+;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <address@hidden>
 ;;; Copyright © 2014, 2015, 2016, 2017 Eric Bavier <address@hidden>
 ;;; Copyright © 2015, 2016 Taylan Ulrich Bayırlı/Kammer <address@hidden>
 ;;; Copyright © 2015 Alex Sassmannshausen <address@hidden>
@@ -166,7 +166,8 @@ and provides a \"top-like\" mode (monitoring).")
               (sha256
                (base32
                 "174q1qg7yg6w1hfvlfv720hr6hid4h5xzw15y3ycfpspllzldhcb"))
-              (patches (search-patches "shepherd-close-fds.patch"))))
+              (patches (search-patches "shepherd-close-fds.patch"
+                                       "shepherd-herd-status-sorted.patch"))))
     (build-system gnu-build-system)
     (arguments
      '(#:configure-flags '("--localstatedir=/var")))
diff --git a/gnu/packages/patches/shepherd-herd-status-sorted.patch 
b/gnu/packages/patches/shepherd-herd-status-sorted.patch
new file mode 100644
index 0000000..c6b9d87
--- /dev/null
+++ b/gnu/packages/patches/shepherd-herd-status-sorted.patch
@@ -0,0 +1,79 @@
+From cc9564586729a5bb90dd5d2722b543fdde9ab821 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <address@hidden>
+Date: Sun, 4 Feb 2018 21:56:36 +0100
+Subject: [PATCH] herd: 'herd status' now sorts the result.
+
+Partly fixes <https://bugs.gnu.org/30299>.
+Reported by Mark H Weaver <address@hidden>.
+
+Previously 'tests/basic.sh' could occasionally fail on:
+
+  test "`$herd status`" == "$pristine_status"
+
+because the order of stopped services were not always the same.  Indeed,
+those services come from 'service-list' on the shepherd side, which uses
+'hash-fold' to traverse the service hash table, and the traversal order
+of 'hash-fold' is undefined.
+
+* modules/shepherd/scripts/herd.scm (display-status-summary)[service<?]:
+New procedure.
+[display-services]: Call 'sort' and use the above.
+---
+ modules/shepherd/scripts/herd.scm | 8 ++++++--
+ modules/shepherd/service.scm      | 5 +++--
+ 2 files changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/modules/shepherd/scripts/herd.scm 
b/modules/shepherd/scripts/herd.scm
+index ebcd1e1..697446c 100644
+--- a/modules/shepherd/scripts/herd.scm
++++ b/modules/shepherd/scripts/herd.scm
+@@ -1,5 +1,5 @@
+ ;; herd.scm -- The program to herd the Shepherd.
+-;; Copyright (C) 2013, 2014, 2016 Ludovic Courtès <address@hidden>
++;; Copyright (C) 2013, 2014, 2016, 2018 Ludovic Courtès <address@hidden>
+ ;; Copyright (C) 2002, 2003 Wolfgang Jährling <address@hidden>
+ ;;
+ ;; This file is part of the GNU Shepherd.
+@@ -46,13 +46,17 @@ of pairs."
+ 
+ (define (display-status-summary services)
+   "Display a summary of the status of all of SERVICES."
++  (define (service<? service1 service2)
++    (string<? (symbol->string (service-canonical-name service1))
++              (symbol->string (service-canonical-name service2))))
++
+   (define (display-services header bullet services)
+     (unless (null? services)
+       (display header)
+       (for-each (lambda (service)
+                   (format #t " ~a ~a~%" bullet
+                           (service-canonical-name service)))
+-                services)))
++                (sort services service<?))))      ;get deterministic output
+   (call-with-values
+       (lambda ()
+         (partition (match-lambda
+diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
+index 0ad28a0..83600e4 100644
+--- a/modules/shepherd/service.scm
++++ b/modules/shepherd/service.scm
+@@ -1,5 +1,5 @@
+ ;; service.scm -- Representation of services.
+-;; Copyright (C) 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <address@hidden>
++;; Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès 
<address@hidden>
+ ;; Copyright (C) 2002, 2003 Wolfgang Järling <address@hidden>
+ ;; Copyright (C) 2014 Alex Sassmannshausen <address@hidden>
+ ;; Copyright (C) 2016 Alex Kost <address@hidden>
+@@ -949,7 +949,8 @@ Return #f if service is not found."
+                  %services))
+ 
+ (define (service-list)
+-  "Return the list of services currently defined."
++  "Return the list of services currently defined.  Note: The order of the list
++returned in unspecified."
+   (hash-fold (lambda (name services result)
+                (let ((service (lookup-canonical-service name services)))
+                  (if service
+-- 
+2.16.1
+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]