mirror of
https://github.com/correl/melpa.git
synced 2024-11-14 19:19:32 +00:00
Unify build-checkout functions so each can directly access the config options it needs
This commit is contained in:
parent
df77b0e0bf
commit
3fc3a0200e
1 changed files with 62 additions and 64 deletions
|
@ -63,13 +63,15 @@
|
|||
:group 'package-build
|
||||
:type 'string)
|
||||
|
||||
(defun package-build-checkout-wiki (filename dir)
|
||||
(defun package-build-checkout-wiki (name config dir)
|
||||
"checkout a package from the wiki"
|
||||
(with-current-buffer (get-buffer-create "*package-build-checkout*")
|
||||
(message dir)
|
||||
(unless (file-exists-p dir)
|
||||
(make-directory dir))
|
||||
(let ((default-directory dir)
|
||||
(let* ((filename (or (car (plist-get config :files))
|
||||
(format "%s.el" name)))
|
||||
(default-directory dir)
|
||||
(download-url (format "http://www.emacswiki.org/emacs/download/%s" filename))
|
||||
(wiki-url (format "http://www.emacswiki.org/emacs/%s" filename)))
|
||||
(url-copy-file download-url filename t)
|
||||
|
@ -91,8 +93,19 @@
|
|||
(let ((default-directory (or dir default-directory)))
|
||||
(apply 'process-file prog nil (current-buffer) t args)))
|
||||
|
||||
(defun package-build-checkout-darcs (repo dir)
|
||||
|
||||
(defun package-build-checkout (name config cwd)
|
||||
"Check out source for package `NAME' with `CONFIG' under working dir `CWD'.
|
||||
In turn, this function uses the :fetcher option in the config to choose a
|
||||
source-specific fetcher function, which it calls with the same arguments."
|
||||
(let ((repo-type (plist-get config :fetcher)))
|
||||
(print repo-type)
|
||||
(funcall (intern (format "package-build-checkout-%s" repo-type))
|
||||
name config cwd)))
|
||||
|
||||
(defun package-build-checkout-darcs (name config dir)
|
||||
"checkout a darcs package"
|
||||
(let ((repo (plist-get config :url)))
|
||||
(with-current-buffer (get-buffer-create "*package-build-checkout*")
|
||||
(cond
|
||||
((file-exists-p dir)
|
||||
|
@ -103,10 +116,11 @@
|
|||
(package-run-process nil "darcs" "get" repo dir)))
|
||||
(package-run-process dir "darcs" "changes" "--last" "1")
|
||||
(package-build-find-parse-time
|
||||
"\\([a-zA-Z]\\{3\\} [a-zA-Z]\\{3\\} \\( \\|[0-9]\\)[0-9] [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\} [A-Za-z]\\{3\\} [0-9]\\{4\\}\\)")))
|
||||
"\\([a-zA-Z]\\{3\\} [a-zA-Z]\\{3\\} \\( \\|[0-9]\\)[0-9] [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\} [A-Za-z]\\{3\\} [0-9]\\{4\\}\\)"))))
|
||||
|
||||
(defun package-build-checkout-svn (repo dir)
|
||||
(defun package-build-checkout-svn (name config dir)
|
||||
"checkout an svn repo"
|
||||
(let ((repo (plist-get config :url)))
|
||||
(with-current-buffer (get-buffer-create "*package-build-checkout*")
|
||||
(goto-char (point-max))
|
||||
(cond
|
||||
|
@ -118,10 +132,12 @@
|
|||
(package-run-process nil "svn" "checkout" repo dir)))
|
||||
(package-run-process dir "svn" "info")
|
||||
(package-build-find-parse-time
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")))
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)"))))
|
||||
|
||||
(defun package-build-checkout-git (repo dir &optional commit)
|
||||
(defun package-build-checkout-git (name config dir)
|
||||
"checkout a git repo"
|
||||
(let ((repo (plist-get config :url))
|
||||
(commit (plist-get config :commit)))
|
||||
(with-current-buffer (get-buffer-create "*package-build-checkout*")
|
||||
(goto-char (point-max))
|
||||
(cond
|
||||
|
@ -135,7 +151,7 @@
|
|||
(package-run-process dir "git" "checkout" commit))
|
||||
(package-run-process dir "git" "show" "-s" "--format='\%ci'" "HEAD")
|
||||
(package-build-find-parse-time
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")))
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)"))))
|
||||
|
||||
(defun package-change-list-elt (lst idx newval)
|
||||
(if (zerop idx)
|
||||
|
@ -252,30 +268,12 @@
|
|||
(expand-file-name file-name package-build-working-dir))))
|
||||
|
||||
(if cfg
|
||||
(let* ((repo-type (plist-get cfg :fetcher))
|
||||
(repo-url (plist-get cfg :url))
|
||||
(version
|
||||
(cond
|
||||
((eq repo-type 'wiki)
|
||||
(print 'EmacsWiki)
|
||||
(package-build-checkout-wiki (or (car (plist-get cfg :files))
|
||||
(concat file-name ".el"))
|
||||
pkg-cwd))
|
||||
((eq repo-type 'svn)
|
||||
(print 'Subversion)
|
||||
(package-build-checkout-svn repo-url pkg-cwd))
|
||||
((eq repo-type 'git)
|
||||
(print 'Git)
|
||||
(package-build-checkout-git repo-url pkg-cwd
|
||||
(plist-get cfg :commit)))
|
||||
((eq repo-type 'darcs)
|
||||
(print 'Darcs)
|
||||
(package-build-checkout-darcs repo-url pkg-cwd))))
|
||||
(let* ((version (package-build-checkout name cfg pkg-cwd))
|
||||
(files (package-expand-file-list pkg-cwd (plist-get cfg :files)))
|
||||
(default-directory package-build-working-dir))
|
||||
(cond
|
||||
((not version)
|
||||
(print (format "Unable to check out repository: %s" repo-url)))
|
||||
(print (format "Unable to check out repository for %s" name)))
|
||||
((= 1 (length files))
|
||||
(let* ((pkgsrc (expand-file-name (car files) pkg-cwd))
|
||||
(pkgdst (expand-file-name
|
||||
|
|
Loading…
Reference in a new issue