mirror of
https://github.com/correl/melpa.git
synced 2024-12-22 19:17:27 +00:00
Fixed the wonkiness. About to test.
This commit is contained in:
parent
d6136c239d
commit
00d101530d
1 changed files with 86 additions and 59 deletions
145
package-build.el
145
package-build.el
|
@ -80,9 +80,9 @@
|
|||
"%Y%m%d"
|
||||
(date-to-time
|
||||
(print (progn
|
||||
(re-search-backward
|
||||
"\\([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\\}\\)")
|
||||
(match-string-no-properties 1))))))))
|
||||
(re-search-backward
|
||||
"\\([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\\}\\)")
|
||||
(match-string-no-properties 1))))))))
|
||||
|
||||
(defun package-build-checkout-svn (repo dir)
|
||||
"checkout an svn repo"
|
||||
|
@ -111,9 +111,9 @@
|
|||
"%Y%m%d"
|
||||
(date-to-time
|
||||
(print (progn
|
||||
(re-search-backward
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")
|
||||
(match-string-no-properties 1))))))))
|
||||
(re-search-backward
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")
|
||||
(match-string-no-properties 1))))))))
|
||||
|
||||
(defun package-build-checkout-git (repo dir)
|
||||
"checkout an git repo"
|
||||
|
@ -143,33 +143,24 @@
|
|||
"%Y%m%d"
|
||||
(date-to-time
|
||||
(print (progn
|
||||
(re-search-backward
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")
|
||||
(match-string-no-properties 1))))))))
|
||||
(re-search-backward
|
||||
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")
|
||||
(match-string-no-properties 1))))))))
|
||||
|
||||
(defun package-change-list-elt (lst idx newval)
|
||||
(if (zerop idx)
|
||||
(cons newval (cdr lst))
|
||||
(cons (car lst) (package-change-list-elt (cdr lst) (1- idx) newval))))
|
||||
|
||||
(defun package-build-pkg-file (pkg-file file-name version homepage)
|
||||
(defun package-build-pkg-file (pkg-file pkg-info)
|
||||
"build the pkg file"
|
||||
(let ((print-level nil)
|
||||
(print-length nil)
|
||||
(pkglst
|
||||
(or (package-read-from-file pkg-file)
|
||||
(list 'define-package
|
||||
file-name
|
||||
version
|
||||
homepage
|
||||
(list 'quote (mapcar
|
||||
(lambda (elt)
|
||||
(list (car elt)
|
||||
(package-version-join (cadr elt))))
|
||||
nil))))))
|
||||
|
||||
;; set the packages version
|
||||
(setq pkglst (package-change-list-elt pkglst 2 version))
|
||||
(pkg-list (list 'define-package
|
||||
(aref pkg-info 0)
|
||||
(aref pkg-info 3)
|
||||
(aref pkg-info 2)
|
||||
(aref pkg-info 1))))
|
||||
|
||||
(write-region
|
||||
(concat
|
||||
|
@ -226,8 +217,37 @@
|
|||
(mapc 'package-build-archive pkgs)
|
||||
(package-build-dump-archive-contents))
|
||||
|
||||
(defun package-get-package-info (file-name)
|
||||
(when (file-exists-p file-name)
|
||||
(save-window-excursion
|
||||
(find-file file-name)
|
||||
(flet ((package-strip-rcs-id
|
||||
(str)
|
||||
(when str
|
||||
(when (string-match "\\`[ \t]*[$]Revision:[ \t]+" str)
|
||||
(setq str (substring str (match-end 0))))
|
||||
(setq str (car (split-string str)))
|
||||
(condition-case nil
|
||||
(if (version-to-list str)
|
||||
str)
|
||||
(error nil)))))
|
||||
(package-buffer-info)))))
|
||||
|
||||
(defun package-get-pkgfile-info (file-name)
|
||||
(when (file-exists-p file-name)
|
||||
(let ((pkgfile-info (cdr (package-read-from-file file-name))))
|
||||
(vector
|
||||
(nth 0 pkgfile-info)
|
||||
(mapcar
|
||||
(lambda (elt)
|
||||
(list (car elt) (version-to-list (cadr elt))))
|
||||
(eval (nth 3 pkgfile-info)))
|
||||
(nth 2 pkgfile-info)
|
||||
(nth 1 pkgfile-info)))))
|
||||
|
||||
|
||||
(defun package-build-archive (file-name)
|
||||
"build a git package archive"
|
||||
"build a package archive"
|
||||
(interactive)
|
||||
|
||||
(let* ((name (intern file-name))
|
||||
|
@ -240,10 +260,7 @@
|
|||
|
||||
(let* ((repo-type (plist-get cfg :fetcher))
|
||||
(repo-url (plist-get cfg :url))
|
||||
(summary (plist-get cfg :summary))
|
||||
(files (plist-get cfg :files))
|
||||
(pkglst)
|
||||
(pkgdeps)
|
||||
(version
|
||||
(cond
|
||||
((eq repo-type 'svn)
|
||||
|
@ -255,42 +272,49 @@
|
|||
((eq repo-type 'darcs)
|
||||
(print 'Darcs)
|
||||
(package-build-checkout-darcs repo-url pkg-cwd))))
|
||||
(pkg-base-dir (concat file-name "-" version))
|
||||
(pkg-file (concat file-name "-pkg.el"))
|
||||
(default-directory package-build-working-dir))
|
||||
|
||||
(cond
|
||||
((= 1 (length files))
|
||||
(copy-file (expand-file-name (car files) pkg-cwd)
|
||||
(expand-file-name (concat file-name "-" version ".el")
|
||||
package-build-archive-dir))
|
||||
(package-build-add-to-archive-contents
|
||||
name version pkgdeps summary 'single))
|
||||
|
||||
(let* ((pkgsrc (expand-file-name (car files) pkg-cwd))
|
||||
(pkg-info (package-get-package-info pkgsrc)))
|
||||
(unless pkg-info
|
||||
(setq pkg-info
|
||||
(vector file-name nil "No description available." version)))
|
||||
(aset version 3 pkg-info)
|
||||
(copy-file pkgsrc
|
||||
(expand-file-name (concat file-name "-" version ".el")
|
||||
package-build-archive-dir))
|
||||
(package-build-add-to-archive-contents pkg-info 'single)))
|
||||
(t
|
||||
(copy-directory file-name pkg-base-dir)
|
||||
(setq pkglst
|
||||
(package-build-pkg-file
|
||||
(expand-file-name
|
||||
pkg-file
|
||||
(concat
|
||||
(file-name-as-directory package-build-working-dir)
|
||||
(file-name-as-directory pkg-base-dir)))
|
||||
file-name version summary))
|
||||
(setq pkgdeps (mapcar
|
||||
(lambda (elt)
|
||||
(list (car elt) (version-to-list (cadr elt))))
|
||||
(eval (nth 4 pkglst))))
|
||||
(let* ((pkg-dir (concat file-name "-" version))
|
||||
(pkg-tar-dir
|
||||
(file-name-as-directory
|
||||
(expand-file-name pkg-dir package-build-working-dir)))
|
||||
(pkg-file (concat file-name "-pkg.el"))
|
||||
(pkg-info (package-get-pkgfile-info
|
||||
(expand-file-name pkg-file pkg-tar-dir))))
|
||||
|
||||
(copy-directory file-name pkg-dir)
|
||||
(unless pkg-info
|
||||
(setq pkg-info (package-get-package-info
|
||||
(expand-file-name file-name pkg-tar-dir))))
|
||||
(unless pkg-info
|
||||
(setq pkg-info
|
||||
(vector file-name nil "No description available." version)))
|
||||
(package-build-pkg-file (expand-file-name pkg-file pkg-tar-dir)
|
||||
pkg-info))
|
||||
|
||||
(when files
|
||||
(add-to-list 'files pkg-file))
|
||||
|
||||
(package-build-create-tar
|
||||
pkg-base-dir
|
||||
pkg-dir
|
||||
(expand-file-name
|
||||
(concat file-name "-" version ".tar") package-build-archive-dir)
|
||||
files)
|
||||
(delete-directory pkg-base-dir t nil)
|
||||
(package-build-add-to-archive-contents
|
||||
name version pkgdeps summary 'tar))))
|
||||
|
||||
(delete-directory pkg-dir t nil)
|
||||
(package-build-add-to-archive-contents pkg-info 'tar))))
|
||||
(package-build-dump-archive-contents))))
|
||||
|
||||
|
||||
|
@ -324,10 +348,13 @@
|
|||
(expand-file-name "archive-contents" package-build-archive-dir)
|
||||
nil nil nil nil))
|
||||
|
||||
|
||||
(defun package-build-add-to-archive-contents (name version deps homepage type)
|
||||
(defun package-build-add-to-archive-contents (pkg-info type)
|
||||
"add an archive to the package-build-archive-contents"
|
||||
(let ((existing (assq name package-build-archive-alist)))
|
||||
(let ((name (aref pkg-info 0))
|
||||
(requires (aref pkg-info 1))
|
||||
(desc (or (aref pkg-info 2) "No description available."))
|
||||
(version (aref pkg-info 3))
|
||||
(existing (assq name package-build-archive-alist)))
|
||||
(when existing
|
||||
(setq package-build-archive-alist
|
||||
(delq existing package-build-archive-alist)))
|
||||
|
@ -335,6 +362,6 @@
|
|||
(cons name
|
||||
(vector
|
||||
(version-to-list version)
|
||||
deps
|
||||
homepage
|
||||
requires
|
||||
desc
|
||||
type)))))
|
||||
|
|
Loading…
Reference in a new issue