Function: package-vc--unpack
package-vc--unpack is a byte-compiled function defined in
package-vc.el.gz.
Signature
(package-vc--unpack PKG-DESC PKG-SPEC &optional REV)
Documentation
Install the package described by PKG-DESC.
PKG-SPEC is a package specification, a property list describing
how to fetch and build the package. See package-vc--archive-spec-alists
for details. The optional argument REV specifies a specific revision to
checkout. This overrides the :branch attribute in PKG-SPEC.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/package-vc.el.gz
(defun package-vc--unpack (pkg-desc pkg-spec &optional rev)
"Install the package described by PKG-DESC.
PKG-SPEC is a package specification, a property list describing
how to fetch and build the package. See `package-vc--archive-spec-alists'
for details. The optional argument REV specifies a specific revision to
checkout. This overrides the `:branch' attribute in PKG-SPEC."
(unless (eq (package-desc-kind pkg-desc) 'vc)
(let ((copy (copy-package-desc pkg-desc)))
(setf (package-desc-kind copy) 'vc
pkg-desc copy)))
(pcase-let* (((map :lisp-dir) pkg-spec)
(name (package-desc-name pkg-desc))
(dirname (package-desc-full-name pkg-desc))
(pkg-dir (file-name-as-directory (expand-file-name dirname package-user-dir))))
(when (string-empty-p name)
(user-error "Empty package name"))
(setf (package-desc-dir pkg-desc) pkg-dir)
(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)))
(package-vc--clone pkg-desc pkg-spec pkg-dir rev)
(when (directory-empty-p pkg-dir)
(delete-directory pkg-dir)
(error "Empty checkout for %s" name))
(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")))
;; When nothing is specified about a `lisp-dir', then should
;; heuristically check if there is a sub-directory with lisp
;; 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)))))
;; Ensure we have a copy of the package specification
(unless (seq-some (lambda (alist) (equal (alist-get name (cdr alist)) pkg-spec))
package-vc--archive-spec-alists)
(customize-save-variable
'package-vc-selected-packages
(cons (cons name pkg-spec)
(seq-remove (lambda (spec) (string= name (car spec)))
package-vc-selected-packages))))
(package-vc--unpack-1 pkg-desc pkg-dir)))