From patchwork Mon Nov 1 07:43:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Tropin X-Patchwork-Id: 34195 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 25D8627BBE3; Mon, 1 Nov 2021 07:54:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B852727BBE1 for ; Mon, 1 Nov 2021 07:54:10 +0000 (GMT) Received: from localhost ([::1]:60508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhS8v-0007GT-RQ for patchwork@mira.cbaines.net; Mon, 01 Nov 2021 03:54:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhS8o-0007Fl-Ge for guix-patches@gnu.org; Mon, 01 Nov 2021 03:54:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhS8o-0001vw-7E for guix-patches@gnu.org; Mon, 01 Nov 2021 03:54:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mhS8o-0005jo-5D for guix-patches@gnu.org; Mon, 01 Nov 2021 03:54:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51541] [PATCH] services: configuration: Fix interpose implementation. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 01 Nov 2021 07:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51541 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51541@debbugs.gnu.org, go.wigust@gmail.com X-Debbugs-Original-To: guix-patches@gnu.org, Oleg Pykhalov Received: via spool by submit@debbugs.gnu.org id=B.163575321522016 (code B ref -1); Mon, 01 Nov 2021 07:54:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 Nov 2021 07:53:35 +0000 Received: from localhost ([127.0.0.1]:33616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mhS8N-0005j2-8u for submit@debbugs.gnu.org; Mon, 01 Nov 2021 03:53:35 -0400 Received: from lists.gnu.org ([209.51.188.17]:33916) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mhS8M-0005iu-3S for submit@debbugs.gnu.org; Mon, 01 Nov 2021 03:53:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhS8L-0007EU-Sk for guix-patches@gnu.org; Mon, 01 Nov 2021 03:53:33 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:39738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhS8J-0001bs-Ij for guix-patches@gnu.org; Mon, 01 Nov 2021 03:53:33 -0400 Received: by mail-lf1-x130.google.com with SMTP id l13so34738741lfg.6 for ; Mon, 01 Nov 2021 00:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=840J6KknOjvKnUde/W72XKcbRwrL4VvlJtJg6arQ29E=; b=VRjz3oVxtQ8jwMAyYbOFSyxmO5NMBq/4QgtLBKW+wX+tvqB+xXszLht161tFDsQHwX P5crFPqj0d31ivqPr49uGU2s646sruwL+yaq1SDfBG9hXzKaOQikp9BM2uHGfALZq7C+ kT4xoiqdj5G+GAuYFsTWwphAeAJ3L9ugBfR5IfKNwzKYcwzFZ9318X4zPbMQP+37DrnM 2KA6qnBl4GoppJqvvHx/rFLtBZcRU6IG32MnnQtxpRk3iOCqC34qZjZf2PVFEnaiipy1 NlnVibRY6wOl5cY/3DpVNtwKvA1xeaQBVshxalygSnagabAT1Uv5iR+/VwPFH3w5oszw 31IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=840J6KknOjvKnUde/W72XKcbRwrL4VvlJtJg6arQ29E=; b=XzQPTzxNAGD9Ni6DiD4cKz4aRK+Y1xVY1aKW4d6PgwRUZf5j+0jJgFbKZaiVSxsdjP 68ySN+5xMCNnrXjyfP6ersxFjPZu0MfjxwU+u0CFjaTTC04q300xYSvHmOUHNXDzYdfD kINczuZ5tXUkLOtpDFXiPLpwIWFuMmBefp0LbxKcmRq1H4OPEd/NIQrowRzL4iDJ31Nk BWvsTO5AK16nqFfnUW3ojotqe7PL12E9iWdax2tT2XDBPHkvFY8Pv+q+NJRJKbA7Jbfa zIrDhOv4Gia4UB4iXjErGrJuRJCrgN8hZWZhoOEAojChIJVrKtQZo5w1bTct/M9sDLVj BAnQ== X-Gm-Message-State: AOAM530YhptPG7djG/uZR0rB2nTog9Oy52UUM8fxvEVxp4644c22Wl8h Rq3sUaeZjJltFHyFm9eSlOp/eK68A0Rzwg== X-Google-Smtp-Source: ABdhPJx145DWFGAZb7pfMNXeYB57xMz7TzeYMFsIF2P4Q8qaOLwsoGBVPR4qB7tvMEqOHfYsvDoyFA== X-Received: by 2002:a05:6512:3092:: with SMTP id z18mr25899855lfd.396.1635753209003; Mon, 01 Nov 2021 00:53:29 -0700 (PDT) Received: from localhost (109-252-140-132.dynamic.spd-mgts.ru. [109.252.140.132]) by smtp.gmail.com with ESMTPSA id f7sm258463lfs.38.2021.11.01.00.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 00:53:28 -0700 (PDT) From: Andrew Tropin Date: Mon, 1 Nov 2021 10:43:12 +0300 Message-ID: <875ytctiq2.fsf@trop.in> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::130; envelope-from=andrew@trop.in; helo=mail-lf1-x130.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/configuration.scm (interpose, serialize-text-config): Fix interpose implementation, move file-like object code to serialize-text-config. --- This gexp reading file-like object content doesn't belong to interpose function, moved that part of code out of it. gnu/services/configuration.scm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index e8c55b6e4d..0de350a4df 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -359,10 +359,7 @@ (define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") grammar))) (fold-right (lambda (e acc) - (cons #~(begin - (use-modules (ice-9 rdelim)) - (with-fluids ((%default-port-encoding "UTF-8")) - (with-input-from-file #$e read-string))) + (cons e (if (and (null? acc) (eq? grammar 'infix)) acc (cons delimiter acc)))) @@ -387,7 +384,16 @@ (define serialize-file-like empty-serializer) (define (text-config? config) (list-of file-like?)) (define (serialize-text-config field-name val) - #~(string-append #$@(interpose val "\n" 'suffix))) + #~(string-append + #$@(interpose + (map + (lambda (e) + #~(begin + (use-modules (ice-9 rdelim)) + (with-fluids ((%default-port-encoding "UTF-8")) + (with-input-from-file #$e read-string)))) + val) + "\n" 'suffix))) (define ((generic-serialize-alist-entry serialize-field) entry) "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY."