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