aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-03-10 18:40:46 -0500
committerChong Yidong2011-03-10 18:40:46 -0500
commitba08b24186711eaeb3748f3d1f23e2c2d9ed0d09 (patch)
tree3a422b8b6e3796a86fab436f67c95ea7246a2ace
parentffbf300e1e88333532721940f8416b54e47ac0e7 (diff)
downloademacs-ba08b24186711eaeb3748f3d1f23e2c2d9ed0d09.tar.gz
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.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/emacs-lisp/package.el37
2 files changed, 38 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0fbdd9dff76..c794ddb0788 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,7 +1,11 @@
12011-03-10 Chong Yidong <cyd@stupidchicken.com> 12011-03-10 Chong Yidong <cyd@stupidchicken.com>
2 2
3 * emacs-lisp/package.el (package-strip-rcs-id): Accept any version 3 * emacs-lisp/package.el (package-version-join): Impose a standard
4 string that does not signal an error in version-to-list. 4 string representation for pre/alpha/beta version lists.
5 (package-unpack-single): Standardize the directory name by passing
6 it through package-version-join.
7 (package-strip-rcs-id): Accept any version string that does not
8 signal an error in version-to-list.
5 9
62011-03-10 Michael Albinus <michael.albinus@gmx.de> 102011-03-10 Michael Albinus <michael.albinus@gmx.de>
7 11
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.")
320(put 'package-obsolete-alist 'risky-local-variable t) 320(put 'package-obsolete-alist 'risky-local-variable t)
321 321
322(defconst package-subdirectory-regexp 322(defconst package-subdirectory-regexp
323 "^\\([^.].*\\)-\\([0-9]+\\(?:[.][0-9]+\\)*\\)$" 323 "\\`\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)\\'"
324 "Regular expression matching the name of a package subdirectory. 324 "Regular expression matching the name of a package subdirectory.
325The first subexpression is the package name. 325The first subexpression is the package name.
326The second subexpression is the version string.") 326The second subexpression is the version string.")
327 327
328(defun package-version-join (l) 328(defun package-version-join (vlist)
329 "Turn a list of version numbers into a version string." 329 "Return the version string corresponding to the list VLIST.
330 (mapconcat 'int-to-string l ".")) 330This is, approximately, the inverse of `version-to-list'.
331\(Actually, it returns only one of the possible inverses, since
332`version-to-list' is a many-to-one operation.)"
333 (if (null vlist)
334 ""
335 (let ((str-list (list "." (int-to-string (car vlist)))))
336 (dolist (num (cdr vlist))
337 (cond
338 ((>= num 0)
339 (push (int-to-string num) str-list)
340 (push "." str-list))
341 ((< num -3)
342 (error "Invalid version list `%s'" vlist))
343 (t
344 ;; pre, or beta, or alpha
345 (cond ((equal "." (car str-list))
346 (pop str-list))
347 ((not (string-match "[0-9]+" (car str-list)))
348 (error "Invalid version list `%s'" vlist)))
349 (push (cond ((= num -1) "pre")
350 ((= num -2) "beta")
351 ((= num -3) "alpha"))
352 str-list))))
353 (if (equal "." (car str-list))
354 (pop str-list))
355 (apply 'concat (nreverse str-list)))))
331 356
332(defun package-strip-version (dirname) 357(defun package-strip-version (dirname)
333 "Strip the version from a combined package name and version. 358 "Strip the version from a combined package name and version.
@@ -592,7 +617,9 @@ Otherwise it uses an external `tar' program.
592 (if (string= file-name "package") 617 (if (string= file-name "package")
593 (package--write-file-no-coding 618 (package--write-file-no-coding
594 (expand-file-name (concat file-name ".el") package-user-dir)) 619 (expand-file-name (concat file-name ".el") package-user-dir))
595 (let* ((pkg-dir (expand-file-name (concat file-name "-" version) 620 (let* ((pkg-dir (expand-file-name (concat file-name "-"
621 (package-version-join
622 (version-to-list version)))
596 package-user-dir)) 623 package-user-dir))
597 (el-file (expand-file-name (concat file-name ".el") pkg-dir)) 624 (el-file (expand-file-name (concat file-name ".el") pkg-dir))
598 (pkg-file (expand-file-name (concat file-name "-pkg.el") pkg-dir))) 625 (pkg-file (expand-file-name (concat file-name "-pkg.el") pkg-dir)))