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