From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id kCzuDovE2GY5DwAAe85BDQ:P1 (envelope-from ) for ; Wed, 04 Sep 2024 20:35:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id kCzuDovE2GY5DwAAe85BDQ (envelope-from ) for ; Wed, 04 Sep 2024 22:35:23 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=PBXRl6w9; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=huQAI2fl; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1725482123; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=cPSaT7NnKA6puFOYtWZdCuViwzBnzCpYHCVjSMnVlok=; b=C6DDeVk1hDqGhsXcdKOp0S/xE4KA6wcPWMKbbs3wWknEG+pdDTXFlsG4pAHMDl+LMXJH+M 7WrG3+AjffnrUa9cLF9tAlqkjlAP1DK7DLcHmxuSwdqHcRSta5VYe1b2e23ZlkRYMe1fhj PGpOqct2gWqgIc0zagcAC6rIUSace76I4JUcV9R1fhW6zbRcasyE/4ojzA2TZmo8DqTZpp zD9jXnLrnuprgtSSjRhaiXGu8h75vRuBhjhTIyIHv3wlX2rqN5lSn9/n1AqJiMqFK8sZhq Pur4zs8BCnEvkFxPX7ZXWb3VaWEz2hBZoCvX67TbJdZMeL7hHANmq9wXONfDww== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=PBXRl6w9; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=huQAI2fl; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1725482123; a=rsa-sha256; cv=none; b=o0yKAZD0DFbaGaY/RsIoJ37jsJfNUkzMHbAxcyg3Ycu4Ex7UNC5mr+xkyppIvzGnkttO6q 4ME3yRQO+0xkygWiip/iel6+n1JdNg8AiIvpDA5qtH/zglFcci0qubjfQqNZmzb99omJrn XUyELuL1fEkOwg1QOV73SX70hi2N4tLqJYWVM1P5eDculYJUko4qe3Wciq7XM4rm0qlh+Q TtJt4MgG56E/LXTFZIAeJD4Se1/+Xco0LRmgFHVvciYIS1LuBbT9FRzCvGC/6u4XM+B4ml N7pi3O0WF1ccHxak92LYD57BAuA0Lady/W10PK9hD81A7qdEDh0fGsvv+nJIJg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D0F863CA93 for ; Wed, 4 Sep 2024 22:35:21 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slwiS-00037Z-3p; Wed, 04 Sep 2024 16:35:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slwiQ-00036v-Ns for guix-patches@gnu.org; Wed, 04 Sep 2024 16:34:58 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1slwiQ-0002EF-EY for guix-patches@gnu.org; Wed, 04 Sep 2024 16:34:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=cPSaT7NnKA6puFOYtWZdCuViwzBnzCpYHCVjSMnVlok=; b=PBXRl6w9ak8G0SK9IGv6mSDO90GjkACm17qcgodp+/vOMyspaaDqSElu9a/7P0rBoOrKsfhaXvVQHgbhBvYKs6d9rz9D7mo0tHQbssXk9O6+gqko4NrjpeSvaXChKWX/GdqaJnrlJmgvOyxejjveNxuPg1Ec3+lJlSxMvTjwSewd2vl8zSpQiC/yU5nFeDxRmVCUQIX+l/k0zliiYVaWVsKyMNBpR4+UZM9UDR5r0Lzpl4oDDHyYyilx8WY6ddacBtrCi6ZrD2b3CCTzwnSDmxc7yEI/iTbCwN4ejEZM7R9a/1vY4lBN6yWjjVFMTRzVry1/Qp/qjkRQX6GSzhAJTg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1slwjS-0005Ld-9h for guix-patches@gnu.org; Wed, 04 Sep 2024 16:36:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70923] [PATCH v2 02/12] import: utils: Emit new-style inputs from maybe-*inputs procedures. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 04 Sep 2024 20:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70923 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70923@debbugs.gnu.org Received: via spool by 70923-submit@debbugs.gnu.org id=B70923.172548210820344 (code B ref 70923); Wed, 04 Sep 2024 20:36:02 +0000 Received: (at 70923) by debbugs.gnu.org; 4 Sep 2024 20:35:08 +0000 Received: from localhost ([127.0.0.1]:35451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slwiZ-0005Hw-JE for submit@debbugs.gnu.org; Wed, 04 Sep 2024 16:35:08 -0400 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117]:39573 helo=email.rimm.ee) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slwiW-0005Gz-GK for 70923@debbugs.gnu.org; Wed, 04 Sep 2024 16:35:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1725482029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cPSaT7NnKA6puFOYtWZdCuViwzBnzCpYHCVjSMnVlok=; b=huQAI2fldu7P33+V1nDRmsVGUlrv1sQCqEvsTeVCDSPv56AP0iMEwW3zFtzhd5bh+cENNF DGfcUkWuLdXcIqkixmto1x+XGGtlIgHKlvAOspvwYLlypKYgMhxrhhkwU/+4YjaJ+cchbI bnBpA6Rxw1rM79RP6HYEhpt8er45xl1D35PkmgtV7nG7zhfa1ddRtm9y6FLktU/yVMNSVQ 8RkMOdVFn+4S+AbHsQGIVLGk+657YdxBB3qMg7/nFGak5HZQ/MmtJEFVUQdwItUjBowYut mka/F6lNSkr+xtUEriuovFCbFYIdeiAUnGk8FwkNYuKwUUOIINvxIcc+Z3E/Gw== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id a891a05b (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO) for <70923@debbugs.gnu.org>; Wed, 4 Sep 2024 20:33:49 +0000 (UTC) Date: Wed, 4 Sep 2024 22:32:56 +0200 Message-ID: <20240904203309.23715-2-herman@rimm.ee> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240904203309.23715-1-herman@rimm.ee> References: <20240904203309.23715-1-herman@rimm.ee> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches From: Herman Rimm via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: D0F863CA93 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -6.98 X-Spam-Score: -6.98 X-TUID: MXafnDOkAv9o * guix/import/utils.scm (package-names->package-inputs)[make-input]: Refactor. (maybe-list-field): Add procedure, which wraps BODY in 'list' instead of 'quasiquote'. (maybe-packages-field): Add procedure. (maybe-inputs, maybe-native-inputs, maybe-propagated-inputs): Use maybe-packages-field. Change-Id: I66588f4c822d507ddbaf465a268bfb71af8a7ecd --- guix/import/utils.scm | 54 +++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index b7756fcc40..75bef1e9c7 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -13,6 +13,7 @@ ;;; Copyright © 2022 Alice Brenon ;;; Copyright © 2022 Kyle Meyer ;;; Copyright © 2022 Philip McGrath +;;; Copyright © 2024 Herman Rimm ;;; ;;; This file is part of GNU Guix. ;;; @@ -65,6 +66,8 @@ (define-module (guix import utils) guix-hash-url package-names->package-inputs + maybe-list-field + maybe-packages-field maybe-inputs maybe-native-inputs maybe-propagated-inputs @@ -418,39 +421,44 @@ (define* (package-names->package-inputs names #:optional (output #f)) optional OUTPUT, tries to generate a quoted list of inputs, as suitable to use in an 'inputs' field of a package definition." (define (make-input input version) - (let ((name (if version (string-append input "-" version) input))) - (if output - (list (string->symbol name) output) - (string->symbol name)))) + (let ((symbol (string->symbol + (if version + (string-append input "-" version) + input)))) + (if output (list symbol output) symbol))) (map (match-lambda ((input version) (make-input input version)) (input (make-input input #f))) names)) -(define* (maybe-inputs package-names #:optional (output #f) - #:key (type #f)) - "Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a -package definition. TYPE can be used to specify the type of the inputs; -either the 'native or 'propagated symbols are accepted. Left unspecified, the -snippet generated is for regular inputs." - (let ((field-name (match type - ('native 'native-inputs) - ('propagated 'propagated-inputs) - (_ 'inputs)))) - (match (package-names->package-inputs package-names output) - (() - '()) - ((package-inputs ...) - `((,field-name (list ,@package-inputs))))))) +(define* (maybe-list-field type body) + "Generates the TYPE field of a package definition if its value, BODY, +is a non-empty list." + (match body + (() + '()) + ((? list?) + (list (list type (cons 'list body)))))) + +(define* (maybe-packages-field type package-names + #:optional (output #f)) + "Given a list of PACKAGE-NAMES, tries to generate the TYPE field of a +package definition." + (maybe-list-field type + (package-names->package-inputs package-names output))) + +(define* (maybe-inputs package-names #:optional (output #f)) + "MAYBE-PACKAGES-FIELD for inputs." + (maybe-packages-field 'inputs package-names output)) (define* (maybe-native-inputs package-names #:optional (output #f)) - "Same as MAYBE-INPUTS, but for native inputs." - (maybe-inputs package-names output #:type 'native)) + "MAYBE-PACKAGES-FIELD for native inputs." + (maybe-packages-field 'native-inputs package-names output)) (define* (maybe-propagated-inputs package-names #:optional (output #f)) - "Same as MAYBE-INPUTS, but for propagated inputs." - (maybe-inputs package-names output #:type 'propagated)) + "MAYBE-PACKAGES-FIELD for propagated inputs." + (maybe-packages-field 'propagated-inputs package-names output)) (define* (package->definition guix-package #:optional append-version?/string) "If APPEND-VERSION?/STRING is #t, append the package's major+minor version. -- 2.45.2