path: root/dh-elpa.el
diff options
authorSean Whitton <>2015-12-17 11:59:41 -0700
committerDavid Bremner <>2016-01-03 19:18:37 -0400
commit983e60fd072e78483f22541daf1befda32e50930 (patch)
treed5e241f9ccb5dcc43edb3ecde6e740c74f111f11 /dh-elpa.el
parent96347aa83d319fd71c5812d06589d1555c51c384 (diff)
generate -pkg.el file for multifile packages
generate a warning if this is attempted, and an error message if it fails.
Diffstat (limited to 'dh-elpa.el')
1 files changed, 22 insertions, 1 deletions
diff --git a/dh-elpa.el b/dh-elpa.el
index cd28770..2ec58fc 100644
--- a/dh-elpa.el
+++ b/dh-elpa.el
@@ -119,7 +119,10 @@ The directory must either be named `package' or
`package-version'. If a working directory WORK-DIR is specified,
cleaning up is the caller's responsibility. Optional EPOCH-TIME
specifies time to use in generated autoloads files."
- (let* ((desc (package-load-descriptor elpa-dir)))
+ (unless (file-exists-p
+ (expand-file-name (package--description-file elpa-dir) elpa-dir))
+ (dhelpa-generate-pkg-file elpa-dir))
+ (let ((desc (package-load-descriptor elpa-dir)))
(if (not desc)
(message "Could not compute version from directory %s" elpa-dir)
(let* ((canonical-dir (package-desc-full-name desc))
@@ -137,4 +140,22 @@ specifies time to use in generated autoloads files."
(delete-file tar-file)
(delete-directory temp-dir))))))
+(defun dhelpa-generate-pkg-file (pkg-dir)
+ "Generate PKG-DIR/foo-pkg.el by consulting PKG-DIR/foo.el."
+ (let* ((pkg-file (expand-file-name (package--description-file pkg-dir) pkg-dir))
+ (root-file (replace-regexp-in-string "-pkg" "" pkg-file))
+ (pkg-desc
+ (condition-case nil
+ (with-temp-buffer
+ (find-file root-file)
+ (package-buffer-info))
+ (error (progn
+ (message "dh_elpa: couldn't generate -pkg file; please write one")
+ (kill-emacs -1))))))
+ ;; although the docstring for `package-generate-description-file'
+ ;; says that it generates a description for single-file packages,
+ ;; there is in fact no difference between the descriptions for
+ ;; single-file and multifile packages
+ (package-generate-description-file pkg-desc pkg-file)))
;;; dh-elpa.el ends here