From patchwork Thu Dec 9 09:01:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Tropin X-Patchwork-Id: 35078 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 1D34827BBEA; Thu, 9 Dec 2021 12:53:21 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9526127BBE9 for ; Thu, 9 Dec 2021 12:53:20 +0000 (GMT) Received: from localhost ([::1]:45496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mvIvH-0001wj-LU for patchwork@mira.cbaines.net; Thu, 09 Dec 2021 07:53:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvIv1-0001vh-C9 for guix-patches@gnu.org; Thu, 09 Dec 2021 07:53:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:59468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mvIv0-0004J3-NM for guix-patches@gnu.org; Thu, 09 Dec 2021 07:53:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mvIv0-0001uH-KK for guix-patches@gnu.org; Thu, 09 Dec 2021 07:53:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52388] [PATCH] build-system: emacs: Add generation of -pkg.el files. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 09 Dec 2021 12:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52388 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52388@debbugs.gnu.org, liliana.prikler@gmail.com Cc: Ivan Sokolov X-Debbugs-Original-To: guix-patches@gnu.org, Liliana Marie Prikler Received: via spool by submit@debbugs.gnu.org id=B.16390543307258 (code B ref -1); Thu, 09 Dec 2021 12:53:02 +0000 Received: (at submit) by debbugs.gnu.org; 9 Dec 2021 12:52:10 +0000 Received: from localhost ([127.0.0.1]:42781 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mvIuA-0001sz-HI for submit@debbugs.gnu.org; Thu, 09 Dec 2021 07:52:10 -0500 Received: from lists.gnu.org ([209.51.188.17]:46116) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mvIu8-0001ss-Jt for submit@debbugs.gnu.org; Thu, 09 Dec 2021 07:52:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvIu8-0001Bo-9P for guix-patches@gnu.org; Thu, 09 Dec 2021 07:52:08 -0500 Received: from [2a00:1450:4864:20::52f] (port=45673 helo=mail-ed1-x52f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mvIu4-00041v-Kp for guix-patches@gnu.org; Thu, 09 Dec 2021 07:52:08 -0500 Received: by mail-ed1-x52f.google.com with SMTP id y12so18928330eda.12 for ; Thu, 09 Dec 2021 04:52:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version; bh=pUsC7QfwclDhZLf3TXL1Atq1MTPz4jSTxgW9TmPz/Bo=; b=qQg+7DnQozjubn6Wk1vEs29z0NvBiZon0Ty1kENZBOTQIft9/pAdTJZ7UnMgQViZZY XCC8+XbJvUikw3JNewW0J1t/GwaHSqINl7hjOH7N589nW1ai+ov0rl5y04uHxIc5OV8Q Bk3L6781rB8Nwd87f5FEiqr0iBTx4lKvpaB1yoo2lkAIZWeihq1Tb8TnpyGluPiq4Sxe T11t+9k0CdzaGbJohXL9VCHL0NJwhWoD0xb7AoBvNj5lr8Br0OFHV0sTg6bvw2xExWAd Kn6Asfn4Bqo12m2pSapu6+2H63/qpvP0NDQLvPmd6aiW46717FGbz/wplZ6sLQW+kfYB kuUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=pUsC7QfwclDhZLf3TXL1Atq1MTPz4jSTxgW9TmPz/Bo=; b=zbGkGcJjvLLIp9bx+JJ6fjyDUwssEgvdkZy1wuH95upyPKc9ipYl/gBjRwHXLVvl0i wuj0Cf+TswsKNDSjeQdtYtd+ibUzIkkr8KuX/T56DxmaidVtd6QqvwcmQ6RxRnabI3wm NOJ5FZ3qU091N4PWbZKVrWhBPQK18Ea7s110sub9X1o/PMfF0v+GhgNQi03Djg9nTwuh joKHEz+8iae81hiJG6LAyfhlf3pdMdUy/5aV8BoaA43/ICUzT1gwqcucHBNJNuZ67/5L PRKbCMb5//7LTHB5cBWodczzSEXtUGeLwIh2/Lpr25LZ18hNZsvZPDEGCv9fLH32pUY8 E3wQ== X-Gm-Message-State: AOAM531I2+lvH9LwjTgXMoWPRiofa9GcOfmlsTkzgI9K3zfHkUqmaRpM GHAJE4BdK7/exk/Fj80IrPZfyzh2vKIqCA== X-Google-Smtp-Source: ABdhPJz708RL5GjcJyO8/MXeeSgOIRrtc6Lk26E25EVQMrkiYnqq1cpMgcowzdK6XPdBJvGN1rDN7w== X-Received: by 2002:a50:cdc8:: with SMTP id h8mr29016138edj.87.1639054321119; Thu, 09 Dec 2021 04:52:01 -0800 (PST) Received: from localhost (109-252-167-227.dynamic.spd-mgts.ru. [109.252.167.227]) by smtp.gmail.com with ESMTPSA id og14sm2713496ejc.107.2021.12.09.04.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 04:52:00 -0800 (PST) From: Andrew Tropin Date: Thu, 9 Dec 2021 12:01:46 +0300 Message-ID: <871r2mrleb.fsf@trop.in> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52f (failed) Received-SPF: none client-ip=2a00:1450:4864:20::52f; envelope-from=andrew@trop.in; helo=mail-ed1-x52f.google.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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 * guix/build/emacs-build-system.scm (%default-exclude): Add generation of -pkg.el files for packages, which do not provide them. --- Implemented phase, which generates -pkg.el from comments in library file. The solution for finding main el file of the package is a little hacky, because package name isn't available build time. I took a part of the elisp implementation from melpa source code. https://github.com/melpa/melpa/blob/master/package-build/package-build.el#L553 guix/build/emacs-build-system.scm | 71 ++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm index f13162d6c4..ee934f4bde 100644 --- a/guix/build/emacs-build-system.scm +++ b/guix/build/emacs-build-system.scm @@ -154,6 +154,74 @@ (define (substitute-program-names) (substitute-program-names)))) #t)) +(define* (find-root-library-file name) + (let lp ((subnames (string-split + (package-name-version->elpa-name-version name) #\-)) + (possible-name "")) + (cond + ((file-exists? (string-append possible-name ".el")) possible-name) + ((null? subnames) #f) + (#t (lp (cdr subnames) (string-append + possible-name + (if (string-null? possible-name) "" "-") + (car subnames))))))) + +(define (add-pkg-expr name) + `(progn + (require 'lisp-mnt) + (require 'package) + + (defun build-package-desc-from-library (name) + (package-desc-from-define + name + ;; Workaround for malformed version string (for example "24 (beta)" in + ;; paredit.el), try to parse version obtained by lm-version, before + ;; trying to create package-desc. Otherwis the whole process of + ;; generation -pkg.el will fail. + (condition-case + nil + (version-to-list (lm-version)) + (lm-version) + (error "0.0.0")) + (or (save-excursion + (goto-char (point-min)) + (and (re-search-forward + "^;;; [^ ]*\\.el ---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$" + nil t) + (match-string-no-properties 1))) + "No description available.") + (when-let ((require-lines (lm-header-multiline "package-requires"))) + (package--prepare-dependencies + (package-read-from-string + (mapconcat 'identity require-lines " ")))) + :kind 'single + :url (lm-homepage) + :keywords (lm-keywords-list) + :maintainer (lm-maintainer) + :authors (lm-authors))) + + (defun generate-package-description-file (name) + (package-generate-description-file + (build-package-desc-from-library name) + (concat name "-pkg.el"))) + + (condition-case err + (generate-package-description-file ,name) + (message (concat ,name "-pkg.el file generated.")) + (error + (message "There are some errors during generation of -pkg.el file:") + (message "%s" (error-message-string err)))))) + +(define* (add-pkg-file #:key name outputs #:allow-other-keys) + (define source (getcwd)) + (chdir (elpa-directory (assoc-ref outputs "out"))) + (let ((el-lib (find-root-library-file name))) + (when (and el-lib (not (file-exists? (string-append el-lib "-pkg.el")))) + (emacs-batch-edit-file (string-append el-lib ".el") + (add-pkg-expr el-lib)))) + (chdir source) + #t) + (define* (check #:key tests? (test-command '("make" "check")) (parallel-tests? #t) #:allow-other-keys) "Run the tests by invoking TEST-COMMAND. @@ -294,7 +362,8 @@ (define %standard-phases enable-autoloads-compilation) (add-after 'enable-autoloads-compilation 'patch-el-files patch-el-files) ;; The .el files are byte compiled directly in the store. - (add-after 'patch-el-files 'build build) + (add-after 'patch-el-files 'add-pkg-file add-pkg-file) + (add-after 'add-pkg-file 'build build) (add-after 'build 'validate-compiled-autoloads validate-compiled-autoloads) (add-after 'validate-compiled-autoloads 'move-doc move-doc)))