From 00d101530d3cd627f5933fd80187cfd6f288a66a Mon Sep 17 00:00:00 2001 From: Donald Ephraim Curtis Date: Sat, 21 Jan 2012 21:49:46 -0600 Subject: [PATCH] Fixed the wonkiness. About to test. --- package-build.el | 145 ++++++++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 59 deletions(-) diff --git a/package-build.el b/package-build.el index 51c4680a..2eaef37f 100644 --- a/package-build.el +++ b/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)))))