annotate lisp/package-admin.el @ 827:28426972f654

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