mirror of
https://github.com/correl/melpa.git
synced 2025-04-13 09:11:07 -09:00
Expand file list specs in package-build-package for a more convenient API
The expansion functions therefore become private once again. See #1274.
This commit is contained in:
parent
2e01dc88a5
commit
c05a403945
1 changed files with 99 additions and 88 deletions
|
@ -660,10 +660,13 @@ of the same-named package which is to be kept."
|
|||
collect pkg-info))
|
||||
|
||||
|
||||
(defun package-build-expand-file-specs (dir specs &optional subdir)
|
||||
(defun pb/expand-file-specs (dir specs &optional subdir allow-empty)
|
||||
"In DIR, expand SPECS, optionally under SUBDIR.
|
||||
The result is a list of (SOURCE . DEST), where SOURCE is a source
|
||||
file path and DEST is the relative path to which it should be copied."
|
||||
file path and DEST is the relative path to which it should be copied.
|
||||
|
||||
If the resulting list is empty, an error will be reported. Pass t
|
||||
for ALLOW-EMPTY to prevent this error."
|
||||
(let ((default-directory dir)
|
||||
(prefix (if subdir (format "%s/" subdir) ""))
|
||||
(lst))
|
||||
|
@ -672,14 +675,15 @@ file path and DEST is the relative path to which it should be copied."
|
|||
(if (consp entry)
|
||||
(if (eq :exclude (car entry))
|
||||
(cl-nset-difference lst
|
||||
(package-build-expand-file-specs dir (cdr entry))
|
||||
(pb/expand-file-specs dir (cdr entry) nil t)
|
||||
:key 'car
|
||||
:test 'equal)
|
||||
(nconc lst
|
||||
(package-build-expand-file-specs
|
||||
(pb/expand-file-specs
|
||||
dir
|
||||
(cdr entry)
|
||||
(concat prefix (car entry)))))
|
||||
(concat prefix (car entry))
|
||||
t)))
|
||||
(nconc
|
||||
lst (mapcar (lambda (f)
|
||||
(let ((destname)))
|
||||
|
@ -689,19 +693,19 @@ file path and DEST is the relative path to which it should be copied."
|
|||
"\\.in\\'"
|
||||
""
|
||||
(file-name-nondirectory f)))))
|
||||
(file-expand-wildcards entry))))))))
|
||||
(file-expand-wildcards entry))))))
|
||||
(when (and (null lst) (not allow-empty))
|
||||
(error "No matching file(s) found in %s: %s" dir specs))
|
||||
lst))
|
||||
|
||||
|
||||
(defun pb/expand-config-file-list (dir config)
|
||||
"In DIR, expand the :files for CONFIG using 'package-build-expand-file-specs."
|
||||
(let* ((patterns (or (plist-get config :files) package-build-default-files-spec))
|
||||
(files (package-build-expand-file-specs dir patterns)))
|
||||
(or files
|
||||
(error "No matching file(s) found in %s: %s" dir patterns))))
|
||||
(defun pb/config-file-list (config)
|
||||
"Get the :files spec from CONFIG, or return `package-build-default-files-spec'."
|
||||
(or (plist-get config :files) package-build-default-files-spec))
|
||||
|
||||
(defun pb/expand-source-file-list (dir config)
|
||||
"Shorthand way to expand paths in DIR for source files listed in CONFIG."
|
||||
(mapcar 'car (pb/expand-config-file-list dir config)))
|
||||
(mapcar 'car (pb/expand-file-specs dir (pb/config-file-list config))))
|
||||
|
||||
(defun pb/generate-info-files (files source-dir target-dir)
|
||||
"Create .info files from any .texi files listed in FILES in SOURCE-DIR in TARGET-DIR.
|
||||
|
@ -809,11 +813,11 @@ and a cl struct in Emacs HEAD. This wrapper normalises the results."
|
|||
|
||||
(pb/message "\n;;; %s\n" file-name)
|
||||
(let* ((version (package-build-checkout name rcp pkg-working-dir))
|
||||
(files (pb/expand-config-file-list pkg-working-dir rcp))
|
||||
(default-directory package-build-working-dir)
|
||||
(start-time (current-time))
|
||||
(archive-entry (package-build-package (symbol-name name)
|
||||
version files
|
||||
version
|
||||
(pb/config-file-list rcp)
|
||||
pkg-working-dir
|
||||
package-build-archive-dir)))
|
||||
(pb/dump archive-entry
|
||||
|
@ -825,13 +829,20 @@ and a cl struct in Emacs HEAD. This wrapper normalises the results."
|
|||
file-name)))
|
||||
|
||||
;;;###autoload
|
||||
(defun package-build-package (package-name version files source-dir target-dir)
|
||||
"Create PACKAGE-NAME with VERSION containing FILES from SOURCE-DIR, and store in TARGET-DIR.
|
||||
(defun package-build-package (package-name version file-specs source-dir target-dir)
|
||||
"Create PACKAGE-NAME with VERSION using FILE-SPECS to gather files from SOURCE-DIR.
|
||||
|
||||
Argument FILES is an list of (SRC . DEST) relative path pairs, as
|
||||
returned by `package-build-expand-file-specs'.
|
||||
The resulting package will be stored as a .el or .tar file in
|
||||
TARGET-DIR, depending on whether there are multiple files.
|
||||
|
||||
Argument FILE-SPECS is a list of specs for source files, which
|
||||
should be relative to SOURCE-DIR. The specs can be wildcards,
|
||||
and optionally specify different target paths. They extended
|
||||
syntax is currently only documented in the MELPA README. You can
|
||||
simply pass `package-build-default-files-spec' in most cases.
|
||||
|
||||
Returns the archive entry for the package."
|
||||
(let ((files (pb/expand-file-specs source-dir file-specs)))
|
||||
(cond
|
||||
((not version)
|
||||
(error "Unable to check out repository for %s" package-name))
|
||||
|
@ -908,7 +919,7 @@ Returns the archive entry for the package."
|
|||
(delete-directory pkg-tmp-dir t nil)
|
||||
(pb/archive-entry pkg-info 'tar)))
|
||||
|
||||
(t (error "Unable to find files matching recipe patterns"))))
|
||||
(t (error "Unable to find files matching recipe patterns")))))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue