[PATCH 1/2] services: ddclient: Fix extra-options serialization.

DoneSubmitted by Attila Lendvai.
Details
3 participants
  • Attila Lendvai
  • Oleg Pykhalov
  • Ludovic Courtès
Owner
unassigned
Severity
normal
A
A
Attila Lendvai wrote on 26 May 15:09 +0200
(address . guix-patches@gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220526130912.29483-1-attila@lendvai.name
Prior to this fix it has serialized "extra-options=..." into the ddclient.conf
file.

* gnu/services/dns.scm (serialize-field): Special case for extra-options.
(serialize-extra-options): Deleted unused function.
(ddclient-configuration): Change the type of the extra-options field to be a
string, and emit it verbatime into the ddclient.conf file. Change
docstring accordingly.
---

please note that even though this does fix an issue, i have abandoned
further work on ddclient. so, this is an improvement indeed, but i
suspect that this does not fully fix ddclient. looks like the conf
file format is different than what the current code emits.

the next patch updates ddclient to an RC2 of the next version,
which will be a major upgrade.

gnu/services/dns.scm | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

Toggle diff (41 lines)
diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm
index 50753b7ab6..c2ede312e8 100644
--- a/gnu/services/dns.scm
+++ b/gnu/services/dns.scm
@@ -904,8 +904,11 @@ (define (uglify-field-name field-name)
   (string-delete #\? (symbol->string field-name)))
 
 (define (serialize-field field-name val)
-  (when (not (member field-name '(group secret-file user)))
-    (format #t "~a=~a\n" (uglify-field-name field-name) val)))
+  (cond
+   ((eq? field-name 'extra-options)
+    (display val))
+   ((not (member field-name '(group secret-file user)))
+    (format #t "~a=~a\n" (uglify-field-name field-name) val))))
 
 (define (serialize-boolean field-name val)
   (serialize-field field-name (if val "yes" "no")))
@@ -921,9 +924,6 @@ (define (serialize-string field-name val)
 (define (serialize-list field-name val)
   (if (null? val) "" (serialize-field field-name (string-join val))))
 
-(define (serialize-extra-options extra-options)
-  (string-join extra-options "\n" 'suffix))
-
 (define-configuration ddclient-configuration
   (ddclient
    (file-like ddclient)
@@ -959,8 +959,8 @@ (define-configuration ddclient-configuration
 file contains credentials for use by ddclient.  You are expected to create it
 manually.")
   (extra-options
-   (list '())
-   "Extra options will be appended to @file{ddclient.conf} file."))
+   (string "")
+   "Extra options will be appended verbatim to the @file{ddclient.conf} file."))
 
 (define (ddclient-account config)
   "Return the user accounts and user groups for CONFIG."
-- 
2.35.1
A
A
Attila Lendvai wrote on 26 May 15:13 +0200
[PATCH 2/2] gnu: ddclient: Update to 3.10.0_2 (RC2).
(address . 55659@debbugs.gnu.org)(name . Attila Lendvai)(address . attila@lendvai.name)
20220526131315.30515-2-attila@lendvai.name
---

note that this seems to work, but is not fully tested. i have
abandoned the use of ddclient and with that this patchset.

also note that i'm not sure why the use of wrap-program is needed, but
without that it was missing some perl modules at runtime.

gnu/packages/dns.scm | 76 ++++++++++++++++----------------------------
1 file changed, 27 insertions(+), 49 deletions(-)

Toggle diff (111 lines)
diff --git a/gnu/packages/dns.scm b/gnu/packages/dns.scm
index fea255c930..0430415b3f 100644
--- a/gnu/packages/dns.scm
+++ b/gnu/packages/dns.scm
@@ -64,6 +64,7 @@ (define-module (gnu packages dns)
   #:use-module (gnu packages nettle)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages perl-check)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
@@ -1094,7 +1095,7 @@ (define-public knot-resolver
 (define-public ddclient
   (package
     (name "ddclient")
-    (version "3.9.1")
+    (version "3.10.0_2")
     (source
      (origin
        (method git-fetch)
@@ -1103,62 +1104,39 @@ (define-public ddclient
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0hf377g4j9r9sac75xp17nk2h58mazswz4vkg4g2gl2yyhvzq91w"))))
-    (build-system trivial-build-system) ; no Makefile.PL
+        (base32 "0jl658yr867y65hh054wg5gbzxsgpsf57qlc182ni4vwgqkrsrd1"))))
+    (build-system gnu-build-system)
     (native-inputs
-     (list bash perl))
+     (list bash autoconf automake
+           perl
+           ;; For the tests.
+           perl-try-tiny perl-test-warnings perl-http-daemon-ssl
+           perl-io-socket-inet6 perl-test-www-mechanize-psgi
+           perl-test-mockmodule))
     (inputs
      (list inetutils ; logger
            net-tools
+           perl
            perl-data-validate-ip
            perl-digest-sha1
            perl-io-socket-ssl))
     (arguments
-     `(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils)
-                      (ice-9 match)
-                      (srfi srfi-26))
-         (setenv "PATH" (string-append
-                         (assoc-ref %build-inputs "bash") "/bin" ":"
-                         (assoc-ref %build-inputs "perl") "/bin"))
-
-         ;; Copy the (read-only) source into the (writable) build directory.
-         (copy-recursively (assoc-ref %build-inputs "source") ".")
-
-         ;; Install.
-         (let* ((out (assoc-ref %outputs "out"))
-                (bin (string-append out "/bin")))
-           (let ((file "ddclient"))
-             (substitute* file
-               (("/usr/bin/perl") (which "perl"))
-               ;; Strictly use ‘/etc/ddclient/ddclient.conf’.
-               (("\\$\\{program\\}\\.conf") "/etc/ddclient/ddclient.conf")
-               (("\\$etc\\$program.conf") "/etc/ddclient/ddclient.conf")
-               ;; Strictly use ‘/var/cache/ddclient/ddclient.cache’
-               (("\\$cachedir\\$program\\.cache")
-                "/var/cache/ddclient/ddclient.cache"))
-             (install-file file bin)
-             (wrap-program (string-append bin "/" file)
-               `("PATH" ":" =
-                 ("$PATH"
-                  ,@(map (lambda (input)
-                           (match input
-                                  ((name . store)
-                                   (string-append store "/bin"))))
-                         %build-inputs)))
-               `("PERL5LIB" ":" =
-                 ,(delete
-                   ""
-                   (map (match-lambda
-                         (((? (cut string-prefix? "perl-" <>) name) . dir)
-                          (string-append dir "/lib/perl5/site_perl"))
-                         (_ ""))
-                        %build-inputs)))))
-           (for-each (cut install-file <> (string-append out
-                                                         "/share/ddclient"))
-                     (find-files "." "sample.*$"))))))
+     ;; The tests run mostly clean (6 failures), but I think they depend on
+     ;; the network config of the machine running them, so I turned them off.
+     `(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'change-dependencies
+           (lambda* (#:key native-inputs target #:allow-other-keys)
+             (substitute* "configure.ac"
+               (("HTTP::Daemon=6.12") "HTTP::Daemon=6.14"))))
+         (add-after 'install 'wrap-ddclient
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out")))
+               (wrap-program (string-append out "/bin/ddclient")
+                 `("PERL5LIB" ":" prefix
+                   (,(getenv "PERL5LIB")
+                    ,(string-append out "/lib/perl5/site_perl"))))))))))
     (home-page "https://ddclient.net/")
     (synopsis "Address updating utility for dynamic DNS services")
     (description "This package provides a client to update dynamic IP
-- 
2.35.1
A
A
Attila Lendvai wrote on 27 May 13:40 +0200
(address . 55659@debbugs.gnu.org)
oNADCetXWwzYR1hBQUS5kmC1SzfmFgk33scKFIDMyT5b9sP-nTGcOnoV3JNLJ7OZKaLZWSg2sk7sE72QIVrYbFGyqly1bOGjhj6VNfeWM4k=@lendvai.name

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“In a democracy, mass opinion creates power. Power diverts funds to the manufacturers of opinion, who manufacture more, etc. […] This feedback loop generates a playing field on which the most competitive ideas are not those which best correspond to reality, but those which produce the strongest feedback.”
— Mencius Moldbug
L
L
Ludovic Courtès wrote on 16 Jun 23:11 +0200
Re: bug#55659: [PATCH 1/2] services: ddclient: Fix extra-options serialization.
(name . Attila Lendvai)(address . attila@lendvai.name)(address . 55659@debbugs.gnu.org)
87mtecjoto.fsf@gnu.org
Hi,

Attila Lendvai <attila@lendvai.name> skribis:

Toggle quote (3 lines)
> Prior to this fix it has serialized "extra-options=..." into the ddclient.conf
> file.

[...]

Toggle quote (30 lines)
> (define (serialize-field field-name val)
> - (when (not (member field-name '(group secret-file user)))
> - (format #t "~a=~a\n" (uglify-field-name field-name) val)))
> + (cond
> + ((eq? field-name 'extra-options)
> + (display val))
> + ((not (member field-name '(group secret-file user)))
> + (format #t "~a=~a\n" (uglify-field-name field-name) val))))
>
> (define (serialize-boolean field-name val)
> (serialize-field field-name (if val "yes" "no")))
> @@ -921,9 +924,6 @@ (define (serialize-string field-name val)
> (define (serialize-list field-name val)
> (if (null? val) "" (serialize-field field-name (string-join val))))
>
> -(define (serialize-extra-options extra-options)
> - (string-join extra-options "\n" 'suffix))
> -
> (define-configuration ddclient-configuration
> (ddclient
> (file-like ddclient)
> @@ -959,8 +959,8 @@ (define-configuration ddclient-configuration
> file contains credentials for use by ddclient. You are expected to create it
> manually.")
> (extra-options
> - (list '())
> - "Extra options will be appended to @file{ddclient.conf} file."))
> + (string "")
> + "Extra options will be appended verbatim to the @file{ddclient.conf} file."))

In other places, such as (gnu home services desktop), I’ve used an extra
‘raw-configuration-string’ field type to handle this cases. This might
be clearer than adding the ‘cond’ above in ‘serialize-field’. WDYT?

The change above also changes the interface (from list to string), but I
think that’s OK.

Thanks,
Ludo’.
O
O
Oleg Pykhalov wrote on 17 Jun 07:38 +0200
(name . Attila Lendvai)(address . attila@lendvai.name)(address . 55659@debbugs.gnu.org)
87r13nkfy1.fsf_-_@gmail.com
Hi,

Attila Lendvai <attila@lendvai.name> writes:

Toggle quote (3 lines)
> note that this seems to work, but is not fully tested. i have
> abandoned the use of ddclient and with that this patchset.

I use it on my system, and could test it.

[…]

Toggle quote (9 lines)
> (native-inputs
> - (list bash perl))
> + (list bash autoconf automake
> + perl
> + ;; For the tests.
> + perl-try-tiny perl-test-warnings perl-http-daemon-ssl
> + perl-io-socket-inet6 perl-test-www-mechanize-psgi
> + perl-test-mockmodule))

Applied on current master 6fc33d91ba6b07beae8a9a38a5b768511bb79ced:
Toggle snippet (6 lines)
oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix build ddclient
gnu/packages/dns.scm:1113:44: In procedure native-inputs:
error: perl-http-daemon-ssl: unbound variable
hint: Did you forget a `use-modules' form?

Did you forget to attach a patch adding the perl-http-daemon-ssl?

[…]

Oleg.
-----BEGIN PGP SIGNATURE-----

iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmKsE0YUHGdvLndpZ3Vz
dEBnbWFpbC5jb20ACgkQFn+OpQAa+pzPVxAAj8ciiNZpRfaTmjqzhRxbERQlrL9r
eH0gjckxXY94KeoEoXA0DO6TJp/AORoQCvwMuhr+kekPwRt06wh6VWTgu+5tCk+N
b5umjmUOGSoGd39rtp3Wa7WVBM1BqxKzeAEA8fNzOGVk4uskeC/O7O8noPBIW0yq
0So9trFgaL5429aD0vz8/2cMsyaA2W44c3waXxk/K8J7GaHQuNBWKRXtn4CK2nse
G42gGsu9nOVdT1QFY+Of6UnHqAxH1CTvR946/KPa0W+sqK/hWZlecOqlF4ziO2Qi
RLtWvw5fHaO/If+afu55z/G4vYTc3bxLjhD2P0XThmLQO24XDYF1XfE816jFHIVk
NguRhdriIlpvHs7lRWdKJ4Lj/eFrv2Ik/NjMGUdeSAE3C60ZaiqRDahTPDqsqU4L
5T6W0PCVRRaAwvJQkDl8fq1H9TglKngPRAYA+IbCt0pq4baFtWtSlPWi2gKlIxtk
sdq3AwVQSFpkrzxsSl4nsUEKtkC6aLz05px8+XCuL4LUA++gy7Gy2dqgvrK9Aab0
ZJ9dmo9IbvJOCvWYykgUS7Jrl/mHkDXB27zcmfpcjQxBrMeE9enXlUA+XbPSsMMZ
Jbe+sdTAt+PW7VQnpWSh5luv/DoZ0OMeZ6TOJ0Kxcx4DTU035vils8KorYLquLKZ
Cjyo+GYUZ/u18pA=
=fPth
-----END PGP SIGNATURE-----

A
A
Attila Lendvai wrote on 17 Jun 10:26 +0200
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 55659@debbugs.gnu.org)
TKw3QG3GQj4OvHKxdVWovBKpDHJvoDJ0Blt-4rpSrqjNUI1O1REFkVK-v7yR1Il58V_X5OjFY06mx_JFtYlpb9C5MaSPzrwf45W535kWeZY=@lendvai.name
Toggle quote (12 lines)
> Applied on current master 6fc33d91ba6b07beae8a9a38a5b768511bb79ced:
> --8<---------------cut here---------------start------------->8---
>
> oleg@guixsd ~/src/guix [env]$ ./pre-inst-env guix build ddclient
> gnu/packages/dns.scm:1113:44: In procedure native-inputs:
> error: perl-http-daemon-ssl: unbound variable
> hint: Did you forget a `use-modules' form?
> --8<---------------cut here---------------end--------------->8---
>
>
> Did you forget to attach a patch adding the perl-http-daemon-ssl?

forgot to say that this depends on https://issues.guix.gnu.org/55656

i was advised to split patchsets, but i think i really shouldn't have in this case.

sorry for the confusion, and thanks for testing it!

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Without love the acquisition of knowledge only increases confusion and leads to self-destruction.”
— Jiddu Krishnamurti (1895–1986)
A
A
Attila Lendvai wrote on 17 Jun 10:53 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 55659@debbugs.gnu.org)
2S-Am7ZdiqFMMIq6yXdzPJWKxVzRAnpPSN1jxE3-ZzepKJLuXXjipZOJNzdCesft1R_JkjD3z6OcQ75_vNFY1alvPW03W88wOLtrH77w77c=@lendvai.name
Toggle quote (5 lines)
> In other places, such as (gnu home services desktop), I’ve used an extra
> ‘raw-configuration-string’ field type to handle this cases. This might
> be clearer than adding the ‘cond’ above in ‘serialize-field’. WDYT?


i agree, it's a much better, more intuitive name. i'll use it from now on.

(note that i'm not planning to work on this more. i hope someone will pick this up who actually uses ddclient, and therefore has the ability to test it with little effort. feel free to close it, too.)

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“There is no leader, there is no teacher, there is nobody to tell you what to do. You are alone in this mad, brutal world.”
— Jiddu Krishnamurti (1895–1986)
L
L
Ludovic Courtès wrote on 3 Aug 12:00 +0200
control message for bug #55659
(address . control@debbugs.gnu.org)
87fsidve7v.fsf@gnu.org
tags 55659 wontfix
close 55659
quit
?