428
|
1 ;;; package-get.el --- Retrieve XEmacs package
|
|
2
|
|
3 ;; Copyright (C) 1998 by Pete Ware
|
793
|
4 ;; Copyright (C) 2002 Ben Wing.
|
428
|
5
|
|
6 ;; Author: Pete Ware <ware@cis.ohio-state.edu>
|
|
7 ;; Heavy-Modifications: Greg Klanderman <greg@alphatech.com>
|
|
8 ;; Jan Vroonhof <vroonhof@math.ethz.ch>
|
|
9 ;; Keywords: internal
|
|
10
|
|
11 ;; This file is part of XEmacs.
|
|
12
|
|
13 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
14 ;; under the terms of the GNU General Public License as published by
|
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
|
18 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
|
24 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
26 ;; 02111-1307, USA.
|
|
27
|
|
28 ;;; Synched up with: Not in FSF
|
|
29
|
|
30 ;;; Commentary:
|
|
31
|
|
32 ;; package-get -
|
|
33 ;; Retrieve a package and any other required packages from an archive
|
|
34 ;;
|
|
35 ;;
|
440
|
36 ;; Note (JV): Most of this no longer applies!
|
428
|
37 ;;
|
|
38 ;; The idea:
|
|
39 ;; A new XEmacs lisp-only release is generated with the following steps:
|
|
40 ;; 1. The maintainer runs some yet to be written program that
|
|
41 ;; generates all the dependency information. This should
|
|
42 ;; determine all the require and provide statements and associate
|
|
43 ;; them with a package.
|
|
44 ;; 2. All the packages are then bundled into their own tar balls
|
|
45 ;; (or whatever format)
|
|
46 ;; 3. Maintainer automatically generates a new `package-get-base'
|
|
47 ;; data structure which contains information such as the
|
|
48 ;; package name, the file to be retrieved, an md5 checksum,
|
|
49 ;; etc (see `package-get-base').
|
|
50 ;; 4. The maintainer posts an announcement with the new version
|
|
51 ;; of `package-get-base'.
|
|
52 ;; 5. A user/system manager saves this posting and runs
|
|
53 ;; `package-get-update' which uses the previously saved list
|
|
54 ;; of packages, `package-get-here' that the user/site
|
|
55 ;; wants to determine what new versions to download and
|
|
56 ;; install.
|
|
57 ;;
|
|
58 ;; A user/site manager can generate a new `package-get-here' structure
|
|
59 ;; by using `package-get-setup' which generates a customize like
|
|
60 ;; interface to the list of packages. The buffer looks something
|
|
61 ;; like:
|
|
62 ;;
|
|
63 ;; gnus - a mail and news reader
|
|
64 ;; [] Always install
|
|
65 ;; [] Needs updating
|
|
66 ;; [] Required by other [packages]
|
|
67 ;; version: 2.0
|
|
68 ;;
|
|
69 ;; vm - a mail reader
|
|
70 ;; [] Always install
|
|
71 ;; [] Needs updating
|
442
|
72 ;; [] Required by other [packages]
|
428
|
73 ;;
|
|
74 ;; Where `[]' indicates a toggle box
|
|
75 ;;
|
|
76 ;; - Clicking on "Always install" puts this into
|
|
77 ;; `package-get-here' list. "Needs updating" indicates a new
|
|
78 ;; version is available. Anything already in
|
|
79 ;; `package-get-here' has this enabled.
|
|
80 ;; - "Required by other" means some other packages are going to force
|
|
81 ;; this to be installed. Clicking on [packages] gives a list
|
|
82 ;; of packages that require this.
|
442
|
83 ;;
|
428
|
84 ;; The `package-get-base' should be installed in a file in
|
|
85 ;; `data-directory'. The `package-get-here' should be installed in
|
|
86 ;; site-lisp. Both are then read at run time.
|
|
87 ;;
|
|
88 ;; TODO:
|
|
89 ;; - Implement `package-get-setup'
|
|
90 ;; - Actually put `package-get-base' and `package-get-here' into
|
|
91 ;; files that are read.
|
|
92 ;; - Allow users to have their own packages that they want installed
|
|
93 ;; in ~/.xemacs/.
|
|
94 ;; - SOMEONE needs to write the programs that generate the
|
|
95 ;; provides/requires database and makes it into a lisp data
|
|
96 ;; structure suitable for `package-get-base'
|
|
97 ;; - Handle errors such as no package providing a required symbol.
|
|
98 ;; - Tie this into the `require' function to download packages
|
|
99 ;; transparently.
|
|
100
|
|
101 ;;; Change Log
|
|
102
|
|
103 ;;; Code:
|
|
104
|
|
105 (require 'package-admin)
|
|
106 ;; (require 'package-get-base)
|
|
107
|
|
108 (defgroup package-tools nil
|
|
109 "Tools to manipulate packages."
|
|
110 :group 'emacs)
|
|
111
|
|
112 (defgroup package-get nil
|
|
113 "Automatic Package Fetcher and Installer."
|
|
114 :prefix "package-get"
|
|
115 :group 'package-tools)
|
|
116
|
442
|
117 ;;;###autoload
|
428
|
118 (defvar package-get-base nil
|
|
119 "List of packages that are installed at this site.
|
|
120 For each element in the alist, car is the package name and the cdr is
|
|
121 a plist containing information about the package. Typical fields
|
|
122 kept in the plist are:
|
|
123
|
|
124 version - version of this package
|
|
125 provides - list of symbols provided
|
|
126 requires - list of symbols that are required.
|
|
127 These in turn are provided by other packages.
|
|
128 filename - name of the file.
|
|
129 size - size of the file (aka the bundled package)
|
|
130 md5sum - computed md5 checksum
|
|
131 description - What this package is for.
|
|
132 type - Whether this is a 'binary (default) or 'single file package
|
|
133
|
|
134 More fields may be added as needed. An example:
|
|
135
|
|
136 '(
|
|
137 (name
|
|
138 (version \"<version 2>\"
|
|
139 file \"filename\"
|
|
140 description \"what this package is about.\"
|
|
141 provides (<list>)
|
|
142 requires (<list>)
|
|
143 size <integer-bytes>
|
|
144 md5sum \"<checksum\"
|
|
145 type single
|
|
146 )
|
|
147 (version \"<version 1>\"
|
|
148 file \"filename\"
|
|
149 description \"what this package is about.\"
|
|
150 provides (<list>)
|
|
151 requires (<list>)
|
|
152 size <integer-bytes>
|
|
153 md5sum \"<checksum\"
|
|
154 type single
|
|
155 )
|
|
156 ...
|
|
157 ))
|
|
158
|
|
159 For version information, it is assumed things are listed in most
|
|
160 recent to least recent -- in other words, the version names don't have to
|
|
161 be lexically ordered. It is debatable if it makes sense to have more than
|
|
162 one version of a package available.")
|
|
163
|
|
164 (defcustom package-get-dir (temp-directory)
|
|
165 "*Where to store temporary files for staging."
|
|
166 :tag "Temporary directory"
|
|
167 :type 'directory
|
|
168 :group 'package-get)
|
|
169
|
|
170 (define-widget 'host-name 'string
|
|
171 "A Host name."
|
|
172 :tag "Host")
|
|
173
|
|
174 (defcustom package-get-remote nil
|
1365
|
175 "*The remote site to contact for downloading packages.
|
|
176 Format is '(site-name directory-on-site). As a special case, `site-name'
|
|
177 can be `nil', in which case `directory-on-site' is treated as a local
|
|
178 directory."
|
428
|
179 :tag "Package repository"
|
1365
|
180 :type '(set (choice (const :tag "None" nil)
|
|
181 (list :tag "Local" (const :tag "Local" nil) directory)
|
|
182 (list :tag "Remote" host-name directory)))
|
428
|
183 :group 'package-get)
|
|
184
|
|
185 ;;;###autoload
|
|
186 (defcustom package-get-download-sites
|
|
187 '(
|
1365
|
188 ;; Main XEmacs Site (ftp.xemacs.org)
|
|
189 ("US (Main XEmacs Site)"
|
|
190 "ftp.xemacs.org" "pub/xemacs/packages")
|
|
191 ;; In alphabetical order of Country, our mirrors...
|
|
192 ("Australia (aarnet.edu.au)" "mirror.aarnet.edu.au" "pub/xemacs/packages")
|
|
193 ("Australia (au.xemacs.org)" "ftp.au.xemacs.org" "pub/xemacs/packages")
|
|
194 ("Austria (at.xemacs.org)" "ftp.at.xemacs.org" "editors/xemacs/packages")
|
|
195 ("Belgium (be.xemacs.org)" "ftp.be.xemacs.org" "xemacs/packages")
|
|
196 ("Brazil (br.xemacs.org)" "ftp.br.xemacs.org" "pub/xemacs/packages")
|
|
197 ("Canada (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/packages")
|
|
198 ("Canada (crc.ca)" "ftp.crc.ca" "pub/packages/editors/xemacs/packages")
|
|
199 ("Czech Republic (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/packages")
|
|
200 ("Denmark (dk.xemacs.org)" "ftp.dk.xemacs.org" "pub/emacs/xemacs/packages")
|
|
201 ("Finland (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/packages")
|
|
202 ("France (fr.xemacs.org)" "ftp.fr.xemacs.org" "pub/xemacs/packages")
|
|
203 ("France (pasteur.fr)" "ftp.pasteur.fr" "pub/computing/xemacs/packages")
|
|
204 ("Germany (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/packages")
|
|
205 ("Germany (tu-darmstadt.de)" "ftp.tu-darmstadt.de" "pub/editors/xemacs/packages")
|
|
206 ("Ireland (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/packages")
|
|
207 ("Italy (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/packages")
|
|
208 ("Japan (aist.go.jp)" "ring.aist.go.jp" "pub/text/xemacs/packages")
|
|
209 ("Japan (asahi-net.or.jp)" "ring.asahi-net.or.jp" "pub/text/xemacs/packages")
|
|
210 ("Japan (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/packages")
|
|
211 ("Japan (jaist.ac.jp)" "ftp.jaist.ac.jp" "pub/GNU/xemacs/packages")
|
|
212 ("Japan (jp.xemacs.org)" "ftp.jp.xemacs.org" "pub/GNU/xemacs/packages")
|
|
213 ("Japan (nucba.ac.jp)" "mirror.nucba.ac.jp" "mirror/xemacs/packages")
|
|
214 ("Japan (sut.ac.jp)" "sunsite.sut.ac.jp" "pub/archives/packages/xemacs/packages")
|
|
215 ("Korea (kr.xemacs.org))" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/packages")
|
|
216 ("Norway (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/packages")
|
|
217 ("Poland (pl.xemacs.org)" "ftp.pl.xemacs.org" "pub/unix/editors/xemacs/packages")
|
|
218 ("Russia (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/xemacs/packages")
|
|
219 ("Slovakia (sk.xemacs.org)" "ftp.sk.xemacs.org" "pub/mirrors/xemacs/packages")
|
|
220 ("South Africa (za.xemacs.org)" "ftp.za.xemacs.org" "mirrorsites/ftp.xemacs.org/packages")
|
|
221 ("Sweden (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/packages")
|
|
222 ("Switzerland (ch.xemacs.org)" "ftp.ch.xemacs.org" "mirror/xemacs/packages")
|
|
223 ("UK (uk.xemacs.org)" "ftp.uk.xemacs.org" "sites/ftp.xemacs.org/pub/xemacs/packages")
|
|
224 ("US (ibiblio.org)" "ibiblio.org" "pub/packages/editors/xemacs/packages")
|
|
225 ("US (stealth.net)" "ftp.stealth.net" "pub/mirrors/ftp.xemacs.org/pub/xemacs/packages")
|
|
226 ("US (us.xemacs.org)" "ftp.us.xemacs.org" "pub/xemacs/packages"))
|
428
|
227 "*List of remote sites available for downloading packages.
|
|
228 List format is '(site-description site-name directory-on-site).
|
|
229 SITE-DESCRIPTION is a textual description of the site. SITE-NAME
|
|
230 is the internet address of the download site. DIRECTORY-ON-SITE
|
|
231 is the directory on the site in which packages may be found.
|
|
232 This variable is used to initialize `package-get-remote', the
|
|
233 variable actually used to specify package download sites."
|
|
234 :tag "Package download sites"
|
442
|
235 :type '(repeat (list (string :tag "Name") host-name directory))
|
428
|
236 :group 'package-get)
|
|
237
|
1365
|
238 ;;;###autoload
|
|
239 (defcustom package-get-pre-release-download-sites
|
|
240 '(
|
|
241 ;; Main XEmacs Site (ftp.xemacs.org)
|
|
242 ("Pre-Releases (Main XEmacs Site)" "ftp.xemacs.org"
|
|
243 "pub/xemacs/beta/experimental/packages")
|
|
244 ;; In alphabetical order of Country, our mirrors...
|
|
245 ("Australia Pre-Releases (aarnet.edu.au)" "mirror.aarnet.edu.au"
|
|
246 "pub/xemacs/beta/experimental/packages")
|
|
247 ("Australia Pre-Releases (au.xemacs.org)" "ftp.au.xemacs.org"
|
|
248 "pub/xemacs/beta/experimental/packages")
|
|
249 ("Austria Pre-Releases (at.xemacs.org)" "ftp.at.xemacs.org"
|
|
250 "editors/xemacs/beta/experimentsl/packages")
|
|
251 ("Brazil Pre-Releases (br.xemacs.org)" "ftp.br.xemacs.org"
|
|
252 "pub/xemacs/xemacs-21.5/experimental/packages")
|
|
253 ("Canada Pre-Releases (ca.xemacs.org)" "ftp.ca.xemacs.org"
|
|
254 "pub/Mirror/xemacs/beta/experimental/packages")
|
|
255 ("Canada Pre-Releases (crc.ca)" "ftp.crc.ca"
|
|
256 "pub/packages/editors/xemacs/beta/experimental/packages")
|
|
257 ("Czech Republic Pre-Releases (cz.xemacs.org)" "ftp.cz.xemacs.org"
|
|
258 "MIRRORS/ftp.xemacs.org/pub/xemacs/xemacs-21.5/experimental/packages")
|
|
259 ("Denmark Pre-Releases (dk.xemacs.org)" "ftp.dk.xemacs.org"
|
|
260 "pub/emacs/xemacs/beta/experimental/packages")
|
|
261 ("Finland Pre-Releases (fi.xemacs.org)" "ftp.fi.xemacs.org"
|
|
262 "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/beta/experimental/packages")
|
|
263 ("France Pre-Releases (fr.xemacs.org)" "ftp.fr.xemacs.org"
|
|
264 "pub/xemacs/beta/experimental/packages")
|
|
265 ("France Pre-Releases (pasteur.fr)" "ftp.pasteur.fr"
|
|
266 "pub/computing/xemacs/beta/experimental/packages")
|
|
267 ("Germany Pre-Releases (de.xemacs.org)" "ftp.de.xemacs.org"
|
|
268 "pub/ftp.xemacs.org/tux/xemacs/beta/experimental/packages")
|
|
269 ("Germany Pre-Releases (tu-darmstadt.de)" "ftp.tu-darmstadt.de"
|
|
270 "pub/editors/xemacs/beta/experimental/packages")
|
|
271 ("Ireland Pre-Releases (ie.xemacs.org)" "ftp.ie.xemacs.org"
|
|
272 "mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages")
|
|
273 ("Italy Pre-Releases (it.xemacs.org)" "ftp.it.xemacs.org"
|
|
274 "unix/packages/XEMACS/beta/experimental/packages")
|
|
275 ("Japan Pre-Releases (aist.go.jp)" "ring.aist.go.jp"
|
|
276 "pub/text/xemacs/beta/experimental/packages")
|
|
277 ("Japan Pre-Releases (asahi-net.or.jp)" "ring.asahi-net.or.jp"
|
|
278 "pub/text/xemacs/beta/experimental/packages")
|
|
279 ("Japan Pre-Releases (dti.ad.jp)" "ftp.dti.ad.jp"
|
|
280 "pub/unix/editor/xemacs/beta/experimental/packages")
|
|
281 ("Japan Pre-Releases (jaist.ac.jp)" "ftp.jaist.ac.jp"
|
|
282 "pub/GNU/xemacs/beta/experimental/packages")
|
|
283 ("Japan Pre-Releases (jp.xemacs.org)" "ftp.jp.xemacs.org"
|
|
284 "pub/GNU/xemacs/beta/experimental/packages")
|
|
285 ("Japan Pre-Releases (sut.ac.jp)" "sunsite.sut.ac.jp"
|
|
286 "pub/archives/packages/xemacs/xemacs-21.5/experimental/packages")
|
|
287 ("Norway Pre-Releases (no.xemacs.org)" "ftp.no.xemacs.org"
|
|
288 "pub/xemacs/beta/experimental/packages")
|
|
289 ("Poland Pre-Releases (pl.xemacs.org)" "ftp.pl.xemacs.org"
|
|
290 "pub/unix/editors/xemacs/beta/experimental/packages")
|
|
291 ("Russia Pre-Releases (ru.xemacs.org)" "ftp.ru.xemacs.org"
|
|
292 "pub/xemacs/beta/experimental/packages")
|
|
293 ("Saudi Arabia Pre-Releases (sa.xemacs.org)" "ftp.sa.xemacs.org"
|
|
294 "pub/mirrors/ftp.xemacs.org/xemacs/xemacs-21.5/experimental/packages")
|
|
295 ("Slovakia Pre-Releases (sk.xemacs.org)" "ftp.sk.xemacs.org"
|
|
296 "pub/mirrors/xemacs/beta/experimental/packages")
|
|
297 ("South Africa Pre-Releases (za.xemacs.org)" "ftp.za.xemacs.org"
|
|
298 "mirrorsites/ftp.xemacs.org/beta/experimental/packages")
|
|
299 ("Sweden Pre-Releases (se.xemacs.org)" "ftp.se.xemacs.org"
|
|
300 "pub/gnu/xemacs/beta/experimental/packages")
|
|
301 ("Switzerland Pre-Releases (ch.xemacs.org)" "ftp.ch.xemacs.org"
|
|
302 "mirror/xemacs/beta/experimental/packages")
|
|
303 ("UK Pre-Releases (uk.xemacs.org)" "ftp.uk.xemacs.org"
|
|
304 "sites/ftp.xemacs.org/pub/xemacs/beta/experimental/packages")
|
|
305 ("US Pre-Releases (ibiblio.org)" "ibiblio.org"
|
|
306 "pub/packages/editors/xemacs/beta/experimental/packages")
|
|
307 ("US Pre-Releases (stealth.net)" "ftp.stealth.net"
|
|
308 "pub/mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages")
|
|
309 ("US Pre-Releases (us.xemacs.org)" "ftp.us.xemacs.org"
|
|
310 "pub/xemacs/beta/experimental/packages"))
|
|
311 "*List of remote sites available for downloading \"Pre-Release\" packages.
|
|
312 List format is '(site-description site-name directory-on-site).
|
|
313 SITE-DESCRIPTION is a textual description of the site. SITE-NAME
|
|
314 is the internet address of the download site. DIRECTORY-ON-SITE
|
|
315 is the directory on the site in which packages may be found.
|
|
316 This variable is used to initialize `package-get-remote', the
|
|
317 variable actually used to specify package download sites."
|
|
318 :tag "Pre-Release Package download sites"
|
|
319 :type '(repeat (list (string :tag "Name") host-name directory))
|
|
320 :group 'package-get)
|
|
321
|
428
|
322 (defcustom package-get-remove-copy t
|
|
323 "*After copying and installing a package, if this is t, then remove the
|
|
324 copy. Otherwise, keep it around."
|
|
325 :type 'boolean
|
|
326 :group 'package-get)
|
|
327
|
|
328 ;; #### it may make sense for this to be a list of names.
|
|
329 ;; #### also, should we rename "*base*" to "*index*" or "*db*"?
|
|
330 ;; "base" is a pretty poor name.
|
681
|
331 (defcustom package-get-base-filename "package-index.LATEST.gpg"
|
428
|
332 "*Name of the default package-get database file.
|
|
333 This may either be a relative path, in which case it is interpreted
|
|
334 with respect to `package-get-remote', or an absolute path."
|
|
335 :type 'file
|
|
336 :group 'package-get)
|
|
337
|
|
338 (defvar package-get-user-index-filename
|
|
339 (paths-construct-path (list user-init-directory package-get-base-filename))
|
|
340 "Name for the user-specific location of the package-get database file.")
|
|
341
|
|
342 (defcustom package-get-always-update nil
|
|
343 "*If Non-nil always make sure we are using the latest package index (base).
|
|
344 Otherwise respect the `force-current' argument of `package-get-require-base'."
|
|
345 :type 'boolean
|
|
346 :group 'package-get)
|
|
347
|
1365
|
348 (defcustom package-get-require-signed-base-updates t
|
428
|
349 "*If set to a non-nil value, require explicit user confirmation for updates
|
|
350 to the package-get database which cannot have their signature verified via PGP.
|
681
|
351 When nil, no PGP verification will be done."
|
428
|
352 :type 'boolean
|
|
353 :group 'package-get)
|
|
354
|
681
|
355 (defvar package-entries-are-signed nil
|
|
356 "Non-nil when the package index file has been PGP signed.")
|
|
357
|
|
358 (defvar package-get-continue-update-base nil
|
|
359 "Non-nil update the index even if it hasn't been signed.")
|
|
360
|
428
|
361 (defvar package-get-was-current nil
|
|
362 "Non-nil we did our best to fetch a current database.")
|
|
363
|
|
364 ;;;###autoload
|
|
365 (defun package-get-require-base (&optional force-current)
|
|
366 "Require that a package-get database has been loaded.
|
|
367 If the optional FORCE-CURRENT argument or the value of
|
|
368 `package-get-always-update' is Non-nil, try to update the database
|
|
369 from a location in `package-get-remote'. Otherwise a local copy is used
|
|
370 if available and remote access is never done.
|
|
371
|
|
372 Please use FORCE-CURRENT only when the user is explictly dealing with packages
|
|
373 and remote access is likely in the near future."
|
|
374 (setq force-current (or force-current package-get-always-update))
|
|
375 (unless (and (boundp 'package-get-base)
|
|
376 package-get-base
|
|
377 (or (not force-current) package-get-was-current))
|
|
378 (package-get-update-base nil force-current))
|
|
379 (if (or (not (boundp 'package-get-base))
|
|
380 (not package-get-base))
|
|
381 (error "Package-get database not loaded")
|
|
382 (setq package-get-was-current force-current)))
|
|
383
|
|
384 (defconst package-get-pgp-signed-begin-line "^-----BEGIN PGP SIGNED MESSAGE-----"
|
|
385 "Text for start of PGP signed messages.")
|
|
386 (defconst package-get-pgp-signature-begin-line "^-----BEGIN PGP SIGNATURE-----"
|
|
387 "Text for beginning of PGP signature.")
|
|
388 (defconst package-get-pgp-signature-end-line "^-----END PGP SIGNATURE-----"
|
|
389 "Text for end of PGP signature.")
|
|
390
|
|
391 ;;;###autoload
|
|
392 (defun package-get-update-base-entry (entry)
|
|
393 "Update an entry in `package-get-base'."
|
|
394 (let ((existing (assq (car entry) package-get-base)))
|
|
395 (if existing
|
|
396 (setcdr existing (cdr entry))
|
824
|
397 (setq package-get-base (cons entry package-get-base)))))
|
428
|
398
|
|
399 (defun package-get-locate-file (file &optional nil-if-not-found no-remote)
|
|
400 "Locate an existing FILE with respect to `package-get-remote'.
|
|
401 If FILE is an absolute path or is not found, simply return FILE.
|
|
402 If optional argument NIL-IF-NOT-FOUND is non-nil, return nil
|
|
403 if FILE can not be located.
|
|
404 If NO-REMOTE is non-nil never search remote locations."
|
|
405 (if (file-name-absolute-p file)
|
|
406 file
|
1365
|
407 (let ((site package-get-remote)
|
428
|
408 (expanded nil))
|
1365
|
409 (when site
|
|
410 (unless (and no-remote (caar (list site)))
|
|
411 (let ((expn (package-get-remote-filename (car (list site)) file)))
|
428
|
412 (if (and expn (file-exists-p expn))
|
1365
|
413 (setq site nil
|
|
414 expanded expn)))))
|
428
|
415 (or expanded
|
|
416 (and (not nil-if-not-found)
|
|
417 file)))))
|
|
418
|
|
419 (defun package-get-locate-index-file (no-remote)
|
|
420 "Locate the package-get index file. Do not return remote paths if NO-REMOTE
|
|
421 is non-nil."
|
|
422 (or (package-get-locate-file package-get-base-filename t no-remote)
|
|
423 (if (file-exists-p package-get-user-index-filename)
|
678
|
424 package-get-user-index-filename)
|
|
425 (locate-data-file package-get-base-filename)
|
|
426 (error "Can't locate a package index file.")))
|
428
|
427
|
|
428 (defun package-get-maybe-save-index (filename)
|
|
429 "Offer to save the current buffer as the local package index file,
|
|
430 if different."
|
|
431 (let ((location (package-get-locate-index-file t)))
|
|
432 (unless (and filename (equal filename location))
|
|
433 (unless (and location
|
|
434 (equal (md5 (current-buffer))
|
|
435 (with-temp-buffer
|
|
436 (insert-file-contents-literally location)
|
|
437 (md5 (current-buffer)))))
|
|
438 (unless (and location (file-writable-p location))
|
|
439 (setq location package-get-user-index-filename))
|
434
|
440 (when (y-or-n-p (concat "Update package index in " location "? "))
|
442
|
441 (let ((coding-system-for-write 'binary))
|
|
442 (write-file location)))))))
|
|
443
|
428
|
444 ;;;###autoload
|
|
445 (defun package-get-update-base (&optional db-file force-current)
|
|
446 "Update the package-get database file with entries from DB-FILE.
|
|
447 Unless FORCE-CURRENT is non-nil never try to update the database."
|
|
448 (interactive
|
|
449 (let ((dflt (package-get-locate-index-file nil)))
|
|
450 (list (read-file-name "Load package-get database: "
|
|
451 (file-name-directory dflt)
|
|
452 dflt
|
|
453 t
|
|
454 (file-name-nondirectory dflt)))))
|
|
455 (setq db-file (expand-file-name (or db-file
|
|
456 (package-get-locate-index-file
|
|
457 (not force-current)))))
|
|
458 (if (not (file-exists-p db-file))
|
|
459 (error "Package-get database file `%s' does not exist" db-file))
|
|
460 (if (not (file-readable-p db-file))
|
|
461 (error "Package-get database file `%s' not readable" db-file))
|
|
462 (let ((buf (get-buffer-create "*package database*")))
|
|
463 (unwind-protect
|
|
464 (save-excursion
|
|
465 (set-buffer buf)
|
|
466 (erase-buffer buf)
|
442
|
467 (insert-file-contents-literally db-file)
|
428
|
468 (package-get-update-base-from-buffer buf)
|
|
469 (if (file-remote-p db-file)
|
|
470 (package-get-maybe-save-index db-file)))
|
|
471 (kill-buffer buf))))
|
|
472
|
|
473 ;;;###autoload
|
|
474 (defun package-get-update-base-from-buffer (&optional buf)
|
|
475 "Update the package-get database with entries from BUFFER.
|
|
476 BUFFER defaults to the current buffer. This command can be
|
|
477 used interactively, for example from a mail or news buffer."
|
|
478 (interactive)
|
|
479 (setq buf (or buf (current-buffer)))
|
1365
|
480 (let (content-beg content-end)
|
428
|
481 (save-excursion
|
|
482 (set-buffer buf)
|
|
483 (goto-char (point-min))
|
|
484 (setq content-beg (point))
|
|
485 (setq content-end (save-excursion (goto-char (point-max)) (point)))
|
|
486 (when (re-search-forward package-get-pgp-signed-begin-line nil t)
|
|
487 (setq content-beg (match-end 0)))
|
|
488 (when (re-search-forward package-get-pgp-signature-begin-line nil t)
|
681
|
489 (setq content-end (match-beginning 0))
|
|
490 (setq package-entries-are-signed t))
|
1365
|
491 (re-search-forward package-get-pgp-signature-end-line nil t)
|
681
|
492 (setq package-get-continue-update-base t)
|
|
493 (if package-get-require-signed-base-updates
|
|
494 (if package-entries-are-signed
|
927
|
495 (if (featurep 'mailcrypt-autoloads)
|
|
496 (progn
|
|
497 (setq package-get-continue-update-base nil)
|
|
498 (autoload 'mc-setversion "mc-setversion")
|
1111
|
499 (with-fboundp 'mc-setversion
|
|
500 (cond ((locate-file "gpg" exec-path
|
|
501 '("" ".btm" ".bat" ".cmd" ".exe"
|
|
502 ".com") 'executable)
|
|
503 (mc-setversion "gpg"))
|
|
504 ((locate-file "pgpe" exec-path
|
|
505 '("" ".btm" ".bat" ".cmd" ".exe"
|
|
506 ".com") 'executable)
|
|
507 (mc-setversion "5.0"))
|
|
508 ((locate-file "pgp" exec-path
|
|
509 '("" ".btm" ".bat" ".cmd" ".exe"
|
|
510 ".com") 'executable)
|
|
511 (mc-setversion "2.6"))
|
|
512 (t
|
|
513 (error 'search-failed
|
|
514 "Can't find a suitable PGP executable"))))
|
927
|
515 (autoload 'mc-verify "mc-toplev")
|
|
516 (declare-fboundp (mc-verify))
|
|
517 (setq package-get-continue-update-base t))
|
|
518 (error 'unimplemented "`mailcrypt' package unavailable"))
|
681
|
519 (if (yes-or-no-p
|
|
520 "Package Index is not PGP signed. Continue anyway? ")
|
|
521 (setq package-get-continue-update-base t)
|
1365
|
522 (setq package-get-continue-update-base nil)
|
|
523 (error "Package database not updated"))))
|
440
|
524 ;; ToDo: We should call package-get-maybe-save-index on the region
|
681
|
525 (if package-get-continue-update-base
|
|
526 (progn
|
|
527 (package-get-update-base-entries content-beg content-end)
|
|
528 (message "Updated package-get database"))))))
|
428
|
529
|
444
|
530 (defun package-get-update-base-entries (start end)
|
428
|
531 "Update the package-get database with the entries found between
|
444
|
532 START and END in the current buffer."
|
428
|
533 (save-excursion
|
444
|
534 (goto-char start)
|
428
|
535 (if (not (re-search-forward "^(package-get-update-base-entry" nil t))
|
|
536 (error "Buffer does not contain package-get database entries"))
|
|
537 (beginning-of-line)
|
|
538 (let ((count 0))
|
|
539 (while (and (< (point) end)
|
|
540 (re-search-forward "^(package-get-update-base-entry" nil t))
|
|
541 (beginning-of-line)
|
|
542 (let ((entry (read (current-buffer))))
|
|
543 (if (or (not (consp entry))
|
|
544 (not (eq (car entry) 'package-get-update-base-entry)))
|
|
545 (error "Invalid package-get database entry found"))
|
|
546 (package-get-update-base-entry
|
|
547 (car (cdr (car (cdr entry)))))
|
|
548 (setq count (1+ count))))
|
|
549 (message "Got %d package-get database entries" count))))
|
|
550
|
|
551 ;;;###autoload
|
|
552 (defun package-get-save-base (file)
|
|
553 "Write the package-get database to FILE.
|
|
554
|
|
555 Note: This database will be unsigned of course."
|
|
556 (interactive "FSave package-get database to: ")
|
|
557 (package-get-require-base t)
|
|
558 (let ((buf (get-buffer-create "*package database*")))
|
|
559 (unwind-protect
|
|
560 (save-excursion
|
|
561 (set-buffer buf)
|
|
562 (erase-buffer buf)
|
|
563 (goto-char (point-min))
|
|
564 (let ((entries package-get-base) entry plist)
|
|
565 (insert ";; Package Index file -- Do not edit manually.\n")
|
|
566 (insert ";;;@@@\n")
|
|
567 (while entries
|
|
568 (setq entry (car entries))
|
|
569 (setq plist (car (cdr entry)))
|
|
570 (insert "(package-get-update-base-entry (quote\n")
|
|
571 (insert (format "(%s\n" (symbol-name (car entry))))
|
|
572 (while plist
|
|
573 (insert (format " %s%s %S\n"
|
|
574 (if (eq plist (car (cdr entry))) "(" " ")
|
|
575 (symbol-name (car plist))
|
|
576 (car (cdr plist))))
|
|
577 (setq plist (cdr (cdr plist))))
|
|
578 (insert "))\n))\n;;;@@@\n")
|
|
579 (setq entries (cdr entries))))
|
|
580 (insert ";; Package Index file ends here\n")
|
|
581 (write-region (point-min) (point-max) file))
|
|
582 (kill-buffer buf))))
|
|
583
|
|
584 (defun package-get-interactive-package-query (get-version package-symbol)
|
|
585 "Perform interactive querying for package and optional version.
|
|
586 Query for a version if GET-VERSION is non-nil. Return package name as
|
|
587 a symbol instead of a string if PACKAGE-SYMBOL is non-nil.
|
|
588 The return value is suitable for direct passing to `interactive'."
|
|
589 (package-get-require-base t)
|
442
|
590 (let ((table (mapcar #'(lambda (item)
|
|
591 (let ((name (symbol-name (car item))))
|
|
592 (cons name name)))
|
|
593 package-get-base))
|
|
594 package package-symbol default-version version)
|
428
|
595 (save-window-excursion
|
|
596 (setq package (completing-read "Package: " table nil t))
|
|
597 (setq package-symbol (intern package))
|
|
598 (if get-version
|
|
599 (progn
|
442
|
600 (setq default-version
|
|
601 (package-get-info-prop
|
428
|
602 (package-get-info-version
|
|
603 (package-get-info-find-package package-get-base
|
|
604 package-symbol) nil)
|
|
605 'version))
|
|
606 (while (string=
|
|
607 (setq version (read-string "Version: " default-version))
|
1365
|
608 ""))
|
428
|
609 (if package-symbol
|
|
610 (list package-symbol version)
|
1365
|
611 (list package version)))
|
428
|
612 (if package-symbol
|
|
613 (list package-symbol)
|
442
|
614 (list package))))))
|
428
|
615
|
|
616 ;;;###autoload
|
|
617 (defun package-get-delete-package (package &optional pkg-topdir)
|
|
618 "Delete an installation of PACKAGE below directory PKG-TOPDIR.
|
|
619 PACKAGE is a symbol, not a string.
|
|
620 This is just an interactive wrapper for `package-admin-delete-binary-package'."
|
|
621 (interactive (package-get-interactive-package-query nil t))
|
|
622 (package-admin-delete-binary-package package pkg-topdir))
|
|
623
|
|
624 ;;;###autoload
|
|
625 (defun package-get-update-all ()
|
|
626 "Fetch and install the latest versions of all currently installed packages."
|
|
627 (interactive)
|
|
628 (package-get-require-base t)
|
|
629 ;; Load a fresh copy
|
|
630 (catch 'exit
|
|
631 (mapcar (lambda (pkg)
|
|
632 (if (not (package-get (car pkg) nil 'never))
|
1365
|
633 (throw 'exit nil))) ;; Bail out if error detected
|
707
|
634 packages-package-list))
|
|
635 (package-net-update-installed-db))
|
428
|
636
|
|
637 ;;;###autoload
|
|
638 (defun package-get-all (package version &optional fetched-packages install-dir)
|
|
639 "Fetch PACKAGE with VERSION and all other required packages.
|
|
640 Uses `package-get-base' to determine just what is required and what
|
|
641 package provides that functionality. If VERSION is nil, retrieves
|
|
642 latest version. Optional argument FETCHED-PACKAGES is used to keep
|
|
643 track of packages already fetched. Optional argument INSTALL-DIR,
|
|
644 if non-nil, specifies the package directory where fetched packages
|
|
645 should be installed.
|
|
646
|
|
647 Returns nil upon error."
|
|
648 (interactive (package-get-interactive-package-query t nil))
|
|
649 (let* ((the-package (package-get-info-find-package package-get-base
|
|
650 package))
|
|
651 (this-package (package-get-info-version
|
|
652 the-package version))
|
1365
|
653 (this-requires (package-get-info-prop this-package 'requires)))
|
428
|
654 (catch 'exit
|
|
655 (setq version (package-get-info-prop this-package 'version))
|
|
656 (unless (package-get-installedp package version)
|
|
657 (if (not (package-get package version nil install-dir))
|
|
658 (progn
|
|
659 (setq fetched-packages nil)
|
|
660 (throw 'exit nil))))
|
|
661 (setq fetched-packages
|
|
662 (append (list package)
|
|
663 (package-get-info-prop this-package 'provides)
|
|
664 fetched-packages))
|
|
665 ;; grab everything that this package requires plus recursively
|
|
666 ;; grab everything that the requires require. Keep track
|
|
667 ;; in `fetched-packages' the list of things provided -- this
|
|
668 ;; keeps us from going into a loop
|
|
669 (while this-requires
|
|
670 (if (not (member (car this-requires) fetched-packages))
|
|
671 (let* ((reqd-package (package-get-package-provider
|
|
672 (car this-requires) t))
|
|
673 (reqd-version (cadr reqd-package))
|
|
674 (reqd-name (car reqd-package)))
|
|
675 (if (null reqd-name)
|
|
676 (error "Unable to find a provider for %s"
|
|
677 (car this-requires)))
|
|
678 (if (not (setq fetched-packages
|
|
679 (package-get-all reqd-name reqd-version
|
|
680 fetched-packages
|
|
681 install-dir)))
|
1365
|
682 (throw 'exit nil))))
|
|
683 (setq this-requires (cdr this-requires))))
|
|
684 fetched-packages))
|
428
|
685
|
|
686 ;;;###autoload
|
|
687 (defun package-get-dependencies (packages)
|
|
688 "Compute dependencies for PACKAGES.
|
|
689 Uses `package-get-base' to determine just what is required and what
|
|
690 package provides that functionality. Returns the list of packages
|
|
691 required by PACKAGES."
|
|
692 (package-get-require-base t)
|
|
693 (let ((orig-packages packages)
|
|
694 dependencies provided)
|
|
695 (while packages
|
|
696 (let* ((package (car packages))
|
|
697 (the-package (package-get-info-find-package
|
|
698 package-get-base package))
|
|
699 (this-package (package-get-info-version
|
|
700 the-package nil))
|
|
701 (this-requires (package-get-info-prop this-package 'requires))
|
|
702 (new-depends (set-difference
|
|
703 (mapcar
|
|
704 #'(lambda (reqd)
|
|
705 (let* ((reqd-package (package-get-package-provider reqd))
|
|
706 (reqd-name (car reqd-package)))
|
|
707 (if (null reqd-name)
|
|
708 (error "Unable to find a provider for %s" reqd))
|
|
709 reqd-name))
|
|
710 this-requires)
|
|
711 dependencies))
|
|
712 (this-provides (package-get-info-prop this-package 'provides)))
|
|
713 (setq dependencies
|
|
714 (union dependencies new-depends))
|
|
715 (setq provided
|
|
716 (union provided (union (list package) this-provides)))
|
|
717 (setq packages
|
|
718 (union new-depends (cdr packages)))))
|
|
719 (set-difference dependencies orig-packages)))
|
|
720
|
|
721 (defun package-get-load-package-file (lispdir file)
|
|
722 (let (pathname)
|
|
723 (setq pathname (expand-file-name file lispdir))
|
793
|
724 (with-trapping-errors
|
|
725 :operation (format "loading package file \"%s\"" pathname)
|
|
726 :error-form nil
|
|
727 (load pathname t)
|
|
728 t)))
|
428
|
729
|
|
730 (defun package-get-init-package (lispdir)
|
|
731 "Initialize the package.
|
|
732 This really assumes that the package has never been loaded. Updating
|
|
733 a newer package can cause problems, due to old, obsolete functions in
|
|
734 the old package.
|
|
735
|
|
736 Return `t' upon complete success, `nil' if any errors occurred."
|
|
737 (progn
|
|
738 (if (and lispdir
|
|
739 (file-accessible-directory-p lispdir))
|
|
740 (progn
|
|
741 ;; Add lispdir to load-path if it doesn't already exist.
|
|
742 ;; NOTE: this does not take symlinks, etc., into account.
|
1365
|
743 (if (let ((dirs load-path))
|
428
|
744 (catch 'done
|
|
745 (while dirs
|
|
746 (if (string-equal (car dirs) lispdir)
|
|
747 (throw 'done nil))
|
1365
|
748 (setq dirs (cdr dirs)))
|
428
|
749 t))
|
|
750 (setq load-path (cons lispdir load-path)))
|
|
751 (if (not (package-get-load-package-file lispdir "auto-autoloads"))
|
|
752 (package-get-load-package-file lispdir "_pkg"))
|
|
753 t)
|
1365
|
754 nil)))
|
|
755
|
|
756 ;;;###autoload
|
|
757 (defun package-get-info (package information &optional arg remote)
|
|
758 "Get information about a package.
|
|
759
|
|
760 Quite similar to `package-get-info-prop', but can retrieve a lot more
|
|
761 information.
|
|
762
|
|
763 Argument PACKAGE is the name of an XEmacs package (a symbol). It must
|
|
764 be a valid package, ie, a member of `package-get-base'.
|
|
765
|
|
766 Argument INFORMATION is a symbol that can be any one of:
|
|
767
|
|
768 standards-version Package system version (not used).
|
|
769 version Version of the XEmacs package.
|
|
770 author-version The upstream version of the package.
|
|
771 date The date the package was last modified.
|
|
772 build-date The date the package was last built.
|
|
773 maintainer The maintainer of the package.
|
|
774 distribution Will always be \"xemacs\" (not used).
|
|
775 priority \"low\", \"medium\", or \"high\" (not used).
|
|
776 category Either \"standard\", \"mule\", or \"unsupported\"..
|
|
777 dump Is the package dumped (not used).
|
|
778 description A description of the package.
|
|
779 filename The filename of the binary tarball of the package.
|
|
780 md5sum The md5sum of filename.
|
|
781 size The size in bytes of filename.
|
|
782 provides A list of symbols that this package provides.
|
|
783 requires A list of packages that this package requires.
|
|
784 type Can be either \"regular\" or \"single-file\".
|
|
785
|
|
786 If optional argument ARG is non-nil insert INFORMATION into current
|
|
787 buffer at point. This is very useful for doing things like inserting
|
|
788 a maintainer's email address into a mail buffer.
|
|
789
|
|
790 If optional argument REMOTE is non-nil use a package list from a
|
|
791 remote site. For this to work `package-get-remote' must be non-nil.
|
|
792
|
|
793 If this function is called interactively it will display INFORMATION
|
|
794 in the minibuffer."
|
|
795 (interactive "SPackage: \nSInfo: \nP")
|
|
796 (if remote
|
|
797 (package-get-require-base t)
|
|
798 (package-get-require-base nil))
|
|
799 (let ((all-pkgs package-get-base)
|
|
800 info)
|
|
801 (loop until (equal package (caar all-pkgs))
|
|
802 do (setq all-pkgs (cdr all-pkgs))
|
|
803 do (if (not all-pkgs)
|
|
804 (error (format "%s is not a valid package" package))))
|
|
805 (setq info (plist-get (cadar all-pkgs) information))
|
|
806 (if (interactive-p)
|
|
807 (if arg
|
|
808 (insert (format "%s" info))
|
|
809 (if (package-get-key package :version)
|
|
810 (message "%s" info)
|
|
811 (message "%s (Package: %s is not installed)" info package)))
|
|
812 (if arg
|
|
813 (insert (format "%s" info))
|
|
814 info))))
|
428
|
815
|
|
816 ;;;###autoload
|
|
817 (defun package-get (package &optional version conflict install-dir)
|
|
818 "Fetch PACKAGE from remote site.
|
|
819 Optional arguments VERSION indicates which version to retrieve, nil
|
|
820 means most recent version. CONFLICT indicates what happens if the
|
|
821 package is already installed. Valid values for CONFLICT are:
|
|
822 'always always retrieve the package even if it is already installed
|
|
823 'never do not retrieve the package if it is installed.
|
|
824 INSTALL-DIR, if non-nil, specifies the package directory where
|
|
825 fetched packages should be installed.
|
|
826
|
442
|
827 The value of `package-get-base' is used to determine what files should
|
428
|
828 be retrieved. The value of `package-get-remote' is used to determine
|
1365
|
829 where a package should be retrieved from.
|
428
|
830
|
|
831 Once the package is retrieved, its md5 checksum is computed. If that
|
|
832 sum does not match that stored in `package-get-base' for this version
|
|
833 of the package, an error is signalled.
|
|
834
|
|
835 Returns `t' upon success, the symbol `error' if the package was
|
|
836 successfully installed but errors occurred during initialization, or
|
|
837 `nil' upon error."
|
|
838 (interactive (package-get-interactive-package-query nil t))
|
|
839 (catch 'skip-update
|
|
840 (let* ((this-package
|
|
841 (package-get-info-version
|
|
842 (package-get-info-find-package package-get-base
|
|
843 package) version))
|
|
844 (latest (package-get-info-prop this-package 'version))
|
|
845 (installed (package-get-key package :version))
|
|
846 (found nil)
|
1365
|
847 (search-dir package-get-remote)
|
428
|
848 (base-filename (package-get-info-prop this-package 'filename))
|
|
849 (package-status t)
|
|
850 filenames full-package-filename)
|
1365
|
851 (if (and (equal (package-get-info package 'category) "mule")
|
|
852 (not (featurep 'mule)))
|
|
853 (error "Mule package %s can't be installed with a non-Mule XEmacs"
|
|
854 package))
|
428
|
855 (if (null this-package)
|
|
856 (if package-get-remote
|
|
857 (error "Couldn't find package %s with version %s"
|
|
858 package version)
|
1365
|
859 (error "No download site or local package location specified.")))
|
428
|
860 (if (null base-filename)
|
|
861 (error "No filename associated with package %s, version %s"
|
|
862 package version))
|
|
863 (setq install-dir
|
1365
|
864 (package-admin-get-install-dir
|
|
865 package install-dir
|
|
866 (equal (package-get-info package 'category) "mule")))
|
428
|
867
|
|
868 ;; If they asked for the latest using version=nil, don't get an older
|
|
869 ;; version than we already have.
|
|
870 (if installed
|
|
871 (if (> (if (stringp installed)
|
|
872 (string-to-number installed)
|
|
873 installed)
|
|
874 (if (stringp latest)
|
|
875 (string-to-number latest)
|
|
876 latest))
|
|
877 (if (not (null version))
|
825
|
878 (warn "Installing %s package version %s, you had a newer version %s"
|
793
|
879 package latest installed)
|
825
|
880 (warn "Skipping %s package, you have a newer version %s"
|
793
|
881 package installed)
|
428
|
882 (throw 'skip-update t))))
|
|
883
|
|
884 ;; Contrive a list of possible package filenames.
|
|
885 ;; Ugly. Is there a better way to do this?
|
|
886 (setq filenames (cons base-filename nil))
|
|
887 (if (string-match "^\\(..*\\)\.tar\.gz$" base-filename)
|
|
888 (setq filenames (append filenames
|
|
889 (list (concat (match-string 1 base-filename)
|
|
890 ".tgz")))))
|
|
891
|
|
892 (setq version latest)
|
|
893 (unless (and (eq conflict 'never)
|
|
894 (package-get-installedp package version))
|
|
895 ;; Find the package from the search list in package-get-remote
|
|
896 ;; and copy it into the staging directory. Then validate
|
|
897 ;; the checksum. Finally, install the package.
|
|
898 (catch 'done
|
1365
|
899 (let (search-filenames host dir current-filename dest-filename)
|
428
|
900 ;; In each search directory ...
|
1365
|
901 (when search-dir
|
|
902 (setq host (car search-dir)
|
|
903 dir (car (cdr search-dir))
|
|
904 search-filenames filenames)
|
428
|
905
|
|
906 ;; Look for one of the possible package filenames ...
|
|
907 (while search-filenames
|
|
908 (setq current-filename (car search-filenames)
|
|
909 dest-filename (package-get-staging-dir current-filename))
|
|
910 (cond
|
|
911 ;; No host means look on the current system.
|
1365
|
912 ((null host)
|
|
913 (setq full-package-filename
|
|
914 (substitute-in-file-name
|
|
915 (expand-file-name current-filename
|
|
916 (file-name-as-directory dir)))))
|
428
|
917
|
|
918 ;; If it's already on the disk locally, and the size is
|
1365
|
919 ;; correct
|
|
920 ((and (file-exists-p dest-filename)
|
|
921 (eq (nth 7 (file-attributes dest-filename))
|
|
922 (package-get-info package 'size)))
|
|
923 (setq full-package-filename dest-filename))
|
428
|
924
|
|
925 ;; If the file exists on the remote system ...
|
1365
|
926 ((file-exists-p (package-get-remote-filename
|
|
927 search-dir current-filename))
|
|
928 ;; Get it
|
|
929 (setq full-package-filename dest-filename)
|
|
930 (message "Retrieving package `%s' ..."
|
|
931 current-filename)
|
|
932 (sit-for 0)
|
|
933 (copy-file (package-get-remote-filename search-dir
|
|
934 current-filename)
|
|
935 full-package-filename t)))
|
428
|
936
|
|
937 ;; If we found it, we're done.
|
|
938 (if (and full-package-filename
|
|
939 (file-exists-p full-package-filename))
|
|
940 (throw 'done nil))
|
|
941 ;; Didn't find it. Try the next possible filename.
|
1365
|
942 (setq search-filenames (cdr search-filenames))))))
|
428
|
943
|
|
944 (if (or (not full-package-filename)
|
|
945 (not (file-exists-p full-package-filename)))
|
|
946 (if package-get-remote
|
|
947 (error "Unable to find file %s" base-filename)
|
|
948 (error
|
|
949 "No download sites or local package locations specified.")))
|
|
950 ;; Validate the md5 checksum
|
|
951 ;; Doing it with XEmacs removes the need for an external md5 program
|
|
952 (message "Validating checksum for `%s'..." package) (sit-for 0)
|
|
953 (with-temp-buffer
|
442
|
954 (insert-file-contents-literally full-package-filename)
|
428
|
955 (if (not (string= (md5 (current-buffer))
|
|
956 (package-get-info-prop this-package
|
|
957 'md5sum)))
|
1365
|
958 (progn
|
|
959 (delete-file full-package-filename)
|
|
960 (error "Package %s does not match md5 checksum %s has been deleted"
|
|
961 base-filename full-package-filename))))
|
428
|
962
|
|
963 (package-admin-delete-binary-package package install-dir)
|
|
964
|
|
965 (message "Installing package `%s' ..." package) (sit-for 0)
|
|
966 (let ((status
|
|
967 (package-admin-add-binary-package full-package-filename
|
|
968 install-dir)))
|
|
969 (if (= status 0)
|
|
970 (progn
|
|
971 ;; clear messages so that only messages from
|
|
972 ;; package-get-init-package are seen, below.
|
|
973 (clear-message)
|
|
974 (if (package-get-init-package (package-admin-get-lispdir
|
|
975 install-dir package))
|
|
976 (progn
|
628
|
977 (run-hook-with-args 'package-install-hook package install-dir)
|
428
|
978 (message "Added package `%s'" package)
|
1365
|
979 (sit-for 0))
|
428
|
980 (progn
|
|
981 ;; display message only if there isn't already one.
|
|
982 (if (not (current-message))
|
|
983 (progn
|
|
984 (message "Added package `%s' (errors occurred)"
|
|
985 package)
|
1365
|
986 (sit-for 0)))
|
428
|
987 (if package-status
|
1365
|
988 (setq package-status 'errors)))))
|
428
|
989 (message "Installation of package %s failed." base-filename)
|
|
990 (sit-for 0)
|
|
991 (switch-to-buffer package-admin-temp-buffer)
|
1365
|
992 (delete-file full-package-filename)
|
|
993 (setq package-status nil)))
|
428
|
994 (setq found t))
|
|
995 (if (and found package-get-remove-copy)
|
|
996 (delete-file full-package-filename))
|
1365
|
997 package-status)))
|
428
|
998
|
|
999 (defun package-get-info-find-package (which name)
|
|
1000 "Look in WHICH for the package called NAME and return all the info
|
|
1001 associated with it. See `package-get-base' for info on the format
|
|
1002 returned.
|
|
1003
|
|
1004 To access fields returned from this, use
|
|
1005 `package-get-info-version' to return information about particular a
|
442
|
1006 version. Use `package-get-info-find-prop' to find particular property
|
428
|
1007 from a version returned by `package-get-info-version'."
|
|
1008 (interactive "xPackage list: \nsPackage Name: ")
|
|
1009 (if which
|
|
1010 (if (eq (caar which) name)
|
|
1011 (cdar which)
|
|
1012 (if (cdr which)
|
|
1013 (package-get-info-find-package (cdr which) name)))))
|
|
1014
|
|
1015 (defun package-get-info-version (package version)
|
|
1016 "In PACKAGE, return the plist associated with a particular VERSION of the
|
|
1017 package. PACKAGE is typically as returned by
|
442
|
1018 `package-get-info-find-package'. If VERSION is nil, then return the
|
428
|
1019 first (aka most recent) version. Use `package-get-info-find-prop'
|
|
1020 to retrieve a particular property from the value returned by this."
|
|
1021 (interactive (package-get-interactive-package-query t t))
|
|
1022 (while (and version package (not (string= (plist-get (car package) 'version) version)))
|
|
1023 (setq package (cdr package)))
|
|
1024 (if package (car package)))
|
|
1025
|
|
1026 (defun package-get-info-prop (package-version property)
|
|
1027 "In PACKAGE-VERSION, return the value associated with PROPERTY.
|
|
1028 PACKAGE-VERSION is typically returned by `package-get-info-version'
|
|
1029 and PROPERTY is typically (although not limited to) one of the
|
|
1030 following:
|
|
1031
|
|
1032 version - version of this package
|
|
1033 provides - list of symbols provided
|
|
1034 requires - list of symbols that are required.
|
|
1035 These in turn are provided by other packages.
|
|
1036 size - size of the bundled package
|
|
1037 md5sum - computed md5 checksum"
|
|
1038 (interactive "xPackage Version: \nSProperty")
|
|
1039 (plist-get package-version property))
|
|
1040
|
|
1041 (defun package-get-info-version-prop (package-list package version property)
|
|
1042 "In PACKAGE-LIST, search for PACKAGE with this VERSION and return
|
|
1043 PROPERTY value."
|
|
1044 (package-get-info-prop
|
|
1045 (package-get-info-version
|
|
1046 (package-get-info-find-package package-list package) version) property))
|
|
1047
|
|
1048 (defun package-get-staging-dir (filename)
|
|
1049 "Return a good place to stash FILENAME when it is retrieved.
|
|
1050 Use `package-get-dir' for directory to store stuff.
|
629
|
1051 Creates `package-get-dir' if it doesn't exist."
|
428
|
1052 (interactive "FPackage filename: ")
|
|
1053 (if (not (file-exists-p package-get-dir))
|
|
1054 (make-directory package-get-dir))
|
|
1055 (expand-file-name
|
776
|
1056 (file-name-nondirectory (or (and-fboundp 'efs-ftp-path
|
|
1057 (nth 2 (efs-ftp-path filename)))
|
428
|
1058 filename))
|
|
1059 (file-name-as-directory package-get-dir)))
|
|
1060
|
|
1061 (defun package-get-remote-filename (search filename)
|
|
1062 "Return FILENAME as a remote filename.
|
|
1063 It first checks if FILENAME already is a remote filename. If it is
|
|
1064 not, then it uses the (car search) as the remote site-name and the (cadr
|
|
1065 search) as the remote-directory and concatenates filename. In other
|
|
1066 words
|
|
1067 site-name:remote-directory/filename.
|
|
1068
|
|
1069 If (car search) is nil, (cadr search is interpreted as a local directory).
|
|
1070 "
|
|
1071 (if (file-remote-p filename)
|
|
1072 filename
|
|
1073 (let ((dir (cadr search)))
|
|
1074 (concat (when (car search)
|
|
1075 (concat
|
|
1076 (if (string-match "@" (car search))
|
|
1077 "/"
|
|
1078 "/anonymous@")
|
|
1079 (car search) ":"))
|
|
1080 (if (string-match "/$" dir)
|
|
1081 dir
|
|
1082 (concat dir "/"))
|
|
1083 filename))))
|
|
1084
|
|
1085 (defun package-get-installedp (package version)
|
|
1086 "Determine if PACKAGE with VERSION has already been installed.
|
442
|
1087 I'm not sure if I want to do this by searching directories or checking
|
428
|
1088 some built in variables. For now, use packages-package-list."
|
|
1089 ;; Use packages-package-list which contains name and version
|
|
1090 (equal (plist-get
|
|
1091 (package-get-info-find-package packages-package-list
|
|
1092 package) ':version)
|
1365
|
1093 (if (floatp version)
|
|
1094 version
|
|
1095 (string-to-number version))))
|
428
|
1096
|
|
1097 ;;;###autoload
|
|
1098 (defun package-get-package-provider (sym &optional force-current)
|
|
1099 "Search for a package that provides SYM and return the name and
|
|
1100 version. Searches in `package-get-base' for SYM. If SYM is a
|
442
|
1101 consp, then it must match a corresponding (provide (SYM VERSION)) from
|
428
|
1102 the package.
|
|
1103
|
|
1104 If FORCE-CURRENT is non-nil make sure the database is up to date. This might
|
|
1105 lead to Emacs accessing remote sites."
|
|
1106 (interactive "SSymbol: ")
|
|
1107 (package-get-require-base force-current)
|
|
1108 (let ((packages package-get-base)
|
|
1109 (done nil)
|
|
1110 (found nil))
|
|
1111 (while (and (not done) packages)
|
|
1112 (let* ((this-name (caar packages))
|
|
1113 (this-package (cdr (car packages)))) ;strip off package name
|
|
1114 (while (and (not done) this-package)
|
|
1115 (if (or (eq this-name sym)
|
|
1116 (eq (cons this-name
|
|
1117 (package-get-info-prop (car this-package) 'version))
|
|
1118 sym)
|
|
1119 (member sym
|
|
1120 (package-get-info-prop (car this-package) 'provides)))
|
|
1121 (progn (setq done t)
|
|
1122 (setq found
|
|
1123 (list (caar packages)
|
|
1124 (package-get-info-prop (car this-package) 'version))))
|
|
1125 (setq this-package (cdr this-package)))))
|
|
1126 (setq packages (cdr packages)))
|
|
1127 (when (interactive-p)
|
|
1128 (if found
|
|
1129 (message "%S" found)
|
|
1130 (message "No appropriate package found")))
|
|
1131 found))
|
|
1132
|
|
1133 (defun package-get-ever-installed-p (pkg &optional notused)
|
|
1134 (string-match "-package$" (symbol-name pkg))
|
442
|
1135 (custom-initialize-set
|
|
1136 pkg
|
|
1137 (if (package-get-info-find-package
|
|
1138 packages-package-list
|
428
|
1139 (intern (substring (symbol-name pkg) 0 (match-beginning 0))))
|
|
1140 t)))
|
|
1141
|
|
1142 (provide 'package-get)
|
|
1143 ;;; package-get.el ends here
|