From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Bruno =?utf-8?Q?F=C3=A9lix?= Rezende Ribeiro Newsgroups: gmane.emacs.devel Subject: elpa-deploy.el --- ELPA deployment library Date: Wed, 28 Aug 2019 21:16:14 -0300 Message-ID: <87k1aw6d2p.fsf@oitofelix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="24884"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 29 02:16:57 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i387U-0006KT-JF for ged-emacs-devel@m.gmane.org; Thu, 29 Aug 2019 02:16:56 +0200 Original-Received: from localhost ([::1]:43940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i387T-00019n-23 for ged-emacs-devel@m.gmane.org; Wed, 28 Aug 2019 20:16:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33182) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i386s-00019h-6Y for emacs-devel@gnu.org; Wed, 28 Aug 2019 20:16:19 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i386s-0008EX-0U for emacs-devel@gnu.org; Wed, 28 Aug 2019 20:16:18 -0400 Original-Received: from [189.15.151.87] (port=52268 helo=felix-laptop) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1i386r-0001hT-FJ for emacs-devel@gnu.org; Wed, 28 Aug 2019 20:16:17 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:239657 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello GNU Emacs developers, Please, find attached =E2=80=98elpa-deploy.el=E2=80=99. Quoting from its c= ommentary section: This library provides =E2=80=98elpa-deploy=E2=80=99: a function which au= tomatizes the deployment of simple and multi-file packages. This consists of updating the version field of a package source using the current timestamp, generating its tar archive if multi-file, and uploading the results to a specified ELPA directory, while deleting any previous version of the same package already deployed. I find this useful for deploying simple and multi-file packages to ELPA directories for test and release (in VCS) within an organization. Please, let me know about desirable improvements and whether this is suitable for inclusion in the standard distribution. I=E2=80=99m also interested to know about alternative approaches. Grateful for your time. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=elpa-deploy.el Content-Transfer-Encoding: quoted-printable ;;; elpa-deploy.el --- ELPA deployment library -*- lexical-binding: t -*- ;; Copyright (C) 2019 Bruno F=C3=A9lix Rezende Ribeiro ;; Author: Bruno F=C3=A9lix Rezende Ribeiro ;; Maintainer: Bruno F=C3=A9lix Rezende Ribeiro ;; Keywords: tools ;; Package: elpa-deploy ;; Package-Version: 20190828.1108 ;; Package-Requires: (package f) ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; This library provides =E2=80=98elpa-deploy=E2=80=99: a function which au= tomatizes ;; the deployment of simple and multi-file packages. This consists of ;; updating the version field of a package source using the current ;; timestamp, generating its tar archive if multi-file, and uploading ;; the results to a specified ELPA directory, while deleting any ;; previous version of the same package already deployed. ;;; Code: (require 'package-x) (require 'lisp-mnt) (require 'f) (cl-defun elpa-deploy (path upload-base &aux (version (format-time-string "%Y%m%d.%H%M")) (package-name (f-base path))) "Deploy simple or multi-file package. PATH is the filename of a single =E2=80=98.el=E2=80=99 file (simple package= ) or a directory containing a =E2=80=98*-pkg.el=E2=80=99 file (multi-file package). UPLOAD-BASE is the target ELPA directory. This function updates the version field of the package source in-place -- using the current timestamp, then it generates its tar archive (in the multi-file case), *deletes* any previously deployed version of the same package in UPLOAD-BASE and finally uploads the result." (interactive "fPackage file or directory: \nDArchive upload base director= y: ") (pcase path ((pred file-regular-p) (elpa-deploy--update-version-string-simple-package path version) (mapc #'delete-file (directory-files upload-base 'full (format "^%s-[[:digit:]]\\{8\\}\\.[[:digit:]]\\{4\\}\\.el$" package-na= me))) (let ((package-archive-upload-base upload-base)) (package-upload-file path))) ((and (pred file-directory-p) (let file (f-expand (f-join (f-parent path) (format "%s-%s.tar" package-= name version))))) (elpa-deploy--update-version-string-multi-file-package path version) (call-process "tar" nil (list (current-buffer) nil) nil "--create" "--file" file (format "--transform=3Ds,^%s,%s-%s," package-name package-name version) (f-relative path)) (mapc #'delete-file (directory-files upload-base 'full (format "^%s-[[:digit:]]\\{8\\}\\.[[:digit:]]\\{4\\}\\.tar$" package-n= ame))) (let ((package-archive-upload-base upload-base)) (package-upload-file file)) (delete-file file)))) (defun elpa-deploy--update-version-string-simple-package (file version) "Update version string of simple package FILE to VERSION. The header \"Package-Version\" takes precedence over \"Version\". Having none previous to the invocation of this function is an error." (with-current-buffer (find-file-noselect file) (save-excursion (goto-char (point-min)) (when (or (re-search-forward (lm-get-header-re "package-version") (lm= -code-mark) t) (re-search-forward (lm-get-header-re "version") (lm-code-mark) t) (error "Package lacks a \"Version\" or \"Package-Version\" header")) (kill-line) (just-one-space) (insert version) (save-buffer))))) (cl-defun elpa-deploy--update-version-string-multi-file-package (dir version &aux (pkg-file (f-join dir (format "%s-pkg.el" (f-base dir= ))))) "Update version string of multi-file package inside directory DIR to VERS= ION. Presumably file =E2=80=98*-pkg.el=E2=80=99 has the =E2=80=98define-package= =E2=80=99 form as its first." (with-current-buffer (or (and (file-exists-p pkg-file) (find-file-noselect pkg-file)) (error "Package definition file =E2=80=98%s=E2=80=99 doesn=E2=80=99t = exist" (f-filename pkg-file))) (save-excursion (goto-char (point-min)) (when (or (package-process-define-package (read (current-buffer))) (error "Can=E2=80=99t find =E2=80=98define-package=E2=80=99 in %s" pkg-fi= le)) (down-list) (forward-sexp 2) (kill-sexp) (just-one-space) (insert (format "\"%s\"" version)) (save-buffer))))) (provide 'elpa-deploy) ;;; elpa-deploy.el ends here --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 88888 FFFFF Bruno F=C3=A9lix Rezende Ribeiro (oitofelix) [0x28D618AF] 8 8 F http://oitofelix.freeshell.org/ 88888 FFFF mailto:oitofelix@gnu.org 8 8 F irc://chat.freenode.org/oitofelix 88888 F xmpp://oitofelix@riseup.net --=-=-=--