summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2011-03-10 18:40:46 -0500
committerChong Yidong <cyd@stupidchicken.com>2011-03-10 18:40:46 -0500
commitba08b24186711eaeb3748f3d1f23e2c2d9ed0d09 (patch)
tree3a422b8b6e3796a86fab436f67c95ea7246a2ace /lisp/emacs-lisp
parentffbf300e1e88333532721940f8416b54e47ac0e7 (diff)
downloademacs-ba08b24186711eaeb3748f3d1f23e2c2d9ed0d09.tar.gz
emacs-ba08b24186711eaeb3748f3d1f23e2c2d9ed0d09.tar.bz2
emacs-ba08b24186711eaeb3748f3d1f23e2c2d9ed0d09.zip
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.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/package.el37
1 files changed, 32 insertions, 5 deletions
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)))