From unknown Sun Jun 15 13:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#48943] [PATCH] import: hackage: Support "common" field and imports Resent-From: Philip Munksgaard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Jun 2021 08:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48943 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48943@debbugs.gnu.org Cc: Philip Munksgaard X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16233144104356 (code B ref -1); Thu, 10 Jun 2021 08:41:02 +0000 Received: (at submit) by debbugs.gnu.org; 10 Jun 2021 08:40:10 +0000 Received: from localhost ([127.0.0.1]:35458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrGER-000189-8f for submit@debbugs.gnu.org; Thu, 10 Jun 2021 04:40:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:49788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrGEO-00017y-ER for submit@debbugs.gnu.org; Thu, 10 Jun 2021 04:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrGEN-0003L8-EZ for guix-patches@gnu.org; Thu, 10 Jun 2021 04:40:04 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:39073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrGEL-0004rT-2M for guix-patches@gnu.org; Thu, 10 Jun 2021 04:40:03 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1E01323AA; Thu, 10 Jun 2021 04:39:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 10 Jun 2021 04:39:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=munksgaard.me; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=fWxxxNzpitI2voLccz4LZT1sCa WWVUvr+Nl+B8eF5r4=; b=XWyAsa1CIs20yqHm1l235WI4ZVAJIRjNoPZNWfsoWH l2oNHb6/dg8u3XFgLz1ur02JAeXMgx0XqBrCYO/EEa7Qio2d72TrC2IveZ9V1pel MVDZtwaNI25SKOotvP1jmr9Est+I0fYUYr1jnfFNvIhRhAdObGBJiebYyZHVRHEk 9AlcIJBM3D3CxRrHvxKck2yHFqkekHp34Ptf1UTIeSJuwrBatB9H5MMRir31X55x VsGbwgnnAlvG050d4P+gFHVozR1BmOKSrgabc6DBDf8/uXzlPr7PqI3+zsHl9j+i wBjxwV/dkW5VHeyisZiNN5JZRRMBZT55X/cmt8WuUSzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=fWxxxNzpitI2voLcc z4LZT1sCaWWVUvr+Nl+B8eF5r4=; b=neDSyKh4gWkziwwZom9UpjREQ1jCxsvoL Xdvgkf1JTCdGAAYQ+kcHwd0spQ2BgM6kH4KLt5bsLrEovXOJeaRSHUaDqJHX6kx+ TFqN3M5feiZHpyqmDsM/sIVSKZjsBot1E6feTOnwGMXjklVhAnHef5TQ8ZNjE1PQ 8cl65Qry5p+v4KMlJQ8v+5oWSe6htPM47a8hVvQdr7FGzo9m7Fmf88QTsfrEKDn9 LgfeJOEQL40zPjUxs6Q3gl1g0C852pXvXoLewn/bOXzUHVHznSuApGE68OcWBbh0 a3RTwQQO0bTHn0Ge+QczMS/T8+et/m4td22WvXEQFalyp8JHKs2eg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedufedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfhhihhlihhpucfouhhnkhhsghgrrghrugcuoehphhhilhhiphes mhhunhhkshhgrggrrhgurdhmvgeqnecuggftrfgrthhtvghrnhepjedtjeduudevfeffve ejgedtgeeutedutedvteekteffgfffffffgfeuffetgefhnecuffhomhgrihhnpehgnhhu rdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epphhhihhlihhpsehmuhhnkhhsghgrrghrugdrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 10 Jun 2021 04:39:55 -0400 (EDT) From: Philip Munksgaard Date: Thu, 10 Jun 2021 10:39:53 +0200 Message-Id: <20210610083953.664318-1-philip@munksgaard.me> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.147.123.20; envelope-from=philip@munksgaard.me; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Fixes . * guix/import/cabal.scm (make-cabal-parser): Modify. (is-common): New variable. (lex-common): New procedure. (is-id): Modify. (eval-cabal): Modify. --- guix/import/cabal.scm | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index da00019297..22b5d164d0 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -145,7 +145,7 @@ to the stack." (lalr-parser ;; --- token definitions (CCURLY VCCURLY OPAREN CPAREN TEST ID VERSION RELATION TRUE FALSE -ANY -NONE - (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB OCURLY) + (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB COMMON OCURLY) (left: OR) (left: PROPERTY AND) (right: ELSE NOT)) @@ -155,6 +155,7 @@ to the stack." (sections source-repo) : (append $1 (list $2)) (sections executables) : (append $1 $2) (sections test-suites) : (append $1 $2) + (sections common) : (append $1 $2) (sections custom-setup) : (append $1 $2) (sections benchmarks) : (append $1 $2) (sections lib-sec) : (append $1 (list $2)) @@ -178,6 +179,10 @@ to the stack." (ts-sec) : (list $1)) (ts-sec (TEST-SUITE OCURLY exprs CCURLY) : `(section test-suite ,$1 ,$3) (TEST-SUITE open exprs close) : `(section test-suite ,$1 ,$3)) + (common (common common-sec) : (append $1 (list $2)) + (common-sec) : (list $1)) + (common-sec (COMMON OCURLY exprs CCURLY) : `(section common ,$1 ,$3) + (COMMON open exprs close) : `(section common ,$1 ,$3)) (custom-setup (CUSTOM-SETUP exprs) : (list `(section custom-setup ,$1 ,$2))) (benchmarks (benchmarks bm-sec) : (append $1 (list $2)) (bm-sec) : (list $1)) @@ -367,6 +372,9 @@ matching a string against the created regexp." (define is-test-suite (make-rx-matcher "^test-suite +([a-z0-9_-]+)" regexp/icase)) +(define is-common (make-rx-matcher "^common +([a-z0-9_-]+)" + regexp/icase)) + (define is-custom-setup (make-rx-matcher "^(custom-setup)" regexp/icase)) @@ -394,7 +402,7 @@ matching a string against the created regexp." (define (is-id s port) (let ((cabal-reserved-words '("if" "else" "library" "flag" "executable" "test-suite" "custom-setup" - "source-repository" "benchmark")) + "source-repository" "benchmark" "common")) (spaces (read-while (cut char-set-contains? char-set:blank <>) port)) (c (peek-char port))) (unread-string spaces port) @@ -469,6 +477,8 @@ string with the read characters." (define (lex-test-suite ts-rx-res loc) (lex-rx-res ts-rx-res 'TEST-SUITE loc)) +(define (lex-common common-rx-res loc) (lex-rx-res common-rx-res 'COMMON loc)) + (define (lex-custom-setup ts-rx-res loc) (lex-rx-res ts-rx-res 'CUSTOM-SETUP loc)) (define (lex-benchmark bm-rx-res loc) (lex-rx-res bm-rx-res 'BENCHMARK loc)) @@ -570,6 +580,7 @@ the current port location." ((is-src-repo s) => (cut lex-src-repo <> loc)) ((is-exec s) => (cut lex-exec <> loc)) ((is-test-suite s) => (cut lex-test-suite <> loc)) + ((is-common s) => (cut lex-common <> loc)) ((is-custom-setup s) => (cut lex-custom-setup <> loc)) ((is-benchmark s) => (cut lex-benchmark <> loc)) ((is-lib s) (lex-lib loc)) @@ -796,7 +807,16 @@ the ordering operation and the version." (let ((value (or (assoc-ref env name) (assoc-ref (cabal-flags->alist (cabal-flags)) name)))) (if (eq? value 'false) #f #t))) + + (define common-stanzas + (filter-map (cut match <> + (('section 'common common-name common) + (cons common-name common)) + (_ #f)) + cabal-sexp)) + (define (eval sexp) + "Given an SEXP and an ENV, return the evaluated (SEXP . ENV)." (match sexp (() '()) ;; nested 'if' @@ -831,6 +851,9 @@ the ordering operation and the version." (list 'section type name (eval parameters))) (((? string? name) values) (list name values)) + ((("import" imports) rest ...) + (eval (append (append-map (cut assoc-ref common-stanzas <>) imports) + rest))) ((element rest ...) (cons (eval element) (eval rest))) (_ (raise (condition -- 2.31.1 From unknown Sun Jun 15 13:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#48943] [PATCH] import: hackage: Support "common" field and imports Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 13 Jun 2021 20:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48943 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Philip Munksgaard Cc: 48943@debbugs.gnu.org Received: via spool by 48943-submit@debbugs.gnu.org id=B48943.16236164958006 (code B ref 48943); Sun, 13 Jun 2021 20:35:01 +0000 Received: (at 48943) by debbugs.gnu.org; 13 Jun 2021 20:34:55 +0000 Received: from localhost ([127.0.0.1]:44425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsWop-000254-Gq for submit@debbugs.gnu.org; Sun, 13 Jun 2021 16:34:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsWoo-00024p-2F for 48943@debbugs.gnu.org; Sun, 13 Jun 2021 16:34:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52322) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsWoi-0008Bd-OP; Sun, 13 Jun 2021 16:34:48 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=57546 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsWoi-00005f-Dr; Sun, 13 Jun 2021 16:34:48 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210610083953.664318-1-philip@munksgaard.me> Date: Sun, 13 Jun 2021 22:34:46 +0200 In-Reply-To: <20210610083953.664318-1-philip@munksgaard.me> (Philip Munksgaard's message of "Thu, 10 Jun 2021 10:39:53 +0200") Message-ID: <87wnqxzeop.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Philip Munksgaard skribis: > Fixes . > > * guix/import/cabal.scm (make-cabal-parser): Modify. > (is-common): New variable. > (lex-common): New procedure. > (is-id): Modify. > (eval-cabal): Modify. Could you add a test case in =E2=80=98tests/hackage.scm=E2=80=99 and send a= n updated patch? Apart from that it LGTM, thanks! Ludo=E2=80=99. From unknown Sun Jun 15 13:02:58 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#48943] [PATCH v2] import: hackage: Support "common" field and imports References: <20210610083953.664318-1-philip@munksgaard.me> In-Reply-To: <20210610083953.664318-1-philip@munksgaard.me> Resent-From: Philip Munksgaard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Jun 2021 12:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48943 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48943@debbugs.gnu.org Cc: Philip Munksgaard Received: via spool by 48943-submit@debbugs.gnu.org id=B48943.162402051813524 (code B ref 48943); Fri, 18 Jun 2021 12:49:02 +0000 Received: (at 48943) by debbugs.gnu.org; 18 Jun 2021 12:48:38 +0000 Received: from localhost ([127.0.0.1]:56051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luDvK-0003W4-27 for submit@debbugs.gnu.org; Fri, 18 Jun 2021 08:48:38 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:52945) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luDvH-0003Vp-DN for 48943@debbugs.gnu.org; Fri, 18 Jun 2021 08:48:36 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 0B1DB10BF; Fri, 18 Jun 2021 08:48:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 18 Jun 2021 08:48:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=munksgaard.me; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=dLa/igxR/sp4gswv8oc0jh6xWa //Esqj9NdYzpHN7Uc=; b=bUjdfH/g0yxn26Y4Oi3qAyrjnuZ8Po7zfe7ZHPHk0w 4yRsoVh0pb4vncnBmcEJkvyLNgnPUqGMg2DdYtT6b7muPMn40NKKzeyDNpI5CGF7 0VwgEeHWtMfKV4xtq6BG0DyvLQrNV4T2+GRgw+HcqL8ngjqjNWDAvNBmIai/hoCW VuqUwF8mjhf9Jo77mmepXvSpC+Xl83MdQC2Xlil0aqAdEffLGgnTT1vfG/yQiWZY jcAvSIYgcWRV9HnWOl0Acj3Ri5dXggqQ6AgF9BNKJDLXI89IAm0gLbX/GZkVNGiY boZbkvBJx0HO/I3f1dSFR17mEPOE6nv82kEZOEVmuApg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=dLa/igxR/sp4gswv8 oc0jh6xWa//Esqj9NdYzpHN7Uc=; b=FwO01vt3l6x8jP/5w6i4rUBf5AuYIC7xb hAxRn9SK/ISM/B7z4ppkm4eB/5nXMPq/HBGMwUdy6/TVpgamEnkfa9czVCy6ONQc zV3PkQR+ERfNuqaSYB6SfewhxKBvSqL7wmwpgJlZfqflZHFe2oTe7Bft3W6LrvP0 s3oOo1HxS7oh+f+MQCE4u/Hm2FlVX5WlhOdRtmN+owlvA6fu9f+L/Oxh//WZAfXk JrpGi3NjqLgtHT+ESRRX5JsgSi6t5OX8HvMUeOSDLSDGmRSP3KOwTPx2hhUQ+Ffb RAYAQFrPigcVqnG6ffPbvG3ckz03Aw40ILm9CPChcW2mvGqnOvGuA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeffedgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfhhihhlihhpucfouhhnkhhsghgrrghrugcuoehphhhilhhiphes mhhunhhkshhgrggrrhgurdhmvgeqnecuggftrfgrthhtvghrnhepfedugefgvdetjefhte ekgfegieefveefledtieelgedttdeftdfghefhkeehleehnecuffhomhgrihhnpehgnhhu rdhorhhgpdhtvghsthdrohhrghdphhgrshhkvghllhdrohhrghenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehphhhilhhiphesmhhunhhkshhg rggrrhgurdhmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 18 Jun 2021 08:48:27 -0400 (EDT) From: Philip Munksgaard Date: Fri, 18 Jun 2021 14:48:13 +0200 Message-Id: <20210618124813.844948-1-philip@munksgaard.me> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Fixes . * guix/import/cabal.scm (make-cabal-parser): Modify. (is-common): New variable. (lex-common): New procedure. (is-id): Modify. (eval-cabal): Modify. * tests/hackage.scm ("hackage->guix-package test cabal import") New test. --- guix/import/cabal.scm | 27 +++++++++++++++++++++++++-- tests/hackage.scm | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index da00019297..22b5d164d0 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -145,7 +145,7 @@ to the stack." (lalr-parser ;; --- token definitions (CCURLY VCCURLY OPAREN CPAREN TEST ID VERSION RELATION TRUE FALSE -ANY -NONE - (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB OCURLY) + (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB COMMON OCURLY) (left: OR) (left: PROPERTY AND) (right: ELSE NOT)) @@ -155,6 +155,7 @@ to the stack." (sections source-repo) : (append $1 (list $2)) (sections executables) : (append $1 $2) (sections test-suites) : (append $1 $2) + (sections common) : (append $1 $2) (sections custom-setup) : (append $1 $2) (sections benchmarks) : (append $1 $2) (sections lib-sec) : (append $1 (list $2)) @@ -178,6 +179,10 @@ to the stack." (ts-sec) : (list $1)) (ts-sec (TEST-SUITE OCURLY exprs CCURLY) : `(section test-suite ,$1 ,$3) (TEST-SUITE open exprs close) : `(section test-suite ,$1 ,$3)) + (common (common common-sec) : (append $1 (list $2)) + (common-sec) : (list $1)) + (common-sec (COMMON OCURLY exprs CCURLY) : `(section common ,$1 ,$3) + (COMMON open exprs close) : `(section common ,$1 ,$3)) (custom-setup (CUSTOM-SETUP exprs) : (list `(section custom-setup ,$1 ,$2))) (benchmarks (benchmarks bm-sec) : (append $1 (list $2)) (bm-sec) : (list $1)) @@ -367,6 +372,9 @@ matching a string against the created regexp." (define is-test-suite (make-rx-matcher "^test-suite +([a-z0-9_-]+)" regexp/icase)) +(define is-common (make-rx-matcher "^common +([a-z0-9_-]+)" + regexp/icase)) + (define is-custom-setup (make-rx-matcher "^(custom-setup)" regexp/icase)) @@ -394,7 +402,7 @@ matching a string against the created regexp." (define (is-id s port) (let ((cabal-reserved-words '("if" "else" "library" "flag" "executable" "test-suite" "custom-setup" - "source-repository" "benchmark")) + "source-repository" "benchmark" "common")) (spaces (read-while (cut char-set-contains? char-set:blank <>) port)) (c (peek-char port))) (unread-string spaces port) @@ -469,6 +477,8 @@ string with the read characters." (define (lex-test-suite ts-rx-res loc) (lex-rx-res ts-rx-res 'TEST-SUITE loc)) +(define (lex-common common-rx-res loc) (lex-rx-res common-rx-res 'COMMON loc)) + (define (lex-custom-setup ts-rx-res loc) (lex-rx-res ts-rx-res 'CUSTOM-SETUP loc)) (define (lex-benchmark bm-rx-res loc) (lex-rx-res bm-rx-res 'BENCHMARK loc)) @@ -570,6 +580,7 @@ the current port location." ((is-src-repo s) => (cut lex-src-repo <> loc)) ((is-exec s) => (cut lex-exec <> loc)) ((is-test-suite s) => (cut lex-test-suite <> loc)) + ((is-common s) => (cut lex-common <> loc)) ((is-custom-setup s) => (cut lex-custom-setup <> loc)) ((is-benchmark s) => (cut lex-benchmark <> loc)) ((is-lib s) (lex-lib loc)) @@ -796,7 +807,16 @@ the ordering operation and the version." (let ((value (or (assoc-ref env name) (assoc-ref (cabal-flags->alist (cabal-flags)) name)))) (if (eq? value 'false) #f #t))) + + (define common-stanzas + (filter-map (cut match <> + (('section 'common common-name common) + (cons common-name common)) + (_ #f)) + cabal-sexp)) + (define (eval sexp) + "Given an SEXP and an ENV, return the evaluated (SEXP . ENV)." (match sexp (() '()) ;; nested 'if' @@ -831,6 +851,9 @@ the ordering operation and the version." (list 'section type name (eval parameters))) (((? string? name) values) (list name values)) + ((("import" imports) rest ...) + (eval (append (append-map (cut assoc-ref common-stanzas <>) imports) + rest))) ((element rest ...) (cons (eval element) (eval rest))) (_ (raise (condition diff --git a/tests/hackage.scm b/tests/hackage.scm index 66a13d9881..53972fc643 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -388,4 +388,46 @@ executable cabal #t) (x (pk 'fail x #f)))) +(define test-cabal-import + "name: foo +version: 1.0.0 +homepage: http://test.org +synopsis: synopsis +description: description +license: BSD3 +common commons + build-depends: + HTTP >= 4000.2.5 && < 4000.3, + mtl >= 2.0 && < 3 + +executable cabal + import: commons +") + +(define-package-matcher match-ghc-foo-import + ('package + ('name "ghc-foo") + ('version "1.0.0") + ('source + ('origin + ('method 'url-fetch) + ('uri ('string-append + "https://hackage.haskell.org/package/foo/foo-" + 'version + ".tar.gz")) + ('sha256 + ('base32 + (? string? hash))))) + ('build-system 'haskell-build-system) + ('inputs + ('quasiquote + (("ghc-http" ('unquote 'ghc-http))))) + ('home-page "http://test.org") + ('synopsis (? string?)) + ('description (? string?)) + ('license 'license:bsd-3))) + +(test-assert "hackage->guix-package test cabal import" + (eval-test-with-cabal test-cabal-import match-ghc-foo-import)) + (test-end "hackage") -- 2.31.1 From unknown Sun Jun 15 13:02:58 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Philip Munksgaard Subject: bug#48943: closed (Re: bug#48943: [PATCH] import: hackage: Support "common" field and imports) Message-ID: References: <87y2ay2kp4.fsf_-_@gnu.org> <20210610083953.664318-1-philip@munksgaard.me> X-Gnu-PR-Message: they-closed 48943 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 48943@debbugs.gnu.org Date: Fri, 25 Jun 2021 12:28:15 +0000 Content-Type: multipart/mixed; boundary="----------=_1624624095-1758-1" This is a multi-part message in MIME format... ------------=_1624624095-1758-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #48943: [PATCH] import: hackage: Support "common" field and imports which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 48943@debbugs.gnu.org. --=20 48943: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D48943 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1624624095-1758-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 48943-done) by debbugs.gnu.org; 25 Jun 2021 12:27:56 +0000 Received: from localhost ([127.0.0.1]:45063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lwkvx-0000RC-AN for submit@debbugs.gnu.org; Fri, 25 Jun 2021 08:27:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lwkvv-0000Qy-8V for 48943-done@debbugs.gnu.org; Fri, 25 Jun 2021 08:27:43 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44586) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwkvp-0003u5-RE; Fri, 25 Jun 2021 08:27:37 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42468 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwkvp-0000y8-Is; Fri, 25 Jun 2021 08:27:37 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Philip Munksgaard Subject: Re: bug#48943: [PATCH] import: hackage: Support "common" field and imports References: <20210610083953.664318-1-philip@munksgaard.me> <20210618124813.844948-1-philip@munksgaard.me> Date: Fri, 25 Jun 2021 14:27:35 +0200 In-Reply-To: <20210618124813.844948-1-philip@munksgaard.me> (Philip Munksgaard's message of "Fri, 18 Jun 2021 14:48:13 +0200") Message-ID: <87y2ay2kp4.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 48943-done Cc: 48943-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Philip Munksgaard skribis: > Fixes . > > * guix/import/cabal.scm (make-cabal-parser): Modify. > (is-common): New variable. > (lex-common): New procedure. > (is-id): Modify. > (eval-cabal): Modify. > * tests/hackage.scm ("hackage->guix-package test cabal import") New test. Applied with the change below (=E2=80=98cut=E2=80=99 is for procedures but = =E2=80=98match=E2=80=99 is a macro). Thanks! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index 22b5d164d0..e9a0179b3d 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -809,10 +809,10 @@ the ordering operation and the version." (if (eq? value 'false) #f #t))) (define common-stanzas - (filter-map (cut match <> - (('section 'common common-name common) - (cons common-name common)) - (_ #f)) + (filter-map (match-lambda + (('section 'common common-name common) + (cons common-name common)) + (_ #f)) cabal-sexp)) (define (eval sexp) --=-=-=-- ------------=_1624624095-1758-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 Jun 2021 08:40:10 +0000 Received: from localhost ([127.0.0.1]:35458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrGER-000189-8f for submit@debbugs.gnu.org; Thu, 10 Jun 2021 04:40:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:49788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrGEO-00017y-ER for submit@debbugs.gnu.org; Thu, 10 Jun 2021 04:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrGEN-0003L8-EZ for guix-patches@gnu.org; Thu, 10 Jun 2021 04:40:04 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:39073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrGEL-0004rT-2M for guix-patches@gnu.org; Thu, 10 Jun 2021 04:40:03 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1E01323AA; Thu, 10 Jun 2021 04:39:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 10 Jun 2021 04:39:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=munksgaard.me; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=fWxxxNzpitI2voLccz4LZT1sCa WWVUvr+Nl+B8eF5r4=; b=XWyAsa1CIs20yqHm1l235WI4ZVAJIRjNoPZNWfsoWH l2oNHb6/dg8u3XFgLz1ur02JAeXMgx0XqBrCYO/EEa7Qio2d72TrC2IveZ9V1pel MVDZtwaNI25SKOotvP1jmr9Est+I0fYUYr1jnfFNvIhRhAdObGBJiebYyZHVRHEk 9AlcIJBM3D3CxRrHvxKck2yHFqkekHp34Ptf1UTIeSJuwrBatB9H5MMRir31X55x VsGbwgnnAlvG050d4P+gFHVozR1BmOKSrgabc6DBDf8/uXzlPr7PqI3+zsHl9j+i wBjxwV/dkW5VHeyisZiNN5JZRRMBZT55X/cmt8WuUSzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=fWxxxNzpitI2voLcc z4LZT1sCaWWVUvr+Nl+B8eF5r4=; b=neDSyKh4gWkziwwZom9UpjREQ1jCxsvoL Xdvgkf1JTCdGAAYQ+kcHwd0spQ2BgM6kH4KLt5bsLrEovXOJeaRSHUaDqJHX6kx+ TFqN3M5feiZHpyqmDsM/sIVSKZjsBot1E6feTOnwGMXjklVhAnHef5TQ8ZNjE1PQ 8cl65Qry5p+v4KMlJQ8v+5oWSe6htPM47a8hVvQdr7FGzo9m7Fmf88QTsfrEKDn9 LgfeJOEQL40zPjUxs6Q3gl1g0C852pXvXoLewn/bOXzUHVHznSuApGE68OcWBbh0 a3RTwQQO0bTHn0Ge+QczMS/T8+et/m4td22WvXEQFalyp8JHKs2eg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedufedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfhhihhlihhpucfouhhnkhhsghgrrghrugcuoehphhhilhhiphes mhhunhhkshhgrggrrhgurdhmvgeqnecuggftrfgrthhtvghrnhepjedtjeduudevfeffve ejgedtgeeutedutedvteekteffgfffffffgfeuffetgefhnecuffhomhgrihhnpehgnhhu rdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epphhhihhlihhpsehmuhhnkhhsghgrrghrugdrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 10 Jun 2021 04:39:55 -0400 (EDT) From: Philip Munksgaard To: guix-patches@gnu.org Subject: [PATCH] import: hackage: Support "common" field and imports Date: Thu, 10 Jun 2021 10:39:53 +0200 Message-Id: <20210610083953.664318-1-philip@munksgaard.me> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.147.123.20; envelope-from=philip@munksgaard.me; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: Philip Munksgaard X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Fixes . * guix/import/cabal.scm (make-cabal-parser): Modify. (is-common): New variable. (lex-common): New procedure. (is-id): Modify. (eval-cabal): Modify. --- guix/import/cabal.scm | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index da00019297..22b5d164d0 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -145,7 +145,7 @@ to the stack." (lalr-parser ;; --- token definitions (CCURLY VCCURLY OPAREN CPAREN TEST ID VERSION RELATION TRUE FALSE -ANY -NONE - (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB OCURLY) + (right: IF FLAG EXEC TEST-SUITE CUSTOM-SETUP SOURCE-REPO BENCHMARK LIB COMMON OCURLY) (left: OR) (left: PROPERTY AND) (right: ELSE NOT)) @@ -155,6 +155,7 @@ to the stack." (sections source-repo) : (append $1 (list $2)) (sections executables) : (append $1 $2) (sections test-suites) : (append $1 $2) + (sections common) : (append $1 $2) (sections custom-setup) : (append $1 $2) (sections benchmarks) : (append $1 $2) (sections lib-sec) : (append $1 (list $2)) @@ -178,6 +179,10 @@ to the stack." (ts-sec) : (list $1)) (ts-sec (TEST-SUITE OCURLY exprs CCURLY) : `(section test-suite ,$1 ,$3) (TEST-SUITE open exprs close) : `(section test-suite ,$1 ,$3)) + (common (common common-sec) : (append $1 (list $2)) + (common-sec) : (list $1)) + (common-sec (COMMON OCURLY exprs CCURLY) : `(section common ,$1 ,$3) + (COMMON open exprs close) : `(section common ,$1 ,$3)) (custom-setup (CUSTOM-SETUP exprs) : (list `(section custom-setup ,$1 ,$2))) (benchmarks (benchmarks bm-sec) : (append $1 (list $2)) (bm-sec) : (list $1)) @@ -367,6 +372,9 @@ matching a string against the created regexp." (define is-test-suite (make-rx-matcher "^test-suite +([a-z0-9_-]+)" regexp/icase)) +(define is-common (make-rx-matcher "^common +([a-z0-9_-]+)" + regexp/icase)) + (define is-custom-setup (make-rx-matcher "^(custom-setup)" regexp/icase)) @@ -394,7 +402,7 @@ matching a string against the created regexp." (define (is-id s port) (let ((cabal-reserved-words '("if" "else" "library" "flag" "executable" "test-suite" "custom-setup" - "source-repository" "benchmark")) + "source-repository" "benchmark" "common")) (spaces (read-while (cut char-set-contains? char-set:blank <>) port)) (c (peek-char port))) (unread-string spaces port) @@ -469,6 +477,8 @@ string with the read characters." (define (lex-test-suite ts-rx-res loc) (lex-rx-res ts-rx-res 'TEST-SUITE loc)) +(define (lex-common common-rx-res loc) (lex-rx-res common-rx-res 'COMMON loc)) + (define (lex-custom-setup ts-rx-res loc) (lex-rx-res ts-rx-res 'CUSTOM-SETUP loc)) (define (lex-benchmark bm-rx-res loc) (lex-rx-res bm-rx-res 'BENCHMARK loc)) @@ -570,6 +580,7 @@ the current port location." ((is-src-repo s) => (cut lex-src-repo <> loc)) ((is-exec s) => (cut lex-exec <> loc)) ((is-test-suite s) => (cut lex-test-suite <> loc)) + ((is-common s) => (cut lex-common <> loc)) ((is-custom-setup s) => (cut lex-custom-setup <> loc)) ((is-benchmark s) => (cut lex-benchmark <> loc)) ((is-lib s) (lex-lib loc)) @@ -796,7 +807,16 @@ the ordering operation and the version." (let ((value (or (assoc-ref env name) (assoc-ref (cabal-flags->alist (cabal-flags)) name)))) (if (eq? value 'false) #f #t))) + + (define common-stanzas + (filter-map (cut match <> + (('section 'common common-name common) + (cons common-name common)) + (_ #f)) + cabal-sexp)) + (define (eval sexp) + "Given an SEXP and an ENV, return the evaluated (SEXP . ENV)." (match sexp (() '()) ;; nested 'if' @@ -831,6 +851,9 @@ the ordering operation and the version." (list 'section type name (eval parameters))) (((? string? name) values) (list name values)) + ((("import" imports) rest ...) + (eval (append (append-map (cut assoc-ref common-stanzas <>) imports) + rest))) ((element rest ...) (cons (eval element) (eval rest))) (_ (raise (condition -- 2.31.1 ------------=_1624624095-1758-1--