From patchwork Fri Jan 14 20:56:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Liliana Marie Prikler X-Patchwork-Id: 36343 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 7A40727BBEA; Fri, 14 Jan 2022 20:58:13 +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=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED 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 DB7A327BBE9 for ; Fri, 14 Jan 2022 20:58:12 +0000 (GMT) Received: from localhost ([::1]:58636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8TeF-00037u-VA for patchwork@mira.cbaines.net; Fri, 14 Jan 2022 15:58:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8Te6-000365-6Z for guix-patches@gnu.org; Fri, 14 Jan 2022 15:58:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8Te5-0007t8-SZ for guix-patches@gnu.org; Fri, 14 Jan 2022 15:58:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8Te5-0005Bq-R6 for guix-patches@gnu.org; Fri, 14 Jan 2022 15:58:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52388] [PATCH] build-system: emacs: Add generation of -pkg.el files. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 14 Jan 2022 20:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52388 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Andrew Tropin , 52388@debbugs.gnu.org Cc: Ivan Sokolov Received: via spool by 52388-submit@debbugs.gnu.org id=B52388.164219382819882 (code B ref 52388); Fri, 14 Jan 2022 20:58:01 +0000 Received: (at 52388) by debbugs.gnu.org; 14 Jan 2022 20:57:08 +0000 Received: from localhost ([127.0.0.1]:38348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8TdE-0005Ac-Cf for submit@debbugs.gnu.org; Fri, 14 Jan 2022 15:57:08 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8TdB-0005A3-Br for 52388@debbugs.gnu.org; Fri, 14 Jan 2022 15:57:08 -0500 Received: by mail-wm1-f68.google.com with SMTP id c66so8317524wma.5 for <52388@debbugs.gnu.org>; Fri, 14 Jan 2022 12:57:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version; bh=mdDEbEsAqcw2rqPR+H28ODuRAOzx9RRjLdndEMoW8LE=; b=nY48ZlUhVqX70FfiI4Ymjjl2f37CQi8AGZgFaOdEPzAFia0+CzaVJVY+S+O2KHeDBu 418hwfabqgtaJ2kyrCcydUV+HEWYiI5pXz61uqACnZ+qxWew5qaTe0Ey0/pV88YWXL2W xxWhNdI0TfYP+7z6iDkjZ3qq6dQVNsBUqtQ+4H3QWU2ptI+IPRNJ6pR/Bd9a8NpkR/dt 97C74gLmVZPmRvuNvLSCBZQcOWdKM6EJVXBCMmcUsTrX2GU+v0An/nFc6By55hWuCwMO h0Mg+FvYngMhDFYZDj5Qv0idRigipykok2znGx4p0AQVtNnkw8EGDe6fZsc3ej/iE9Kl EfBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version; bh=mdDEbEsAqcw2rqPR+H28ODuRAOzx9RRjLdndEMoW8LE=; b=wxM3MTUZFber7NDqDgTrtPrao8Y/Rdi9rgSC2C7wqhvOJrdoepfCP9uqNe9Ut2vRud uVo8/huXcqlWuTTorgr1RelyWNXIpQKl+6yuNplh7KliOKYSvcjiYU3u+sInBE/LkOf2 pJV88368Q0b39h4w/SeqdWcDSlttycENIcLsIBiA0UG5apw0PS3P5SaacneZ071F2i9A n+c+zfe+FGa5SjtJbNBAGUVjt+dUZ70l+4TkFYuHZfZPTSehdApVOQiNvyM7+FEfrBv1 x2GNQOPw2GZEetg2oUbJmcIlEfvm3XTNPDwzcsji+XH3KOwbi8gBCAvaln7QDdh9+CqM xe/w== X-Gm-Message-State: AOAM530TJxv2hd6NbyusVjT1kN2qfY8+eLi6Z/xWbV5ZqlqCHjp3OIjQ QPqcCN+tMhrsuV3RJcAFag0= X-Google-Smtp-Source: ABdhPJxeCKPTXEnx6IBapQI6K+cxutaogF2UivBa+6yJmv08GTn5tbM9u3HZjpxgh4Jfzg6TjcwuYw== X-Received: by 2002:a5d:64c3:: with SMTP id f3mr9679064wri.155.1642193819439; Fri, 14 Jan 2022 12:56:59 -0800 (PST) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id o15sm1846934wri.71.2022.01.14.12.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 12:56:58 -0800 (PST) Message-ID: <80cfa468ef91649dce477779a70d3a8ce64fd0e4.camel@gmail.com> From: Liliana Marie Prikler Date: Fri, 14 Jan 2022 21:56:56 +0100 In-Reply-To: <871r2mrleb.fsf@trop.in> References: <871r2mrleb.fsf@trop.in> User-Agent: Evolution 3.42.1 MIME-Version: 1.0 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 Hi Andrew, Am Donnerstag, dem 09.12.2021 um 12:01 +0300 schrieb Andrew Tropin: > > * 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 As promised, I took a deeper look at your patch. As already noted, there were some clean-up actions I had to perform, such as keeping to our line limit (it was not easy, I tell you) among other things. Also, confusingly, your condition-case code did not handle errors and wrong handling of the version field blew up everything for me. Did you test this code? In any case, attached is my revised patch. I so far only checked it with emacs-olivetti -- a package whose description is missing in current Guix Emacs. I'll give everyone some time to test things before pushing this however; I don't want to break a bunch of Emacs packages scattered around various files. Cheers From 9fa6a09a131cfe436ca053c960ed9625263bc650 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Thu, 9 Dec 2021 12:01:46 +0300 Subject: [PATCH] build-system: emacs: Ensure that package descriptions are generated. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch addresses the second part of . While existing -pkg.el files were previously installed, no such files were generated for packages lacking them, resulting in packages not being listed as installed and not being available towards “describe-package”. * guix/build/emacs-build-system.scm (find-root-library-file) (ensure-package-description): New variables. (%standard-phases): Add ‘ensure-package-description’. --- guix/build/emacs-build-system.scm | 77 ++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm index ab77e57f33..58d2a9b9f4 100644 --- a/guix/build/emacs-build-system.scm +++ b/guix/build/emacs-build-system.scm @@ -140,6 +140,79 @@ (define (substitute-program-names) (substitute-program-names)))) #t)) +(define (find-root-library-file name) + (let loop ((parts (string-split + (package-name-version->elpa-name-version name) #\-)) + (candidate "")) + (cond + ;; at least one version part is given, so we don't terminate "early" + ((null? parts) #f) + ((string-null? candidate) (loop (cdr parts) (car parts))) + ((file-exists? (string-append candidate ".el")) candidate) + (else + (loop (cdr parts) (string-append candidate "-" (car parts))))))) + +(define* (ensure-package-description #:key outputs #:allow-other-keys) + (define (write-pkg-file name) + (define summary-regexp + "^;;; [^ ]*\\.el ---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$") + (define %write-pkg-file-form + `(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 + (let ((version (lm-version))) + ;; raises an error if version is invalid + (and (version-to-list version) version)) + (error "0.0.0")) + (or (save-excursion + (goto-char (point-min)) + (and (re-search-forward ,summary-regexp nil t) + (match-string-no-properties 1))) + package--default-summary) + (let ((require-lines (lm-header-multiline "package-requires"))) + (and require-lines + (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 + (let ((name (file-name-base (buffer-file-name)))) + (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)))))) + + (unless (file-exists? (string-append name "-pkg.el")) + (emacs-batch-edit-file (string-append name ".el") + %write-pkg-file-form))) + + (let* ((out (assoc-ref outputs "out")) + (elpa-name-ver (store-directory->elpa-name-version out))) + (with-directory-excursion (elpa-directory out) + (and=> (find-root-library-file elpa-name-ver) write-pkg-file)))) + (define* (check #:key tests? (test-command '("make" "check")) (parallel-tests? #t) #:allow-other-keys) "Run the tests by invoking TEST-COMMAND. @@ -279,8 +352,10 @@ (define %standard-phases (add-after 'make-autoloads 'enable-autoloads-compilation enable-autoloads-compilation) (add-after 'enable-autoloads-compilation 'patch-el-files patch-el-files) + (add-after 'patch-el-files 'ensure-package-description + ensure-package-description) ;; The .el files are byte compiled directly in the store. - (add-after 'patch-el-files 'build build) + (add-after 'ensure-package-description 'build build) (add-after 'build 'validate-compiled-autoloads validate-compiled-autoloads) (add-after 'validate-compiled-autoloads 'move-doc move-doc))) -- 2.34.0