217
|
1 ;;; package-admin.el --- Installation and Maintenance of XEmacs packages
|
|
2
|
|
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: SL Baur <steve@altair.xemacs.org>
|
|
6 ;; Keywords: internal
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
23 ;; 02111-1307, USA.
|
|
24
|
|
25 ;;; Synched up with: Not in FSF
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
|
29 ;; First pass at lisp front end to package maintenance.
|
|
30
|
|
31 ;;; Code:
|
|
32
|
|
33 (require 'config)
|
|
34
|
237
|
35 (defvar package-admin-xemacs (concat invocation-directory invocation-name)
|
217
|
36 "Location of XEmacs binary to use.")
|
|
37
|
|
38 (defvar package-admin-temp-buffer "*Package Output*"
|
|
39 "Temporary buffer where output of backend commands is saved.")
|
|
40
|
314
|
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
|
217
|
80 ;;;###autoload
|
|
81 (defun package-admin-add-single-file-package (file destdir &optional pkg-dir)
|
|
82 "Install a single file Lisp package into XEmacs package hierarchy.
|
|
83 `file' should be the full path to the lisp file to install.
|
|
84 `destdir' should be a simple directory name.
|
243
|
85 The optional `pkg-dir' can be used to override the default package hierarchy
|
274
|
86 \(car \(last late-packages))."
|
217
|
87 (interactive "fLisp File: \nsDestination: ")
|
|
88 (when (null pkg-dir)
|
274
|
89 (setq pkg-dir (car (last late-packages))))
|
217
|
90 (let ((destination (concat pkg-dir "/lisp/" destdir))
|
|
91 (buf (get-buffer-create package-admin-temp-buffer)))
|
|
92 (call-process "add-little-package.sh"
|
|
93 nil
|
|
94 buf
|
|
95 t
|
|
96 ;; rest of command line follows
|
|
97 package-admin-xemacs file destination)))
|
|
98
|
314
|
99 (defun package-admin-install-function-mswindows (file pkg-dir buf)
|
|
100 "Install function for mswindows"
|
|
101 (let ( (default-directory pkg-dir) )
|
|
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)
|
217
|
124 (when (null pkg-dir)
|
274
|
125 (when (or (not (listp late-packages))
|
|
126 (not late-packages))
|
217
|
127 (error "No package path"))
|
274
|
128 (setq pkg-dir (car (last late-packages))))
|
314
|
129 pkg-dir
|
|
130 )
|
217
|
131
|
314
|
132 ;;;###autoload
|
|
133 (defun package-admin-add-binary-package (file &optional pkg-dir)
|
|
134 "Install a pre-bytecompiled XEmacs package into package hierarchy."
|
|
135 (interactive "fPackage tarball: ")
|
|
136 (setq pkg-dir (package-admin-get-install-dir pkg-dir))
|
|
137 (let ((buf (get-buffer-create package-admin-temp-buffer))
|
|
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 ))
|
217
|
165
|
|
166 (provide 'package-admin)
|
|
167
|
|
168 ;;; package-admin.el ends here
|