annotate lisp/package-admin.el @ 1410:44de306310b8

[xemacs-hg @ 2003-04-14 03:40:26 by youngs] 2003-04-14 Steve Youngs <youngs@xemacs.org> * package-admin.el (package-admin-find-top-directory): Use 'directory-sep-char'. (package-admin-get-install-dir): Ditto. This is so PUI won't break on platforms that don't use '/' as the directory separator. * package-get.el (package-get-pgp-available-p): New. (package-get-require-signed-base-updates): Use it. (package-get-update-base-from-buffer): Move the code that finds the gpg stuff into `package-get-pgp-available-p'. Now if you have Mailcrypt and a PGP binary installed and set up on your system, PUI will automatically default to doing PGP verification, otherwise it'll default to off. (package-get-require-base): Use the DATUM arg to `error'. (package-get-locate-index-file): Ditto. (package-get-update-base): Ditto. (package-get-update-base-entries): Ditto. (package-get-all): Ditto. (package-get-dependencies): Ditto. (package-get-info): Ditto. (package-get): Ditto. * package-info.el (batch-update-package-info): Use the DATUM arg to `error'. * package-net.el (package-net-batch-generate-bin-ini): Use the DATUM arg to `error'. * package-ui.el (pui-toggle-package-key): Use the DATUM arg to `error'. (pui-toggle-package-delete-key): Ditto. (pui-install-selected-packages): Ditto. (pui-add-required-packages): Ditto. (pui-display-info): Ditto. (list-packages-mode): Ditto. * packages.el (package-require): Use the DATUM arg to `error'.
author youngs
date Mon, 14 Apr 2003 03:40:27 +0000
parents 69a674f5861f
children a939d086aa0f
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.
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
4 ;; Copyright (C) 2003, Steve Youngs.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Author: SL Baur <steve@xemacs.org>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: internal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; 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
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; First pass at lisp front end to package maintenance.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 (require 'config)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 (defvar package-admin-xemacs (concat invocation-directory invocation-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 "Location of XEmacs binary to use.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 (defvar package-admin-temp-buffer "*Package Output*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 "Temporary buffer where output of backend commands is saved.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (defvar package-admin-install-function (if (eq system-type 'windows-nt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 'package-admin-install-function-mswindows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 'package-admin-default-install-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 "The function to call to install a package.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
46 Three args are passed: FILENAME PKG-DIR BUFFER
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 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
48 to buffer BUFFER.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (defvar package-admin-error-messages '(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 "No space left on device"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 "No such file or directory"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 "Filename too long"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 "Read-only file system"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 "File too large"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 "Too many open files"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 "Not enough space"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 "Permission denied"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 "Input/output error"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 "Out of memory"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 "Unable to create directory"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 "Directory checksum error"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 "Cannot exclusively open file"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 "corrupted file"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 "incomplete .* tree"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 "Bad table"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 "corrupt input"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 "invalid compressed data"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 "too many leaves in Huffman tree"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 "not a valid zip file"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 "first entry not deflated or stored"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 "encrypted file --"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 "unexpected end of file"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 "Regular expressions of possible error messages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 After each package extraction, the `package-admin-temp-buffer' buffer is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 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
78 found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 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
81 under MS Windows.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (defvar package-admin-tar-filename-regexps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 '(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 ;; GNU tar:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 ;; drwxrwxr-x john/doe 123 1997-02-18 15:48 pathname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 "\\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
88 ;; HP-UX & SunOS tar:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 ;; rwxrwxr-x 501/501 123 Feb 18 15:46 1997 pathname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 ;; Solaris tar (phooey!):
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 ;; rwxrwxr-x501/501 123 Feb 18 15:46 1997 pathname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 ;; AIX tar:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 ;; -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
94 "\\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
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 ;; djtar:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 ;; drwx Aug 31 02:01:41 1998 123 pathname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 "\\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
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 "List of regexps to use to search for tar filenames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 Note that \"\\(\" and \"\\)\" must be used to delimit the pathname (as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 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
104 is already implicit, as `looking-at' is used. Filenames can,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 unfortunately, contain spaces, so be careful in constructing any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 regexps.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
628
e545f3ec2337 [xemacs-hg @ 2001-07-14 08:42:16 by youngs]
youngs
parents: 448
diff changeset
108 (defvar package-install-hook nil
e545f3ec2337 [xemacs-hg @ 2001-07-14 08:42:16 by youngs]
youngs
parents: 448
diff changeset
109 "*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
110 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
111 the install directory.")
e545f3ec2337 [xemacs-hg @ 2001-07-14 08:42:16 by youngs]
youngs
parents: 448
diff changeset
112
e545f3ec2337 [xemacs-hg @ 2001-07-14 08:42:16 by youngs]
youngs
parents: 448
diff changeset
113 (defvar package-delete-hook nil
e545f3ec2337 [xemacs-hg @ 2001-07-14 08:42:16 by youngs]
youngs
parents: 448
diff changeset
114 "*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
115 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
116 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
117
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
118 (defun package-admin-install-function-mswindows (file pkg-dir buffer)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
119 "Install function for mswindows."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 (let ((default-directory (file-name-as-directory pkg-dir)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (unless (file-directory-p default-directory)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 (make-directory default-directory t))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
123 (call-process "minitar" nil buffer t file)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
125 (defun package-admin-default-install-function (filename pkg-dir buffer)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 "Default function to install a package.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 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
128 to BUFFER."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (let* ((pkg-dir (file-name-as-directory pkg-dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (default-directory pkg-dir)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
131 (filename (expand-file-name filename)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 (unless (file-directory-p pkg-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (make-directory pkg-dir t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 ;; Don't assume GNU tar.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
135 (if (shell-command (concat "gunzip -c " filename " | tar xvf -") buffer)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 0
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
137 1)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
139 ;; A few things needed by the following 2 functions.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
140 (eval-when-compile
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
141 (require 'packages)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
142 (autoload 'package-get-info "package-get")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
143 (autoload 'paths-decode-directory-path "find-paths")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
144 (defvar package-get-install-to-user-init-directory))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
145
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
146 (defun package-admin-find-top-directory (type &optional user-dir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
147 "Return the top level directory for a package.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
148
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
149 Argument TYPE is a symbol that determines the type of package we're
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
150 trying to find a directory for.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
151
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
152 Optional Argument USER-DIR if non-nil use directories off
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
153 `user-init-directory'. This overrides everything except
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
154 \"EMACSPACKAGEPATH\".
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
155
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
156 This function honours the environment variable \"EMACSPACKAGEPATH\"
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
157 and returns directories found there as a priority. If that variable
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
158 doesn't exist and USER-DIR is nil, check in the normal places.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
159
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
160 If we still can't find a suitable directory, return nil.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
161
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
162 Possible values for TYPE are:
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
163
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
164 std == For \"standard\" packages that go in '/xemacs-packages/'
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
165 mule == For \"mule\" packages that go in '/mule-packages/'
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
166 site == For \"unsupported\" packages that go in '/site-packages/'
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
167
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
168 Note: Type \"site\" is not yet fully supported."
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
169 (let* ((env-value (getenv "EMACSPACKAGEPATH"))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
170 top-dir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
171 ;; First, check the environment var.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
172 (if env-value
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
173 (let ((path-list (paths-decode-directory-path env-value 'drop-empties)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
174 (cond ((eq type 'std)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
175 (while path-list
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
176 (if (equal (substring (car path-list) -16)
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
177 (concat "xemacs-packages" directory-sep-char))
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
178 (setq top-dir (car path-list)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
179 (setq path-list (cdr path-list))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
180 ((eq type 'mule)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
181 (while path-list
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
182 (if (equal (substring (car path-list) -14)
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
183 (concat "mule-packages" directory-sep-char))
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
184 (setq top-dir (car path-list)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
185 (setq path-list (cdr path-list)))))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
186 ;; Wasn't in the environment, try `user-init-directory' if
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
187 ;; USER-DIR is non-nil.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
188 (if (and user-dir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
189 (not top-dir))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
190 (cond ((eq type 'std)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
191 (setq top-dir (file-name-as-directory
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
192 (expand-file-name "xemacs-packages" user-init-directory))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
193 ((eq type 'mule)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
194 (setq top-dir (file-name-as-directory
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
195 (expand-file-name "mule-packages" user-init-directory))))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
196 ;; Finally check the normal places
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
197 (if (not top-dir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
198 (let ((path-list (nth 1 (packages-find-packages
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
199 emacs-data-roots
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
200 (packages-compute-package-locations user-init-directory)))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
201 (cond ((eq type 'std)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
202 (while path-list
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
203 (if (equal (substring (car path-list) -16)
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
204 (concat "xemacs-packages" directory-sep-char))
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
205 (setq top-dir (car path-list)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
206 (setq path-list (cdr path-list))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
207 ((eq type 'mule)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
208 (while path-list
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
209 (if (equal (substring (car path-list) -14)
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
210 (concat "mule-packages" directory-sep-char))
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
211 (setq top-dir (car path-list)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
212 (setq path-list (cdr path-list)))))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
213 ;; Now return either the directory or nil.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
214 top-dir))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
215
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
216 (defun package-admin-get-install-dir (package &optional pkg-dir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
217 "Find a suitable installation directory for a package.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
218
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
219 Argument PACKAGE is the package to find a installation directory for.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
220 Optional Argument PKG-DIR, if non-nil is a directory to use for
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
221 installation.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
222
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
223 If PKG-DIR is non-nil and writable, return that. Otherwise check to
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
224 see if the PACKAGE is already installed and return that location, if
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
225 it is writable. Finally, fall back to the `user-init-directory' if
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
226 all else fails. As a side effect of installing packages under
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
227 `user-init-directory' these packages become part of `early-packages'."
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
228 ;; If pkg-dir specified, return that if writable.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
229 (if (and pkg-dir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
230 (file-writable-p (directory-file-name pkg-dir)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 pkg-dir
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
232 ;; If the user want her packages under ~/.xemacs/, do so.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
233 (let ((type (package-get-info package 'category)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
234 (if package-get-install-to-user-init-directory
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
235 (progn
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
236 (cond ((equal type "standard")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
237 (setq pkg-dir (package-admin-find-top-directory 'std 'user-dir)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
238 ((equal type "mule")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
239 (setq pkg-dir (package-admin-find-top-directory 'mule 'user-dir))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
240 pkg-dir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
241 ;; Maybe the package has been installed before, if so, return
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
242 ;; that directory.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
243 (let ((package-feature (intern-soft (concat
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
244 (symbol-name package) "-autoloads")))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
245 autoload-dir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
246 (when (and (not (eq package 'unknown))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
247 (featurep package-feature)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
248 (setq autoload-dir (feature-file package-feature))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
249 (setq autoload-dir (file-name-directory autoload-dir))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
250 (member autoload-dir (append early-package-load-path late-package-load-path)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
251 ;; Find the corresponding entry in late-package
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
252 (setq pkg-dir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
253 (car-safe (member-if (lambda (h)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
254 (string-match (concat "^" (regexp-quote h))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
255 autoload-dir))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
256 (append (cdr early-packages) late-packages)))))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
257 (if (and pkg-dir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
258 (file-writable-p (directory-file-name pkg-dir)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
259 pkg-dir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
260 ;; OK, the package hasn't been previously installed so we need
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
261 ;; to guess where it should go.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
262 (cond ((equal type "standard")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
263 (setq pkg-dir (package-admin-find-top-directory 'std)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
264 ((equal type "mule")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
265 (setq pkg-dir (package-admin-find-top-directory 'mule)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
266 (t
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
267 (error 'invalid-operation
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
268 "Invalid package type")))
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
269 (if (and pkg-dir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
270 (file-writable-p (directory-file-name pkg-dir)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
271 pkg-dir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
272 ;; Oh no! Either we still haven't found a suitable
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
273 ;; directory, or we can't write to the one we did find.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
274 ;; Drop back to the `user-init-directory'.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
275 (if (y-or-n-p (format "Directory isn't writable, use %s instead? "
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
276 user-init-directory))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
277 (progn
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
278 (cond ((equal type "standard")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
279 (setq pkg-dir (package-admin-find-top-directory 'std 'user-dir)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
280 ((equal type "mule")
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
281 (setq pkg-dir (package-admin-find-top-directory 'mule 'user-dir)))
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
282 (t
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
283 (error 'invalid-operation
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
284 "Invalid package type")))
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
285 ;; Turn on `package-get-install-to-user-init-directory'
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
286 ;; so we don't get asked for each package we try to
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
287 ;; install in this session.
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
288 (setq package-get-install-to-user-init-directory t)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
289 pkg-dir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
290 ;; If we get to here XEmacs can't make up its mind and
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
291 ;; neither can the user, nothing left to do except barf. :-(
1410
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
292 (error 'search-failed
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
293 (format
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
294 "Can't find suitable installation directory for package: %s"
44de306310b8 [xemacs-hg @ 2003-04-14 03:40:26 by youngs]
youngs
parents: 1378
diff changeset
295 package))))))))))
428
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 (defun package-admin-get-manifest-file (pkg-topdir package)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 "Return the name of the MANIFEST file for package PACKAGE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 Note that PACKAGE is a symbol, and not a string."
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
300 (let ((dir (file-name-as-directory
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
301 (expand-file-name "pkginfo" pkg-topdir))))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
302 (expand-file-name (concat "MANIFEST." (symbol-name package)) dir)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 (defun package-admin-check-manifest (pkg-outbuf pkg-topdir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 "Check for a MANIFEST.<package> file in the package distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 If it doesn't exist, create and write one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 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
308 is the top-level directory under which the package was installed."
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
309 (let ((manifest-buf " *pkg-manifest*")
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
310 (old-case-fold-search case-fold-search)
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
311 regexp package-name pathname regexps)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (save-excursion ;; Probably redundant.
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
314 (set-buffer (get-buffer pkg-outbuf)) ;; Probably already the current buffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 ;; Make filenames case-insensitive, if necessary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (if (eq system-type 'windows-nt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 (setq case-fold-search t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
321 (setq regexp (concat "\\bpkginfo"
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
322 (char-to-string directory-sep-char)
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
323 "MANIFEST\\...*"))
428
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 ;; Look for the manifest.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (if (not (re-search-forward regexp nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 ;; We didn't find a manifest. Make one.
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 ;; Yuk. We weren't passed the package name, and so we have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 ;; to dig for it. Look for it as the subdirectory name below
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
332 ;; "lisp", or "man".
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 ;; 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
334 ;; the directories for a package name in a particular order.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 (if (catch 'done
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
336 (let ((dirs '("lisp" "man"))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
337 rexp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 (while dirs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (setq rexp (concat "\\b" (car dirs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 "[\\/]\\([^\\/]+\\)[\//]"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (if (re-search-forward rexp nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (throw 'done t))
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
343 (setq dirs (cdr dirs)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (setq package-name (buffer-substring (match-beginning 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 (match-end 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 ;; Get and erase the manifest buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (setq manifest-buf (get-buffer-create manifest-buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (buffer-disable-undo manifest-buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (erase-buffer manifest-buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 ;; Now, scan through the output buffer, looking for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 ;; file and directory names.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 ;; for each line ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (while (< (point) (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (beginning-of-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (setq pathname nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 ;; scan through the regexps, looking for a pathname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (if (catch 'found-path
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (setq regexps package-admin-tar-filename-regexps)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (while regexps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (if (looking-at (car regexps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (setq pathname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 (buffer-substring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (match-beginning 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (match-end 1)))
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
371 (throw 'found-path t)))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
372 (setq regexps (cdr regexps))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 ;; found a pathname -- add it to the manifest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 ;; buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (set-buffer manifest-buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 (goto-char (point-max))
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
379 (insert pathname "\n"))))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
380 (forward-line 1))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 ;; Processed all lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 ;; Now, create the file, pkginfo/MANIFEST.<pkgname>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 ;; We use `expand-file-name' instead of `concat',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 ;; for portability.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 (setq pathname (expand-file-name "pkginfo"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 pkg-topdir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 ;; Create pkginfo, if necessary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 (if (not (file-directory-p pathname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (make-directory pathname))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
392 (setq pathname (expand-file-name
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (concat "MANIFEST." package-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 pathname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (set-buffer manifest-buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 ;; Put the files in sorted order
776
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 629
diff changeset
398 (if-fboundp 'sort-lines
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 629
diff changeset
399 (sort-lines nil (point-min) (point-max))
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
400 (warn "`xemacs-base' not installed, MANIFEST.%s not sorted"
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
401 package-name))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 ;; Write the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 ;; Note that using `write-region' *BYPASSES* any check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 ;; to see if XEmacs is currently editing/visiting the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 ;; file.
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
406 (write-region (point-min) (point-max) pathname))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
407 (kill-buffer manifest-buf))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 ;; Restore old case-fold-search status
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
409 (setq case-fold-search old-case-fold-search))))
428
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 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (defun package-admin-add-binary-package (file &optional pkg-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 "Install a pre-bytecompiled XEmacs package into package hierarchy."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 (interactive "fPackage tarball: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (let ((buf (get-buffer-create package-admin-temp-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 (status 1)
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
417 start err-list)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (setq pkg-dir (package-admin-get-install-dir 'unknown pkg-dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 ;; Ensure that the current directory doesn't change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (set-buffer buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 ;; This is not really needed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (setq default-directory (file-name-as-directory pkg-dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (setq case-fold-search t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (buffer-disable-undo)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (goto-char (setq start (point-max)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 (if (= 0 (setq status (funcall package-admin-install-function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 file pkg-dir buf)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 ;; First, check for errors.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 ;; We can't necessarily rely upon process error codes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (catch 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 (goto-char start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (setq err-list package-admin-error-messages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (while err-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (if (re-search-forward (car err-list) nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (setq status 1)
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
439 (throw 'done nil)))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
440 (setq err-list (cdr err-list))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 ;; Make sure that the MANIFEST file exists
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
442 (package-admin-check-manifest buf pkg-dir))))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
443 status))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (defun package-admin-rmtree (directory)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 "Delete a directory and all of its contents, recursively.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 This is a feeble attempt at making a portable rmdir."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (setq directory (file-name-as-directory directory))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (let ((files (directory-files directory nil nil nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (dirs (directory-files directory nil nil nil 'dirs)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (while dirs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (if (not (member (car dirs) '("." "..")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (let ((dir (expand-file-name (car dirs) directory)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 (condition-case err
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (if (file-symlink-p dir) ;; just in case, handle symlinks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (delete-file dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (package-admin-rmtree dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (file-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (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
460 (setq dirs (cdr dirs))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (while files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (condition-case err
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (delete-file (expand-file-name (car files) directory))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (file-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (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
466 (setq files (cdr files)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 (condition-case err
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (delete-directory directory)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 (file-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 (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
471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (defun package-admin-get-lispdir (pkg-topdir package)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (let (package-lispdir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (if (and (setq package-lispdir (expand-file-name "lisp" pkg-topdir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (setq package-lispdir (expand-file-name (symbol-name package)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 package-lispdir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 (file-accessible-directory-p package-lispdir))
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
478 package-lispdir)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (defun package-admin-delete-binary-package (package pkg-topdir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 "Delete a binary installation of PACKAGE below directory PKG-TOPDIR.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 PACKAGE is a symbol, not a string."
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
483 (let (manifest-file package-lispdir dirs file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (setq pkg-topdir (package-admin-get-install-dir package pkg-topdir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (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
486 (run-hook-with-args 'package-delete-hook package pkg-topdir)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (if (file-exists-p manifest-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 ;; The manifest file exists! Use it to delete the old distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (message "Removing old files for package \"%s\" ..." package)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (sit-for 0)
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
492 (with-temp-buffer
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (buffer-disable-undo)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (erase-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (insert-file-contents manifest-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 ;; For each entry in the MANIFEST ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (while (< (point) (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (beginning-of-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (setq file (expand-file-name (buffer-substring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (point-at-eol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 pkg-topdir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (if (file-directory-p file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 ;; Keep a record of each directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (setq dirs (cons file dirs))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 ;; Delete each file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 ;; Make sure that the file is writable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 ;; (This is important under MS Windows.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 ;; 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
512 ;; 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
513 ;; 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
514 ;; If it wants to, XEmacs may ask, but that is about all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 ;; (set-file-modes file 438) ;; 438 -> #o666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 ;; Note, user might have removed the file!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (condition-case ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 (delete-file file)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
519 (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
520 (forward-line 1))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
521
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 ;; Delete empty directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (if dirs
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
524 (progn
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
525 (mapc
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
526 (lambda (dir)
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
527 (condition-case ()
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
528 (delete-directory dir)))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
529 dirs)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 ;; Delete the MANIFEST file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 ;; (set-file-modes manifest-file 438) ;; 438 -> #o666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 ;; Note. Packages can have MANIFEST in MANIFEST.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (condition-case ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 (delete-file manifest-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 (error nil)) ;; Do warning?
1365
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
536 (message "Removing old files for package \"%s\" ... done" package)))
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
537 ;; The manifest file doesn't exist. Fallback to just deleting the
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
538 ;; package-specific lisp directory, if it exists.
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
539 ;;
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
540 ;; Delete old lisp directory, if any
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
541 ;; Gads, this is ugly. However, we're not supposed to use `concat'
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
542 ;; in the name of portability.
02909207294a [xemacs-hg @ 2003-03-20 13:19:56 by youngs]
youngs
parents: 776
diff changeset
543 (setq package-lispdir (package-admin-get-lispdir pkg-topdir package))
1378
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
544 (when package-lispdir
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
545 (message "Removing old lisp directory \"%s\" ..." package-lispdir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
546 (sit-for 0)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
547 (package-admin-rmtree package-lispdir)
69a674f5861f [xemacs-hg @ 2003-03-24 16:30:55 by youngs]
youngs
parents: 1365
diff changeset
548 (message "Removing old lisp directory \"%s\" ... done" package-lispdir)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 ;; Delete the package from the database of installed packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 (package-delete-name package)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (provide 'package-admin)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 ;;; package-admin.el ends here