annotate lisp/package-admin.el @ 384:bbff43aa5eb7 r21-2-7

Import from CVS: tag r21-2-7
author cvs
date Mon, 13 Aug 2007 11:08:24 +0200
parents 064ab7fed2e0
children aabb7f5b1c81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1 ;;; package-admin.el --- Installation and Maintenance of XEmacs packages
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
4
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
5 ;; Author: SL Baur <steve@altair.xemacs.org>
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
6 ;; Keywords: internal
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
7
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
9
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
13 ;; any later version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
14
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
18 ;; General Public License for more details.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
19
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
24
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
26
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
27 ;;; Commentary:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
28
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
29 ;; First pass at lisp front end to package maintenance.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
30
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
31 ;;; Code:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
32
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
33 (require 'config)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
34
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 217
diff changeset
35 (defvar package-admin-xemacs (concat invocation-directory invocation-name)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
36 "Location of XEmacs binary to use.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
37
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
38 (defvar package-admin-temp-buffer "*Package Output*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
39 "Temporary buffer where output of backend commands is saved.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
40
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
41 (defvar package-admin-install-function 'package-admin-default-install-function
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
42 "The function to call to install a package.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
43 Three args are passed: FILENAME PKG-DIR BUF
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
44 Install package FILENAME into directory PKG-DIR, with any messages output
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
45 to buffer BUF.")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
46
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
47 (defvar package-admin-error-messages '(
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
48 "No space left on device"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
49 "No such file or directory"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
50 "Filename too long"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
51 "Read-only file system"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
52 "File too large"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
53 "Too many open files"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
54 "Not enough space"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
55 "Permission denied"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
56 "Input/output error"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
57 "Out of memory"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
58 "Unable to create directory"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
59 "Directory checksum error"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
60 "Cannot exclusively open file"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
61 "corrupted file"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
62 "incomplete .* tree"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
63 "Bad table"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
64 "corrupt input"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
65 "invalid compressed data"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
66 "too many leaves in Huffman tree"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
67 "not a valid zip file"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
68 "first entry not deflated or stored"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
69 "encrypted file --"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
70 "unexpected end of file"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
71 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
72 "Regular expressions of possible error messages.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
73 After each package extraction, the `package-admin-temp-buffer' buffer is
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
74 scanned for these messages. An error code is returned if one of these are
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
75 found.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
76
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
77 This is awful, but it exists because error return codes aren't reliable
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
78 under MS Windows.")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
79
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
80 (defvar package-admin-tar-filename-regexps
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
81 '(
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
82 ;; GNU tar:
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
83 ;; drwxrwxr-x john/doe 123 1997-02-18 15:48 pathname
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
84 "\\S-+\\s-+[-a-z0-9_/]+\\s-+[0-9]+\\s-+[-0-9]+\\s-+[0-9:]+\\s-+\\(\\S-.*\\)"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
85 ;; HP-UX & SunOS tar:
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
86 ;; rwxrwxr-x 501/501 123 Feb 18 15:46 1997 pathname
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
87 ;; Solaris tar (phooey!):
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
88 ;; rwxrwxr-x501/501 123 Feb 18 15:46 1997 pathname
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
89 ;; AIX tar:
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
90 ;; -rw-r--r-- 147 1019 32919 Mar 26 12:00:09 1992 pathname
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
91 "\\S-+\\s-*[-a-z0-9_]+[/ ][-a-z0-9_]+\\s-+[0-9]+\\s-+[a-z][a-z][a-z]\\s-+[0-9]+\\s-+[0-9:]+\\s-+[0-9]+\\s-+\\(\\S-.*\\)"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
92
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
93 ;; djtar:
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
94 ;; drwx Aug 31 02:01:41 1998 123 pathname
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
95 "\\S-+\\s-+[a-z][a-z][a-z]\\s-+[0-9]+\\s-+[0-9:]+\\s-+[0-9]+\\s-+[0-9]+\\s-+\\(\\S-.*\\)"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
96
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
97 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
98 "List of regexps to use to search for tar filenames.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
99 Note that \"\\(\" and \"\\)\" must be used to delimit the pathname (as
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
100 match #1). Don't put \"^\" to match the beginning of the line; this
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
101 is already implicit, as `looking-at' is used. Filenames can,
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
102 unfortunately, contain spaces, so be careful in constructing any
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
103 regexps.")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
104
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
105 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
106 (defun package-admin-add-single-file-package (file destdir &optional pkg-dir)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
107 "Install a single file Lisp package into XEmacs package hierarchy.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
108 `file' should be the full path to the lisp file to install.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
109 `destdir' should be a simple directory name.
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 237
diff changeset
110 The optional `pkg-dir' can be used to override the default package hierarchy
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 243
diff changeset
111 \(car \(last late-packages))."
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
112 (interactive "fLisp File: \nsDestination: ")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
113 (when (null pkg-dir)
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents: 243
diff changeset
114 (setq pkg-dir (car (last late-packages))))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
115 (let ((destination (concat pkg-dir "/lisp/" destdir))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
116 (buf (get-buffer-create package-admin-temp-buffer)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
117 (call-process "add-little-package.sh"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
118 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
119 buf
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
120 t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
121 ;; rest of command line follows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
122 package-admin-xemacs file destination)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
123
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
124 (defun package-admin-install-function-mswindows (file pkg-dir buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
125 "Install function for mswindows"
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
126 (let ((default-directory (file-name-as-directory pkg-dir)))
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
127 (unless (file-directory-p default-directory)
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
128 (make-directory default-directory t))
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
129 (call-process "djtar" nil buf t "-x" file)))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
130
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
131 (defun package-admin-default-install-function (file pkg-dir buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
132 "Default function to install a package.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
133 Install package FILENAME into directory PKG-DIR, with any messages output
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
134 to buffer BUF."
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
135 (let* ((pkg-dir (file-name-as-directory pkg-dir))
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
136 (default-directory pkg-dir)
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
137 (filename (expand-file-name file)))
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
138 (unless (file-directory-p pkg-dir)
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
139 (make-directory pkg-dir t))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
140 ;; Don't assume GNU tar.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
141 (if (shell-command (concat "gunzip -c " filename " | tar xvf -") buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
142 0
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
143 1)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
144 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
145
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
146 ; (call-process "add-big-package.sh"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
147 ; nil
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
148 ; buf
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
149 ; t
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
150 ; ;; rest of command line follows
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
151 ; package-admin-xemacs file pkg-dir))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
152
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
153 (defun package-admin-get-install-dir (package pkg-dir &optional mule-related)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
154 "If PKG-DIR is non-nil return that,
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
155 else return the current location of the package if it is already installed
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
156 or return a location appropriate for the package otherwise."
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
157 (if pkg-dir
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
158 pkg-dir
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
159 (let ((package-feature (intern-soft (concat
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
160 (symbol-name package) "-autoloads")))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
161 autoload-dir)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
162 (when (and (not (eq package 'unknown))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
163 (featurep package-feature)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
164 (setq autoload-dir (feature-file package-feature))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
165 (setq autoload-dir (file-name-directory autoload-dir))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
166 (member autoload-dir late-package-load-path))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
167 ;; Find the corresonding entry in late-package
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
168 (setq pkg-dir
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
169 (car-safe (member-if (lambda (h)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
170 (string-match (concat "^" (regexp-quote h))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
171 autoload-dir))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
172 late-packages))))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
173 (if pkg-dir
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
174 pkg-dir
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
175 ;; Ok we need to guess
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
176 (if mule-related
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
177 (package-admin-get-install-dir 'mule-base nil nil)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
178 (car (last late-packages)))))))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
179
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
180
318
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 314
diff changeset
181
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
182 (defun package-admin-get-manifest-file (pkg-topdir package)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
183 "Return the name of the MANIFEST file for package PACKAGE.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
184 Note that PACKAGE is a symbol, and not a string."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
185 (let (dir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
186 (setq dir (expand-file-name "pkginfo" pkg-topdir))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
187 (expand-file-name (concat "MANIFEST." (symbol-name package)) dir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
188 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
189
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
190 (defun package-admin-check-manifest (pkg-outbuf pkg-topdir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
191 "Check for a MANIFEST.<package> file in the package distribution.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
192 If it doesn't exist, create and write one.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
193 PKG-OUTBUF is the buffer that holds the output from `tar', and PKG-TOPDIR
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
194 is the top-level directory under which the package was installed."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
195 (let ( (manifest-buf " *pkg-manifest*")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
196 old-case-fold-search regexp package-name pathname regexps)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
197 ;; Save and restore the case-fold-search status.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
198 ;; We do this in case we have to screw with it (as it the case of
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
199 ;; case-insensitive filesystems such as MS Windows).
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
200 (setq old-case-fold-search case-fold-search)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
201 (unwind-protect
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
202 (save-excursion ;; Probably redundant.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
203 (set-buffer (get-buffer pkg-outbuf)) ;; Probably already the
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
204 ;; current buffer.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
205 (goto-char (point-min))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
206
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
207 ;; Make filenames case-insensitive, if necessary
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
208 (if (eq system-type 'windows-nt)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
209 (setq case-fold-search t))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
210
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
211 ;; We really should compute the regexp.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
212 ;; However, directory-sep-char is currently broken, but we need
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
213 ;; functional code *NOW*.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
214 (setq regexp "\\bpkginfo[\\/]MANIFEST\\...*")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
215
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
216 ;; Look for the manifest.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
217 (if (not (re-search-forward regexp nil t))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
218 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
219 ;; We didn't find a manifest. Make one.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
220
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
221 ;; Yuk. We weren't passed the package name, and so we have
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
222 ;; to dig for it. Look for it as the subdirectory name below
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
223 ;; "lisp", "man", "info", or "etc".
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
224 ;; Here, we don't use a single regexp because we want to search
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
225 ;; the directories for a package name in a particular order.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
226 ;; The problem is that packages could have directories like
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
227 ;; "etc/sounds/" or "etc/photos/" and we don't want to get
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
228 ;; these confused with the actual package name (although, in
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
229 ;; the case of "etc/sounds/", it's probably correct).
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
230 (if (catch 'done
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
231 (let ( (dirs '("lisp" "info" "man" "etc")) rexp)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
232 (while dirs
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
233 (setq rexp (concat "\\b" (car dirs)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
234 "[\\/]\\([^\\/]+\\)[\//]"))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
235 (if (re-search-forward rexp nil t)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
236 (throw 'done t))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
237 (setq dirs (cdr dirs))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
238 )))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
239 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
240 (setq package-name (buffer-substring (match-beginning 1)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
241 (match-end 1)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
242
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
243 ;; Get and erase the manifest buffer
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
244 (setq manifest-buf (get-buffer-create manifest-buf))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
245 (buffer-disable-undo manifest-buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
246 (erase-buffer manifest-buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
247
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
248 ;; Now, scan through the output buffer, looking for
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
249 ;; file and directory names.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
250 (goto-char (point-min))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
251 ;; for each line ...
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
252 (while (< (point) (point-max))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
253 (beginning-of-line)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
254 (setq pathname nil)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
255
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
256 ;; scan through the regexps, looking for a pathname
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
257 (if (catch 'found-path
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
258 (setq regexps package-admin-tar-filename-regexps)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
259 (while regexps
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
260 (if (looking-at (car regexps))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
261 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
262 (setq pathname
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
263 (buffer-substring
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
264 (match-beginning 1)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
265 (match-end 1)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
266 (throw 'found-path t)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
267 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
268 (setq regexps (cdr regexps))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
269 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
270 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
271 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
272 ;; found a pathname -- add it to the manifest
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
273 ;; buffer
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
274 (save-excursion
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
275 (set-buffer manifest-buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
276 (goto-char (point-max))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
277 (insert pathname "\n")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
278 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
279 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
280 (forward-line 1)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
281 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
282
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
283 ;; Processed all lines.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
284 ;; Now, create the file, pkginfo/MANIFEST.<pkgname>
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
285
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
286 ;; We use `expand-file-name' instead of `concat',
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
287 ;; for portability.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
288 (setq pathname (expand-file-name "pkginfo"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
289 pkg-topdir))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
290 ;; Create pkginfo, if necessary
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
291 (if (not (file-directory-p pathname))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
292 (make-directory pathname))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
293 (setq pathname (expand-file-name
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
294 (concat "MANIFEST." package-name)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
295 pathname))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
296 (save-excursion
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
297 (set-buffer manifest-buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
298 ;; Put the files in sorted order
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
299 (sort-lines nil (point-min) (point-max))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
300 ;; Write the file.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
301 ;; Note that using `write-region' *BYPASSES* any check
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
302 ;; to see if XEmacs is currently editing/visiting the
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
303 ;; file.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
304 (write-region (point-min) (point-max) pathname)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
305 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
306 (kill-buffer manifest-buf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
307 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
308 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
309 ;; We can't determine the package name from an extracted
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
310 ;; file in the tar output buffer.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
311 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
312 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
313 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
314 ;; Restore old case-fold-search status
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
315 (setq case-fold-search old-case-fold-search))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
316 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
317
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
318 ;;;###autoload
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
319 (defun package-admin-add-binary-package (file &optional pkg-dir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
320 "Install a pre-bytecompiled XEmacs package into package hierarchy."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
321 (interactive "fPackage tarball: ")
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
322 (let ((buf (get-buffer-create package-admin-temp-buffer))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
323 (status 1)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
324 start err-list
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
325 )
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
326 (setq pkg-dir (package-admin-get-install-dir 'unknown pkg-dir))
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
327 ;; Ensure that the current directory doesn't change
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
328 (save-excursion
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
329 (set-buffer buf)
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
330 ;; This is not really needed
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
331 (setq default-directory (file-name-as-directory pkg-dir))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
332 (setq case-fold-search t)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
333 (buffer-disable-undo)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
334 (goto-char (setq start (point-max)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
335 (if (= 0 (setq status (funcall package-admin-install-function
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
336 file pkg-dir buf)))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
337 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
338 ;; First, check for errors.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
339 ;; We can't necessarily rely upon process error codes.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
340 (catch 'done
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
341 (goto-char start)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
342 (setq err-list package-admin-error-messages)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
343 (while err-list
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
344 (if (re-search-forward (car err-list) nil t)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
345 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
346 (setq status 1)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
347 (throw 'done nil)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
348 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
349 (setq err-list (cdr err-list))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
350 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
351 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
352 ;; Make sure that the MANIFEST file exists
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
353 (package-admin-check-manifest buf pkg-dir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
354 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
355 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
356 status
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
357 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
358
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
359 (defun package-admin-rmtree (directory)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
360 "Delete a directory and all of its contents, recursively.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
361 This is a feeble attempt at making a portable rmdir."
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
362 (setq directory (file-name-as-directory directory))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
363 (let ((files (directory-files directory nil nil nil t))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
364 (dirs (directory-files directory nil nil nil 'dirs)))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
365 (while dirs
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
366 (if (not (member (car dirs) '("." "..")))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
367 (let ((dir (expand-file-name (car dirs) directory)))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
368 (condition-case err
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
369 (if (file-symlink-p dir) ;; just in case, handle symlinks
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
370 (delete-file dir)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
371 (package-admin-rmtree dir))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
372 (file-error
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
373 (message "%s: %s: \"%s\"" (nth 1 err) (nth 2 err) (nth 3 err)))))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
374 (setq dirs (cdr dirs))))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
375 (while files
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
376 (condition-case err
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
377 (delete-file (expand-file-name (car files) directory))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
378 (file-error
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
379 (message "%s: %s: \"%s\"" (nth 1 err) (nth 2 err) (nth 3 err))))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
380 (setq files (cdr files)))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
381 (condition-case err
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
382 (delete-directory directory)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
383 (file-error
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
384 (message "%s: %s: \"%s\"" (nth 1 err) (nth 2 err) (nth 3 err))))))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
385
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
386 (defun package-admin-get-lispdir (pkg-topdir package)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
387 (let (package-lispdir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
388 (if (and (setq package-lispdir (expand-file-name "lisp" pkg-topdir))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
389 (setq package-lispdir (expand-file-name (symbol-name package)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
390 package-lispdir))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
391 (file-accessible-directory-p package-lispdir))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
392 package-lispdir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
393 ))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
394
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
395 (defun package-admin-delete-binary-package (package pkg-topdir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
396 "Delete a binary installation of PACKAGE below directory PKG-TOPDIR.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
397 PACKAGE is a symbol, not a string."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
398 (let ( (tmpbuf " *pkg-manifest*") manifest-file package-lispdir dirs file)
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
399 (setq pkg-topdir (package-admin-get-install-dir package pkg-topdir))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
400 (setq manifest-file (package-admin-get-manifest-file pkg-topdir package))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
401 (if (file-exists-p manifest-file)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
402 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
403 ;; The manifest file exists! Use it to delete the old distribution.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
404 (message "Removing old files for package \"%s\" ..." package)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
405 (sit-for 0)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
406 (setq tmpbuf (get-buffer-create tmpbuf))
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
407 (with-current-buffer tmpbuf
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
408 (buffer-disable-undo)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
409 (erase-buffer)
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
410 (insert-file-contents manifest-file)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
411 (goto-char (point-min))
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
412
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
413 ;; For each entry in the MANIFEST ...
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
414 (while (< (point) (point-max))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
415 (beginning-of-line)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
416 (setq file (expand-file-name (buffer-substring
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
417 (point)
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
418 (point-at-eol))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
419 pkg-topdir))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
420 (if (file-directory-p file)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
421 ;; Keep a record of each directory
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
422 (setq dirs (cons file dirs))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
423 ;; Delete each file.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
424 ;; Make sure that the file is writable.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
425 ;; (This is important under MS Windows.)
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
426 ;; I do not know why it important under MS Windows but
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
427 ;; 1. It bombs out out when the file does not exist. This can be condition-cased
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
428 ;; 2. If I removed the write permissions, I do not want XEmacs to just ignore them.
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
429 ;; If it wants to, XEmacs may ask, but that is about all
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
430 ;; (set-file-modes file 438) ;; 438 -> #o666
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
431 ;; Note, user might have removed the file!
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
432 (condition-case ()
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
433 (delete-file file)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
434 (error nil))) ;; We may want to turn the error into a Warning?
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
435 (forward-line 1))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
436
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
437 ;; Delete empty directories.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
438 (if dirs
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
439 (let ( (orig-default-directory default-directory)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 382
diff changeset
440 directory files file )
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
441 ;; Make sure we preserve the existing `default-directory'.
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
442 ;; JV, why does this change the default directory? Does it indeed?
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
443 (unwind-protect
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
444 (progn
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
445 ;; Warning: destructive sort!
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
446 (setq dirs (nreverse (sort dirs 'string<)))
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
447 ; ;; For each directory ...
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
448 ; (while dirs
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
449 ; (setq directory (file-name-as-directory (car dirs)))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
450 ; (setq files (directory-files directory))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
451 ; ;; Delete the directory if it's empty.
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
452 ; (if (catch 'done
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
453 ; (while files
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
454 ; (setq file (car files))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
455 ; (if (and (not (string= file "."))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
456 ; (not (string= file "..")))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
457 ; (throw 'done nil))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
458 ; (setq files (cdr files))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
459 ; )
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
460 ; t)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
461 ; (
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
462 ; (delete-directory directory))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
463 ; (setq dirs (cdr dirs))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
464 ; )
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
465 ;; JV, On all OS's that I know of delete-directory fails on
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
466 ;; on non-empty dirs anyway
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
467 (mapc
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
468 (lambda (dir)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
469 (condition-case ()
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
470 (delete-directory dir)))
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
471 dirs))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
472 (setq default-directory orig-default-directory)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
473 )))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
474 )
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
475 (kill-buffer tmpbuf)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
476 ;; Delete the MANIFEST file
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
477 ;; (set-file-modes manifest-file 438) ;; 438 -> #o666
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
478 ;; Note. Packages can have MANIFEST in MANIFEST.
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
479 (condition-case ()
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
480 (delete-file manifest-file)
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
481 (error nil)) ;; Do warning?
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
482 (message "Removing old files for package \"%s\" ... done" package))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
483 ;; The manifest file doesn't exist. Fallback to just deleting the
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
484 ;; package-specific lisp directory, if it exists.
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
485 ;;
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
486 ;; Delete old lisp directory, if any
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
487 ;; Gads, this is ugly. However, we're not supposed to use `concat'
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
488 ;; in the name of portability.
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
489 (when (setq package-lispdir (package-admin-get-lispdir pkg-topdir
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
490 package))
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
491 (message "Removing old lisp directory \"%s\" ..."
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
492 package-lispdir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
493 (sit-for 0)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
494 (package-admin-rmtree package-lispdir)
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
495 (message "Removing old lisp directory \"%s\" ... done"
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
496 package-lispdir)
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
497 ))
373
6240c7796c7a Import from CVS: tag r21-2b2
cvs
parents: 371
diff changeset
498 ;; Delete the package from the database of installed packages.
375
a300bb07d72d Import from CVS: tag r21-2b3
cvs
parents: 373
diff changeset
499 (package-delete-name package)))
318
afd57c14dfc8 Import from CVS: tag r21-0b57
cvs
parents: 314
diff changeset
500
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
501 (provide 'package-admin)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
502
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
503 ;;; package-admin.el ends here