mirror of
https://github.com/correl/melpa.git
synced 2024-11-22 19:18:39 +00:00
Use shorter "pb/" prefix for internal functions to aid clarity
This commit is contained in:
parent
589ea72384
commit
647189743d
1 changed files with 62 additions and 62 deletions
124
package-build.el
124
package-build.el
|
@ -70,7 +70,7 @@
|
|||
"List of already-built packages, in the standard package.el format.")
|
||||
|
||||
|
||||
(defun package-build-find-parse-time (regex)
|
||||
(defun pb/find-parse-time (regex)
|
||||
"Find REGEX in current buffer and format as a proper time version."
|
||||
(format-time-string
|
||||
"%Y%m%d"
|
||||
|
@ -78,24 +78,24 @@
|
|||
(print (progn (re-search-backward regex)
|
||||
(match-string-no-properties 1))))))
|
||||
|
||||
(defun package-run-process (dir prog &rest args)
|
||||
(defun pb/run-process (dir prog &rest args)
|
||||
"In DIR (or `default-directory' if unset) run command PROG with ARGS.
|
||||
Output is written to the current buffer."
|
||||
(let ((default-directory (or dir default-directory)))
|
||||
(apply 'process-file prog nil (current-buffer) t args)))
|
||||
|
||||
|
||||
(defun package-build-checkout (name config cwd)
|
||||
(defun pb/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))
|
||||
(funcall (intern (format "pb/checkout-%s" repo-type))
|
||||
name config cwd)))
|
||||
|
||||
(defun package-build-checkout-wiki (name config dir)
|
||||
(defun pb/checkout-wiki (name config dir)
|
||||
"Checkout package NAME with config CONFIG from the EmacsWiki into DIR."
|
||||
(with-current-buffer (get-buffer-create "*package-build-checkout*")
|
||||
(message dir)
|
||||
|
@ -108,25 +108,25 @@ the same arguments."
|
|||
(wiki-url (format "http://www.emacswiki.org/emacs/%s" filename)))
|
||||
(url-copy-file download-url filename t)
|
||||
(with-current-buffer (url-retrieve-synchronously wiki-url)
|
||||
(package-build-find-parse-time
|
||||
(pb/find-parse-time
|
||||
"Last edited \\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\} [A-Z]\\{3\\}\\)")))))
|
||||
|
||||
(defun package-build-checkout-darcs (name config dir)
|
||||
(defun pb/checkout-darcs (name config dir)
|
||||
"Check package NAME with config CONFIG out of darcs into DIR."
|
||||
(let ((repo (plist-get config :url)))
|
||||
(with-current-buffer (get-buffer-create "*package-build-checkout*")
|
||||
(cond
|
||||
((file-exists-p dir)
|
||||
(print "checkout directory exists, updating...")
|
||||
(package-run-process dir "darcs" "pull"))
|
||||
(pb/run-process dir "darcs" "pull"))
|
||||
(t
|
||||
(print "cloning repository")
|
||||
(package-run-process nil "darcs" "get" repo dir)))
|
||||
(package-run-process dir "darcs" "changes" "--last" "1")
|
||||
(package-build-find-parse-time
|
||||
(pb/run-process nil "darcs" "get" repo dir)))
|
||||
(pb/run-process dir "darcs" "changes" "--last" "1")
|
||||
(pb/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\\}\\)"))))
|
||||
|
||||
(defun package-build-checkout-svn (name config dir)
|
||||
(defun pb/checkout-svn (name config dir)
|
||||
"Check package NAME with config CONFIG out of svn into DIR."
|
||||
(let ((repo (plist-get config :url)))
|
||||
(with-current-buffer (get-buffer-create "*package-build-checkout*")
|
||||
|
@ -134,15 +134,15 @@ the same arguments."
|
|||
(cond
|
||||
((file-exists-p dir)
|
||||
(print "checkout directory exists, updating...")
|
||||
(package-run-process dir "svn" "up"))
|
||||
(pb/run-process dir "svn" "up"))
|
||||
(t
|
||||
(print "cloning repository")
|
||||
(package-run-process nil "svn" "checkout" repo dir)))
|
||||
(package-run-process dir "svn" "info")
|
||||
(package-build-find-parse-time
|
||||
(pb/run-process nil "svn" "checkout" repo dir)))
|
||||
(pb/run-process dir "svn" "info")
|
||||
(pb/find-parse-time
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)"))))
|
||||
|
||||
(defun package-build-checkout-git (name config dir)
|
||||
(defun pb/checkout-git (name config dir)
|
||||
"Check package NAME with config CONFIG out of git into DIR."
|
||||
(let ((repo (plist-get config :url))
|
||||
(commit (plist-get config :commit)))
|
||||
|
@ -151,24 +151,24 @@ the same arguments."
|
|||
(cond
|
||||
((file-exists-p dir)
|
||||
(print "checkout directory exists, updating...")
|
||||
(package-run-process dir "git" "pull"))
|
||||
(pb/run-process dir "git" "pull"))
|
||||
(t
|
||||
(print (format "cloning %s to %s" repo dir))
|
||||
(package-run-process nil "git" "clone" repo dir)))
|
||||
(pb/run-process nil "git" "clone" repo dir)))
|
||||
(when commit
|
||||
(package-run-process dir "git" "checkout" commit))
|
||||
(package-run-process dir "git" "show" "-s" "--format='\%ci'" "HEAD")
|
||||
(package-build-find-parse-time
|
||||
(pb/run-process dir "git" "checkout" commit))
|
||||
(pb/run-process dir "git" "show" "-s" "--format='\%ci'" "HEAD")
|
||||
(pb/find-parse-time
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)"))))
|
||||
|
||||
|
||||
(defun package-build-dump (data file)
|
||||
(defun pb/dump (data file)
|
||||
"Write DATA to FILE as a pretty-printed Lisp sexp."
|
||||
(write-region (concat (pp-to-string data) "\n") nil file nil nil nil nil))
|
||||
|
||||
(defun package-build-pkg-file (pkg-file pkg-info)
|
||||
(defun pb/write-pkg-file (pkg-file pkg-info)
|
||||
"Write PKG-FILE containing PKG-INFO."
|
||||
(package-build-dump
|
||||
(pb/dump
|
||||
`(define-package
|
||||
,(aref pkg-info 0)
|
||||
,(aref pkg-info 3)
|
||||
|
@ -180,7 +180,7 @@ the same arguments."
|
|||
(aref pkg-info 1)))
|
||||
pkg-file))
|
||||
|
||||
(defun package-build-read-from-file (file-name)
|
||||
(defun pb/read-from-file (file-name)
|
||||
"Read and return the Lisp data stored in FILE-NAME, or nil if no such file exists."
|
||||
(when (file-exists-p file-name)
|
||||
(with-temp-buffer
|
||||
|
@ -188,16 +188,16 @@ the same arguments."
|
|||
(goto-char (point-min))
|
||||
(read (current-buffer)))))
|
||||
|
||||
(defun package-build-get-config (pkg-name)
|
||||
(defun pb/get-config (pkg-name)
|
||||
"Get the configuration information for the given PKG-NAME."
|
||||
(package-build-read-from-file (format "epkgs/%s/.config" pkg-name)))
|
||||
(pb/read-from-file (format "epkgs/%s/.config" pkg-name)))
|
||||
|
||||
(defun package-build-get-master (pkg-name)
|
||||
(defun pb/get-master (pkg-name)
|
||||
"Get the configuration information for the given PKG-NAME."
|
||||
(package-build-read-from-file (format "epkgs/%s/master" pkg-name)))
|
||||
(pb/read-from-file (format "epkgs/%s/master" pkg-name)))
|
||||
|
||||
|
||||
(defun package-build-create-tar (file dir &optional files)
|
||||
(defun pb/create-tar (file dir &optional files)
|
||||
"Create a tar FILE containing the contents of DIR, or just FILES if non-nil.
|
||||
The file is written to `package-build-working-dir'."
|
||||
(let* ((default-directory package-build-working-dir))
|
||||
|
@ -214,7 +214,7 @@ The file is written to `package-build-working-dir'."
|
|||
"--exclude=_darcs"
|
||||
files)))
|
||||
|
||||
(defun package-build-get-package-info (file-path)
|
||||
(defun pb/get-package-info (file-path)
|
||||
"Get a vector of package info from the docstrings in FILE-PATH."
|
||||
(when (file-exists-p file-path)
|
||||
(ignore-errors
|
||||
|
@ -228,10 +228,10 @@ The file is written to `package-build-working-dir'."
|
|||
(flet ((package-strip-rcs-id (str) "0"))
|
||||
(package-buffer-info))))))
|
||||
|
||||
(defun package-build-get-pkg-file-info (file-path)
|
||||
(defun pb/get-pkg-file-info (file-path)
|
||||
"Get a vector of package info from \"-pkg.el\" file FILE-PATH."
|
||||
(when (file-exists-p file-path)
|
||||
(let ((pkgfile-info (cdr (package-build-read-from-file file-path))))
|
||||
(let ((pkgfile-info (cdr (pb/read-from-file file-path))))
|
||||
(vector
|
||||
(nth 0 pkgfile-info)
|
||||
(mapcar
|
||||
|
@ -253,12 +253,12 @@ The file is written to `package-build-working-dir'."
|
|||
(interactive)
|
||||
(mapc 'package-build-archive pkgs))
|
||||
|
||||
(defun package-build-expand-file-list (dir files)
|
||||
(defun pb/expand-file-list (dir files)
|
||||
"In DIR, expand FILES, some of which may be shell-style wildcards."
|
||||
(let ((default-directory dir))
|
||||
(mapcan 'file-expand-wildcards files)))
|
||||
|
||||
(defun package-build-merge-package-info (pkg-info name version)
|
||||
(defun pb/merge-package-info (pkg-info name version)
|
||||
"Return a version of PKG-INFO updated with NAME and VERSION.
|
||||
If PKG-INFO is nil, an empty one is created."
|
||||
(let ((merged (or (copy-seq pkg-info)
|
||||
|
@ -279,8 +279,8 @@ If PKG-INFO is nil, an empty one is created."
|
|||
(expand-file-name file-name package-build-working-dir))))
|
||||
|
||||
(if cfg
|
||||
(let* ((version (package-build-checkout name cfg pkg-cwd))
|
||||
(files (package-build-expand-file-list pkg-cwd (plist-get cfg :files)))
|
||||
(let* ((version (pb/checkout name cfg pkg-cwd))
|
||||
(files (pb/expand-file-list pkg-cwd (plist-get cfg :files)))
|
||||
(default-directory package-build-working-dir))
|
||||
(cond
|
||||
((not version)
|
||||
|
@ -293,61 +293,61 @@ If PKG-INFO is nil, an empty one is created."
|
|||
(pkgdst (expand-file-name
|
||||
(concat file-name "-" version ".el")
|
||||
package-build-archive-dir))
|
||||
(pkg-info (package-build-merge-package-info
|
||||
(package-build-get-package-info pkgsrc)
|
||||
(pkg-info (pb/merge-package-info
|
||||
(pb/get-package-info pkgsrc)
|
||||
file-name
|
||||
version)))
|
||||
(print pkg-info)
|
||||
(when (file-exists-p pkgdst)
|
||||
(delete-file pkgdst t))
|
||||
(copy-file pkgsrc pkgdst)
|
||||
(package-build-add-to-archive-contents pkg-info 'single)))
|
||||
(pb/add-to-archive-contents pkg-info 'single)))
|
||||
(t
|
||||
(let* ((pkg-dir (concat file-name "-" version))
|
||||
(pkg-file (concat file-name "-pkg.el"))
|
||||
(pkg-info
|
||||
(package-build-merge-package-info
|
||||
(pb/merge-package-info
|
||||
(let ((default-directory pkg-cwd))
|
||||
(or (package-build-get-pkg-file-info pkg-file)
|
||||
(or (pb/get-pkg-file-info pkg-file)
|
||||
;; some packages (like magit) provide name-pkg.el.in
|
||||
(package-build-get-pkg-file-info (concat pkg-file ".in"))
|
||||
(package-build-get-package-info (concat file-name ".el"))))
|
||||
(pb/get-pkg-file-info (concat pkg-file ".in"))
|
||||
(pb/get-package-info (concat file-name ".el"))))
|
||||
file-name version)))
|
||||
|
||||
(print pkg-info)
|
||||
(copy-directory file-name pkg-dir)
|
||||
|
||||
(package-build-pkg-file (expand-file-name
|
||||
pkg-file
|
||||
(file-name-as-directory
|
||||
(expand-file-name
|
||||
pkg-dir
|
||||
package-build-working-dir)))
|
||||
pkg-info)
|
||||
(pb/write-pkg-file (expand-file-name
|
||||
pkg-file
|
||||
(file-name-as-directory
|
||||
(expand-file-name
|
||||
pkg-dir
|
||||
package-build-working-dir)))
|
||||
pkg-info)
|
||||
|
||||
(when files
|
||||
(add-to-list 'files pkg-file))
|
||||
|
||||
(package-build-create-tar
|
||||
(pb/create-tar
|
||||
(expand-file-name
|
||||
(concat file-name "-" version ".tar") package-build-archive-dir)
|
||||
pkg-dir
|
||||
files)
|
||||
|
||||
(delete-directory pkg-dir t nil)
|
||||
(package-build-add-to-archive-contents pkg-info 'tar))))
|
||||
(package-build-dump-archive-contents))
|
||||
(pb/add-to-archive-contents pkg-info 'tar))))
|
||||
(pb/dump-archive-contents))
|
||||
(message "\nERROR: Cannot find package %s\n" file-name))))
|
||||
|
||||
|
||||
|
||||
(defun package-build-dump-archive-contents ()
|
||||
(defun pb/dump-archive-contents ()
|
||||
"Dump the list of built packages back to the archive-contents file."
|
||||
(package-build-dump (cons 1 package-build-archive-alist)
|
||||
(expand-file-name "archive-contents"
|
||||
package-build-archive-dir)))
|
||||
(pb/dump (cons 1 package-build-archive-alist)
|
||||
(expand-file-name "archive-contents"
|
||||
package-build-archive-dir)))
|
||||
|
||||
(defun package-build-add-to-archive-contents (pkg-info type)
|
||||
(defun pb/add-to-archive-contents (pkg-info type)
|
||||
"Add the built archive with info PKG-INFO and TYPE to `package-build-archive-alist'."
|
||||
(let* ((name (intern (aref pkg-info 0)))
|
||||
(requires (aref pkg-info 1))
|
||||
|
@ -369,8 +369,8 @@ If PKG-INFO is nil, an empty one is created."
|
|||
"Load the pkglist and archive-contents files."
|
||||
(interactive)
|
||||
(setq
|
||||
package-build-alist (package-build-read-from-file package-build-alist-file)
|
||||
package-build-archive-alist (cdr (package-build-read-from-file
|
||||
package-build-alist (pb/read-from-file package-build-alist-file)
|
||||
package-build-archive-alist (cdr (pb/read-from-file
|
||||
(expand-file-name "archive-contents"
|
||||
package-build-archive-dir)))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue