diff options
| author | Chong Yidong | 2010-09-04 13:13:14 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-09-04 13:13:14 -0400 |
| commit | ebf662f4945f64dd36e0fe62a6cb7ab63c833a2e (patch) | |
| tree | 98c46ceaaf656596f954fd2cdf02c55d0539c168 | |
| parent | 864419991308a82d45f7982f2bcd6bacca3a9567 (diff) | |
| download | emacs-ebf662f4945f64dd36e0fe62a6cb7ab63c833a2e.tar.gz emacs-ebf662f4945f64dd36e0fe62a6cb7ab63c833a2e.zip | |
Avoid corrupting archive-contents file.
* emacs-lisp/package.el (package--download-one-archive): Ensure
that archive-contents is valid before saving it.
(package-activate-1, package-mark-obsolete, define-package)
(package-compute-transaction, package-list-maybe-add): Use push.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 53 |
2 files changed, 32 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fbee96a4fd7..efec2b3fcb4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2010-09-02 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * emacs-lisp/package.el (package--download-one-archive): Ensure | ||
| 4 | that archive-contents is valid before saving it. | ||
| 5 | (package-activate-1, package-mark-obsolete, define-package) | ||
| 6 | (package-compute-transaction, package-list-maybe-add): Use push. | ||
| 7 | |||
| 1 | 2010-09-03 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2010-09-03 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | Use SMIE's blink-paren for octave-mode. | 10 | Use SMIE's blink-paren for octave-mode. |
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index c1c4e2b6015..6c5aee2a735 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -406,16 +406,15 @@ updates `package-alist' and `package-obsolete-alist'." | |||
| 406 | (error "Internal error: could not find directory for %s-%s" | 406 | (error "Internal error: could not find directory for %s-%s" |
| 407 | name version-str)) | 407 | name version-str)) |
| 408 | ;; Add info node. | 408 | ;; Add info node. |
| 409 | (if (file-exists-p (expand-file-name "dir" pkg-dir)) | 409 | (when (file-exists-p (expand-file-name "dir" pkg-dir)) |
| 410 | (progn | 410 | ;; FIXME: not the friendliest, but simple. |
| 411 | ;; FIXME: not the friendliest, but simple. | 411 | (require 'info) |
| 412 | (require 'info) | 412 | (info-initialize) |
| 413 | (info-initialize) | 413 | (push pkg-dir Info-directory-list)) |
| 414 | (setq Info-directory-list (cons pkg-dir Info-directory-list)))) | ||
| 415 | ;; Add to load path, add autoloads, and activate the package. | 414 | ;; Add to load path, add autoloads, and activate the package. |
| 416 | (setq load-path (cons pkg-dir load-path)) | 415 | (push pkg-dir load-path) |
| 417 | (load (expand-file-name (concat name "-autoloads") pkg-dir) nil t) | 416 | (load (expand-file-name (concat name "-autoloads") pkg-dir) nil t) |
| 418 | (setq package-activated-list (cons package package-activated-list)) | 417 | (push package package-activated-list) |
| 419 | ;; Don't return nil. | 418 | ;; Don't return nil. |
| 420 | t)) | 419 | t)) |
| 421 | 420 | ||
| @@ -466,10 +465,9 @@ Return nil if the package could not be activated." | |||
| 466 | (setcdr elt (cons (cons (package-desc-vers pkg-vec) pkg-vec) | 465 | (setcdr elt (cons (cons (package-desc-vers pkg-vec) pkg-vec) |
| 467 | (cdr elt)))) | 466 | (cdr elt)))) |
| 468 | ;; Make a new association. | 467 | ;; Make a new association. |
| 469 | (setq package-obsolete-alist | 468 | (push (cons package (list (cons (package-desc-vers pkg-vec) |
| 470 | (cons (cons package (list (cons (package-desc-vers pkg-vec) | 469 | pkg-vec))) |
| 471 | pkg-vec))) | 470 | package-obsolete-alist)))) |
| 472 | package-obsolete-alist))))) | ||
| 473 | 471 | ||
| 474 | (defun define-package (name-str version-string | 472 | (defun define-package (name-str version-string |
| 475 | &optional docstring requirements | 473 | &optional docstring requirements |
| @@ -505,7 +503,7 @@ EXTRA-PROPERTIES is currently unused." | |||
| 505 | (setq package-alist (delq pkg-desc package-alist)) | 503 | (setq package-alist (delq pkg-desc package-alist)) |
| 506 | (package-mark-obsolete (car pkg-desc) (cdr pkg-desc))) | 504 | (package-mark-obsolete (car pkg-desc) (cdr pkg-desc))) |
| 507 | ;; Add package to the alist. | 505 | ;; Add package to the alist. |
| 508 | (setq package-alist (cons new-pkg-desc package-alist))) | 506 | (push new-pkg-desc package-alist)) |
| 509 | ;; You can have two packages with the same version, for instance | 507 | ;; You can have two packages with the same version, for instance |
| 510 | ;; one in the system package directory and one in your private | 508 | ;; one in the system package directory and one in your private |
| 511 | ;; directory. We just let the first one win. | 509 | ;; directory. We just let the first one win. |
| @@ -707,7 +705,7 @@ but version %s required" | |||
| 707 | (package-version-join (package-desc-vers (cdr pkg-desc))))) | 705 | (package-version-join (package-desc-vers (cdr pkg-desc))))) |
| 708 | ;; Only add to the transaction if we don't already have it. | 706 | ;; Only add to the transaction if we don't already have it. |
| 709 | (unless (memq next-pkg package-list) | 707 | (unless (memq next-pkg package-list) |
| 710 | (setq package-list (cons next-pkg package-list))) | 708 | (push next-pkg package-list)) |
| 711 | (setq package-list | 709 | (setq package-list |
| 712 | (package-compute-transaction package-list | 710 | (package-compute-transaction package-list |
| 713 | (package-desc-reqs | 711 | (package-desc-reqs |
| @@ -992,17 +990,19 @@ The file can either be a tar file or an Emacs Lisp file." | |||
| 992 | (re-search-forward "^$" nil 'move) | 990 | (re-search-forward "^$" nil 'move) |
| 993 | (forward-char) | 991 | (forward-char) |
| 994 | (delete-region (point-min) (point)) | 992 | (delete-region (point-min) (point)) |
| 995 | (make-directory dir t) | 993 | ;; Read the retrieved buffer to make sure it is valid (e.g. it |
| 996 | (setq buffer-file-name (expand-file-name file dir)) | 994 | ;; may fetch a URL redirect page). |
| 997 | (let ((version-control 'never)) | 995 | (when (listp (read buffer)) |
| 998 | (save-buffer))) | 996 | (make-directory dir t) |
| 997 | (setq buffer-file-name (expand-file-name file dir)) | ||
| 998 | (let ((version-control 'never)) | ||
| 999 | (save-buffer)))) | ||
| 999 | (kill-buffer buffer))) | 1000 | (kill-buffer buffer))) |
| 1000 | 1001 | ||
| 1001 | (defun package-refresh-contents () | 1002 | (defun package-refresh-contents () |
| 1002 | "Download the ELPA archive description if needed. | 1003 | "Download the ELPA archive description if needed. |
| 1003 | Invoking this will ensure that Emacs knows about the latest versions | 1004 | This informs Emacs about the latest versions of all packages, and |
| 1004 | of all packages. This will let Emacs make them available for | 1005 | makes them available for download." |
| 1005 | download." | ||
| 1006 | (interactive) | 1006 | (interactive) |
| 1007 | (unless (file-exists-p package-user-dir) | 1007 | (unless (file-exists-p package-user-dir) |
| 1008 | (make-directory package-user-dir t)) | 1008 | (make-directory package-user-dir t)) |
| @@ -1301,11 +1301,9 @@ Letters do not insert themselves; instead, they are commands. | |||
| 1301 | (run-mode-hooks 'package-menu-mode-hook)) | 1301 | (run-mode-hooks 'package-menu-mode-hook)) |
| 1302 | 1302 | ||
| 1303 | (defun package-menu-refresh () | 1303 | (defun package-menu-refresh () |
| 1304 | "Download the ELPA archive. | 1304 | "Download the Emacs Lisp package archive. |
| 1305 | This fetches the file describing the current contents of | 1305 | This fetches the contents of each archive specified in |
| 1306 | the Emacs Lisp Package Archive, and then refreshes the | 1306 | `package-archives', and then refreshes the package menu." |
| 1307 | package menu. This lets you see what new packages are | ||
| 1308 | available for download." | ||
| 1309 | (interactive) | 1307 | (interactive) |
| 1310 | (unless (eq major-mode 'package-menu-mode) | 1308 | (unless (eq major-mode 'package-menu-mode) |
| 1311 | (error "The current buffer is not a Package Menu")) | 1309 | (error "The current buffer is not a Package Menu")) |
| @@ -1460,8 +1458,7 @@ Emacs." | |||
| 1460 | 1458 | ||
| 1461 | (defun package-list-maybe-add (package version status description result) | 1459 | (defun package-list-maybe-add (package version status description result) |
| 1462 | (unless (assoc (cons package version) result) | 1460 | (unless (assoc (cons package version) result) |
| 1463 | (setq result (cons (list (cons package version) status description) | 1461 | (push (list (cons package version) status description) result)) |
| 1464 | result))) | ||
| 1465 | result) | 1462 | result) |
| 1466 | 1463 | ||
| 1467 | (defvar package-menu-package-list nil | 1464 | (defvar package-menu-package-list nil |