path: root/dh-elpa.el
diff options
authorDavid Bremner <>2015-09-19 10:50:40 -0300
committerDavid Bremner <>2015-09-19 10:50:40 -0300
commitf5e8269e142b76f8c3053db88ac8d3ef15aa16ba (patch)
treee1bfeeb96829ccfabe963e94389c0fb5c8e7b0cc /dh-elpa.el
parentbba12d529c40cf88e4cb3780c082da61f01e1eda (diff)
version 0.0.10: compute version number from lisp source.
Diffstat (limited to 'dh-elpa.el')
1 files changed, 32 insertions, 0 deletions
diff --git a/dh-elpa.el b/dh-elpa.el
index 6db53f8..7dee0c5 100644
--- a/dh-elpa.el
+++ b/dh-elpa.el
@@ -66,6 +66,14 @@ tar file) into second command line argument (a directory)"
(dhelpa-install-file dest el-file)))
+(defun dhelpa-batch-install-directory ()
+ "Install third command line argument (a directory containing a
+multifile elpa package) into second command line argument (a
+directory). An optional third command line argument specifies
+where to make temporary files."
+ (apply #'dhelpa-install-directory command-line-args-left))
(defun dhelpa-install-file (dest el-file)
"Install second argument (an emacs lisp file or tar file) into
first command line argument (a directory)"
@@ -74,4 +82,28 @@ first command line argument (a directory)"
(when (string-match "\\.tar\\'" el-file) (tar-mode))
(dhelpa-install-from-buffer (expand-file-name dest))))
+(defun dhelpa-install-directory (dest elpa-dir &optional work-dir)
+ "Install second argument (an unpacked elpa tarball) into first
+command line argument (a directory). The directory must either be
+named `package' or `package-version'. If a working directory is
+specified, cleaning up is the caller's responsibility."
+ (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))
+ (base-dir (file-name-nondirectory elpa-dir))
+ (parent-dir (file-name-directory elpa-dir))
+ (temp-dir (or work-dir (make-temp-file nil t)))
+ (tar-file (concat (expand-file-name canonical-dir temp-dir) ".tar"))
+ ;; this relies on GNU tar features.
+ (transform-command (concat "--transform=s/"
+ (regexp-quote base-dir) "/" canonical-dir "/")))
+ (call-process "tar" nil nil nil "--create" "-C" parent-dir transform-command
+ "--file" tar-file base-dir)
+ (dhelpa-install-file dest tar-file)
+ (unless work-dir
+ (delete-file tar-file)
+ (delete-directory temp-dir))))))
;;; dh-elpa.el ends here