From patchwork Wed Nov 21 14:17:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 261 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 32B4016837; Wed, 21 Nov 2018 14:19:18 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id BBB1D167F9 for ; Wed, 21 Nov 2018 14:19:17 +0000 (GMT) Received: from localhost ([::1]:39425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTLZ-0003Hp-1F for patchwork@mira.cbaines.net; Wed, 21 Nov 2018 09:19:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTKW-0002Gv-3V for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPTKM-0004Pg-MW for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:08 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:33728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPTKM-0004PG-Go for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gPTKL-0000gF-PN for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33448] [PATCH 1/3] describe: Use a procedure to format output. References: <20181120222616.3941-1-go.wigust@gmail.com> In-Reply-To: <20181120222616.3941-1-go.wigust@gmail.com> Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Nov 2018 14:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33448 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33448@debbugs.gnu.org Received: via spool by 33448-submit@debbugs.gnu.org id=B33448.15428098712557 (code B ref 33448); Wed, 21 Nov 2018 14:18:01 +0000 Received: (at 33448) by debbugs.gnu.org; 21 Nov 2018 14:17:51 +0000 Received: from localhost ([127.0.0.1]:37981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPTKA-0000fA-QD for submit@debbugs.gnu.org; Wed, 21 Nov 2018 09:17:51 -0500 Received: from mail-lf1-f50.google.com ([209.85.167.50]:39459) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPTK8-0000ea-Hw for 33448@debbugs.gnu.org; Wed, 21 Nov 2018 09:17:49 -0500 Received: by mail-lf1-f50.google.com with SMTP id n18so4095198lfh.6 for <33448@debbugs.gnu.org>; Wed, 21 Nov 2018 06:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zZMonOlYz2OWHfhukf+S/MLam9zDDMLR67q42X9YMTE=; b=SXouQuw++Whgf2GmDi4JGmo6ifQAUrCt9l7EcQrdu0W7g4SHRQe1n9nvOp/pQmuIGG KwWpsGloRsvl531z/Y1AJmeTg/kuLtWY3U9Ro79PevRHqQu6k4zQXe5Hxi0EAvOnTxYN RDzz7NS+lDAMWLwbKq2QlE7E5rZSKbi/T7iAk+3BaKBxGO1nbqqyBPMsSFR0CJzIS4cd /PiNKdPgXFAwzBTgaZv8pwMzPuGD1rgj5dz6LoUPRUz67y8uYdodXcuGuWi1WEMsx+xh hiCo3gfCqY8Ig+ZQ++V4V6O4UacxGstN+hQXGXDDCQzqWyLENztb5RVpabdU9c5TgaM3 S1gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zZMonOlYz2OWHfhukf+S/MLam9zDDMLR67q42X9YMTE=; b=oZ8p1AjP3qvTowu2D98M4pfu4JkURv+ddbw8+tba/lyTGBKsYWBJnIB6OkkmKkYfai pafeUMli/68EgJOFCzQUhSxz0GjVxq6YE+J8kI4atGLULfKypLw/CzPUy7Shc2uLHjnH 4NbE6XiLsWsrZjBvKC0uppiwphdLuIRAWIOQHEc4EZLDlXppC8UMSbiTvphZsRU0KPGl IZoTfU6yYaQNhLyUfFxpvXgCmyeL9UI39yhMOIuXloBTyiN8wv+0ST+VLcfCUD/lVjL/ /8wk6ZVXhIktpdikV60HS2WRcaVy/siXgxUzJ+93ib4kxOMf153rIr0eGyhiIKgNjRCs tSFQ== X-Gm-Message-State: AGRZ1gIqLDR0IRS0JpjqnjKF+RcZpTkgfa9z0O86Qpv8NVGQpekZ/VYz dhW4VEdaW2+Ia+vPAdukdAhacRAi+IU= X-Google-Smtp-Source: AJdET5dZupp8fOpr+7s2VPtV4n9OA2iYNj3YQEwjFbLbsrJoceCQ/f+V73zowFEbTFwVcGQ1B0/DUw== X-Received: by 2002:a19:2c92:: with SMTP id s140mr3759047lfs.42.1542809862273; Wed, 21 Nov 2018 06:17:42 -0800 (PST) Received: from localhost.localdomain (95-55-9-11.dynamic.avangarddsl.ru. [95.55.9.11]) by smtp.gmail.com with ESMTPSA id k3-v6sm1589040lja.8.2018.11.21.06.17.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 06:17:41 -0800 (PST) From: Oleg Pykhalov Date: Wed, 21 Nov 2018 17:17:13 +0300 Message-Id: <20181121141715.16417-1-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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 * guix/channels.scm (channel->sexp): New procedure. * guix/scripts/describe.scm (display-checkout-info, display-profile-info): Use this. --- guix/channels.scm | 9 +++++++ guix/scripts/describe.scm | 57 ++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/guix/channels.scm b/guix/channels.scm index 82389eb58..bfdbf470b 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -39,6 +39,7 @@ channel-commit channel-location + channel->sexp %default-channels channel-instance? @@ -85,6 +86,14 @@ "Return true if CHANNEL is the 'guix' channel." (eq? 'guix (channel-name channel))) +(define channel->sexp + (match-lambda + (($ name url branch commit location) + `(channel + (name ,name) + (url ,url) + (commit ,commit))))) + (define-record-type (channel-instance channel commit checkout) channel-instance? diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index d817d7f7c..6a30d19b1 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -18,6 +18,7 @@ (define-module (guix scripts describe) #:use-module ((guix ui) #:hide (display-profile-content)) + #:use-module (guix channels) #:use-module (guix scripts) #:use-module (guix describe) #:use-module (guix profiles) @@ -104,10 +105,9 @@ within a Git checkout." (format #t (G_ " branch: ~a~%") (reference-shorthand head)) (format #t (G_ " commit: ~a~%") commit)) ('channels - (pretty-print `(list (channel - (name 'guix) - (url ,(dirname directory)) - (commit ,commit)))))) + (pretty-print (channel->sexp (channel (name 'guix) + (url (dirname directory)) + (commit commit)))))) (display-package-search-path fmt))) (define (display-profile-info profile fmt) @@ -116,34 +116,35 @@ in the format specified by FMT." (define number (generation-number profile)) + (define (channels) + (map (lambda (entry) + (match (assq 'source (manifest-entry-properties entry)) + (('source ('repository ('version 0) + ('url url) + ('branch branch) + ('commit commit) + _ ...)) + (channel (name (string->symbol (manifest-entry-name entry))) + (url url) + (commit commit))) + + ;; Pre-0.15.0 Guix does not provide that information, + ;; so there's not much we can do in that case. + (_ '???))) + + ;; Show most recently installed packages last. + (reverse + (manifest-entries + (profile-manifest + (if (zero? number) + profile + (generation-file-name profile number))))))) + (match fmt ('human (display-profile-content profile number)) ('channels - (pretty-print - `(list ,@(map (lambda (entry) - (match (assq 'source (manifest-entry-properties entry)) - (('source ('repository ('version 0) - ('url url) - ('branch branch) - ('commit commit) - _ ...)) - `(channel (name ',(string->symbol - (manifest-entry-name entry))) - (url ,url) - (commit ,commit))) - - ;; Pre-0.15.0 Guix does not provide that information, - ;; so there's not much we can do in that case. - (_ '???))) - - ;; Show most recently installed packages last. - (reverse - (manifest-entries - (profile-manifest - (if (zero? number) - profile - (generation-file-name profile number)))))))))) + (pretty-print (map channel->sexp (channels))))) (display-package-search-path fmt)) From patchwork Wed Nov 21 14:17:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 260 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 57DCE16837; Wed, 21 Nov 2018 14:19:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id EA422167F9 for ; Wed, 21 Nov 2018 14:19:15 +0000 (GMT) Received: from localhost ([::1]:39424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTLX-0003DL-80 for patchwork@mira.cbaines.net; Wed, 21 Nov 2018 09:19:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTKV-0002GI-3k for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPTKM-0004PX-Hb for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:06 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:33729) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPTKM-0004PT-EU for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gPTKM-0000gN-A3 for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33448] [PATCH 2/3] describe: Add json format. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Nov 2018 14:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33448 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33448@debbugs.gnu.org Received: via spool by 33448-submit@debbugs.gnu.org id=B33448.15428098732578 (code B ref 33448); Wed, 21 Nov 2018 14:18:02 +0000 Received: (at 33448) by debbugs.gnu.org; 21 Nov 2018 14:17:53 +0000 Received: from localhost ([127.0.0.1]:37984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPTKD-0000fT-95 for submit@debbugs.gnu.org; Wed, 21 Nov 2018 09:17:53 -0500 Received: from mail-lj1-f176.google.com ([209.85.208.176]:44141) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPTK9-0000ef-UX for 33448@debbugs.gnu.org; Wed, 21 Nov 2018 09:17:50 -0500 Received: by mail-lj1-f176.google.com with SMTP id k19-v6so4952417lji.11 for <33448@debbugs.gnu.org>; Wed, 21 Nov 2018 06:17:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KJW9fjfUR7H2gBddt0ifGttS/FYQn+6GY9MjbUkpwoo=; b=SLsV5h99r52tfg/bZxtjeMUNKZUlTBdvlQfmE0hggWf0JWU/Iz0zhmu21B7Kw/qvXB NsLjwbpMX4cnaAuJpiGTSZp4uKi5qeTsXAkc4Uq1FvnwuCTTh1/HaGAfilyEVI1tDmS/ 45pki1zX+pZkyZjrnXq/WMVUh3T5wQqCDl6RXWm1uu77cfxlhJCzJHeBzE/NGgVX0tSX Fza/WcsRG5SaWw0x3RECtQxwDVlgs5+rfvTCbzu6Vc/IxqMQHoCEh6SYdRtdvDrra5hs b/96euBzn86Gy9tPnvS2E+bZ7dcVLhSN2mxpe9LcxuB1bUxW7bEvxyRXxjgmZY/x2Xb2 NjuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KJW9fjfUR7H2gBddt0ifGttS/FYQn+6GY9MjbUkpwoo=; b=bZ3N1N6aBF6RykOlrIr8R4GFULiQ0SQaNr4BuYi1fEkH5Zn+H4EJBQSsvnjAJDEvGH mAjMHEI2Yn6E0LuAESLKf1p1mKlhLuAvu2KmJNENbvX5kahUBwofd5Y9NB9+0KODBFLC a+aNHAegnyl15MatXKRsm3CHzDIbl8n2QMIZ0S6DUVFRJ/9FNmDR6mkEX/SZLx3brdZt irJ9UrRm81WqBDsiXzYrV+1h0kximAxcZtMh4Lou1oYTTl6PJ1sVN1//5tITSDkDwDCb ZgH6APRz9mQZqabXjKCX6U3HY4DrEwFsyoIWqVvrdr94gI20nYNVz1RF5ygxMG28rq2S AYjA== X-Gm-Message-State: AGRZ1gJ78uJHCOG0wxUrBmxlc1VkaTdtxbtB8q80PIAqSHMxUw2kEMQy 22ajbbrMuF33qZzEUStvVAaq42uIc18= X-Google-Smtp-Source: AJdET5dE73Yq15icN+bCDdJcWr6i4eUG+BfdLS95TOk33HiQQM1XaKLhm+KnLJd0+51AyE9kCM0dtw== X-Received: by 2002:a2e:9059:: with SMTP id n25-v6mr4138151ljg.155.1542809863628; Wed, 21 Nov 2018 06:17:43 -0800 (PST) Received: from localhost.localdomain (95-55-9-11.dynamic.avangarddsl.ru. [95.55.9.11]) by smtp.gmail.com with ESMTPSA id k3-v6sm1589040lja.8.2018.11.21.06.17.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 06:17:42 -0800 (PST) From: Oleg Pykhalov Date: Wed, 21 Nov 2018 17:17:14 +0300 Message-Id: <20181121141715.16417-2-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121141715.16417-1-go.wigust@gmail.com> References: <20181121141715.16417-1-go.wigust@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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 * guix/channels.scm (channel->json): New procedure. * guix/scripts/describe.scm (%options): Add 'json' option. (display-checkout-info, display-profile-info): Use 'channel->json'. * doc/guix.texi (Invoking guix describe): Document this. --- doc/guix.texi | 5 ++++- guix/channels.scm | 12 ++++++++++++ guix/scripts/describe.scm | 13 ++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 082e81bf7..3413eb30f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3273,7 +3273,10 @@ produce human-readable output; @item channels produce a list of channel specifications that can be passed to @command{guix pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking -guix pull}). +guix pull}); +@item json +@cindex JSON +produce a list of channel specifications in JSON format. @end table @item --profile=@var{profile} diff --git a/guix/channels.scm b/guix/channels.scm index bfdbf470b..9f2c9103e 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -26,6 +26,7 @@ #:use-module (guix derivations) #:use-module (guix store) #:use-module (guix i18n) + #:use-module (json) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-11) @@ -39,7 +40,9 @@ channel-commit channel-location + channel->json channel->sexp + %default-channels channel-instance? @@ -94,6 +97,15 @@ (url ,url) (commit ,commit))))) +(define channel->json + (match-lambda + (($ name url branch commit location) + (scm->json-string + (list + (cons 'name name) + (cons 'url url) + (cons 'commit commit)))))) + (define-record-type (channel-instance channel commit checkout) channel-instance? diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index 6a30d19b1..d7e276769 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -39,7 +39,7 @@ ;; Specifications of the command-line options. (list (option '(#\f "format") #t #f (lambda (opt name arg result) - (unless (member arg '("human" "channels")) + (unless (member arg '("human" "channels" "json")) (leave (G_ "~a: unsupported output format~%") arg)) (alist-cons 'format (string->symbol arg) result))) (option '(#\p "profile") #t #f @@ -107,7 +107,12 @@ within a Git checkout." ('channels (pretty-print (channel->sexp (channel (name 'guix) (url (dirname directory)) - (commit commit)))))) + (commit commit))))) + ('json + (display (channel->json (channel (name 'guix) + (url (dirname directory)) + (commit commit)))) + (newline))) (display-package-search-path fmt))) (define (display-profile-info profile fmt) @@ -144,7 +149,9 @@ in the format specified by FMT." ('human (display-profile-content profile number)) ('channels - (pretty-print (map channel->sexp (channels))))) + (pretty-print (map channel->sexp (channels)))) + ('json + (format #t "[~a]~%" (string-join (map channel->json (channels)) ",")))) (display-package-search-path fmt)) From patchwork Wed Nov 21 14:17:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 259 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 0A42C16837; Wed, 21 Nov 2018 14:18:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id 922D9167F9 for ; Wed, 21 Nov 2018 14:18:32 +0000 (GMT) Received: from localhost ([::1]:39422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTKn-0002OT-LN for patchwork@mira.cbaines.net; Wed, 21 Nov 2018 09:18:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTKb-0002N6-Fv for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPTKV-0004SV-5q for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:15 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:33730) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPTKO-0004Qf-Ku for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gPTKM-0000gW-Pj for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33448] [PATCH 3/3] describe: Add recutils format. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Nov 2018 14:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33448 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33448@debbugs.gnu.org Received: via spool by 33448-submit@debbugs.gnu.org id=B33448.15428098742584 (code B ref 33448); Wed, 21 Nov 2018 14:18:02 +0000 Received: (at 33448) by debbugs.gnu.org; 21 Nov 2018 14:17:54 +0000 Received: from localhost ([127.0.0.1]:37986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPTKD-0000fX-Kn for submit@debbugs.gnu.org; Wed, 21 Nov 2018 09:17:53 -0500 Received: from mail-lf1-f51.google.com ([209.85.167.51]:42982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPTKB-0000ek-1X for 33448@debbugs.gnu.org; Wed, 21 Nov 2018 09:17:51 -0500 Received: by mail-lf1-f51.google.com with SMTP id l10so4090422lfh.9 for <33448@debbugs.gnu.org>; Wed, 21 Nov 2018 06:17:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n0qeXb+nBA9ijI40pzn7RRvQDja5vhIrR1uJHWBCpcU=; b=GjVjTQrY4/OcBKZGMzt3rgJgpouweqHCnM+XtSLEmpKri9VFQNDFbGaUzb3FwbRaKt RvbQRkLAcIFQMjbnAfT/7ycPqcKt7IhafkHacXvYDcE1BSdOfdYwkLK/kCt+diz2WbWM mlCo1+2M37YIyvtJrTp5hBPfyhFE0NCmNvsDa+UrRRA0vCLmHtC10e9eGn7JRraWtmSD 7ukx+hU2phghHZqWCf5aw5FM/5KVPK0QTyul7GuXGkBttBsH8KpUBXQQqn4OPAaHE5KI arefUyd80StDuPTSel7RE8HeRs2GwBwhb3zhDtSF4wQm0Yrh4TIx0duY2S6NBi9kgynu fSug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n0qeXb+nBA9ijI40pzn7RRvQDja5vhIrR1uJHWBCpcU=; b=ozOlYHRh6tzcR3R5h+sSytmz2223D1MrofugxmsGsM0VtJdtvFb6bQvuEZt87OvTx8 daseJbAfXaEOr86oy45MWu2stSuytZ8eGOjOglKBA9UeiKsDhcX2Akr1cyLQGVbIOcUm pbLB88h4rU7glWM5+WoS01J+hqeU/9JIdDWxbIZRn0YCiA1+dRvk83sd7XXqW/m9LGVA 37X/g3feMnKBBvl5CEDjwC2frKqGsIPdnVBselDLGQWwajmMitsXy37OvYHw/9Xm0OLv xqoo7mITIWvPrCULW5xXEY0J2z/TgUX9JYNhB4X5VzlJ2hB8zo7DbRPDXv/o3xvrD2Sl vSpw== X-Gm-Message-State: AGRZ1gI8a4jSMdNh8kc9ZfOKMXoyjskqUhgIFeQNQMmgVwUJpXQezMmz eXITyISR+7aGRoHHglklkBPTcyWDeyk= X-Google-Smtp-Source: AJdET5d81b59/+/Sq3Q55576euUbf5ylK7tZvR34T2GSvy4UubwfVqeQ8NHSwn6x5ruLFYnRTxxITQ== X-Received: by 2002:a19:4f0c:: with SMTP id d12mr3761277lfb.121.1542809864924; Wed, 21 Nov 2018 06:17:44 -0800 (PST) Received: from localhost.localdomain (95-55-9-11.dynamic.avangarddsl.ru. [95.55.9.11]) by smtp.gmail.com with ESMTPSA id k3-v6sm1589040lja.8.2018.11.21.06.17.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 06:17:43 -0800 (PST) From: Oleg Pykhalov Date: Wed, 21 Nov 2018 17:17:15 +0300 Message-Id: <20181121141715.16417-3-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121141715.16417-1-go.wigust@gmail.com> References: <20181121141715.16417-1-go.wigust@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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 * guix/channels.scm (channel->recutils): New procedure. * guix/scripts/describe.scm (%options): Add 'recutils' option. (display-checkout-info, display-profile-info): Use 'channel->recutils'. * doc/guix.texi (Invoking guix describe): Document this. --- doc/guix.texi | 4 +++- guix/channels.scm | 8 ++++++++ guix/scripts/describe.scm | 18 +++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3413eb30f..44594d168 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3276,7 +3276,9 @@ pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking guix pull}); @item json @cindex JSON -produce a list of channel specifications in JSON format. +produce a list of channel specifications in JSON format; +@item recutils +produce a list of channel specifications in Recutils format. @end table @item --profile=@var{profile} diff --git a/guix/channels.scm b/guix/channels.scm index 9f2c9103e..ed9bc67c3 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -41,6 +41,7 @@ channel-location channel->json + channel->recutils channel->sexp %default-channels @@ -106,6 +107,13 @@ (cons 'url url) (cons 'commit commit)))))) +(define (channel->recutils c port) + (match c + (($ name url branch commit location) + (format port "name: ~a~%" name) + (format port "url: ~a~%" url) + (format port "commit: ~a~%" commit)))) + (define-record-type (channel-instance channel commit checkout) channel-instance? diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index d7e276769..90365b7ae 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -39,7 +39,7 @@ ;; Specifications of the command-line options. (list (option '(#\f "format") #t #f (lambda (opt name arg result) - (unless (member arg '("human" "channels" "json")) + (unless (member arg '("human" "channels" "json" "recutils")) (leave (G_ "~a: unsupported output format~%") arg)) (alist-cons 'format (string->symbol arg) result))) (option '(#\p "profile") #t #f @@ -112,7 +112,12 @@ within a Git checkout." (display (channel->json (channel (name 'guix) (url (dirname directory)) (commit commit)))) - (newline))) + (newline)) + ('recutils + (channel->recutils (channel (name 'guix) + (url (dirname directory)) + (commit commit)) + #t))) (display-package-search-path fmt))) (define (display-profile-info profile fmt) @@ -151,7 +156,14 @@ in the format specified by FMT." ('channels (pretty-print (map channel->sexp (channels)))) ('json - (format #t "[~a]~%" (string-join (map channel->json (channels)) ",")))) + (format #t "[~a]~%" (string-join (map channel->json (channels)) ","))) + ('recutils + (format #t "~{~a~%~}" + (map (lambda (channel) + (with-output-to-string + (lambda () + (channel->recutils channel (current-output-port))))) + (channels))))) (display-package-search-path fmt))