annotate lisp/package-get.el @ 314:341dac730539 r21-0b55

Import from CVS: tag r21-0b55
author cvs
date Mon, 13 Aug 2007 10:44:22 +0200
parents 9ea74add5d37
children 512e409c26a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
1 ;;; package-get.el --- Retrieve XEmacs package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
2
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
3 ;; Copyright (C) 1998 by Pete Ware
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
4
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
5 ;; Author: Pete Ware <ware@cis.ohio-state.edu>
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
6 ;; Keywords: internal
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
7
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
9
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
13 ;; any later version.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
14
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
18 ;; General Public License for more details.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
19
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
24
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
26
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
27 ;;; Commentary:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
28
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
29 ;; package-get -
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
30 ;; Retrieve a package and any other required packages from an archive
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
31 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
32 ;; The idea:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
33 ;; A new XEmacs lisp-only release is generated with the following steps:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
34 ;; 1. The maintainer runs some yet to be written program that
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
35 ;; generates all the dependency information. This should
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
36 ;; determine all the require and provide statements and associate
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
37 ;; them with a package.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
38 ;; 2. All the packages are then bundled into their own tar balls
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
39 ;; (or whatever format)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
40 ;; 3. Maintainer automatically generates a new `package-get-base'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
41 ;; data structure which contains information such as the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
42 ;; package name, the file to be retrieved, an md5 checksum,
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
43 ;; etc (see `package-get-base').
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
44 ;; 4. The maintainer posts an announcement with the new version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
45 ;; of `package-get-base'.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
46 ;; 5. A user/system manager saves this posting and runs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
47 ;; `package-get-update' which uses the previously saved list
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
48 ;; of packages, `package-get-here' that the user/site
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
49 ;; wants to determine what new versions to download and
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
50 ;; install.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
51 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
52 ;; A user/site manager can generate a new `package-get-here' structure
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
53 ;; by using `package-get-setup' which generates a customize like
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
54 ;; interface to the list of packages. The buffer looks something
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
55 ;; like:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
56 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
57 ;; gnus - a mail and news reader
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
58 ;; [] Always install
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
59 ;; [] Needs updating
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
60 ;; [] Required by other [packages]
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
61 ;; version: 2.0
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
62 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
63 ;; vm - a mail reader
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
64 ;; [] Always install
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
65 ;; [] Needs updating
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
66 ;; [] Required by other [packages]
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
67 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
68 ;; Where `[]' indicates a toggle box
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
69 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
70 ;; - Clicking on "Always install" puts this into
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
71 ;; `package-get-here' list. "Needs updating" indicates a new
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
72 ;; version is available. Anything already in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
73 ;; `package-get-here' has this enabled.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
74 ;; - "Required by other" means some other packages are going to force
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
75 ;; this to be installed. Clicking on [packages] gives a list
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
76 ;; of packages that require this.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
77 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
78 ;; The `package-get-base' should be installed in a file in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
79 ;; `data-directory'. The `package-get-here' should be installed in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
80 ;; site-lisp. Both are then read at run time.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
81 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
82 ;; TODO:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
83 ;; - Implement `package-get-setup'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
84 ;; - Actually put `package-get-base' and `package-get-here' into
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
85 ;; files that are read.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
86 ;; - Allow users to have their own packages that they want installed
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
87 ;; in ~/.xemacs/.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
88 ;; - SOMEONE needs to write the programs that generate the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
89 ;; provides/requires database and makes it into a lisp data
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
90 ;; structure suitable for `package-get-base'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
91 ;; - Handle errors such as no package providing a required symbol.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
92 ;; - Tie this into the `require' function to download packages
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
93 ;; transparently.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
94
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
95 ;;; Change Log
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
96
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
97 ;;; Code:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
98
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
99 (require 'package-admin)
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
100 (require 'package-get-base)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
101
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
102 (defvar package-get-base nil
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
103 "List of packages that are installed at this site.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
104 For each element in the alist, car is the package name and the cdr is
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
105 a plist containing information about the package. Typical fields
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
106 kept in the plist are:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
107
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
108 version - version of this package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
109 provides - list of symbols provided
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
110 requires - list of symbols that are required.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
111 These in turn are provided by other packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
112 filename - name of the file.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
113 size - size of the file (aka the bundled package)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
114 md5sum - computed md5 checksum
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
115 description - What this package is for.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
116 type - Whether this is a 'binary (default) or 'single file package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
117
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
118 More fields may be added as needed. An example:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
119
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
120 '(
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
121 (name
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
122 (version \"<version 2>\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
123 file \"filename\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
124 description \"what this package is about.\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
125 provides (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
126 requires (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
127 size <integer-bytes>
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
128 md5sum \"<checksum\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
129 type single
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
130 )
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
131 (version \"<version 1>\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
132 file \"filename\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
133 description \"what this package is about.\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
134 provides (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
135 requires (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
136 size <integer-bytes>
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
137 md5sum \"<checksum\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
138 type single
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
139 )
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
140 ...
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
141 ))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
142
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
143 For version information, it is assumed things are listed in most
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
144 recent to least recent -- in other words, the version names don't have to
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
145 be lexically ordered. It is debatable if it makes sense to have more than
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
146 one version of a package available.")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
147
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
148 (defvar package-get-dir (temp-directory)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
149 "*Where to store temporary files for staging.")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
150
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
151 (defvar package-get-remote
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
152 '(
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 263
diff changeset
153 ("ftp.xemacs.org" "/pub/xemacs/beta/xemacs-21.0/packages/binary-packages")
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 263
diff changeset
154 ("ftp.xemacs.org" "/pub/xemacs/beta/xemacs-21.0/packages/single-file-packages")
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
155 ("ftp.xemacs.org" "/pub/xemacs/package"))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
156 "*List of remote sites to contact for downloading packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
157 List format is '(site-name directory-on-site). Each site is tried in
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
158 order until the package is found. As a special case, `site-name' can be
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
159 `nil', in which case `directory-on-site' is treated as a local directory.")
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
160
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
161 (defvar package-get-remove-copy nil
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
162 "*After copying and installing a package, if this is T, then remove the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
163 copy. Otherwise, keep it around.")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
164
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
165 (defun package-get-rmtree (directory)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
166 "Delete a directory and all of its contents, recursively.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
167 This is a feeble attempt at making a portable rmdir."
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
168 (let ( (orig-default-directory default-directory) files dirs dir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
169 (unwind-protect
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
170 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
171 (setq directory (file-name-as-directory directory))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
172 (setq files (directory-files directory nil nil nil t))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
173 (setq dirs (directory-files directory nil nil nil 'dirs))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
174 (while dirs
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
175 (setq dir (car dirs))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
176 (if (file-symlink-p dir) ;; just in case, handle symlinks
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
177 (delete-file dir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
178 (if (not (or (string-equal dir ".") (string-equal dir "..")))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
179 (package-get-rmtree (expand-file-name dir directory))))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
180 (setq dirs (cdr dirs))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
181 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
182 (setq default-directory directory)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
183 (condition-case err
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
184 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
185 (while files
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
186 (delete-file (car files))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
187 (setq files (cdr files))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
188 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
189 (delete-directory directory)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
190 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
191 (file-error
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
192 (message "%s: %s: \"%s\"" (nth 1 err) (nth 2 err) (nth 3 err)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
193 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
194 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
195 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
196 (setq default-directory orig-default-directory)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
197 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
198 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
199
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
200 ;;;###autoload
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
201 (defun package-get-update-all ()
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
202 "Fetch and install the latest versions of all currently installed packages."
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
203 (interactive)
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
204 ;; Load a fresh copy
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
205 (catch 'exit
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
206 (mapcar (lambda (pkg)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
207 (if (not (package-get (car pkg) nil 'never))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
208 (throw 'exit nil) ;; Bail out if error detected
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
209 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
210 packages-package-list)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
211
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
212 (defun package-get-interactive-package-query (get-version package-symbol)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
213 "Perform interactive querying for package and optional version.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
214 Query for a version if GET-VERSION is non-nil. Return package name as
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
215 a symbol instead of a string if PACKAGE-SYMBOL is non-nil.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
216 The return value is suitable for direct passing to `interactive'."
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
217 (let ( (table (mapcar '(lambda (item)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
218 (let ( (name (symbol-name (car item))) )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
219 (cons name name)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
220 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
221 package-get-base))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
222 package package-symbol default-version version)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
223 (save-window-excursion
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
224 (setq package (completing-read "Package: " table nil t))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
225 (setq package-symbol (intern package))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
226 (if get-version
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
227 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
228 (setq default-version
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
229 (package-get-info-prop
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
230 (package-get-info-version
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
231 (package-get-info-find-package package-get-base
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
232 package-symbol) nil)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
233 'version))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
234 (while (string=
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
235 (setq version (read-string "Version: " default-version))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
236 "")
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
237 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
238 (if package-symbol
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
239 (list package-symbol version)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
240 (list package version))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
241 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
242 (if package-symbol
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
243 (list package-symbol)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
244 (list package)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
245 )))
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
246
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
247 ;;;###autoload
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
248 (defun package-get-all (package version &optional fetched-packages)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
249 "Fetch PACKAGE with VERSION and all other required packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
250 Uses `package-get-base' to determine just what is required and what
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
251 package provides that functionality. If VERSION is nil, retrieves
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
252 latest version. Optional argument FETCHED-PACKAGES is used to keep
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
253 track of packages already fetched.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
254
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
255 Returns nil upon error."
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
256 (interactive (package-get-interactive-package-query t nil))
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
257 (let* ((the-package (package-get-info-find-package package-get-base
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
258 package))
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
259 (this-package (package-get-info-version
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
260 the-package version))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
261 (this-requires (package-get-info-prop this-package 'requires))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
262 )
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
263 (catch 'exit
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
264 (setq version (package-get-info-prop this-package 'version))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
265 (unless (package-get-installedp package version)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
266 (if (not (package-get package version))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
267 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
268 (setq fetched-packages nil)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
269 (throw 'exit nil))))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
270 (setq fetched-packages
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
271 (append (list package)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
272 (package-get-info-prop this-package 'provides)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
273 fetched-packages))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
274 ;; grab everything that this package requires plus recursively
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
275 ;; grab everything that the requires require. Keep track
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
276 ;; in `fetched-packages' the list of things provided -- this
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
277 ;; keeps us from going into a loop
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
278 (while this-requires
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
279 (if (not (member (car this-requires) fetched-packages))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
280 (let* ((reqd-package (package-get-package-provider
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
281 (car this-requires)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
282 (reqd-version (cadr reqd-package))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
283 (reqd-name (car reqd-package)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
284 (if (null reqd-name)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
285 (error "Unable to find a provider for %s"
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
286 (car this-requires)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
287 (if (not (setq fetched-packages
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
288 (package-get-all reqd-name reqd-version
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
289 fetched-packages)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
290 (throw 'exit nil)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
291 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
292 (setq this-requires (cdr this-requires)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
293 )
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
294 fetched-packages
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
295 ))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
296
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
297 (defun package-get-load-package-file (lispdir file)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
298 (let (pathname)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
299 (setq pathname (expand-file-name file lispdir))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
300 (condition-case err
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
301 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
302 (load pathname t)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
303 t)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
304 (t
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
305 (message "Error loading package file \"%s\" %s!" pathname err)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
306 nil))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
307 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
308
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
309 (defun package-get-init-package (lispdir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
310 "Initialize the package.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
311 This really assumes that the package has never been loaded. Updating
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
312 a newer package can cause problems, due to old, obsolete functions in
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
313 the old package.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
315 Return `t' upon complete success, `nil' if any errors occurred."
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
316 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
317 (if (and lispdir
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
318 (file-accessible-directory-p lispdir))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
319 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
320 ;; Add lispdir to load-path if it doesn't already exist.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
321 ;; NOTE: this does not take symlinks, etc., into account.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
322 (if (let ( (dirs load-path) )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
323 (catch 'done
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
324 (while dirs
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
325 (if (string-equal (car dirs) lispdir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
326 (throw 'done nil))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
327 (setq dirs (cdr dirs))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
328 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
329 t))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
330 (setq load-path (cons lispdir load-path)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
331 (package-get-load-package-file lispdir "auto-autoloads")
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
332 t)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
333 nil)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
334 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
335
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
336 ;;;###autoload
306
9ea74add5d37 Import from CVS: tag r21-0b51
cvs
parents: 298
diff changeset
337 (defun package-get (package &optional version conflict install-dir)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
338 "Fetch PACKAGE from remote site.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
339 Optional arguments VERSION indicates which version to retrieve, nil
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
340 means most recent version. CONFLICT indicates what happens if the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
341 package is already installed. Valid values for CONFLICT are:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
342 'always always retrieve the package even if it is already installed
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
343 'never do not retrieve the package if it is installed.
306
9ea74add5d37 Import from CVS: tag r21-0b51
cvs
parents: 298
diff changeset
344 INSTALL-DIR, if non-nil, specifies the package directory where
9ea74add5d37 Import from CVS: tag r21-0b51
cvs
parents: 298
diff changeset
345 fetched packages should be installed.
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
346
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
347 The value of `package-get-base' is used to determine what files should
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
348 be retrieved. The value of `package-get-remote' is used to determine
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
349 where a package should be retrieved from. The sites are tried in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
350 order so one is better off listing easily reached sites first.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
351
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
352 Once the package is retrieved, its md5 checksum is computed. If that
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
353 sum does not match that stored in `package-get-base' for this version
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
354 of the package, an error is signalled.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
355
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
356 Returns `t' upon success, the symbol `error' if the package was
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
357 successfully installed but errors occurred during initialization, or
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
358 `nil' upon error."
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
359 (interactive (package-get-interactive-package-query nil t))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
360 (let* ((this-package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
361 (package-get-info-version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
362 (package-get-info-find-package package-get-base
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
363 package) version))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
364 (found nil)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
365 (search-dirs package-get-remote)
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
366 (base-filename (package-get-info-prop this-package 'filename))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
367 (package-status t)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
368 filenames full-package-filename package-lispdir)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
369 (if (null this-package)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
370 (error "Couldn't find package %s with version %s"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
371 package version))
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
372 (if (null base-filename)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
373 (error "No filename associated with package %s, version %s"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
374 package version))
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
375 (if (null install-dir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
376 (setq install-dir (package-admin-get-install-dir nil)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
377
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
378 ;; Contrive a list of possible package filenames.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
379 ;; Ugly. Is there a better way to do this?
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
380 (setq filenames (cons base-filename nil))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
381 (if (string-match "^\\(..*\\)\.tar\.gz$" base-filename)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
382 (setq filenames (cons (concat (match-string 1 base-filename) ".tgz")
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
383 filenames)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
384
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
385 (setq version (package-get-info-prop this-package 'version))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
386 (unless (and (eq conflict 'never)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
387 (package-get-installedp package version))
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
388 ;; Find the package from the search list in package-get-remote
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
389 ;; and copy it into the staging directory. Then validate
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
390 ;; the checksum. Finally, install the package.
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
391 (catch 'done
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
392 (let (search-filenames current-dir-entry host dir current-filename)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
393 ;; In each search directory ...
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
394 (while search-dirs
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
395 (setq current-dir-entry (car search-dirs)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
396 host (car current-dir-entry)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
397 dir (car (cdr current-dir-entry))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
398 search-filenames filenames)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
399
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
400 ;; Look for one of the possible package filenames ...
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
401 (while search-filenames
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
402 (setq current-filename (car search-filenames))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
403 (if (null host)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
404 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
405 ;; No host means look on the current system.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
406 (setq full-package-filename
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
407 (substitute-in-file-name
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
408 (expand-file-name current-filename
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
409 (file-name-as-directory dir))))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
410 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
411 ;; If the file exists on the remote system ...
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
412 (if (file-exists-p (package-get-remote-filename
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
413 current-dir-entry current-filename))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
414 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
415 ;; Get it
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
416 (setq full-package-filename
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
417 (package-get-staging-dir current-filename))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
418 (message "Retrieving package `%s' ..."
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
419 current-filename)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
420 (sit-for 0)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
421 (copy-file (package-get-remote-filename current-dir-entry
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
422 current-filename)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
423 ))))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
424 ;; If we found it, we're done.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
425 (if (file-exists-p full-package-filename)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
426 (throw 'done nil))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
427 ;; Didn't find it. Try the next possible filename.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
428 (setq search-filenames (cdr search-filenames))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
429 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
430 ;; Try looking in the next possible directory ...
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
431 (setq search-dirs (cdr search-dirs))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
432 )
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
433 ))
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
434
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
435 (if (or (not full-package-filename)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
436 (not (file-exists-p full-package-filename)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
437 (error "Unable to find file %s" base-filename))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
438 ;; Validate the md5 checksum
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
439 ;; Doing it with XEmacs removes the need for an external md5 program
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
440 (message "Validating checksum for `%s'..." package) (sit-for 0)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
441 (with-temp-buffer
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
442 ;; What ever happened to i-f-c-literally
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
443 (let (file-name-handler-alist)
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
444 (insert-file-contents-internal full-package-filename))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
445 (if (not (string= (md5 (current-buffer))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
446 (package-get-info-prop this-package
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
447 'md5sum)))
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
448 (error "Package %s does not match md5 checksum" base-filename)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
449
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
450 ;; Now delete old lisp directory, if any
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
451 ;;
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
452 ;; Gads, this is ugly. However, we're not supposed to use `concat'
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
453 ;; in the name of portability.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
454 (if (and (setq package-lispdir (expand-file-name "lisp" install-dir))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
455 (setq package-lispdir (expand-file-name (symbol-name package)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
456 package-lispdir))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
457 (file-accessible-directory-p package-lispdir))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
458 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
459 (message "Removing old lisp directory \"%s\" ..." package-lispdir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
460 (sit-for 0)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
461 (package-get-rmtree package-lispdir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
462 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
463
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
464 (message "Installing package `%s' ..." package) (sit-for 0)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
465 (let ((status
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
466 (package-admin-add-binary-package full-package-filename
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
467 install-dir)))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
468 (if (= status 0)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
469 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
470 ;; clear messages so that only messages from
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
471 ;; package-get-init-package are seen, below.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
472 (clear-message)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
473 (if (package-get-init-package package-lispdir)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
474 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
475 (message "Added package `%s'" package)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
476 (sit-for 0)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
477 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
478 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
479 ;; display message only if there isn't already one.
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
480 (if (not (current-message))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
481 (progn
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
482 (message "Added package `%s' (errors occurred)"
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
483 package)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
484 (sit-for 0)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
485 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
486 (if package-status
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
487 (setq package-status 'errors))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
488 ))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
489 )
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
490 (message "Installation of package %s failed." base-filename)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
491 (sit-for 0)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
492 (switch-to-buffer package-admin-temp-buffer)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
493 (setq package-status nil)
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
494 ))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
495 (setq found t))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
496 (if (and found package-get-remove-copy)
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
497 (delete-file full-package-filename))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
498 package-status
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
499 ))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
500
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
501 (defun package-get-info-find-package (which name)
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
502 "Look in WHICH for the package called NAME and return all the info
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
503 associated with it. See `package-get-base' for info on the format
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
504 returned.
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
505
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
506 To access fields returned from this, use
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
507 `package-get-info-version' to return information about particular a
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
508 version. Use `package-get-info-find-prop' to find particular property
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
509 from a version returned by `package-get-info-version'."
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
510 (interactive "xPackage list: \nsPackage Name: ")
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
511 (if which
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
512 (if (eq (caar which) name)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
513 (cdar which)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
514 (if (cdr which)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
515 (package-get-info-find-package (cdr which) name)))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
516
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
517 (defun package-get-info-version (package version)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
518 "In PACKAGE, return the plist associated with a particular VERSION of the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
519 package. PACKAGE is typically as returned by
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
520 `package-get-info-find-package'. If VERSION is nil, then return the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
521 first (aka most recent) version. Use `package-get-info-find-prop'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
522 to retrieve a particular property from the value returned by this."
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
523 (interactive (package-get-interactive-package-query t t))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
524 (while (and version package (not (string= (plist-get (car package) 'version) version)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
525 (setq package (cdr package)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
526 (if package (car package)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
527
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
528 (defun package-get-info-prop (package-version property)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
529 "In PACKAGE-VERSION, return the value associated with PROPERTY.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
530 PACKAGE-VERSION is typically returned by `package-get-info-version'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
531 and PROPERTY is typically (although not limited to) one of the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
532 following:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
533
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
534 version - version of this package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
535 provides - list of symbols provided
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
536 requires - list of symbols that are required.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
537 These in turn are provided by other packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
538 size - size of the bundled package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
539 md5sum - computed md5 checksum"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
540 (interactive "xPackage Version: \nSProperty")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
541 (plist-get package-version property))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
542
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
543 (defun package-get-info-version-prop (package-list package version property)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
544 "In PACKAGE-LIST, search for PACKAGE with this VERSION and return
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
545 PROPERTY value."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
546 (package-get-info-prop
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
547 (package-get-info-version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
548 (package-get-info-find-package package-list package) version) property))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
549
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
550 (defun package-get-set-version-prop (package-list package version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
551 property value)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
552 "A utility to make it easier to add a VALUE for a specific PROPERTY
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
553 in this VERSION of a specific PACKAGE kept in the PACKAGE-LIST.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
554 Returns the modified PACKAGE-LIST. Any missing fields are created."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
555 )
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
556
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
557 (defun package-get-staging-dir (filename)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
558 "Return a good place to stash FILENAME when it is retrieved.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
559 Use `package-get-dir' for directory to store stuff.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
560 Creates `package-get-dir' it it doesn't exist."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
561 (interactive "FPackage filename: ")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
562 (if (not (file-exists-p package-get-dir))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
563 (make-directory package-get-dir))
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
564 (expand-file-name
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
565 (file-name-nondirectory (or (nth 2 (efs-ftp-path filename)) filename))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
566 (file-name-as-directory package-get-dir)))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
567
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
568
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
569 (defun package-get-remote-filename (search filename)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
570 "Return FILENAME as a remote filename.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
571 It first checks if FILENAME already is a remote filename. If it is
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
572 not, then it uses the (car search) as the remote site-name and the (cadr
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
573 search) as the remote-directory and concatenates filename. In other
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
574 words
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
575 site-name:remote-directory/filename
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
576 "
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
577 (if (efs-ftp-path filename)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
578 filename
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
579 (let ((dir (cadr search)))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
580 (concat "/"
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
581 (car search) ":"
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
582 (if (string-match "/$" dir)
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
583 dir
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
584 (concat dir "/"))
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 294
diff changeset
585 filename))))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
586
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
587
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
588 (defun package-get-installedp (package version)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
589 "Determine if PACKAGE with VERSION has already been installed.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
590 I'm not sure if I want to do this by searching directories or checking
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
591 some built in variables. For now, use packages-package-list."
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
592 ;; Use packages-package-list which contains name and version
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
593 (equal (plist-get
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
594 (package-get-info-find-package packages-package-list
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
595 package) ':version)
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
596 (if (floatp version) version (string-to-number version))))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
597
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
598 ;;;###autoload
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
599 (defun package-get-package-provider (sym)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
600 "Search for a package that provides SYM and return the name and
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
601 version. Searches in `package-get-base' for SYM. If SYM is a
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
602 consp, then it must match a corresponding (provide (SYM VERSION)) from
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
603 the package."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
604 (interactive "SSymbol: ")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
605 (let ((packages package-get-base)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
606 (done nil)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
607 (found nil))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
608 (while (and (not done) packages)
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
609 (let* ((this-name (caar packages))
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
610 (this-package (cdr (car packages)))) ;strip off package name
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
611 (while (and (not done) this-package)
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
612 (if (or (eq this-name sym)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
613 (eq (cons this-name
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
614 (package-get-info-prop (car this-package) 'version))
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
615 sym)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
616 (member sym (package-get-info-prop (car this-package) 'provides)))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
617 (progn (setq done t)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
618 (setq found (list (caar packages)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
619 (package-get-info-prop (car this-package) 'version))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
620 (setq this-package (cdr this-package)))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
621 (setq packages (cdr packages)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
622 found))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
623
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
624 ;;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
625 ;; customize interfaces.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
626 ;; The group is in this file so that custom loads includes this file.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
627 ;;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
628 (defgroup packages nil
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
629 "Configure XEmacs packages."
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
630 :group 'emacs)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
631
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
632 ;;;###autoload
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
633 (defun package-get-custom ()
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
634 "Fetch and install the latest versions of all customized packages."
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
635 (interactive)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
636 ;; Load a fresh copy
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
637 (load "package-get-custom.el")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
638 (mapcar (lambda (pkg)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
639 (if (eval (intern (concat (symbol-name (car pkg)) "-package")))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
640 (package-get-all (car pkg) nil))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
641 t)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
642 package-get-base))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
643
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
644 (defun package-get-ever-installed-p (pkg &optional notused)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
645 (string-match "-package$" (symbol-name pkg))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
646 (custom-initialize-set
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
647 pkg
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
648 (if (package-get-info-find-package
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
649 packages-package-list
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
650 (intern (substring (symbol-name pkg) 0 (match-beginning 0))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
651 t)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
652
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
653 (defun package-get-file-installed-p (file &optional paths)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
654 "Return absolute-path of FILE if FILE exists in PATHS.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
655 If PATHS is omitted, `load-path' is used."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
656 (if (null paths)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
657 (setq paths load-path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
658 )
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
659 (catch 'tag
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
660 (let (path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
661 (while paths
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
662 (setq path (expand-file-name file (car paths)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
663 (if (file-exists-p path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
664 (throw 'tag path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
665 )
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
666 (setq paths (cdr paths))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
667 ))))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
668
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
669 (defun package-get-create-custom ()
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
670 "Creates a package customization file package-get-custom.el.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
671 Entries in the customization file are retrieved from package-get-base.el."
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
672 (interactive)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
673 ;; Load a fresh copy
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
674 (let ((custom-buffer (find-file-noselect
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
675 (or (package-get-file-installed-p
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
676 "package-get-custom.el")
314
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
677 (expand-file-name
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
678 "package-get-custom.el"
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
679 (file-name-directory
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
680 (package-get-file-installed-p
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
681 "package-get-base.el"))
341dac730539 Import from CVS: tag r21-0b55
cvs
parents: 306
diff changeset
682 ))))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
683 (pkg-groups nil))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
684
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
685 ;; clear existing stuff
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
686 (delete-region (point-min custom-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
687 (point-max custom-buffer) custom-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
688 (insert-string "(require 'package-get)\n" custom-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
689
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
690 (mapcar (lambda (pkg)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
691 (let ((category (plist-get (car (cdr pkg)) 'category)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
692 (or (memq (intern category) pkg-groups)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
693 (progn
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
694 (setq pkg-groups (cons (intern category) pkg-groups))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
695 (insert-string
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
696 (concat "(defgroup " category "-packages nil\n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
697 " \"" category " package group\"\n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
698 " :group 'packages)\n\n") custom-buffer)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
699
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
700 (insert-string
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
701 (concat "(defcustom " (symbol-name (car pkg))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
702 "-package nil \n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
703 " \"" (plist-get (car (cdr pkg)) 'description) "\"\n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
704 " :group '" category "-packages\n"
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
705 " :initialize 'package-get-ever-installed-p\n"
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
706 " :type 'boolean)\n\n") custom-buffer)))
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
707 package-get-base) custom-buffer)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
708 )
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
709
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
710 ;; need this first to avoid infinite dependency loops
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
711 (provide 'package-get)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
712
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
713 ;; potentially update the custom dependencies every time we load this
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
714 (let ((custom-file (package-get-file-installed-p "package-get-custom.el"))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
715 (package-file (package-get-file-installed-p "package-get-base.el")))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
716 ;; update custom file if it doesn't exist
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
717 (if (or (not custom-file)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
718 (and (< (car (nth 5 (file-attributes custom-file)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
719 (car (nth 5 (file-attributes package-file))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
720 (< (car (nth 5 (file-attributes custom-file)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
721 (car (nth 5 (file-attributes package-file))))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
722 (save-excursion
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
723 (message "generating package customizations...")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
724 (set-buffer (package-get-create-custom))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
725 (save-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
726 (message "generating package customizations...done")))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
727 (load "package-get-custom.el"))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
728
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
729 ;;; package-get.el ends here