From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KIxOOT78sWEHywAAgWs5BA (envelope-from ) for ; Thu, 09 Dec 2021 13:53:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id OPEyNT78sWGmOQAAB5/wlQ (envelope-from ) for ; Thu, 09 Dec 2021 12:53:18 +0000 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 5DBDB326CA for ; Thu, 9 Dec 2021 13:53:18 +0100 (CET) Received: from localhost ([::1]:45496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mvIvF-0001wj-FI for larch@yhetil.org; Thu, 09 Dec 2021 07:53:17 -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 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639054398; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=pUsC7QfwclDhZLf3TXL1Atq1MTPz4jSTxgW9TmPz/Bo=; b=Ucpwin1L8YuspM1RV89n4jzh1PGhnTKWh3JGp3+SiJ0zzaFvZBlsIIWsaOsTPJjy186u7+ SWIwsSZAwuAOt79iri1/OFlwHcZhU6hwroWADdggpfJ1NMib74RVqHdbCwE9N3s6FrvaKY fNrhG0iZNrebx6c7tWt9PhuY/qowz2RoeEBBIqhtnRELpmZWV/GVh1tSMdF8EsZhQ8BuTO g3ihsK9MQci/xqCLiQvvbvMEJ2o5fV9MGtq0O+zS1WQl5CYJ7Yw89gzDQaU2R7BKBlyFLk 60RNQ/+lWUDmouEVuWxqgdJVobSSRHeQgre5qeS456z6VT/tV9mAScMiRYxZYA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639054398; a=rsa-sha256; cv=none; b=DNr3cdoBeWFOe0iuXvSDlcjDVVYewrF/NlIw+sTvwnuqDpoR675fVYS6pSF1fq07/XptsK PELRprIBHCFAVzE6B8aR/xFJAfpURhiuzWQC0DM42sOuqqpvuXz43OfzMiWqPwHKlq3g+b 36M/KR+nTt6JcHfqlgEmX/aWgjaHWk4f7SCkDg8OqTF2nL1FQKQrwTuaApayFs1qlr0J26 cMu9amnbTAEoV3Fyy7VhvvS32ldDWRz8r20vGRnpp4L1qqTkd758I3RQlRLxtFfuJCLC4J TLzlJjoxc/JtD0BZ328+9yyXHq96Pzfzn3w6lr+++nmuor/m+QSEGyHW8ZTELA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop-in.20210112.gappssmtp.com header.s=20210112 header.b=qQg+7DnQ; dmarc=none; 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" X-Migadu-Spam-Score: -3.75 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop-in.20210112.gappssmtp.com header.s=20210112 header.b=qQg+7DnQ; dmarc=none; 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" X-Migadu-Queue-Id: 5DBDB326CA X-Spam-Score: -3.75 X-Migadu-Scanner: scn1.migadu.com X-TUID: ZfWJ+sBAJ7FL --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable * guix/build/emacs-build-system.scm (%default-exclude): Add generation of =2Dpkg.el files for packages, which do not provide them. =2D-- 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#L= 553 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-sys= tem.scm index f13162d6c4..ee934f4bde 100644 =2D-- 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)) =20 +(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-file= s) ;; The .el files are byte compiled directly in the store. =2D (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-autol= oads) (add-after 'validate-compiled-autoloads 'move-doc move-doc))) =20 =2D-=20 2.34.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmGx++wPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wwywP/3cBay9sx2zxlAy8akx9sJXutBoLDdf7w2JN F35wzeBEJbmK7yLilD2PghRyf0WNQcjbdf216UGwbRH3VnoiAK1KKM+9l8WLAKRo 1FC6qYW1d/Yr0Old3+ax0C7IxkOLbOyU5M97bS9+POoEvBhx+V9Qk+SOBDtQ/Sjp +GdTlgxI9Zw+Mg4MFuzXjw00F3uQfLJWDpyBAo2Qu7d573jtQqyCvpmgDcjYP3/4 dcmtUmRlQvm0eEFHP8I9QiHu+0TIEkCYZk/xavwdStyUzjrbD0UPshQr3HHmgJHj 12bmHT4hbrkyLCdlpbyCunTeJtEZkvakZafqEKkmaDfaikXnapqzh/Vr/A1RGPWp tcPmPfIMtCylVTUU3vtC/Jz1rgy2KTdbyBfvz64BNLjdbdNAfNZ760tChcTCQMwr H3gFfMauZcs4VxPZ8HwLLgU52eyzwaSutkesfPM/qhesUCRzNSfWnlCNdInkiyki Lfb/KnfE92dFTsTXHDbcNUqsLplRNrmvrBGfDm4zv5N8E+z3Cgh+o/Nj+I+D4BX6 Yb5euokW18tj+yMbJqoMXRpRoWRqN31f1vPBDjXjq/DW1LJLvpnMuozEHR0ZxHWZ exJw+J0nK+9/rfPLE4+BtenTqEPgJTSqqhU42+pbaBusOY2UeksjDIK/Or459p02 M4VBH6fI =FiWO -----END PGP SIGNATURE----- --=-=-=--