Update package-build.el to latest version on melpa
This commit is contained in:
parent
5ba8159037
commit
5735221365
|
@ -0,0 +1,51 @@
|
|||
;;; package-build-badges.el --- Create batches for packages
|
||||
|
||||
;; Copyright (C) 2011-2013 Donald Ephraim Curtis <dcurtis@milkbox.net>
|
||||
;; Copyright (C) 2012-2014 Steve Purcell <steve@sanityinc.com>
|
||||
;; Copyright (C) 2009 Phil Hagelberg <technomancy@gmail.com>
|
||||
|
||||
;; Author: Donald Ephraim Curtis <dcurtis@milkbox.net>
|
||||
;; Keywords: tools
|
||||
|
||||
;; This file is not (yet) part of GNU Emacs.
|
||||
;; However, it is distributed under the same license.
|
||||
|
||||
;; GNU Emacs 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; In future we should provide a hook. Note also that it would be
|
||||
;; straightforward to generate the SVG ourselves, which would save
|
||||
;; the network overhead.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'package-build)
|
||||
|
||||
(defun package-build--write-melpa-badge-image (name version target-dir)
|
||||
(shell-command
|
||||
(mapconcat #'shell-quote-argument
|
||||
(list "curl" "-f" "-o"
|
||||
(expand-file-name (concat name "-badge.svg") target-dir)
|
||||
(format "https://img.shields.io/badge/%s-%s-%s.svg"
|
||||
(if package-build-stable "melpa stable" "melpa")
|
||||
(url-hexify-string version)
|
||||
(if package-build-stable "3e999f" "922793")))
|
||||
" ")))
|
||||
|
||||
(provide 'package-build-badges)
|
||||
;; End:
|
||||
;;; package-badges.el ends here
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,105 @@
|
|||
;;; package-recipe-mode.el --- Minor mode for editing package recipes
|
||||
|
||||
;; Copyright (C) 2011-2013 Donald Ephraim Curtis <dcurtis@milkbox.net>
|
||||
;; Copyright (C) 2012-2014 Steve Purcell <steve@sanityinc.com>
|
||||
;; Copyright (C) 2009 Phil Hagelberg <technomancy@gmail.com>
|
||||
|
||||
;; Author: Donald Ephraim Curtis <dcurtis@milkbox.net>
|
||||
;; Keywords: tools
|
||||
|
||||
;; This file is not (yet) part of GNU Emacs.
|
||||
;; However, it is distributed under the same license.
|
||||
|
||||
;; GNU Emacs 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This library defines the minor mode `package-build-minor-mode',
|
||||
;; which will likely be replaced with the `emacs-lisp-mode' derived
|
||||
;; `package-recipe-mode' eventually.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'package-build)
|
||||
|
||||
(defvar package-build-minor-mode-map
|
||||
(let ((m (make-sparse-keymap)))
|
||||
(define-key m (kbd "C-c C-c") 'package-build-current-recipe)
|
||||
m)
|
||||
"Keymap for `package-build-minor-mode'.")
|
||||
|
||||
(define-minor-mode package-build-minor-mode
|
||||
"Helpful functionality for building packages."
|
||||
nil
|
||||
" PBuild"
|
||||
package-build-minor-mode-map
|
||||
(when package-build-minor-mode
|
||||
(message "Use C-c C-c to build this recipe.")))
|
||||
|
||||
;;;###autoload
|
||||
(defun package-build-create-recipe (name fetcher)
|
||||
"Create a new recipe for the package named NAME using FETCHER."
|
||||
(interactive
|
||||
(list (read-string "Package name: ")
|
||||
(intern (completing-read "Fetcher: "
|
||||
(list "git" "github" "gitlab"
|
||||
"hg" "bitbucket")
|
||||
nil t nil nil "github"))))
|
||||
(let ((recipe-file (expand-file-name name package-build-recipes-dir)))
|
||||
(when (file-exists-p recipe-file)
|
||||
(error "Recipe already exists"))
|
||||
(find-file recipe-file)
|
||||
(insert (pp-to-string `(,(intern name)
|
||||
:fetcher ,fetcher
|
||||
,@(cl-case fetcher
|
||||
(github (list :repo "USER/REPO"))
|
||||
(t (list :url "SCM_URL_HERE"))))))
|
||||
(emacs-lisp-mode)
|
||||
(package-build-minor-mode)
|
||||
(goto-char (point-min))))
|
||||
|
||||
;;;###autoload
|
||||
(defun package-build-current-recipe ()
|
||||
"Build archive for the recipe defined in the current buffer."
|
||||
(interactive)
|
||||
(unless (and (buffer-file-name)
|
||||
(file-equal-p (file-name-directory (buffer-file-name))
|
||||
package-build-recipes-dir))
|
||||
(error "Buffer is not visiting a recipe"))
|
||||
(when (buffer-modified-p)
|
||||
(if (y-or-n-p (format "Save file %s? " buffer-file-name))
|
||||
(save-buffer)
|
||||
(error "Aborting")))
|
||||
(check-parens)
|
||||
(let ((name (file-name-nondirectory (buffer-file-name))))
|
||||
(package-build-archive name t)
|
||||
(let ((output-buffer-name "*package-build-result*"))
|
||||
(with-output-to-temp-buffer output-buffer-name
|
||||
(princ ";; Please check the following package descriptor.\n")
|
||||
(princ ";; If the correct package description or dependencies are missing,\n")
|
||||
(princ ";; then the source .el file is likely malformed, and should be fixed.\n")
|
||||
(pp (assoc (intern name) (package-build-archive-alist))))
|
||||
(with-current-buffer output-buffer-name
|
||||
(emacs-lisp-mode)
|
||||
(view-mode)))
|
||||
(when (yes-or-no-p "Install new package? ")
|
||||
(package-install-file
|
||||
(package-build--artifact-file
|
||||
(assq (intern name) (package-build-archive-alist)))))))
|
||||
|
||||
(provide 'package-recipe-mode)
|
||||
;; End:
|
||||
;;; package-recipe-mode.el ends here
|
|
@ -0,0 +1,163 @@
|
|||
;;; package-recipe.el --- Package recipes as EIEIO objects -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2018 Jonas Bernoulli
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
|
||||
;; This file is not (yet) part of GNU Emacs.
|
||||
;; However, it is distributed under the same license.
|
||||
|
||||
;; GNU Emacs 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Package recipes as EIEIO objects.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'eieio)
|
||||
|
||||
(defvar package-build-recipes-dir)
|
||||
(defvar package-build-working-dir)
|
||||
|
||||
;;; Classes
|
||||
|
||||
(defclass package-recipe ()
|
||||
((url-format :allocation :class :initform nil)
|
||||
(repopage-format :allocation :class :initform nil)
|
||||
(tag-regexp :allocation :class :initform nil)
|
||||
(stable-p :allocation :class :initform nil)
|
||||
(name :initarg :name :initform nil)
|
||||
(url :initarg :url :initform nil)
|
||||
(repo :initarg :repo :initform nil)
|
||||
(repopage :initarg :repopage :initform nil)
|
||||
(files :initarg :files :initform nil)
|
||||
(branch :initarg :branch :initform nil)
|
||||
(commit :initarg :commit :initform nil)
|
||||
(version-regexp :initarg :version-regexp :initform nil)
|
||||
(old-names :initarg :old-names :initform nil))
|
||||
:abstract t)
|
||||
|
||||
(defmethod package-recipe--working-tree ((rcp package-recipe))
|
||||
(file-name-as-directory
|
||||
(expand-file-name (oref rcp name) package-build-working-dir)))
|
||||
|
||||
(defmethod package-recipe--upstream-url ((rcp package-recipe))
|
||||
(or (oref rcp url)
|
||||
(format (oref rcp url-format)
|
||||
(oref rcp repo))))
|
||||
|
||||
;;;; Git
|
||||
|
||||
(defclass package-git-recipe (package-recipe)
|
||||
((tag-regexp :initform "\
|
||||
\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} \
|
||||
[0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\( [+-][0-9]\\{4\\}\\)?\\)")))
|
||||
|
||||
(defclass package-github-recipe (package-git-recipe)
|
||||
((url-format :initform "https://github.com/%s.git")
|
||||
(repopage-format :initform "https://github.com/%s")))
|
||||
|
||||
(defclass package-gitlab-recipe (package-git-recipe)
|
||||
((url-format :initform "https://gitlab.com/%s.git")
|
||||
(repopage-format :initform "https://gitlab.com/%s")))
|
||||
|
||||
;;;; Mercurial
|
||||
|
||||
(defclass package-hg-recipe (package-recipe)
|
||||
((tag-regexp :initform "\
|
||||
\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} \
|
||||
[0-9]\\{2\\}:[0-9]\\{2\\}\\( [+-][0-9]\\{4\\}\\)?\\)")))
|
||||
|
||||
(defclass package-bitbucket-recipe (package-hg-recipe)
|
||||
((url-format :initform "https://bitbucket.org/%s")
|
||||
(repopage-format :initform "https://bitbucket.org/%s")))
|
||||
|
||||
;;; Interface
|
||||
|
||||
(defun package-recipe-recipes ()
|
||||
"Return a list of the names of packages with available recipes."
|
||||
(directory-files package-build-recipes-dir nil "^[^.]"))
|
||||
|
||||
(defun package-recipe-read-name ()
|
||||
"Read the name of a package for which a recipe is available."
|
||||
(completing-read "Package: " (package-recipe-recipes)))
|
||||
|
||||
(defun package-recipe-lookup (name)
|
||||
"Return a recipe object for the package named NAME.
|
||||
If no such recipe file exists or if the contents of the recipe
|
||||
file is invalid, then raise an error."
|
||||
(let ((file (expand-file-name name package-build-recipes-dir)))
|
||||
(if (file-exists-p file)
|
||||
(let* ((recipe (with-temp-buffer
|
||||
(insert-file-contents file)
|
||||
(read (current-buffer))))
|
||||
(plist (cdr recipe))
|
||||
(fetcher (plist-get plist :fetcher))
|
||||
key val args)
|
||||
(package-recipe--validate recipe name)
|
||||
(while (and (setq key (pop plist))
|
||||
(setq val (pop plist)))
|
||||
(unless (eq key :fetcher)
|
||||
(push val args)
|
||||
(push key args)))
|
||||
(apply (intern (format "package-%s-recipe" fetcher))
|
||||
name :name name args))
|
||||
(error "No such recipe: %s" name))))
|
||||
|
||||
;;; Validation
|
||||
|
||||
(defun package-recipe--validate (recipe name)
|
||||
"Perform some basic checks on the raw RECIPE for the package named NAME."
|
||||
(pcase-let ((`(,ident . ,plist) recipe))
|
||||
(cl-assert ident)
|
||||
(cl-assert (symbolp ident))
|
||||
(cl-assert (string= (symbol-name ident) name)
|
||||
nil "Recipe '%s' contains mismatched package name '%s'"
|
||||
name ident)
|
||||
(cl-assert plist)
|
||||
(let* ((symbol-keys '(:fetcher))
|
||||
(string-keys '(:url :repo :commit :branch :version-regexp))
|
||||
(list-keys '(:files :old-names))
|
||||
(all-keys (append symbol-keys string-keys list-keys)))
|
||||
(dolist (thing plist)
|
||||
(when (keywordp thing)
|
||||
(cl-assert (memq thing all-keys) nil "Unknown keyword %S" thing)))
|
||||
(let ((fetcher (plist-get plist :fetcher)))
|
||||
(cl-assert fetcher nil ":fetcher is missing")
|
||||
(if (memq fetcher '(github gitlab bitbucket))
|
||||
(progn
|
||||
(cl-assert (plist-get plist :repo) ":repo is missing")
|
||||
(cl-assert (not (plist-get plist :url)) ":url is redundant"))
|
||||
(cl-assert (plist-get plist :url) ":url is missing")))
|
||||
(dolist (key symbol-keys)
|
||||
(let ((val (plist-get plist key)))
|
||||
(when val
|
||||
(cl-assert (symbolp val) nil "%s must be a symbol but is %S" key val))))
|
||||
(dolist (key list-keys)
|
||||
(let ((val (plist-get plist key)))
|
||||
(when val
|
||||
(cl-assert (listp val) nil "%s must be a list but is %S" key val))))
|
||||
(dolist (key string-keys)
|
||||
(let ((val (plist-get plist key)))
|
||||
(when val
|
||||
(cl-assert (stringp val) nil "%s must be a string but is %S" key val)))))
|
||||
recipe))
|
||||
|
||||
;;; _
|
||||
(provide 'package-recipe)
|
||||
;; End:
|
||||
;;; package-recipe.el ends here
|
Loading…
Reference in New Issue