Mercurial > hg > xemacs-beta
comparison lisp/package-admin.el @ 314:341dac730539 r21-0b55
Import from CVS: tag r21-0b55
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:44:22 +0200 |
parents | ca9a9ec9c1c1 |
children | afd57c14dfc8 |
comparison
equal
deleted
inserted
replaced
313:2905de29931f | 314:341dac730539 |
---|---|
36 "Location of XEmacs binary to use.") | 36 "Location of XEmacs binary to use.") |
37 | 37 |
38 (defvar package-admin-temp-buffer "*Package Output*" | 38 (defvar package-admin-temp-buffer "*Package Output*" |
39 "Temporary buffer where output of backend commands is saved.") | 39 "Temporary buffer where output of backend commands is saved.") |
40 | 40 |
41 (defvar package-admin-install-function 'package-admin-default-install-function | |
42 "The function to call to install a package. | |
43 Three args are passed: FILENAME PKG-DIR BUF | |
44 Install package FILENAME into directory PKG-DIR, with any messages output | |
45 to buffer BUF.") | |
46 | |
47 (defvar package-admin-error-messages '( | |
48 "No space left on device" | |
49 "No such file or directory" | |
50 "Filename too long" | |
51 "Read-only file system" | |
52 "File too large" | |
53 "Too many open files" | |
54 "Not enough space" | |
55 "Permission denied" | |
56 "Input/output error" | |
57 "Out of memory" | |
58 "Unable to create directory" | |
59 "Directory checksum error" | |
60 "Cannot exclusively open file" | |
61 "corrupted file" | |
62 "incomplete .* tree" | |
63 "Bad table" | |
64 "corrupt input" | |
65 "invalid compressed data" | |
66 "too many leaves in Huffman tree" | |
67 "not a valid zip file" | |
68 "first entry not deflated or stored" | |
69 "encrypted file --" | |
70 "unexpected end of file" | |
71 ) | |
72 "Regular expressions of possible error messages. | |
73 After each package extraction, the `package-admin-temp-buffer' buffer is | |
74 scanned for these messages. An error code is returned if one of these are | |
75 found. | |
76 | |
77 This is awful, but it exists because error return codes aren't reliable | |
78 under MS Windows.") | |
79 | |
41 ;;;###autoload | 80 ;;;###autoload |
42 (defun package-admin-add-single-file-package (file destdir &optional pkg-dir) | 81 (defun package-admin-add-single-file-package (file destdir &optional pkg-dir) |
43 "Install a single file Lisp package into XEmacs package hierarchy. | 82 "Install a single file Lisp package into XEmacs package hierarchy. |
44 `file' should be the full path to the lisp file to install. | 83 `file' should be the full path to the lisp file to install. |
45 `destdir' should be a simple directory name. | 84 `destdir' should be a simple directory name. |
55 buf | 94 buf |
56 t | 95 t |
57 ;; rest of command line follows | 96 ;; rest of command line follows |
58 package-admin-xemacs file destination))) | 97 package-admin-xemacs file destination))) |
59 | 98 |
60 ;;;###autoload | 99 (defun package-admin-install-function-mswindows (file pkg-dir buf) |
61 (defun package-admin-add-binary-package (file &optional pkg-dir) | 100 "Install function for mswindows" |
62 "Install a pre-bytecompiled XEmacs package into package hierarchy." | 101 (let ( (default-directory pkg-dir) ) |
63 (interactive "fPackage tarball: ") | 102 (call-process "djtar" nil buf t "-x" file) |
103 )) | |
104 | |
105 (defun package-admin-default-install-function (file pkg-dir buf) | |
106 "Default function to install a package. | |
107 Install package FILENAME into directory PKG-DIR, with any messages output | |
108 to buffer BUF." | |
109 (let (filename) | |
110 (setq filename (expand-file-name file pkg-dir)) | |
111 (if (shell-command (concat "gunzip -c " filename " | tar xvf -") buf) | |
112 0 | |
113 1) | |
114 )) | |
115 | |
116 ; (call-process "add-big-package.sh" | |
117 ; nil | |
118 ; buf | |
119 ; t | |
120 ; ;; rest of command line follows | |
121 ; package-admin-xemacs file pkg-dir)) | |
122 | |
123 (defun package-admin-get-install-dir (pkg-dir) | |
64 (when (null pkg-dir) | 124 (when (null pkg-dir) |
65 (when (or (not (listp late-packages)) | 125 (when (or (not (listp late-packages)) |
66 (not late-packages)) | 126 (not late-packages)) |
67 (error "No package path")) | 127 (error "No package path")) |
68 (setq pkg-dir (car (last late-packages)))) | 128 (setq pkg-dir (car (last late-packages)))) |
129 pkg-dir | |
130 ) | |
69 | 131 |
70 (let ((buf (get-buffer-create package-admin-temp-buffer))) | 132 ;;;###autoload |
71 (call-process "add-big-package.sh" | 133 (defun package-admin-add-binary-package (file &optional pkg-dir) |
72 nil | 134 "Install a pre-bytecompiled XEmacs package into package hierarchy." |
73 buf | 135 (interactive "fPackage tarball: ") |
74 t | 136 (setq pkg-dir (package-admin-get-install-dir pkg-dir)) |
75 ;; rest of command line follows | 137 (let ((buf (get-buffer-create package-admin-temp-buffer)) |
76 package-admin-xemacs file pkg-dir))) | 138 (status 1) |
139 start err-list | |
140 ) | |
141 ;; Insure that the current directory doesn't change | |
142 (save-excursion | |
143 (set-buffer buf) | |
144 (setq default-directory pkg-dir) | |
145 (setq case-fold-search t) | |
146 (buffer-disable-undo) | |
147 (goto-char (setq start (point-max))) | |
148 (if (= 0 (setq status (funcall package-admin-install-function | |
149 file pkg-dir buf))) | |
150 (catch 'done | |
151 (goto-char start) | |
152 (setq err-list package-admin-error-messages) | |
153 (while err-list | |
154 (if (re-search-forward (car err-list) nil t) | |
155 (progn | |
156 (setq status 1) | |
157 (throw 'done nil) | |
158 )) | |
159 (setq err-list (cdr err-list)) | |
160 ) | |
161 )) | |
162 ) | |
163 status | |
164 )) | |
77 | 165 |
78 (provide 'package-admin) | 166 (provide 'package-admin) |
79 | 167 |
80 ;;; package-admin.el ends here | 168 ;;; package-admin.el ends here |