From: Chong Yidong Date: Thu, 10 Mar 2011 23:40:46 +0000 (-0500) Subject: Fix package.el handling of version numbers like 1.0pre6. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~608 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ba08b24186711eaeb3748f3d1f23e2c2d9ed0d09;p=emacs.git Fix package.el handling of version numbers like 1.0pre6. * lisp/emacs-lisp/package.el (package-version-join): Impose a standard string representation for pre/alpha/beta version lists. (package-unpack-single): Standardize the directory name by passing it through package-version-join. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0fbdd9dff76..c794ddb0788 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,7 +1,11 @@ 2011-03-10 Chong Yidong - * emacs-lisp/package.el (package-strip-rcs-id): Accept any version - string that does not signal an error in version-to-list. + * emacs-lisp/package.el (package-version-join): Impose a standard + string representation for pre/alpha/beta version lists. + (package-unpack-single): Standardize the directory name by passing + it through package-version-join. + (package-strip-rcs-id): Accept any version string that does not + signal an error in version-to-list. 2011-03-10 Michael Albinus diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 29089400cef..399e0fb2e24 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -320,14 +320,39 @@ The inner alist is keyed by version.") (put 'package-obsolete-alist 'risky-local-variable t) (defconst package-subdirectory-regexp - "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$" + "\\`\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)\\'" "Regular expression matching the name of a package subdirectory. The first subexpression is the package name. The second subexpression is the version string.") -(defun package-version-join (l) - "Turn a list of version numbers into a version string." - (mapconcat 'int-to-string l ".")) +(defun package-version-join (vlist) + "Return the version string corresponding to the list VLIST. +This is, approximately, the inverse of `version-to-list'. +\(Actually, it returns only one of the possible inverses, since +`version-to-list' is a many-to-one operation.)" + (if (null vlist) + "" + (let ((str-list (list "." (int-to-string (car vlist))))) + (dolist (num (cdr vlist)) + (cond + ((>= num 0) + (push (int-to-string num) str-list) + (push "." str-list)) + ((< num -3) + (error "Invalid version list `%s'" vlist)) + (t + ;; pre, or beta, or alpha + (cond ((equal "." (car str-list)) + (pop str-list)) + ((not (string-match "[0-9]+" (car str-list))) + (error "Invalid version list `%s'" vlist))) + (push (cond ((= num -1) "pre") + ((= num -2) "beta") + ((= num -3) "alpha")) + str-list)))) + (if (equal "." (car str-list)) + (pop str-list)) + (apply 'concat (nreverse str-list))))) (defun package-strip-version (dirname) "Strip the version from a combined package name and version. @@ -592,7 +617,9 @@ Otherwise it uses an external `tar' program. (if (string= file-name "package") (package--write-file-no-coding (expand-file-name (concat file-name ".el") package-user-dir)) - (let* ((pkg-dir (expand-file-name (concat file-name "-" version) + (let* ((pkg-dir (expand-file-name (concat file-name "-" + (package-version-join + (version-to-list version))) package-user-dir)) (el-file (expand-file-name (concat file-name ".el") pkg-dir)) (pkg-file (expand-file-name (concat file-name "-pkg.el") pkg-dir)))