all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Services configuration syntaxes patches.
@ 2017-02-28 22:50 Clément Lassieur
  2017-02-28 22:50 ` [PATCH 1/2] services: dovecot: Reimplement proper configuration functions Clément Lassieur
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Clément Lassieur @ 2017-02-28 22:50 UTC (permalink / raw)
  To: guix-devel; +Cc: jmd

There was a bug in the dovecot service introduced by a refactoring of syntaxes
functions.  I don't think those functions should be put in a common file,
because syntaxes are often specific to services, as I explained in one of the
commit messages.

Therefore I did two commits.  The first fixes the bug.  The other removes
functions that should not be abstracted from configuration.scm, and put them
back into their specific services.

The second commit should not have any actual effect, but I checked that
services depending on configuration.scm were still working and:
  - Dovecot works (because of the first commit).
  - Prosody works (no changes).
  - Cups works.
  - I don't know how to test Kerberos, but its configuration file didn't move.
  - OpenVPN does not build when put in config.scm, because of a tls issue, so
    I could not check (but I didn't need to modify it).

WDYT?

Clément Lassieur (2):
  services: dovecot: Reimplement proper configuration functions.
  services: Move configuration functions that shouldn't be factorized.

 gnu/services/configuration.scm | 40 ----------------------------------------
 gnu/services/cups.scm          | 32 ++++++++++++++++++++++++++++++++
 gnu/services/kerberos.scm      | 15 +++++++++++++++
 gnu/services/mail.scm          | 30 ++++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 40 deletions(-)

-- 
2.12.0

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

* [PATCH 1/2] services: dovecot: Reimplement proper configuration functions.
  2017-02-28 22:50 [PATCH 0/2] Services configuration syntaxes patches Clément Lassieur
@ 2017-02-28 22:50 ` Clément Lassieur
  2017-02-28 22:50 ` [PATCH 2/2] services: Move configuration functions that shouldn't be factorized Clément Lassieur
  2017-03-01  9:53 ` [PATCH 0/2] Services configuration syntaxes patches Andy Wingo
  2 siblings, 0 replies; 4+ messages in thread
From: Clément Lassieur @ 2017-02-28 22:50 UTC (permalink / raw)
  To: guix-devel; +Cc: jmd

* gnu/services/mail.scm (uglify-field-name, serialize-field, serialize-string)
  (space-separated-string-list?, serialize-space-separated-string-list)
  (file-name?, serialize-file-name, serialize-boolean): Add them.

These functions were inadvertently changed while being factorized in
gnu/service/configuration.scm.
---
 gnu/services/mail.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 30b1672d3..8b75134a7 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -62,6 +62,27 @@
 ;;;
 ;;; Code:
 
+(define (uglify-field-name field-name)
+  (let ((str (symbol->string field-name)))
+    (string-join (string-split (if (string-suffix? "?" str)
+                                   (substring str 0 (1- (string-length str)))
+                                   str)
+                               #\-)
+                 "_")))
+
+(define (serialize-field field-name val)
+  (format #t "~a=~a\n" (uglify-field-name field-name) val))
+
+(define (serialize-string field-name val)
+  (serialize-field field-name val))
+
+(define (space-separated-string-list? val)
+  (and (list? val)
+       (and-map (lambda (x)
+                  (and (string? x) (not (string-index x #\space))))
+                val)))
+(define (serialize-space-separated-string-list field-name val)
+  (serialize-field field-name (string-join val " ")))
 
 (define (comma-separated-string-list? val)
   (and (list? val)
@@ -71,6 +92,12 @@
 (define (serialize-comma-separated-string-list field-name val)
   (serialize-field field-name (string-join val ",")))
 
+(define (file-name? val)
+  (and (string? val)
+       (string-prefix? "/" val)))
+(define (serialize-file-name field-name val)
+  (serialize-string field-name val))
+
 (define (colon-separated-file-name-list? val)
   (and (list? val)
        ;; Trailing slashes not needed and not
@@ -78,6 +105,9 @@
 (define (serialize-colon-separated-file-name-list field-name val)
   (serialize-field field-name (string-join val ":")))
 
+(define (serialize-boolean field-name val)
+  (serialize-string field-name (if val "yes" "no")))
+
 (define (non-negative-integer? val)
   (and (exact-integer? val) (not (negative? val))))
 (define (serialize-non-negative-integer field-name val)
-- 
2.12.0

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

* [PATCH 2/2] services: Move configuration functions that shouldn't be factorized.
  2017-02-28 22:50 [PATCH 0/2] Services configuration syntaxes patches Clément Lassieur
  2017-02-28 22:50 ` [PATCH 1/2] services: dovecot: Reimplement proper configuration functions Clément Lassieur
@ 2017-02-28 22:50 ` Clément Lassieur
  2017-03-01  9:53 ` [PATCH 0/2] Services configuration syntaxes patches Andy Wingo
  2 siblings, 0 replies; 4+ messages in thread
From: Clément Lassieur @ 2017-02-28 22:50 UTC (permalink / raw)
  To: guix-devel; +Cc: jmd

* gnu/services/configuration.scm (serialize-field, serialize-string)
  (serialize-space-separated-string-list, space-separated-string-list?)
  (serialize-file-name, file-name?, serialize-boolean): Move these functions...
* gnu/services/cups.scm: ...to this file.
* gnu/services/kerberos.scm: ...to this file.

Configuration syntaxes are very specific to services.  Some services may have
the same configuration syntax, but none of them is common enough to be
abstracted in configuration.scm.
---
 gnu/services/configuration.scm | 40 ----------------------------------------
 gnu/services/cups.scm          | 32 ++++++++++++++++++++++++++++++++
 gnu/services/kerberos.scm      | 15 +++++++++++++++
 3 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index a98db64fa..2ad3a637a 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -39,14 +39,6 @@
             define-configuration
             validate-configuration
             generate-documentation
-            serialize-field
-            serialize-string
-            serialize-name
-            serialize-space-separated-string-list
-            space-separated-string-list?
-            serialize-file-name
-            file-name?
-            serialize-boolean
             serialize-package))
 
 ;;; Commentary:
@@ -140,41 +132,9 @@
                                            #,(id #'stem #'stem #'-fields))
                    conf))))))))
 
-(define (uglify-field-name field-name)
-  (let ((str (symbol->string field-name)))
-    (string-concatenate
-     (map string-titlecase
-          (string-split (if (string-suffix? "?" str)
-                            (substring str 0 (1- (string-length str)))
-                            str)
-                        #\-)))))
-
-(define (serialize-field field-name val)
-  (format #t "~a ~a\n" (uglify-field-name field-name) val))
-
 (define (serialize-package field-name val)
   #f)
 
-(define (serialize-string field-name val)
-  (serialize-field field-name val))
-
-(define (space-separated-string-list? val)
-  (and (list? val)
-       (and-map (lambda (x)
-                  (and (string? x) (not (string-index x #\space))))
-                val)))
-(define (serialize-space-separated-string-list field-name val)
-  (serialize-field field-name (string-join val " ")))
-
-(define (file-name? val)
-  (and (string? val)
-       (string-prefix? "/" val)))
-(define (serialize-file-name field-name val)
-  (serialize-string field-name val))
-
-(define (serialize-boolean field-name val)
-  (serialize-string field-name (if val "yes" "no")))
-
 ;; A little helper to make it easier to document all those fields.
 (define (generate-documentation documentation documentation-name)
   (define (str x) (object->string x))
diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm
index 70b858479..70a71eff0 100644
--- a/gnu/services/cups.scm
+++ b/gnu/services/cups.scm
@@ -57,6 +57,21 @@
          (home-directory "/var/empty")
          (shell (file-append shadow "/sbin/nologin")))))
 
+(define (uglify-field-name field-name)
+  (let ((str (symbol->string field-name)))
+    (string-concatenate
+     (map string-titlecase
+          (string-split (if (string-suffix? "?" str)
+                            (substring str 0 (1- (string-length str)))
+                            str)
+                        #\-)))))
+
+(define (serialize-field field-name val)
+  (format #t "~a ~a\n" (uglify-field-name field-name) val))
+
+(define (serialize-string field-name val)
+  (serialize-field field-name val))
+
 (define (multiline-string-list? val)
   (and (list? val)
        (and-map (lambda (x)
@@ -65,11 +80,28 @@
 (define (serialize-multiline-string-list field-name val)
   (for-each (lambda (str) (serialize-field field-name str)) val))
 
+(define (space-separated-string-list? val)
+  (and (list? val)
+       (and-map (lambda (x)
+                  (and (string? x) (not (string-index x #\space))))
+                val)))
+(define (serialize-space-separated-string-list field-name val)
+  (serialize-field field-name (string-join val " ")))
+
 (define (space-separated-symbol-list? val)
   (and (list? val) (and-map symbol? val)))
 (define (serialize-space-separated-symbol-list field-name val)
   (serialize-field field-name (string-join (map symbol->string val) " ")))
 
+(define (file-name? val)
+  (and (string? val)
+       (string-prefix? "/" val)))
+(define (serialize-file-name field-name val)
+  (serialize-string field-name val))
+
+(define (serialize-boolean field-name val)
+  (serialize-string field-name (if val "yes" "no")))
+
 (define (non-negative-integer? val)
   (and (exact-integer? val) (not (negative? val))))
 (define (serialize-non-negative-integer field-name val)
diff --git a/gnu/services/kerberos.scm b/gnu/services/kerberos.scm
index cb33a7c53..f09f47893 100644
--- a/gnu/services/kerberos.scm
+++ b/gnu/services/kerberos.scm
@@ -96,6 +96,12 @@ trailing '?' removed."
   (unless (eq? val unset-field)
       (serialize-field* field-name (string-join val " "))))
 
+(define (space-separated-string-list? val)
+  (and (list? val)
+       (and-map (lambda (x)
+                  (and (string? x) (not (string-index x #\space))))
+                val)))
+
 (define space-separated-string-list/unset?
   (predicate/unset space-separated-string-list?))
 
@@ -118,10 +124,19 @@ trailing '?' removed."
                     (lambda (val)
                       (string-prefix? "/" val))))
 
+(define (serialize-field field-name val)
+  (format #t "~a ~a\n" (uglify-field-name field-name) val))
+
+(define (serialize-string field-name val)
+  (serialize-field field-name val))
+
 (define (serialize-file-name field-name val)
   (unless (eq? val unset-field)
     (serialize-string field-name val)))
 
+(define (serialize-space-separated-string-list field-name val)
+  (serialize-field field-name (string-join val " ")))
+
 (define (non-negative-integer? val)
   (and (exact-integer? val) (not (negative? val))))
 
-- 
2.12.0

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

* Re: [PATCH 0/2] Services configuration syntaxes patches.
  2017-02-28 22:50 [PATCH 0/2] Services configuration syntaxes patches Clément Lassieur
  2017-02-28 22:50 ` [PATCH 1/2] services: dovecot: Reimplement proper configuration functions Clément Lassieur
  2017-02-28 22:50 ` [PATCH 2/2] services: Move configuration functions that shouldn't be factorized Clément Lassieur
@ 2017-03-01  9:53 ` Andy Wingo
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2017-03-01  9:53 UTC (permalink / raw)
  To: Clément Lassieur; +Cc: guix-devel, jmd

Hi Clément,

On Tue 28 Feb 2017 23:50, Clément Lassieur <clement@lassieur.org> writes:

> There was a bug in the dovecot service introduced by a refactoring of syntaxes
> functions.  I don't think those functions should be put in a common file,
> because syntaxes are often specific to services, as I explained in one of the
> commit messages.
>
> Therefore I did two commits.  The first fixes the bug.  The other removes
> functions that should not be abstracted from configuration.scm, and put them
> back into their specific services.
>
> The second commit should not have any actual effect, but I checked that
> services depending on configuration.scm were still working and:
>   - Dovecot works (because of the first commit).
>   - Prosody works (no changes).
>   - Cups works.
>   - I don't know how to test Kerberos, but its configuration file didn't move.
>   - OpenVPN does not build when put in config.scm, because of a tls issue, so
>     I could not check (but I didn't need to modify it).
>
> WDYT?

Great patches; will apply when I get to my other machine :)

Andy

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

end of thread, other threads:[~2017-03-01  9:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-28 22:50 [PATCH 0/2] Services configuration syntaxes patches Clément Lassieur
2017-02-28 22:50 ` [PATCH 1/2] services: dovecot: Reimplement proper configuration functions Clément Lassieur
2017-02-28 22:50 ` [PATCH 2/2] services: Move configuration functions that shouldn't be factorized Clément Lassieur
2017-03-01  9:53 ` [PATCH 0/2] Services configuration syntaxes patches Andy Wingo

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.