Extract code for single and multi-file package builds into helper fns

This commit is contained in:
Steve Purcell 2014-10-22 18:58:36 +01:00
parent 80e99703d3
commit 2ffb028ccd

View file

@ -1029,7 +1029,13 @@ Returns the archive entry for the package."
((not version) ((not version)
(error "Unable to check out repository for %s" package-name)) (error "Unable to check out repository for %s" package-name))
((= 1 (length files)) ((= 1 (length files))
(let* ((pkg-source (expand-file-name (caar files) source-dir)) (pb/build-single-file-package package-name version (caar files) source-dir target-dir))
((< 1 (length files))
(pb/build-multi-file-package package-name version files source-dir target-dir))
(t (error "Unable to find files matching recipe patterns")))))
(defun pb/build-single-file-package (package-name version file source-dir target-dir)
(let* ((pkg-source (expand-file-name file source-dir))
(pkg-target (expand-file-name (pkg-target (expand-file-name
(concat package-name "-" version ".el") (concat package-name "-" version ".el")
target-dir)) target-dir))
@ -1060,7 +1066,8 @@ Returns the archive entry for the package."
(pb/find-package-commentary pkg-source) (pb/find-package-commentary pkg-source)
package-name) package-name)
(pb/archive-entry pkg-info 'single))) (pb/archive-entry pkg-info 'single)))
((< 1 (length files))
(defun pb/build-multi-file-package (package-name version files source-dir target-dir)
(let* ((tmp-dir (file-name-as-directory (make-temp-file package-name t))) (let* ((tmp-dir (file-name-as-directory (make-temp-file package-name t)))
(pkg-dir-name (concat package-name "-" version)) (pkg-dir-name (concat package-name "-" version))
(pkg-tmp-dir (expand-file-name pkg-dir-name tmp-dir)) (pkg-tmp-dir (expand-file-name pkg-dir-name tmp-dir))
@ -1080,8 +1087,6 @@ Returns the archive entry for the package."
(pb/get-package-info pkg-source))) (pb/get-package-info pkg-source)))
package-name package-name
version))) version)))
(pb/copy-package-files files source-dir pkg-tmp-dir) (pb/copy-package-files files source-dir pkg-tmp-dir)
(pb/write-pkg-file (expand-file-name pkg-file (pb/write-pkg-file (expand-file-name pkg-file
(file-name-as-directory pkg-tmp-dir)) (file-name-as-directory pkg-tmp-dir))
@ -1103,8 +1108,6 @@ Returns the archive entry for the package."
(delete-directory pkg-tmp-dir t nil) (delete-directory pkg-tmp-dir t nil)
(pb/archive-entry pkg-info 'tar))) (pb/archive-entry pkg-info 'tar)))
(t (error "Unable to find files matching recipe patterns")))))
;; In future we should provide a hook, and perform this step in a separate package. ;; In future we should provide a hook, and perform this step in a separate package.
;; Note also that it would be straightforward to generate the SVG ourselves, which would ;; Note also that it would be straightforward to generate the SVG ourselves, which would