Fixed the wonkiness. About to test.

This commit is contained in:
Donald Ephraim Curtis 2012-01-21 21:49:46 -06:00
parent d6136c239d
commit 00d101530d

View file

@ -80,9 +80,9 @@
"%Y%m%d" "%Y%m%d"
(date-to-time (date-to-time
(print (progn (print (progn
(re-search-backward (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\\}\\)") "\\([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)))))))) (match-string-no-properties 1))))))))
(defun package-build-checkout-svn (repo dir) (defun package-build-checkout-svn (repo dir)
"checkout an svn repo" "checkout an svn repo"
@ -111,9 +111,9 @@
"%Y%m%d" "%Y%m%d"
(date-to-time (date-to-time
(print (progn (print (progn
(re-search-backward (re-search-backward
"\\([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\\}\\)")
(match-string-no-properties 1)))))))) (match-string-no-properties 1))))))))
(defun package-build-checkout-git (repo dir) (defun package-build-checkout-git (repo dir)
"checkout an git repo" "checkout an git repo"
@ -143,33 +143,24 @@
"%Y%m%d" "%Y%m%d"
(date-to-time (date-to-time
(print (progn (print (progn
(re-search-backward (re-search-backward
"\\([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\\}\\)")
(match-string-no-properties 1)))))))) (match-string-no-properties 1))))))))
(defun package-change-list-elt (lst idx newval) (defun package-change-list-elt (lst idx newval)
(if (zerop idx) (if (zerop idx)
(cons newval (cdr lst)) (cons newval (cdr lst))
(cons (car lst) (package-change-list-elt (cdr lst) (1- idx) newval)))) (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" "build the pkg file"
(let ((print-level nil) (let ((print-level nil)
(print-length nil) (print-length nil)
(pkglst (pkg-list (list 'define-package
(or (package-read-from-file pkg-file) (aref pkg-info 0)
(list 'define-package (aref pkg-info 3)
file-name (aref pkg-info 2)
version (aref pkg-info 1))))
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))
(write-region (write-region
(concat (concat
@ -226,8 +217,37 @@
(mapc 'package-build-archive pkgs) (mapc 'package-build-archive pkgs)
(package-build-dump-archive-contents)) (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) (defun package-build-archive (file-name)
"build a git package archive" "build a package archive"
(interactive) (interactive)
(let* ((name (intern file-name)) (let* ((name (intern file-name))
@ -240,10 +260,7 @@
(let* ((repo-type (plist-get cfg :fetcher)) (let* ((repo-type (plist-get cfg :fetcher))
(repo-url (plist-get cfg :url)) (repo-url (plist-get cfg :url))
(summary (plist-get cfg :summary))
(files (plist-get cfg :files)) (files (plist-get cfg :files))
(pkglst)
(pkgdeps)
(version (version
(cond (cond
((eq repo-type 'svn) ((eq repo-type 'svn)
@ -255,42 +272,49 @@
((eq repo-type 'darcs) ((eq repo-type 'darcs)
(print 'Darcs) (print 'Darcs)
(package-build-checkout-darcs repo-url pkg-cwd)))) (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)) (default-directory package-build-working-dir))
(cond (cond
((= 1 (length files)) ((= 1 (length files))
(copy-file (expand-file-name (car files) pkg-cwd) (let* ((pkgsrc (expand-file-name (car files) pkg-cwd))
(expand-file-name (concat file-name "-" version ".el") (pkg-info (package-get-package-info pkgsrc)))
package-build-archive-dir)) (unless pkg-info
(package-build-add-to-archive-contents (setq pkg-info
name version pkgdeps summary 'single)) (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 (t
(copy-directory file-name pkg-base-dir) (let* ((pkg-dir (concat file-name "-" version))
(setq pkglst (pkg-tar-dir
(package-build-pkg-file (file-name-as-directory
(expand-file-name (expand-file-name pkg-dir package-build-working-dir)))
pkg-file (pkg-file (concat file-name "-pkg.el"))
(concat (pkg-info (package-get-pkgfile-info
(file-name-as-directory package-build-working-dir) (expand-file-name pkg-file pkg-tar-dir))))
(file-name-as-directory pkg-base-dir)))
file-name version summary)) (copy-directory file-name pkg-dir)
(setq pkgdeps (mapcar (unless pkg-info
(lambda (elt) (setq pkg-info (package-get-package-info
(list (car elt) (version-to-list (cadr elt)))) (expand-file-name file-name pkg-tar-dir))))
(eval (nth 4 pkglst)))) (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 (when files
(add-to-list 'files pkg-file)) (add-to-list 'files pkg-file))
(package-build-create-tar (package-build-create-tar
pkg-base-dir pkg-dir
(expand-file-name (expand-file-name
(concat file-name "-" version ".tar") package-build-archive-dir) (concat file-name "-" version ".tar") package-build-archive-dir)
files) files)
(delete-directory pkg-base-dir t nil)
(package-build-add-to-archive-contents (delete-directory pkg-dir t nil)
name version pkgdeps summary 'tar)))) (package-build-add-to-archive-contents pkg-info 'tar))))
(package-build-dump-archive-contents)))) (package-build-dump-archive-contents))))
@ -324,10 +348,13 @@
(expand-file-name "archive-contents" package-build-archive-dir) (expand-file-name "archive-contents" package-build-archive-dir)
nil nil nil nil)) nil nil nil nil))
(defun package-build-add-to-archive-contents (pkg-info type)
(defun package-build-add-to-archive-contents (name version deps homepage type)
"add an archive to the package-build-archive-contents" "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 (when existing
(setq package-build-archive-alist (setq package-build-archive-alist
(delq existing package-build-archive-alist))) (delq existing package-build-archive-alist)))
@ -335,6 +362,6 @@
(cons name (cons name
(vector (vector
(version-to-list version) (version-to-list version)
deps requires
homepage desc
type))))) type)))))