Commit 1f6c9174 authored by Ryan Thompson's avatar Ryan Thompson

Merge pull request #533 from DarwinAwardWinner/register-method-keywords

Backend changes to el-get install methods and checksums

 * Fixed an omission the docstring of el-get-methods
 * Add functions `el-get-register-derived-method` and `el-get-register-method-alias` and use them as appropriate
 * Add checksum methods to hg and git
 * Add `el-get-self-checksum` as shortcut for `(el-get-checksum 'el-get)` (fixes #524)
 * Rewrite `el-get-register-method` and `el-get-register-derived-method` to use keyword args (fixes #528)
parents 6063cfe3 5c89a936
......@@ -35,6 +35,11 @@ release.
Please note that this versioning policy has been picked while backing
1.2~dev, so 1.0 was a "stable" release in fact. Ah, history.
In addition to the version, you can also get the exact git revision by
running M-x +el-get-self-checksum+. You should provide this checksum
when seeking support or reporting a bug, so that the developers will
know exactly which version you are using.
== How to Install it?
Here's the 'lazy installer':
......
......@@ -36,19 +36,45 @@
The methods list is a PLIST, each entry has a method name
property which value is another PLIST, which must contain values
for :install, :install-hook, :update, :remove and :checksum
properties. Those should be the elisp functions to call for doing
the named package action in the given method.")
for :install, :install-hook, :update, :remove, :remove-hook
and :checksum properties. Those should be the elisp functions to
call for doing the named package action in the given method.")
(defun el-get-register-method (name install update remove
&optional install-hook remove-hook compute-checksum)
(defun el-get-method-defined-p (name)
"Returns t if NAME is a known el-get install method backend, nil otherwise."
(and (el-get-method name :install) t))
(defun* el-get-register-method (name &key install update remove
install-hook remove-hook compute-checksum)
"Register the method for backend NAME, with given functions"
(loop for required-arg in '(install update remove)
unless (symbol-value required-arg)
do (error "Missing required argument: :%s" required-arg))
(let ((def (list :install install :update update :remove remove)))
(when install-hook (setq def (append def (list :install-hook install-hook))))
(when remove-hook (setq def (append def (list :remove-hook remove-hook))))
(when compute-checksum (setq def (append def (list :compute-checksum compute-checksum))))
(when install-hook (setq def (plist-put def :install-hook install-hook)))
(when remove-hook (setq def (plist-put def :remove-hook remove-hook)))
(when compute-checksum (setq def (plist-put def :compute-checksum compute-checksum)))
(setq el-get-methods (plist-put el-get-methods name def))))
(put 'el-get-register-method 'lisp-indent-function
(get 'prog1 'lisp-indent-function))
(defun* el-get-register-derived-method (name derived-from-name
&rest keys &key &allow-other-keys)
"Register the method for backend NAME.
Defaults for all optional arguments are taken from
already-defined method DERIVED-FROM-NAME."
(unless (el-get-method-defined-p derived-from-name)
(error "Cannot derive new el-get method from unknown method %s" derived-from-name))
(apply #'el-get-register-method name (append keys (plist-get el-get-methods derived-from-name))))
(put 'el-get-register-derived-method 'lisp-indent-function
(get 'prog2 'lisp-indent-function))
(defun el-get-register-method-alias (name old-name)
"Register NAME as an alias for install method OLD-NAME."
(el-get-register-derived-method name old-name))
;;
......@@ -136,8 +162,9 @@ entry."
(defun el-get-method (method-name action)
"Return the function to call for doing action (e.g. install) in
given method."
(let* ((method (intern (concat ":" (format "%s" method-name))))
(actions (plist-get el-get-methods method)))
(let* ((method (if (keywordp method-name) method-name
(intern (concat ":" (format "%s" method-name)))))
(actions (plist-get el-get-methods method)))
(plist-get actions action)))
(defun el-get-check-init ()
......
......@@ -27,6 +27,11 @@
;;
;; Please note that this versioning policy has been picked while backing
;; 1.2~dev, so 1.0 was a "stable" release in fact. Ah, history.
;;
;; In addition to the version, you can also get the exact git revision
;; by running M-x `el-get-self-checksum'. You should provide this
;; checksum when seeking support or reporting a bug, so that the
;; developers will know exactly which version you are using.
;;; Change Log:
;;
......@@ -700,8 +705,16 @@ entry which is not a symbol and is not already a known recipe."
(error "package method %s does not support checksums" type))
(when compute-checksum
(let ((checksum (funcall compute-checksum package)))
(message "Checksum for package %s is: %s" package checksum)
(kill-new checksum)))))
(message "Checksum for package %s is: %s. It has been copied to the kill-ring."
package checksum)
(kill-new checksum)))))
(defun el-get-self-checksum ()
"Compute the checksum of the running version of el-get itself.
Also put the checksum in the kill-ring."
(interactive)
(el-get-checksum 'el-get))
;;
......
......@@ -150,8 +150,11 @@ password prompt."
(add-hook 'el-get-apt-get-remove-hook 'el-get-dpkg-remove-symlink)
(el-get-register-method
:apt-get #'el-get-apt-get-install #'el-get-apt-get-install #'el-get-apt-get-remove
#'el-get-apt-get-install-hook #'el-get-apt-get-remove-hook)
(el-get-register-method :apt-get
:install #'el-get-apt-get-install
:update #'el-get-apt-get-install
:remove #'el-get-apt-get-remove
:install-hook #'el-get-apt-get-install-hook
:remove-hook #'el-get-apt-get-remove-hook)
(provide 'el-get-apt-get)
......@@ -89,8 +89,11 @@
(add-hook 'el-get-brew-remove-hook 'el-get-dpkg-remove-symlink)
(el-get-register-method
:brew
#'el-get-brew-install #'el-get-brew-update #'el-get-brew-remove #'el-get-brew-install-hook #'el-get-brew-remove-hook)
(el-get-register-method :brew
:install #'el-get-brew-install
:update #'el-get-brew-update
:remove #'el-get-brew-remove
:install-hook #'el-get-brew-install-hook
:remove-hook #'el-get-brew-remove-hook)
(provide 'el-get-brew)
......@@ -25,8 +25,10 @@
(make-directory pdir))
(funcall post-install-fun package)))
(el-get-register-method
:builtin #'el-get-builtin-install #'el-get-builtin-install #'el-get-rmdir
#'el-get-builtin-install-hook)
(el-get-register-method :builtin
:install #'el-get-builtin-install
:update #'el-get-builtin-install
:remove #'el-get-rmdir
:install-hook #'el-get-builtin-install-hook)
(provide 'el-get-builtin)
......@@ -56,8 +56,10 @@
:error ,ko))
post-update-fun)))
(el-get-register-method
:bzr #'el-get-bzr-branch #'el-get-bzr-pull #'el-get-rmdir
el-get-bzr-branch-hook)
(el-get-register-method :bzr
:install #'el-get-bzr-branch
:update #'el-get-bzr-pull
:remove #'el-get-rmdir
:install-hook el-get-bzr-branch-hook)
(provide 'el-get-bzr)
......@@ -73,8 +73,10 @@
:error ,ko))
post-update-fun)))
(el-get-register-method
:cvs #'el-get-cvs-checkout #'el-get-cvs-update #'el-get-rmdir
#'el-get-cvs-checkout-hook)
(el-get-register-method :cvs
:install #'el-get-cvs-checkout
:update #'el-get-cvs-update
:remove #'el-get-rmdir
:install-hook #'el-get-cvs-checkout-hook)
(provide 'el-get-cvs)
......@@ -56,8 +56,10 @@
:error ,ko))
post-update-fun)))
(el-get-register-method
:darcs #'el-get-darcs-get #'el-get-darcs-pull #'el-get-rmdir
#'el-get-darcs-get-hook)
(el-get-register-method :darcs
:install #'el-get-darcs-get
:update #'el-get-darcs-pull
:remove #'el-get-rmdir
:install-hook #'el-get-darcs-get-hook)
(provide 'el-get-darcs)
......@@ -134,8 +134,11 @@ the recipe, then return nil."
(add-hook 'el-get-elpa-remove-hook 'el-get-elpa-post-remove)
(el-get-register-method
:elpa #'el-get-elpa-install #'el-get-elpa-update #'el-get-elpa-remove
#'el-get-elpa-install-hook #'el-get-elpa-remove-hook)
(el-get-register-method :elpa
:install #'el-get-elpa-install
:update #'el-get-elpa-update
:remove #'el-get-elpa-remove
:install-hook #'el-get-elpa-install-hook
:remove-hook #'el-get-elpa-remove-hook)
(provide 'el-get-elpa)
......@@ -33,8 +33,7 @@
(url (or url (format el-get-emacsmirror-base-url pkgname))))
(el-get-git-clone package url post-install-fun)))
(el-get-register-method
:emacsmirror #'el-get-emacsmirror-clone #'el-get-git-pull #'el-get-rmdir
#'el-get-git-clone-hook)
(el-get-register-derived-method :emacsmirror :git
:install #'el-get-emacsmirror-clone)
(provide 'el-get-emacsmirror)
......@@ -36,9 +36,9 @@ filename.el ;;; filename.el --- description"
(let ((url (or url (format "%s%s.el" el-get-emacswiki-base-url package))))
(el-get-http-install package url post-install-fun)))
(el-get-register-method
:emacswiki #'el-get-emacswiki-install #'el-get-emacswiki-install #'el-get-rmdir
#'el-get-http-install-hook nil #'el-get-http-compute-checksum)
(el-get-register-derived-method :emacswiki :http
:install #'el-get-emacswiki-install
:update #'el-get-emacswiki-install)
;;;
;;; Functions to maintain a local recipe list from EmacsWiki
......
......@@ -76,9 +76,11 @@
(add-hook 'el-get-fink-remove-hook 'el-get-dpkg-remove-symlink)
(el-get-register-method
:fink
#'el-get-fink-install #'el-get-fink-install #'el-get-fink-remove
#'el-get-fink-install-hook #'el-get-fink-remove-hook)
(el-get-register-method :fink
:install #'el-get-fink-install
:update #'el-get-fink-install
:remove #'el-get-fink-remove
:install-hook #'el-get-fink-install-hook
:remove-hook #'el-get-fink-remove-hook)
(provide 'el-get-fink)
......@@ -68,9 +68,9 @@
:error ,r-ko))
post-update-fun)))
(el-get-register-method
:git-svn
#'el-get-git-svn-clone #'el-get-git-svn-update #'el-get-rmdir
#'el-get-git-svn-clone-hook)
(el-get-register-derived-method :git-svn :git
:install #'el-get-git-svn-clone
:update #'el-get-git-svn-update
:install-hook #'el-get-git-svn-clone-hook)
(provide 'el-get-git-svn)
......@@ -89,8 +89,22 @@ found."
:error "Could not update git submodules"))
post-update-fun)))
(el-get-register-method
:git #'el-get-git-clone #'el-get-git-pull #'el-get-rmdir
#'el-get-git-clone-hook)
(defun el-get-git-compute-checksum (package)
"Return the hash of the checked-out revision of PACKAGE."
(with-temp-buffer
(cd (el-get-package-directory package))
(let* ((args '("git" "show-ref" "HEAD"))
(cmd (mapconcat 'shell-quote-argument args " "))
(output (shell-command-to-string cmd))
(hash (and (string-match "^[[:space:]]*\\([^[:space:]]+\\)" output)
(match-string 0 output))))
hash)))
(el-get-register-method :git
:install #'el-get-git-clone
:update #'el-get-git-pull
:remove #'el-get-rmdir
:install-hook #'el-get-git-clone-hook
:compute-checksum #'el-get-git-compute-checksum)
(provide 'el-get-git)
......@@ -58,8 +58,22 @@
:error ,ko))
post-update-fun)))
(el-get-register-method
:hg #'el-get-hg-clone #'el-get-hg-pull #'el-get-rmdir
#'el-get-hg-clone-hook)
(defun el-get-hg-compute-checksum (package)
"Return the hash of the checked-out revision of PACKAGE."
(with-temp-buffer
(cd (el-get-package-directory package))
(let* ((args '("hg" "--debug" "tags"))
(cmd (mapconcat 'shell-quote-argument args " "))
(output (shell-command-to-string cmd))
(hash (and (string-match "^tip[[:space:]]+[0-9]+\\:\\([0-9A-Fa-f]+\\)" output)
(match-string 0 output))))
hash)))
(el-get-register-method :hg
:install #'el-get-hg-clone
:update #'el-get-hg-pull
:remove #'el-get-rmdir
:install-hook #'el-get-hg-clone-hook
:compute-checksum #'el-get-hg-compute-checksum)
(provide 'el-get-hg)
......@@ -63,8 +63,10 @@ the files up."
(add-hook 'el-get-http-tar-install-hook 'el-get-http-tar-cleanup-extract-hook)
(el-get-register-method
:http-tar #'el-get-http-tar-install #'el-get-http-tar-install #'el-get-rmdir
#'el-get-http-tar-install-hook)
(el-get-register-method :http-tar
:install #'el-get-http-tar-install
:update #'el-get-http-tar-install
:remove #'el-get-rmdir
:install-hook #'el-get-http-tar-install-hook)
(provide 'el-get-http-tar)
......@@ -60,11 +60,13 @@ the files up."
:error ,ko))
,(symbol-function post-install-fun))))))
(el-get-http-install package url post dest)))
(add-hook 'el-get-http-zip-install-hook 'el-get-http-zip-cleanup-extract-hook)
(el-get-register-method
:http-zip #'el-get-http-zip-install #'el-get-http-zip-install #'el-get-rmdir
#'el-get-http-zip-install-hook)
(el-get-register-method :http-zip
:install #'el-get-http-zip-install
:update #'el-get-http-zip-install
:remove #'el-get-rmdir
:install-hook #'el-get-http-zip-install-hook)
(provide 'el-get-http-zip)
......@@ -90,12 +90,13 @@ into the package :localname option or its `file-name-nondirectory' part."
(puthash package checksum el-get-http-checksums))
checksum))
(el-get-register-method
:http #'el-get-http-install #'el-get-http-install #'el-get-rmdir
#'el-get-http-install-hook nil #'el-get-http-compute-checksum)
(el-get-register-method :http
:install #'el-get-http-install
:update #'el-get-http-install
:remove #'el-get-rmdir
:install-hook #'el-get-http-install-hook
:compute-checksum #'el-get-http-compute-checksum)
(el-get-register-method
:ftp #'el-get-http-install #'el-get-http-install #'el-get-rmdir
#'el-get-http-install-hook nil #'el-get-http-compute-checksum)
(el-get-register-method-alias :ftp :http)
(provide 'el-get-http)
......@@ -63,9 +63,11 @@
(add-hook 'el-get-pacman-remove-hook 'el-get-dpkg-remove-symlink)
(el-get-register-method
:pacman
#'el-get-pacman-install #'el-get-pacman-install #'el-get-pacman-remove
#'el-get-pacman-install-hook #'el-get-pacman-remove-hook)
(el-get-register-method :pacman
:install #'el-get-pacman-install
:update #'el-get-pacman-install
:remove #'el-get-pacman-remove
:install-hook #'el-get-pacman-install-hook
:remove-hook #'el-get-pacman-remove-hook)
(provide 'el-get-pacman)
......@@ -66,8 +66,10 @@
:error ,ko))
post-update-fun)))
(el-get-register-method
:svn #'el-get-svn-checkout #'el-get-svn-update #'el-get-rmdir
#'el-get-svn-checkout-hook)
(el-get-register-method :svn
:install #'el-get-svn-checkout
:update #'el-get-svn-update
:remove #'el-get-rmdir
:install-hook #'el-get-svn-checkout-hook)
(provide 'el-get-svn)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment