2022-07-31 21:32:38 +02:00
|
|
|
;;; package-vc.el --- Manage packages from VC checkouts -*- lexical-binding: t; -*-
|
|
|
|
|
2023-01-01 05:31:12 -05:00
|
|
|
;; Copyright (C) 2022-2023 Free Software Foundation, Inc.
|
2022-07-31 21:32:38 +02:00
|
|
|
|
|
|
|
;; Author: Philip Kaludercic <philipk@posteo.net>
|
|
|
|
;; Keywords: tools
|
|
|
|
|
2022-12-08 23:56:24 +01:00
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2022-07-31 21:32:38 +02:00
|
|
|
;; 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.
|
|
|
|
|
2022-12-08 23:56:24 +01:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2022-07-31 21:32:38 +02:00
|
|
|
;; 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
|
2022-12-08 23:56:24 +01:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2022-07-31 21:32:38 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; While packages managed by package.el use tarballs for distributing
|
|
|
|
;; the source code, this extension allows for packages to be fetched
|
|
|
|
;; and updated directly from a version control system.
|
2022-11-04 18:53:02 +01:00
|
|
|
;;
|
|
|
|
;; To install a package from source use `package-vc-install'. If you
|
|
|
|
;; aren't interested in activating a package, you can use
|
|
|
|
;; `package-vc-checkout' instead, which will prompt you for a target
|
|
|
|
;; directory. If you wish to re-use an existing checkout, the command
|
2022-11-05 16:31:16 +01:00
|
|
|
;; `package-vc-install-from-checkout' will create a symbolic link and
|
|
|
|
;; prepare the package.
|
2022-11-04 18:53:02 +01:00
|
|
|
;;
|
|
|
|
;; If you make local changes that you wish to share with an upstream
|
|
|
|
;; maintainer, the command `package-vc-prepare-patch' can prepare
|
|
|
|
;; these as patches to send via Email.
|
2022-07-31 21:32:38 +02:00
|
|
|
|
2022-08-03 13:47:54 +02:00
|
|
|
;;; TODO:
|
|
|
|
|
2022-10-23 18:18:37 +02:00
|
|
|
;; - Allow maintaining patches that are ported back onto regular
|
|
|
|
;; packages and maintained between versions.
|
2022-08-03 13:47:54 +02:00
|
|
|
|
2022-07-31 21:32:38 +02:00
|
|
|
;;; Code:
|
|
|
|
|
2022-08-11 10:55:43 +02:00
|
|
|
(eval-when-compile (require 'rx))
|
2022-10-23 18:20:30 +02:00
|
|
|
(eval-when-compile (require 'map))
|
2022-12-10 09:43:22 +01:00
|
|
|
(eval-when-compile (require 'cl-lib))
|
2022-07-31 21:32:38 +02:00
|
|
|
(require 'package)
|
|
|
|
(require 'lisp-mnt)
|
|
|
|
(require 'vc)
|
2022-08-03 20:25:17 +02:00
|
|
|
(require 'seq)
|
2022-07-31 21:32:38 +02:00
|
|
|
|
|
|
|
(defgroup package-vc nil
|
|
|
|
"Manage packages from VC checkouts."
|
|
|
|
:group 'package
|
2023-03-30 23:24:08 +02:00
|
|
|
:link '(custom-manual "(emacs) Fetching Package Sources")
|
2022-11-04 18:19:01 +01:00
|
|
|
:prefix "package-vc-"
|
2022-07-31 21:32:38 +02:00
|
|
|
:version "29.1")
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defconst package-vc--elpa-packages-version 1
|
2022-10-28 19:58:05 +02:00
|
|
|
"Version number of the package specification format understood by package-vc.")
|
|
|
|
|
2022-10-23 18:38:12 +02:00
|
|
|
(defcustom package-vc-heuristic-alist
|
2022-10-07 19:19:44 +02:00
|
|
|
`((,(rx bos "http" (? "s") "://"
|
|
|
|
(or (: (? "www.") "github.com"
|
|
|
|
"/" (+ (or alnum "-" "." "_"))
|
|
|
|
"/" (+ (or alnum "-" "." "_")))
|
|
|
|
(: "codeberg.org"
|
|
|
|
"/" (+ (or alnum "-" "." "_"))
|
|
|
|
"/" (+ (or alnum "-" "." "_")))
|
|
|
|
(: (? "www.") "gitlab" (+ "." (+ alnum))
|
|
|
|
"/" (+ (or alnum "-" "." "_"))
|
|
|
|
"/" (+ (or alnum "-" "." "_")))
|
|
|
|
(: "git.sr.ht"
|
|
|
|
"/~" (+ (or alnum "-" "." "_"))
|
|
|
|
"/" (+ (or alnum "-" "." "_")))
|
|
|
|
(: "git." (or "savannah" "sv") "." (? "non") "gnu.org/"
|
|
|
|
(or "r" "git") "/"
|
|
|
|
(+ (or alnum "-" "." "_")) (? "/")))
|
|
|
|
(or (? "/") ".git") eos)
|
|
|
|
. Git)
|
|
|
|
(,(rx bos "http" (? "s") "://"
|
|
|
|
(or (: "hg.sr.ht"
|
|
|
|
"/~" (+ (or alnum "-" "." "_"))
|
|
|
|
"/" (+ (or alnum "-" "." "_")))
|
|
|
|
(: "hg." (or "savannah" "sv") "." (? "non") "gnu.org/hgweb/"
|
|
|
|
(+ (or alnum "-" "." "_")) (? "/")))
|
|
|
|
eos)
|
|
|
|
. Hg)
|
|
|
|
(,(rx bos "http" (? "s") "://"
|
|
|
|
(or (: "bzr." (or "savannah" "sv") "." (? "non") "gnu.org/r/"
|
|
|
|
(+ (or alnum "-" "." "_")) (? "/")))
|
|
|
|
eos)
|
|
|
|
. Bzr))
|
|
|
|
"Heuristic mapping URL regular expressions to VC backends."
|
|
|
|
:type `(alist :key-type (regexp :tag "Regular expression matching URLs")
|
|
|
|
:value-type (choice :tag "VC Backend"
|
|
|
|
,@(mapcar (lambda (b) `(const ,b))
|
|
|
|
vc-handled-backends)))
|
|
|
|
:version "29.1")
|
2022-08-11 10:53:11 +02:00
|
|
|
|
2022-10-18 22:34:11 +02:00
|
|
|
(defcustom package-vc-default-backend 'Git
|
2022-10-23 18:27:07 +02:00
|
|
|
"Default VC backend used when cloning a package repository.
|
|
|
|
If no repository type was specified or could be guessed by
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
`package-vc-heuristic-alist', this is the default VC backend
|
|
|
|
used as fallback. The value must be a member of
|
|
|
|
`vc-handled-backends' and the named backend must implement
|
|
|
|
the `clone' function."
|
2022-10-23 18:27:07 +02:00
|
|
|
:type `(choice ,@(mapcar (lambda (b) (list 'const b))
|
|
|
|
vc-handled-backends))
|
2022-10-18 22:34:11 +02:00
|
|
|
:version "29.1")
|
|
|
|
|
2022-11-04 20:15:42 +01:00
|
|
|
(defvar package-vc-selected-packages) ; pacify byte-compiler
|
2022-11-06 09:52:57 +01:00
|
|
|
|
|
|
|
;;;###autoload
|
2022-11-06 09:51:45 +01:00
|
|
|
(defun package-vc-install-selected-packages ()
|
2022-11-05 16:43:05 +01:00
|
|
|
"Ensure packages specified in `package-vc-selected-packages' are installed."
|
2022-11-06 09:52:12 +01:00
|
|
|
(interactive)
|
2022-11-06 09:47:39 +01:00
|
|
|
(pcase-dolist (`(,name . ,spec) package-vc-selected-packages)
|
|
|
|
(when (stringp name)
|
|
|
|
(setq name (intern name)))
|
2022-11-12 09:14:33 +01:00
|
|
|
(let ((pkg-descs (assoc name package-alist #'string=)))
|
|
|
|
(unless (seq-some #'package-vc-p (cdr pkg-descs))
|
2022-10-31 09:58:37 +01:00
|
|
|
(cond
|
|
|
|
((null spec)
|
|
|
|
(package-vc-install name))
|
|
|
|
((stringp spec)
|
2022-12-25 09:53:07 +01:00
|
|
|
(package-vc-install name spec))
|
2022-10-31 09:58:37 +01:00
|
|
|
((listp spec)
|
|
|
|
(package-vc--archives-initialize)
|
2023-02-12 14:29:26 +01:00
|
|
|
(package-vc--unpack
|
|
|
|
(or (cadr (assoc name package-archive-contents))
|
|
|
|
(package-desc-create :name name :kind 'vc))
|
|
|
|
spec)))))))
|
2022-10-31 09:58:37 +01:00
|
|
|
|
|
|
|
(defcustom package-vc-selected-packages '()
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"List of packages that must be installed.
|
|
|
|
Each member of the list is of the form (NAME . SPEC), where NAME
|
2022-10-31 09:58:37 +01:00
|
|
|
is a symbol designating the package and SPEC is one of:
|
|
|
|
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
- nil, if any package version can be installed;
|
|
|
|
- a version string, if that specific revision is to be installed;
|
2023-03-27 20:57:31 -04:00
|
|
|
- a property list, describing a package specification. For more
|
|
|
|
details, please consult the subsection \"Specifying Package
|
|
|
|
Sources\" in the Info node `(emacs)Fetching Package Sources'.
|
2022-10-31 09:58:37 +01:00
|
|
|
|
2023-03-15 09:51:14 +01:00
|
|
|
This user option will be automatically updated to store package
|
|
|
|
specifications for packages that are not specified in any
|
|
|
|
archive."
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
:type '(alist :tag "List of packages you want to be installed"
|
2022-10-31 09:58:37 +01:00
|
|
|
:key-type (symbol :tag "Package")
|
|
|
|
:value-type
|
|
|
|
(choice (const :tag "Any revision" nil)
|
|
|
|
(string :tag "Specific revision")
|
|
|
|
(plist :options ((:url string)
|
|
|
|
(:branch string)
|
|
|
|
(:lisp-dir string)
|
|
|
|
(:main-file string)
|
2023-03-27 20:57:31 -04:00
|
|
|
(:doc string)
|
2022-10-31 09:58:37 +01:00
|
|
|
(:vc-backend symbol)))))
|
|
|
|
:version "29.1")
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defvar package-vc--archive-spec-alist nil
|
2022-10-18 22:34:11 +02:00
|
|
|
"List of package specifications for each archive.
|
2022-11-10 21:52:46 +01:00
|
|
|
The list maps each package name, as a string, to a plist as
|
|
|
|
specified in `package-vc-selected-packages'.")
|
2022-10-18 22:34:11 +02:00
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defvar package-vc--archive-data-alist nil
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"List of package specification metadata for archives.
|
2022-10-28 19:58:05 +02:00
|
|
|
Each element of the list has the form (ARCHIVE . PLIST), where
|
|
|
|
PLIST keys are one of:
|
|
|
|
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
`:version' (integer)
|
|
|
|
Indicates the version of the file formatting, to be compared
|
|
|
|
with `package-vc--elpa-packages-version'.
|
2022-10-28 19:58:05 +02:00
|
|
|
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
`:vc-backend' (symbol)
|
|
|
|
A symbol of the default VC backend to use if a package specification
|
|
|
|
does not indicate a backend. The value ought to be a member of
|
|
|
|
`vc-handled-backends'. If omitted, `vc-clone' will fall back on
|
|
|
|
`package-vc-default-backend'.
|
2022-10-28 19:58:05 +02:00
|
|
|
|
|
|
|
All other values are ignored.")
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--desc->spec (pkg-desc &optional name)
|
2022-10-18 22:34:11 +02:00
|
|
|
"Retrieve the package specification for PKG-DESC.
|
|
|
|
The optional argument NAME can be used to override the default
|
|
|
|
name for PKG-DESC."
|
2022-10-23 13:07:43 +02:00
|
|
|
(alist-get
|
2023-03-15 09:51:14 +01:00
|
|
|
(setq name (or name (package-desc-name pkg-desc)))
|
|
|
|
(if (and (package-desc-archive pkg-desc)
|
|
|
|
(not (alist-get name package-vc-selected-packages
|
|
|
|
nil nil #'string=)))
|
2022-10-30 11:43:11 +01:00
|
|
|
(alist-get (intern (package-desc-archive pkg-desc))
|
2022-11-03 19:38:34 +01:00
|
|
|
package-vc--archive-spec-alist)
|
2023-03-15 09:51:14 +01:00
|
|
|
;; Consult both our local list of package specifications, as well
|
|
|
|
;; as the lists provided by the archives.
|
|
|
|
(apply #'append (cons package-vc-selected-packages
|
|
|
|
(mapcar #'cdr package-vc--archive-spec-alist))))
|
|
|
|
'() nil #'string=))
|
2022-10-18 22:34:11 +02:00
|
|
|
|
|
|
|
(defun package-vc--read-archive-data (archive)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Update `package-vc--archive-spec-alist' for ARCHIVE.
|
2022-11-21 15:16:08 +01:00
|
|
|
This function is meant to be used as a hook for `package-read-archive-hook'."
|
2022-11-02 10:15:28 +01:00
|
|
|
(let ((contents-file (expand-file-name
|
|
|
|
(format "archives/%s/elpa-packages.eld" archive)
|
|
|
|
package-user-dir)))
|
2022-10-18 22:34:11 +02:00
|
|
|
(when (file-exists-p contents-file)
|
|
|
|
(with-temp-buffer
|
|
|
|
(let ((coding-system-for-read 'utf-8))
|
2022-10-28 19:58:05 +02:00
|
|
|
(insert-file-contents contents-file)
|
|
|
|
;; The response from the server is expected to have the form
|
|
|
|
;;
|
|
|
|
;; ((("foo" :url "..." ...) ...)
|
|
|
|
;; :version 1
|
|
|
|
;; :default-vc Git)
|
|
|
|
(let ((spec (read (current-buffer))))
|
2022-11-03 19:38:34 +01:00
|
|
|
(when (eq package-vc--elpa-packages-version
|
2022-10-30 14:07:56 +01:00
|
|
|
(plist-get (cdr spec) :version))
|
2022-11-03 19:38:34 +01:00
|
|
|
(setf (alist-get (intern archive) package-vc--archive-spec-alist)
|
2022-10-28 19:58:05 +02:00
|
|
|
(car spec)))
|
2022-11-03 19:38:34 +01:00
|
|
|
(setf (alist-get (intern archive) package-vc--archive-data-alist)
|
2022-10-28 19:58:05 +02:00
|
|
|
(cdr spec))
|
|
|
|
(when-let ((default-vc (plist-get (cdr spec) :default-vc))
|
|
|
|
((not (memq default-vc vc-handled-backends))))
|
|
|
|
(warn "Archive `%S' expects missing VC backend %S"
|
|
|
|
archive (plist-get (cdr spec) :default-vc)))))))))
|
2022-10-18 22:34:11 +02:00
|
|
|
|
|
|
|
(defun package-vc--download-and-read-archives (&optional async)
|
|
|
|
"Download specifications of all `package-archives' and read them.
|
2022-11-03 19:38:34 +01:00
|
|
|
Populate `package-vc--archive-spec-alist' with the result.
|
2022-10-18 22:34:11 +02:00
|
|
|
|
|
|
|
If optional argument ASYNC is non-nil, perform the downloads
|
|
|
|
asynchronously."
|
|
|
|
(dolist (archive package-archives)
|
2023-02-12 13:25:54 +01:00
|
|
|
(condition-case err
|
2022-10-22 00:06:02 +02:00
|
|
|
(package--download-one-archive archive "elpa-packages.eld" async)
|
2023-02-12 13:25:54 +01:00
|
|
|
(error (message "Failed to download `%s' archive: %S" (car archive) err)))))
|
2022-10-18 22:34:11 +02:00
|
|
|
|
|
|
|
(add-hook 'package-read-archive-hook #'package-vc--read-archive-data 20)
|
|
|
|
|
2022-07-31 21:32:38 +02:00
|
|
|
(defun package-vc-commit (pkg)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Return the last commit of a development package PKG."
|
2022-10-07 18:58:02 +02:00
|
|
|
(cl-assert (package-vc-p pkg))
|
2022-07-31 21:32:38 +02:00
|
|
|
;; FIXME: vc should be extended to allow querying the commit of a
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
;; directory (as is possible when dealing with git repositories).
|
2022-07-31 21:32:38 +02:00
|
|
|
;; This should be a fallback option.
|
|
|
|
(cl-loop with dir = (package-desc-dir pkg)
|
|
|
|
for file in (directory-files dir t "\\.el\\'" t)
|
|
|
|
when (vc-working-revision file) return it
|
|
|
|
finally return "unknown"))
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--version (pkg)
|
2022-11-27 15:31:29 +01:00
|
|
|
"Return the version number for the VC package PKG."
|
2022-10-07 18:58:02 +02:00
|
|
|
(cl-assert (package-vc-p pkg))
|
2022-11-03 19:38:34 +01:00
|
|
|
(if-let ((main-file (package-vc--main-file pkg)))
|
2022-11-03 19:28:47 +01:00
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents main-file)
|
|
|
|
(package-strip-rcs-id
|
|
|
|
(or (lm-header "package-version")
|
2022-12-10 09:47:42 +01:00
|
|
|
(lm-header "version")
|
|
|
|
"0")))
|
2022-11-03 19:28:47 +01:00
|
|
|
"0"))
|
2022-07-31 21:32:38 +02:00
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--main-file (pkg-desc)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Return the name of the main file for PKG-DESC."
|
2022-10-30 11:43:11 +01:00
|
|
|
(cl-assert (package-vc-p pkg-desc))
|
2022-12-10 09:43:22 +01:00
|
|
|
(let* ((pkg-spec (package-vc--desc->spec pkg-desc))
|
|
|
|
(name (symbol-name (package-desc-name pkg-desc)))
|
|
|
|
(directory (file-name-concat
|
|
|
|
(or (package-desc-dir pkg-desc)
|
|
|
|
(expand-file-name name package-user-dir))
|
2023-03-15 10:05:39 +01:00
|
|
|
(plist-get pkg-spec :lisp-dir)))
|
|
|
|
(file (expand-file-name
|
|
|
|
(or (plist-get pkg-spec :main-file)
|
|
|
|
(concat name ".el"))
|
|
|
|
directory)))
|
2022-12-10 09:43:22 +01:00
|
|
|
(if (file-exists-p file) file
|
|
|
|
;; The following heuristic is only necessary when fetching a
|
|
|
|
;; repository with URL that would break the above assumptions.
|
|
|
|
;; Concrete example: https://github.com/sachac/waveform-el does
|
|
|
|
;; not have a file waveform-el.el, but a file waveform.el, so we
|
|
|
|
;; try and find the closest match.
|
|
|
|
(let ((distance most-positive-fixnum) (best nil))
|
|
|
|
(dolist (alt (directory-files directory t "\\.el\\'" t))
|
|
|
|
(let ((sd (string-distance file alt)))
|
|
|
|
(when (and (not (string-match-p (rx (or (: "-autoloads.el")
|
|
|
|
(: "-pkg.el"))
|
|
|
|
eos)
|
|
|
|
alt))
|
|
|
|
(< sd distance))
|
|
|
|
(when (< sd distance)
|
|
|
|
(setq distance (string-distance file alt)
|
|
|
|
best alt)))))
|
|
|
|
best))))
|
2022-10-30 11:43:11 +01:00
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--generate-description-file (pkg-desc pkg-file)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Generate a package description file for PKG-DESC and write it to PKG-FILE."
|
2022-10-16 17:18:06 +02:00
|
|
|
(let ((name (package-desc-name pkg-desc)))
|
|
|
|
;; Infer the subject if missing.
|
|
|
|
(unless (package-desc-summary pkg-desc)
|
|
|
|
(setf (package-desc-summary pkg-desc)
|
2022-11-03 19:38:34 +01:00
|
|
|
(let ((main-file (package-vc--main-file pkg-desc)))
|
2022-10-30 11:43:11 +01:00
|
|
|
(or (package-desc-summary pkg-desc)
|
|
|
|
(and-let* ((pkg (cadr (assq name package-archive-contents))))
|
|
|
|
(package-desc-summary pkg))
|
|
|
|
(and main-file (file-exists-p main-file)
|
|
|
|
(lm-summary main-file))
|
|
|
|
package--default-summary))))
|
2022-07-31 21:32:38 +02:00
|
|
|
(let ((print-level nil)
|
|
|
|
(print-quoted t)
|
|
|
|
(print-length nil))
|
|
|
|
(write-region
|
|
|
|
(concat
|
|
|
|
";;; Generated package description from "
|
|
|
|
(replace-regexp-in-string
|
|
|
|
"-pkg\\.el\\'" ".el"
|
|
|
|
(file-name-nondirectory pkg-file))
|
|
|
|
" -*- no-byte-compile: t -*-\n"
|
|
|
|
(prin1-to-string
|
|
|
|
(nconc
|
|
|
|
(list 'define-package
|
|
|
|
(symbol-name name)
|
2022-11-20 15:36:24 +01:00
|
|
|
(package-vc--version pkg-desc)
|
2022-07-31 21:32:38 +02:00
|
|
|
(package-desc-summary pkg-desc)
|
|
|
|
(let ((requires (package-desc-reqs pkg-desc)))
|
|
|
|
(list 'quote
|
|
|
|
;; Turn version lists into string form.
|
|
|
|
(mapcar
|
|
|
|
(lambda (elt)
|
|
|
|
(list (car elt)
|
|
|
|
(package-version-join (cadr elt))))
|
|
|
|
requires))))
|
2022-11-20 15:36:24 +01:00
|
|
|
(list :kind 'vc)
|
2022-07-31 21:32:38 +02:00
|
|
|
(package--alist-to-plist-args
|
|
|
|
(package-desc-extras pkg-desc))))
|
|
|
|
"\n")
|
|
|
|
nil pkg-file nil 'silent))))
|
|
|
|
|
2022-10-20 21:34:48 +02:00
|
|
|
(declare-function org-export-to-file "ox" (backend file))
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--build-documentation (pkg-desc file)
|
2022-11-06 12:12:23 +01:00
|
|
|
"Build documentation for package PKG-DESC from documentation source in FILE.
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
FILE can be an Org file, indicated by its \".org\" extension,
|
|
|
|
otherwise it's assumed to be an Info file."
|
2022-11-06 21:53:32 +01:00
|
|
|
(let* ((pkg-name (package-desc-name pkg-desc))
|
2022-11-11 00:09:46 +01:00
|
|
|
(default-directory (package-desc-dir pkg-desc))
|
2022-11-15 13:27:59 +01:00
|
|
|
(output (expand-file-name (format "%s.info" pkg-name)))
|
|
|
|
clean-up)
|
2022-10-20 21:34:48 +02:00
|
|
|
(when (string-match-p "\\.org\\'" file)
|
|
|
|
(require 'ox)
|
|
|
|
(require 'ox-texinfo)
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents file)
|
|
|
|
(setq file (make-temp-file "ox-texinfo-"))
|
2022-11-15 13:27:59 +01:00
|
|
|
(org-export-to-file 'texinfo file)
|
|
|
|
(setq clean-up t)))
|
2022-11-11 00:09:46 +01:00
|
|
|
(with-current-buffer (get-buffer-create " *package-vc doc*")
|
|
|
|
(erase-buffer)
|
|
|
|
(cond
|
|
|
|
((/= 0 (call-process "makeinfo" nil t nil
|
|
|
|
"--no-split" file "-o" output))
|
|
|
|
(message "Failed to build manual %s, see buffer %S"
|
|
|
|
file (buffer-name)))
|
|
|
|
((/= 0 (call-process "install-info" nil t nil
|
|
|
|
output (expand-file-name "dir")))
|
|
|
|
(message "Failed to install manual %s, see buffer %S"
|
|
|
|
output (buffer-name)))
|
2022-11-15 13:27:59 +01:00
|
|
|
((kill-buffer))))
|
|
|
|
(when clean-up
|
|
|
|
(delete-file file))))
|
2022-10-20 21:34:48 +02:00
|
|
|
|
2022-12-25 09:35:36 +01:00
|
|
|
(defun package-vc-install-dependencies (requirements)
|
|
|
|
"Install missing dependencies, and return missing ones.
|
|
|
|
The return value will be nil if everything was found, or a list
|
|
|
|
of (NAME VERSION) pairs of all packages that couldn't be found.
|
|
|
|
|
|
|
|
REQUIREMENTS should be a list of additional requirements; each
|
|
|
|
element in this list should have the form (PACKAGE VERSION-LIST),
|
|
|
|
where PACKAGE is a package name and VERSION-LIST is the required
|
|
|
|
version of that package."
|
|
|
|
(let ((to-install '()) (missing '()))
|
|
|
|
(cl-labels ((search (pkg)
|
|
|
|
"Attempt to find all dependencies for PKG."
|
|
|
|
(cond
|
|
|
|
((assq (car pkg) to-install)) ;inhibit cycles
|
|
|
|
((package-installed-p (car pkg)))
|
|
|
|
((let* ((pac package-archive-contents)
|
|
|
|
(desc (cadr (assoc (car pkg) pac))))
|
|
|
|
(if desc
|
2023-02-12 13:10:04 +01:00
|
|
|
(let ((reqs (package-desc-reqs desc)))
|
|
|
|
(push desc to-install)
|
2022-12-25 09:35:36 +01:00
|
|
|
(mapc #'search reqs))
|
|
|
|
(push pkg missing))))))
|
|
|
|
(version-order (a b)
|
|
|
|
"Predicate to sort packages in order."
|
2023-02-14 19:48:01 +01:00
|
|
|
(version-list-<
|
|
|
|
(package-desc-version b)
|
|
|
|
(package-desc-version a)))
|
2022-12-25 09:35:36 +01:00
|
|
|
(duplicate-p (a b)
|
|
|
|
"Are A and B the same package?"
|
2023-02-16 11:38:51 +01:00
|
|
|
(eq (package-desc-name a) (package-desc-name b)))
|
2022-12-25 09:35:36 +01:00
|
|
|
(depends-on-p (target package)
|
|
|
|
"Does PACKAGE depend on TARGET?"
|
|
|
|
(or (eq target package)
|
|
|
|
(let* ((pac package-archive-contents)
|
|
|
|
(desc (cadr (assoc package pac))))
|
2023-02-14 19:48:01 +01:00
|
|
|
(and desc (seq-some
|
|
|
|
(apply-partially #'depends-on-p target)
|
|
|
|
(package-desc-reqs desc))))))
|
2022-12-25 09:35:36 +01:00
|
|
|
(dependent-order (a b)
|
2023-02-14 19:48:01 +01:00
|
|
|
(let ((desc-a (package-desc-name a))
|
|
|
|
(desc-b (package-desc-name b)))
|
|
|
|
(or (not desc-a) (not desc-b)
|
|
|
|
(not (depends-on-p desc-b desc-a))
|
|
|
|
(depends-on-p desc-a desc-b)))))
|
2022-12-25 09:35:36 +01:00
|
|
|
(mapc #'search requirements)
|
|
|
|
(cl-callf sort to-install #'version-order)
|
2023-02-16 11:38:51 +01:00
|
|
|
(cl-callf seq-uniq to-install #'duplicate-p)
|
2022-12-25 09:35:36 +01:00
|
|
|
(cl-callf sort to-install #'dependent-order))
|
|
|
|
(mapc #'package-install-from-archive to-install)
|
|
|
|
missing))
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--unpack-1 (pkg-desc pkg-dir)
|
2022-11-06 13:16:50 +01:00
|
|
|
"Prepare PKG-DESC that is already checked-out in PKG-DIR.
|
|
|
|
This includes downloading missing dependencies, generating
|
|
|
|
autoloads, generating a package description file (used to
|
2022-11-27 15:31:29 +01:00
|
|
|
identify a package as a VC package later on), building
|
2022-11-06 13:16:50 +01:00
|
|
|
documentation and marking the package as installed."
|
2022-12-25 09:35:36 +01:00
|
|
|
(let (missing)
|
|
|
|
;; Remove any previous instance of PKG-DESC from `package-alist'
|
|
|
|
(let ((pkgs (assq (package-desc-name pkg-desc) package-alist)))
|
|
|
|
(when pkgs
|
|
|
|
(setf (cdr pkgs) (seq-remove #'package-vc-p (cdr pkgs)))))
|
|
|
|
|
|
|
|
;; In case the package was installed directly from source, the
|
|
|
|
;; dependency list wasn't know beforehand, and they might have
|
|
|
|
;; to be installed explicitly.
|
|
|
|
(let ((deps '()))
|
|
|
|
(dolist (file (directory-files pkg-dir t "\\.el\\'" t))
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents file)
|
|
|
|
(when-let* ((require-lines (lm-header-multiline "package-requires")))
|
|
|
|
(thread-last
|
|
|
|
(mapconcat #'identity require-lines " ")
|
|
|
|
package-read-from-string
|
|
|
|
package--prepare-dependencies
|
|
|
|
(nconc deps)
|
|
|
|
(setq deps)))))
|
|
|
|
(dolist (dep deps)
|
|
|
|
(cl-callf version-to-list (cadr dep)))
|
|
|
|
(setf missing (package-vc-install-dependencies (delete-dups deps)))
|
|
|
|
(setf missing (delq (assq (package-desc-name pkg-desc)
|
|
|
|
missing)
|
|
|
|
missing)))
|
|
|
|
|
|
|
|
(let ((default-directory (file-name-as-directory pkg-dir))
|
2023-03-15 10:05:39 +01:00
|
|
|
(pkg-file (expand-file-name (package--description-file pkg-dir) pkg-dir))
|
|
|
|
(pkg-spec (package-vc--desc->spec pkg-desc)))
|
2022-12-25 09:35:36 +01:00
|
|
|
;; Generate autoloads
|
|
|
|
(let* ((name (package-desc-name pkg-desc))
|
|
|
|
(auto-name (format "%s-autoloads.el" name))
|
2023-03-15 10:05:39 +01:00
|
|
|
(lisp-dir (plist-get pkg-spec :lisp-dir)))
|
2022-12-25 09:35:36 +01:00
|
|
|
(package-generate-autoloads
|
|
|
|
name (file-name-concat pkg-dir lisp-dir))
|
|
|
|
(when lisp-dir
|
|
|
|
(write-region
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert ";; Autoload indirection for package-vc\n\n")
|
|
|
|
(prin1 `(load (expand-file-name
|
|
|
|
,(file-name-concat lisp-dir auto-name)
|
|
|
|
(or (and load-file-name
|
|
|
|
(file-name-directory load-file-name))
|
|
|
|
(car load-path))))
|
|
|
|
(current-buffer))
|
|
|
|
(buffer-string))
|
|
|
|
nil (expand-file-name auto-name pkg-dir))))
|
|
|
|
|
|
|
|
;; Generate package file
|
|
|
|
(package-vc--generate-description-file pkg-desc pkg-file)
|
|
|
|
|
|
|
|
;; Detect a manual
|
2023-03-15 10:05:39 +01:00
|
|
|
(when (executable-find "install-info")
|
2022-12-25 09:35:36 +01:00
|
|
|
(dolist (doc-file (ensure-list (plist-get pkg-spec :doc)))
|
|
|
|
(package-vc--build-documentation pkg-desc doc-file))))
|
|
|
|
|
|
|
|
;; Update package-alist.
|
|
|
|
(let ((new-desc (package-load-descriptor pkg-dir)))
|
|
|
|
;; Activation has to be done before compilation, so that if we're
|
|
|
|
;; upgrading and macros have changed we load the new definitions
|
|
|
|
;; before compiling.
|
|
|
|
(when (package-activate-1 new-desc :reload :deps)
|
|
|
|
;; FIXME: Compilation should be done as a separate, optional, step.
|
|
|
|
;; E.g. for multi-package installs, we should first install all packages
|
|
|
|
;; and then compile them.
|
|
|
|
(package--compile new-desc)
|
|
|
|
(when package-native-compile
|
|
|
|
(package--native-compile-async new-desc))
|
|
|
|
;; After compilation, load again any files loaded by
|
|
|
|
;; `activate-1', so that we use the byte-compiled definitions.
|
|
|
|
(package--reload-previously-loaded new-desc)))
|
|
|
|
|
|
|
|
;; Mark package as selected
|
|
|
|
(package--save-selected-packages
|
|
|
|
(cons (package-desc-name pkg-desc)
|
|
|
|
package-selected-packages))
|
|
|
|
(package--quickstart-maybe-refresh)
|
|
|
|
|
|
|
|
;; Confirm that the installation was successful
|
|
|
|
(let ((main-file (package-vc--main-file pkg-desc)))
|
|
|
|
(message "VC package `%s' installed (Version %s, Revision %S).%s"
|
|
|
|
(package-desc-name pkg-desc)
|
|
|
|
(lm-with-file main-file
|
|
|
|
(package-strip-rcs-id
|
|
|
|
(or (lm-header "package-version")
|
|
|
|
(lm-header "version"))))
|
|
|
|
(vc-working-revision main-file)
|
|
|
|
(if missing
|
|
|
|
(format
|
|
|
|
" Failed to install the following dependencies: %s"
|
|
|
|
(mapconcat
|
|
|
|
(lambda (p)
|
|
|
|
(format "%s (%s)" (car p) (cadr p)))
|
|
|
|
missing ", "))
|
|
|
|
"")))
|
|
|
|
t))
|
2022-10-12 16:09:25 +02:00
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--guess-backend (url)
|
2022-10-23 18:41:36 +02:00
|
|
|
"Guess the VC backend for URL.
|
|
|
|
This function will internally query `package-vc-heuristic-alist'
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
and return nil if it cannot reasonably guess."
|
2022-10-23 18:41:36 +02:00
|
|
|
(and url (alist-get url package-vc-heuristic-alist
|
|
|
|
nil nil #'string-match-p)))
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--clone (pkg-desc pkg-spec dir rev)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Clone the package PKG-DESC whose spec is PKG-SPEC into the directory DIR.
|
|
|
|
REV specifies a specific revision to checkout. This overrides the `:branch'
|
|
|
|
attribute in PKG-SPEC."
|
2022-11-03 19:26:21 +01:00
|
|
|
(pcase-let* ((name (package-desc-name pkg-desc))
|
|
|
|
((map :url :branch) pkg-spec))
|
|
|
|
|
|
|
|
;; Clone the repository into `repo-dir' if necessary
|
|
|
|
(unless (file-exists-p dir)
|
|
|
|
(make-directory (file-name-directory dir) t)
|
|
|
|
(let ((backend (or (plist-get pkg-spec :vc-backend)
|
2022-11-03 19:38:34 +01:00
|
|
|
(package-vc--guess-backend url)
|
2022-11-03 19:26:21 +01:00
|
|
|
(plist-get (alist-get (package-desc-archive pkg-desc)
|
2022-11-03 19:38:34 +01:00
|
|
|
package-vc--archive-data-alist
|
2022-11-03 19:26:21 +01:00
|
|
|
nil nil #'string=)
|
|
|
|
:vc-backend)
|
|
|
|
package-vc-default-backend)))
|
|
|
|
(unless (vc-clone url backend dir
|
|
|
|
(or (and (not (eq rev :last-release)) rev) branch))
|
|
|
|
(error "Failed to clone %s from %s" name url))))
|
|
|
|
|
|
|
|
;; Check out the latest release if requested
|
|
|
|
(when (eq rev :last-release)
|
2022-11-03 19:38:34 +01:00
|
|
|
(if-let ((release-rev (package-vc--release-rev pkg-desc)))
|
2022-11-03 19:26:21 +01:00
|
|
|
(vc-retrieve-tag dir release-rev)
|
|
|
|
(message "No release revision was found, continuing...")))))
|
|
|
|
|
2023-02-16 11:11:23 +01:00
|
|
|
(defvar package-vc-non-code-file-names
|
|
|
|
'(".dir-locals.el" ".dir-locals-2.el")
|
|
|
|
"List of file names that do not contain Emacs Lisp code.
|
|
|
|
This list is used by `package-vc--unpack' to better check if the
|
|
|
|
user is fetching code from a repository that does not contain any
|
|
|
|
Emacs Lisp files.")
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--unpack (pkg-desc pkg-spec &optional rev)
|
2022-10-18 22:34:11 +02:00
|
|
|
"Install the package described by PKG-DESC.
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
PKG-SPEC is a package specification, a property list describing
|
|
|
|
how to fetch and build the package. See `package-vc--archive-spec-alist'
|
|
|
|
for details. The optional argument REV specifies a specific revision to
|
|
|
|
checkout. This overrides the `:branch' attribute in PKG-SPEC."
|
2023-02-22 15:23:43 +01:00
|
|
|
(unless (eq (package-desc-kind pkg-desc) 'vc)
|
|
|
|
(let ((copy (copy-package-desc pkg-desc)))
|
|
|
|
(setf (package-desc-kind copy) 'vc
|
|
|
|
pkg-desc copy)))
|
2022-11-10 21:55:30 +01:00
|
|
|
(pcase-let* (((map :lisp-dir) pkg-spec)
|
2022-11-03 19:26:21 +01:00
|
|
|
(name (package-desc-name pkg-desc))
|
|
|
|
(dirname (package-desc-full-name pkg-desc))
|
2023-02-14 19:49:51 +01:00
|
|
|
(pkg-dir (file-name-as-directory (expand-file-name dirname package-user-dir))))
|
2023-01-11 09:27:01 +01:00
|
|
|
(when (string-empty-p name)
|
|
|
|
(user-error "Empty package name"))
|
2022-07-31 21:32:38 +02:00
|
|
|
(setf (package-desc-dir pkg-desc) pkg-dir)
|
|
|
|
(when (file-exists-p pkg-dir)
|
2022-11-25 00:06:37 +07:00
|
|
|
(if (yes-or-no-p (format "Overwrite previous checkout for package `%s'?" name))
|
2022-11-08 23:45:35 +01:00
|
|
|
(package--delete-directory pkg-dir)
|
2022-07-31 21:32:38 +02:00
|
|
|
(error "There already exists a checkout for %s" name)))
|
2022-11-08 23:45:35 +01:00
|
|
|
(package-vc--clone pkg-desc pkg-spec pkg-dir rev)
|
2023-02-14 19:49:51 +01:00
|
|
|
(when (directory-empty-p pkg-dir)
|
|
|
|
(delete-directory pkg-dir)
|
|
|
|
(error "Empty checkout for %s" name))
|
2023-02-16 11:11:23 +01:00
|
|
|
(unless (seq-remove
|
|
|
|
(lambda (file)
|
|
|
|
(member (file-name-nondirectory file) package-vc-non-code-file-names))
|
|
|
|
(directory-files-recursively pkg-dir "\\.el\\'" nil))
|
|
|
|
(when (yes-or-no-p (format "No Emacs Lisp files found when fetching \"%s\", \
|
|
|
|
abort installation?" name))
|
|
|
|
(delete-directory pkg-dir t)
|
|
|
|
(user-error "Installation aborted")))
|
2022-11-03 19:26:21 +01:00
|
|
|
|
2022-12-25 11:18:51 +01:00
|
|
|
;; When nothing is specified about a `lisp-dir', then should
|
|
|
|
;; heuristically check if there is a sub-directory with lisp
|
2022-12-27 20:28:05 +01:00
|
|
|
;; files. These are conventionally just called "lisp" or "src".
|
|
|
|
;; If this directory exists and contains non-zero number of lisp
|
|
|
|
;; files, we will use that instead of `pkg-dir'.
|
|
|
|
(catch 'done
|
|
|
|
(dolist (name '("lisp" "src"))
|
|
|
|
(when-let* (((null lisp-dir))
|
|
|
|
(dir (expand-file-name name pkg-dir))
|
|
|
|
((file-directory-p dir))
|
|
|
|
((directory-files dir nil "\\`[^.].+\\.el\\'" t 1)))
|
|
|
|
;; We won't use `dir', since dir is an absolute path and we
|
|
|
|
;; don't want `lisp-dir' to depend on the current location of
|
|
|
|
;; the package installation, ie. to break if moved around the
|
|
|
|
;; file system or between installations.
|
|
|
|
(throw 'done (setq lisp-dir name)))))
|
|
|
|
|
2023-03-15 09:51:14 +01:00
|
|
|
;; Ensure we have a copy of the package specification
|
|
|
|
(unless (equal (alist-get name (mapcar #'cdr package-vc--archive-spec-alist)) pkg-spec)
|
|
|
|
(customize-save-variable
|
|
|
|
'package-vc-selected-packages
|
|
|
|
(cons (cons name pkg-spec)
|
|
|
|
(seq-remove (lambda (spec) (string= name (car spec)))
|
|
|
|
package-vc-selected-packages))))
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(package-vc--unpack-1 pkg-desc pkg-dir)))
|
2022-07-31 21:32:38 +02:00
|
|
|
|
2022-11-06 10:24:56 +01:00
|
|
|
(defun package-vc--read-package-name (prompt &optional allow-url installed)
|
2022-11-27 15:31:29 +01:00
|
|
|
"Query the user for a VC package and return a name with PROMPT.
|
2022-11-06 10:24:56 +01:00
|
|
|
If the optional argument ALLOW-URL is non-nil, the user is also
|
|
|
|
allowed to specify a non-package name. If the optional argument
|
|
|
|
INSTALLED is non-nil, the selection will be filtered down to
|
2022-11-27 15:31:29 +01:00
|
|
|
VC packages that have already been installed."
|
2022-11-06 10:24:56 +01:00
|
|
|
(package-vc--archives-initialize)
|
|
|
|
(completing-read prompt (if installed package-alist package-archive-contents)
|
|
|
|
(if installed
|
|
|
|
(lambda (pkg) (package-vc-p (cadr pkg)))
|
|
|
|
(lambda (pkg)
|
|
|
|
(or (package-vc--desc->spec (cadr pkg))
|
|
|
|
;; If we have no explicit VC data, we can try a kind of
|
|
|
|
;; heuristic and use the URL header, that might already be
|
|
|
|
;; pointing towards a repository, and use that as a backup
|
|
|
|
(and-let* ((extras (package-desc-extras (cadr pkg)))
|
|
|
|
(url (alist-get :url extras))
|
|
|
|
((package-vc--guess-backend url)))))))
|
2022-11-10 19:18:00 +01:00
|
|
|
(not allow-url)))
|
2022-11-06 10:24:56 +01:00
|
|
|
|
|
|
|
(defun package-vc--read-package-desc (prompt &optional installed)
|
2022-11-27 15:31:29 +01:00
|
|
|
"Query the user for a VC package and return a description with PROMPT.
|
2022-11-06 10:24:56 +01:00
|
|
|
If the optional argument INSTALLED is non-nil, the selection will
|
2022-11-27 15:31:29 +01:00
|
|
|
be filtered down to VC packages that have already been
|
2022-11-06 10:24:56 +01:00
|
|
|
installed, and the package description will be that of an
|
|
|
|
installed package."
|
|
|
|
(cadr (assoc (package-vc--read-package-name prompt nil installed)
|
|
|
|
(if installed package-alist package-archive-contents)
|
|
|
|
#'string=)))
|
2022-08-11 10:53:11 +02:00
|
|
|
|
2022-11-17 17:39:46 +01:00
|
|
|
;;;###autoload
|
2022-11-13 08:12:18 +01:00
|
|
|
(defun package-vc-update-all ()
|
|
|
|
"Attempt to update all installed VC packages."
|
|
|
|
(interactive)
|
|
|
|
(dolist (package package-alist)
|
|
|
|
(dolist (pkg-desc (cdr package))
|
|
|
|
(when (package-vc-p pkg-desc)
|
|
|
|
(package-vc-update pkg-desc))))
|
|
|
|
(message "Done updating packages."))
|
|
|
|
|
2022-11-17 17:39:46 +01:00
|
|
|
;;;###autoload
|
2022-08-11 13:23:51 +02:00
|
|
|
(defun package-vc-update (pkg-desc)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Attempt to update the package PKG-DESC."
|
2022-11-27 15:31:29 +01:00
|
|
|
(interactive (list (package-vc--read-package-desc "Update VC package: " t)))
|
2022-11-03 19:38:34 +01:00
|
|
|
;; HACK: To run `package-vc--unpack-1' after checking out the new
|
2022-11-01 16:35:23 +01:00
|
|
|
;; revision, we insert a hook into `vc-post-command-functions', and
|
|
|
|
;; remove it right after it ran. To avoid running the hook multiple
|
|
|
|
;; times or even for the wrong repository (as `vc-pull' is often
|
|
|
|
;; asynchronous), we extract the relevant arguments using a pseudo
|
|
|
|
;; filter for `vc-filter-command-function', executed only for the
|
|
|
|
;; side effect, and store them in the lexical scope. When the hook
|
|
|
|
;; is run, we check if the arguments are the same (`eq') as the ones
|
|
|
|
;; previously extracted, and only in that case will be call
|
2022-11-03 19:38:34 +01:00
|
|
|
;; `package-vc--unpack-1'. Ugh...
|
2022-11-01 16:35:23 +01:00
|
|
|
;;
|
|
|
|
;; If there is a better way to do this, it should be done.
|
2022-11-13 08:12:18 +01:00
|
|
|
(cl-assert (package-vc-p pkg-desc))
|
2022-11-01 16:35:23 +01:00
|
|
|
(letrec ((pkg-dir (package-desc-dir pkg-desc))
|
2022-11-15 10:20:01 +01:00
|
|
|
(vc-flags)
|
2022-11-01 16:35:23 +01:00
|
|
|
(vc-filter-command-function
|
|
|
|
(lambda (command file-or-list flags)
|
2022-11-15 10:20:01 +01:00
|
|
|
(setq vc-flags flags)
|
2022-11-01 16:35:23 +01:00
|
|
|
(list command file-or-list flags)))
|
|
|
|
(post-upgrade
|
2022-11-15 10:20:01 +01:00
|
|
|
(lambda (_command _file-or-list flags)
|
|
|
|
(when (and (file-equal-p pkg-dir default-directory)
|
|
|
|
(eq flags vc-flags))
|
|
|
|
(unwind-protect
|
|
|
|
(with-demoted-errors "Failed to activate: %S"
|
|
|
|
(package-vc--unpack-1 pkg-desc pkg-dir))
|
|
|
|
(remove-hook 'vc-post-command-functions post-upgrade))))))
|
2022-11-01 16:35:23 +01:00
|
|
|
(add-hook 'vc-post-command-functions post-upgrade)
|
|
|
|
(with-demoted-errors "Failed to fetch: %S"
|
2022-11-15 10:20:01 +01:00
|
|
|
(let ((default-directory pkg-dir))
|
|
|
|
(vc-pull)))))
|
2022-10-12 20:26:17 +02:00
|
|
|
|
2022-10-28 20:10:30 +02:00
|
|
|
(defun package-vc--archives-initialize ()
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Initialize package.el and fetch package specifications."
|
2022-10-28 20:10:30 +02:00
|
|
|
(package--archives-initialize)
|
2022-11-03 19:38:34 +01:00
|
|
|
(unless package-vc--archive-data-alist
|
2022-10-28 20:10:30 +02:00
|
|
|
(package-vc--download-and-read-archives)))
|
|
|
|
|
2022-11-03 19:38:34 +01:00
|
|
|
(defun package-vc--release-rev (pkg-desc)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Return the latest revision that bumps the \"Version\" tag for PKG-DESC.
|
2022-10-30 11:43:11 +01:00
|
|
|
If no such revision can be found, return nil."
|
2022-11-03 19:38:34 +01:00
|
|
|
(with-current-buffer (find-file-noselect (package-vc--main-file pkg-desc))
|
2022-10-30 11:43:11 +01:00
|
|
|
(vc-buffer-sync)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(let ((case-fold-search t))
|
2022-10-30 14:43:10 +01:00
|
|
|
(when (cond
|
|
|
|
((re-search-forward
|
|
|
|
(concat (lm-get-header-re "package-version") ".*$")
|
|
|
|
(lm-code-start) t))
|
|
|
|
((re-search-forward
|
|
|
|
(concat (lm-get-header-re "version") ".*$")
|
|
|
|
(lm-code-start) t)))
|
2022-10-30 11:43:11 +01:00
|
|
|
(ignore-error vc-not-supported
|
|
|
|
(vc-call-backend (vc-backend (buffer-file-name))
|
|
|
|
'last-change
|
2022-10-30 16:52:08 +01:00
|
|
|
(buffer-file-name)
|
|
|
|
(line-number-at-pos nil t))))))))
|
2022-10-30 11:43:11 +01:00
|
|
|
|
2022-08-12 17:02:20 +02:00
|
|
|
;;;###autoload
|
2022-12-25 09:53:07 +01:00
|
|
|
(defun package-vc-install (package &optional rev backend name)
|
2022-11-15 20:05:33 +01:00
|
|
|
"Fetch a PACKAGE and set it up for using with Emacs.
|
|
|
|
|
|
|
|
If PACKAGE is a string containing an URL, download the package
|
|
|
|
from the repository at that URL; the function will try to guess
|
|
|
|
the name of the package from the URL. This can be overridden by
|
|
|
|
passing the optional argument NAME. If PACKAGE is a cons-cell,
|
|
|
|
it should have the form (NAME . SPEC), where NAME is a symbol
|
|
|
|
indicating the package name and SPEC is a plist as described in
|
|
|
|
`package-vc-selected-packages'. Otherwise PACKAGE should be a
|
|
|
|
symbol whose name is the package name, and the URL for the
|
|
|
|
package will be taken from the package's metadata.
|
|
|
|
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
By default, this function installs the last version of the package
|
|
|
|
available from its repository, but if REV is given and non-nil, it
|
|
|
|
specifies the revision to install. If REV has the special value
|
|
|
|
`:last-release' (interactively, the prefix argument), that stands
|
|
|
|
for the last released version of the package.
|
2022-11-15 20:05:33 +01:00
|
|
|
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
Optional argument BACKEND specifies the VC backend to use for cloning
|
|
|
|
the package's repository; this is only possible if NAME-OR-URL is a URL,
|
|
|
|
a string. If BACKEND is omitted or nil, the function
|
2022-11-13 08:18:49 +01:00
|
|
|
uses `package-vc-heuristic-alist' to guess the backend.
|
2022-11-27 15:31:29 +01:00
|
|
|
Note that by default, a VC package will be prioritized over a
|
2022-12-25 09:53:07 +01:00
|
|
|
regular package, but it will not remove a VC package.
|
|
|
|
|
|
|
|
\(fn PACKAGE &optional REV BACKEND)"
|
2022-07-31 21:32:38 +02:00
|
|
|
(interactive
|
|
|
|
(progn
|
|
|
|
;; Initialize the package system to get the list of package
|
|
|
|
;; symbols for completion.
|
2022-10-28 20:10:30 +02:00
|
|
|
(package-vc--archives-initialize)
|
2022-11-06 10:24:56 +01:00
|
|
|
(let* ((name-or-url (package-vc--read-package-name
|
|
|
|
"Fetch and install package: " t))
|
2023-01-11 09:27:01 +01:00
|
|
|
(name (file-name-base (directory-file-name name-or-url))))
|
|
|
|
(when (string-empty-p name)
|
|
|
|
(user-error "Empty package name"))
|
2022-12-25 09:53:07 +01:00
|
|
|
(list name-or-url
|
|
|
|
(and current-prefix-arg :last-release)
|
|
|
|
nil
|
|
|
|
(intern (string-remove-prefix "emacs-" name))))))
|
2022-10-28 20:10:30 +02:00
|
|
|
(package-vc--archives-initialize)
|
2022-10-18 22:34:11 +02:00
|
|
|
(cond
|
2022-11-15 20:05:33 +01:00
|
|
|
((null package)
|
2022-11-12 09:18:19 +01:00
|
|
|
(signal 'wrong-type-argument nil))
|
2022-11-15 20:05:33 +01:00
|
|
|
((consp package)
|
|
|
|
(package-vc--unpack
|
|
|
|
(package-desc-create :name (car package)
|
|
|
|
:kind 'vc)
|
|
|
|
(cdr package)
|
|
|
|
rev))
|
|
|
|
((and-let* (((stringp package))
|
|
|
|
(backend (or backend (package-vc--guess-backend package))))
|
2022-11-03 19:38:34 +01:00
|
|
|
(package-vc--unpack
|
2022-07-31 21:32:38 +02:00
|
|
|
(package-desc-create
|
2022-11-15 20:05:33 +01:00
|
|
|
:name (or name (intern (file-name-base package)))
|
2022-10-18 22:34:11 +02:00
|
|
|
:kind 'vc)
|
2022-11-15 20:05:33 +01:00
|
|
|
(list :vc-backend backend :url package)
|
2022-10-18 22:34:11 +02:00
|
|
|
rev)))
|
2022-11-15 20:05:33 +01:00
|
|
|
((and-let* ((desc (assoc package package-archive-contents #'string=)))
|
2022-11-03 19:38:34 +01:00
|
|
|
(package-vc--unpack
|
2023-02-22 15:23:43 +01:00
|
|
|
(cadr desc)
|
2022-11-03 19:38:34 +01:00
|
|
|
(or (package-vc--desc->spec (cadr desc))
|
2022-10-30 11:43:11 +01:00
|
|
|
(and-let* ((extras (package-desc-extras (cadr desc)))
|
|
|
|
(url (alist-get :url extras))
|
2022-11-03 19:38:34 +01:00
|
|
|
(backend (package-vc--guess-backend url)))
|
2022-10-30 11:43:11 +01:00
|
|
|
(list :vc-backend backend :url url))
|
2022-11-15 20:05:33 +01:00
|
|
|
(user-error "Package `%s' has no VC data" package))
|
2022-10-18 22:34:11 +02:00
|
|
|
rev)))
|
2022-11-15 20:05:33 +01:00
|
|
|
((user-error "Unknown package to fetch: %s" package))))
|
2022-07-31 21:32:38 +02:00
|
|
|
|
2022-11-03 23:15:12 +01:00
|
|
|
;;;###autoload
|
2022-11-03 19:26:21 +01:00
|
|
|
(defun package-vc-checkout (pkg-desc directory &optional rev)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Clone the sources for PKG-DESC into DIRECTORY and visit that directory.
|
|
|
|
Unlike `package-vc-install', this does not yet set up the package
|
2022-12-09 19:49:44 +01:00
|
|
|
for use with Emacs; use `package-vc-install-from-checkout' for
|
|
|
|
setting the package up after this function finishes. Optional
|
|
|
|
argument REV means to clone a specific version of the package; it
|
|
|
|
defaults to the last version available from the package's
|
|
|
|
repository. If REV has the special value
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
`:last-release' (interactively, the prefix argument), that stands
|
|
|
|
for the last released version of the package."
|
2022-11-03 19:26:21 +01:00
|
|
|
(interactive
|
2022-11-06 10:24:56 +01:00
|
|
|
(let* ((name (package-vc--read-package-name "Fetch package source: ")))
|
|
|
|
(list (cadr (assoc name package-archive-contents #'string=))
|
|
|
|
(read-file-name "Clone into new or empty directory: " nil nil t nil
|
|
|
|
(lambda (dir) (or (not (file-exists-p dir))
|
|
|
|
(directory-empty-p dir))))
|
|
|
|
(and current-prefix-arg :last-release))))
|
2022-11-03 19:26:21 +01:00
|
|
|
(package-vc--archives-initialize)
|
2022-11-03 19:38:34 +01:00
|
|
|
(let ((pkg-spec (or (package-vc--desc->spec pkg-desc)
|
2022-11-03 19:26:21 +01:00
|
|
|
(and-let* ((extras (package-desc-extras pkg-desc))
|
|
|
|
(url (alist-get :url extras))
|
2022-11-03 19:38:34 +01:00
|
|
|
(backend (package-vc--guess-backend url)))
|
2022-11-03 19:26:21 +01:00
|
|
|
(list :vc-backend backend :url url))
|
2022-11-13 08:17:07 +01:00
|
|
|
(user-error "Package `%s' has no VC data"
|
|
|
|
(package-desc-name pkg-desc)))))
|
2022-11-03 19:38:34 +01:00
|
|
|
(package-vc--clone pkg-desc pkg-spec directory rev)
|
2022-11-03 19:26:21 +01:00
|
|
|
(find-file directory)))
|
|
|
|
|
2022-11-03 23:15:12 +01:00
|
|
|
;;;###autoload
|
2022-11-05 16:31:16 +01:00
|
|
|
(defun package-vc-install-from-checkout (dir name)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Set up the package NAME in DIR by linking it into the ELPA directory.
|
|
|
|
Interactively, prompt the user for DIR, which should be a directory
|
|
|
|
under version control, typically one created by `package-vc-checkout'.
|
|
|
|
If invoked interactively with a prefix argument, prompt the user
|
|
|
|
for the NAME of the package to set up. Otherwise infer the package
|
|
|
|
name from the base name of DIR."
|
2022-10-12 21:25:54 +02:00
|
|
|
(interactive (let ((dir (read-directory-name "Directory: ")))
|
|
|
|
(list dir
|
|
|
|
(if current-prefix-arg
|
|
|
|
(read-string "Package name: ")
|
|
|
|
(file-name-base (directory-file-name dir))))))
|
2022-10-12 16:09:25 +02:00
|
|
|
(unless (vc-responsible-backend dir)
|
|
|
|
(user-error "Directory %S is not under version control" dir))
|
2022-10-28 20:10:30 +02:00
|
|
|
(package-vc--archives-initialize)
|
2022-10-20 21:45:17 +02:00
|
|
|
(let* ((name (or name (file-name-base (directory-file-name dir))))
|
2022-10-12 16:09:25 +02:00
|
|
|
(pkg-dir (expand-file-name name package-user-dir)))
|
2022-12-09 19:54:25 +01:00
|
|
|
(when (file-exists-p pkg-dir)
|
|
|
|
(if (yes-or-no-p (format "Overwrite previous checkout for package `%s'?" name))
|
|
|
|
(package--delete-directory pkg-dir)
|
|
|
|
(error "There already exists a checkout for %s" name)))
|
2022-11-16 10:28:14 +01:00
|
|
|
(make-symbolic-link (expand-file-name dir) pkg-dir)
|
|
|
|
(package-vc--unpack-1
|
|
|
|
(package-desc-create
|
|
|
|
:name (intern name)
|
2022-12-15 18:21:24 +01:00
|
|
|
:dir pkg-dir
|
2022-11-16 10:28:14 +01:00
|
|
|
:kind 'vc)
|
|
|
|
(file-name-as-directory pkg-dir))))
|
2022-10-12 16:09:25 +02:00
|
|
|
|
2022-11-03 23:15:12 +01:00
|
|
|
;;;###autoload
|
2022-11-13 00:59:35 +01:00
|
|
|
(defun package-vc-rebuild (pkg-desc)
|
|
|
|
"Rebuild the installation for package given by PKG-DESC.
|
|
|
|
Rebuilding an installation means scraping for new autoload
|
|
|
|
cookies, re-compiling Emacs Lisp files, building and installing
|
|
|
|
any documentation, downloading any missing dependencies. This
|
|
|
|
command does not fetch new revisions from a remote server. That
|
|
|
|
is the responsibility of `package-vc-update'. Interactively,
|
|
|
|
prompt for the name of the package to rebuild."
|
|
|
|
(interactive (list (package-vc--read-package-desc "Rebuild package: " t)))
|
2022-11-03 19:38:34 +01:00
|
|
|
(package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc)))
|
2022-10-12 21:21:38 +02:00
|
|
|
|
2022-10-08 18:22:03 +02:00
|
|
|
;;;###autoload
|
2022-11-13 17:05:20 +01:00
|
|
|
(defun package-vc-prepare-patch (pkg-desc subject revisions)
|
; Fix documentation of package-vc.el
* lisp/emacs-lisp/package-vc.el (package-vc-default-backend)
(package-vc-selected-packages, package-vc--archive-spec-alist)
(package-vc--archive-data-alist, package-vc--query-spec)
(package-vc--read-archive-data, package-vc-commit)
(package-vc--main-file, package-vc--generate-description-file)
(package-vc--build-documentation, package-vc--unpack-1)
(package-vc--guess-backend, package-vc--clone)
(package-vc--unpack, package-vc-update, package-vc--release-rev)
(package-vc-install, package-vc-checkout)
(package-vc-link-directory, package-vc-refresh)
(package-vc-prepare-patch, package-vc--archives-initialize): Doc fixes.
2022-11-05 13:11:28 +02:00
|
|
|
"Send patch for REVISIONS to maintainer of the package PKG using SUBJECT.
|
2022-11-13 17:05:20 +01:00
|
|
|
The function uses `vc-prepare-patch', passing SUBJECT and
|
|
|
|
REVISIONS directly. PKG-DESC must be a package description.
|
|
|
|
Interactively, prompt for PKG-DESC, SUBJECT, and REVISIONS. When
|
|
|
|
invoked with a numerical prefix argument, use the last N
|
|
|
|
revisions. When invoked interactively in a Log View buffer with
|
|
|
|
marked revisions, use those."
|
2022-10-07 18:57:00 +02:00
|
|
|
(interactive
|
2022-11-06 10:24:56 +01:00
|
|
|
(list (package-vc--read-package-desc "Package to prepare a patch for: " t)
|
2022-10-07 18:57:00 +02:00
|
|
|
(and (not vc-prepare-patches-separately)
|
|
|
|
(read-string "Subject: " "[PATCH] " nil nil t))
|
2022-11-13 17:05:20 +01:00
|
|
|
(vc-prepare-patch-prompt-revisions)))
|
2022-11-16 10:46:43 +01:00
|
|
|
(let ((default-directory (package-desc-dir pkg-desc)))
|
|
|
|
(vc-prepare-patch (package-maintainers pkg-desc t)
|
|
|
|
subject revisions)))
|
2022-10-07 18:57:00 +02:00
|
|
|
|
2022-07-31 21:32:38 +02:00
|
|
|
(provide 'package-vc)
|
|
|
|
;;; package-vc.el ends here
|