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))
|
824
|
340 (setq package-get-base (cons entry package-get-base)))))
|
428
|
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)))
|
771
|
425 (let (content-beg content-end ;beg end
|
|
426 )
|
428
|
427 (save-excursion
|
|
428 (set-buffer buf)
|
|
429 (goto-char (point-min))
|
|
430 (setq content-beg (point))
|
|
431 (setq content-end (save-excursion (goto-char (point-max)) (point)))
|
|
432 (when (re-search-forward package-get-pgp-signed-begin-line nil t)
|
771
|
433 ;(setq beg (match-beginning 0))
|
428
|
434 (setq content-beg (match-end 0)))
|
|
435 (when (re-search-forward package-get-pgp-signature-begin-line nil t)
|
681
|
436 (setq content-end (match-beginning 0))
|
|
437 (setq package-entries-are-signed t))
|
428
|
438 (when (re-search-forward package-get-pgp-signature-end-line nil t)
|
771
|
439 ;(setq end (point))
|
|
440 )
|
681
|
441 (setq package-get-continue-update-base t)
|
|
442 (if package-get-require-signed-base-updates
|
|
443 (if package-entries-are-signed
|
|
444 (progn
|
|
445 (setq package-get-continue-update-base nil)
|
|
446 (autoload 'mc-setversion "mc-setversion")
|
771
|
447 (with-fboundp 'mc-setversion
|
776
|
448 (if-boundp 'exec-suffix-list
|
|
449 (or
|
|
450 (cond ((locate-file "gpg" exec-path exec-suffix-list)
|
|
451 (mc-setversion "gpg"))
|
|
452 ((locate-file "pgpe" exec-path exec-suffix-list)
|
|
453 (mc-setversion "5.0"))
|
|
454 ((locate-file "pgp" exec-path exec-suffix-list)
|
|
455 (mc-setversion "2.6")))
|
|
456 (error "Can't find a suitable pgp executable"))
|
|
457 (error 'unimplemented "`apel' package unavailable")))
|
682
|
458 (autoload 'mc-verify "mc-toplev")
|
771
|
459 (declare-fboundp (mc-verify))
|
681
|
460 (setq package-get-continue-update-base t))
|
|
461 (if (yes-or-no-p
|
|
462 "Package Index is not PGP signed. Continue anyway? ")
|
|
463 (setq package-get-continue-update-base t)
|
|
464 (error "Package database not updated")
|
|
465 (setq package-get-continue-update-base nil))))
|
440
|
466 ;; ToDo: We should call package-get-maybe-save-index on the region
|
681
|
467 (if package-get-continue-update-base
|
|
468 (progn
|
|
469 (package-get-update-base-entries content-beg content-end)
|
|
470 (message "Updated package-get database"))))))
|
428
|
471
|
444
|
472 (defun package-get-update-base-entries (start end)
|
428
|
473 "Update the package-get database with the entries found between
|
444
|
474 START and END in the current buffer."
|
428
|
475 (save-excursion
|
444
|
476 (goto-char start)
|
428
|
477 (if (not (re-search-forward "^(package-get-update-base-entry" nil t))
|
|
478 (error "Buffer does not contain package-get database entries"))
|
|
479 (beginning-of-line)
|
|
480 (let ((count 0))
|
|
481 (while (and (< (point) end)
|
|
482 (re-search-forward "^(package-get-update-base-entry" nil t))
|
|
483 (beginning-of-line)
|
|
484 (let ((entry (read (current-buffer))))
|
|
485 (if (or (not (consp entry))
|
|
486 (not (eq (car entry) 'package-get-update-base-entry)))
|
|
487 (error "Invalid package-get database entry found"))
|
|
488 (package-get-update-base-entry
|
|
489 (car (cdr (car (cdr entry)))))
|
|
490 (setq count (1+ count))))
|
|
491 (message "Got %d package-get database entries" count))))
|
|
492
|
|
493 ;;;###autoload
|
|
494 (defun package-get-save-base (file)
|
|
495 "Write the package-get database to FILE.
|
|
496
|
|
497 Note: This database will be unsigned of course."
|
|
498 (interactive "FSave package-get database to: ")
|
|
499 (package-get-require-base t)
|
|
500 (let ((buf (get-buffer-create "*package database*")))
|
|
501 (unwind-protect
|
|
502 (save-excursion
|
|
503 (set-buffer buf)
|
|
504 (erase-buffer buf)
|
|
505 (goto-char (point-min))
|
|
506 (let ((entries package-get-base) entry plist)
|
|
507 (insert ";; Package Index file -- Do not edit manually.\n")
|
|
508 (insert ";;;@@@\n")
|
|
509 (while entries
|
|
510 (setq entry (car entries))
|
|
511 (setq plist (car (cdr entry)))
|
|
512 (insert "(package-get-update-base-entry (quote\n")
|
|
513 (insert (format "(%s\n" (symbol-name (car entry))))
|
|
514 (while plist
|
|
515 (insert (format " %s%s %S\n"
|
|
516 (if (eq plist (car (cdr entry))) "(" " ")
|
|
517 (symbol-name (car plist))
|
|
518 (car (cdr plist))))
|
|
519 (setq plist (cdr (cdr plist))))
|
|
520 (insert "))\n))\n;;;@@@\n")
|
|
521 (setq entries (cdr entries))))
|
|
522 (insert ";; Package Index file ends here\n")
|
|
523 (write-region (point-min) (point-max) file))
|
|
524 (kill-buffer buf))))
|
|
525
|
|
526 (defun package-get-interactive-package-query (get-version package-symbol)
|
|
527 "Perform interactive querying for package and optional version.
|
|
528 Query for a version if GET-VERSION is non-nil. Return package name as
|
|
529 a symbol instead of a string if PACKAGE-SYMBOL is non-nil.
|
|
530 The return value is suitable for direct passing to `interactive'."
|
|
531 (package-get-require-base t)
|
442
|
532 (let ((table (mapcar #'(lambda (item)
|
|
533 (let ((name (symbol-name (car item))))
|
|
534 (cons name name)))
|
|
535 package-get-base))
|
|
536 package package-symbol default-version version)
|
428
|
537 (save-window-excursion
|
|
538 (setq package (completing-read "Package: " table nil t))
|
|
539 (setq package-symbol (intern package))
|
|
540 (if get-version
|
|
541 (progn
|
442
|
542 (setq default-version
|
|
543 (package-get-info-prop
|
428
|
544 (package-get-info-version
|
|
545 (package-get-info-find-package package-get-base
|
|
546 package-symbol) nil)
|
|
547 'version))
|
|
548 (while (string=
|
|
549 (setq version (read-string "Version: " default-version))
|
|
550 "")
|
|
551 )
|
|
552 (if package-symbol
|
|
553 (list package-symbol version)
|
|
554 (list package version))
|
|
555 )
|
|
556 (if package-symbol
|
|
557 (list package-symbol)
|
442
|
558 (list package))))))
|
428
|
559
|
|
560 ;;;###autoload
|
|
561 (defun package-get-delete-package (package &optional pkg-topdir)
|
|
562 "Delete an installation of PACKAGE below directory PKG-TOPDIR.
|
|
563 PACKAGE is a symbol, not a string.
|
|
564 This is just an interactive wrapper for `package-admin-delete-binary-package'."
|
|
565 (interactive (package-get-interactive-package-query nil t))
|
|
566 (package-admin-delete-binary-package package pkg-topdir))
|
|
567
|
|
568 ;;;###autoload
|
|
569 (defun package-get-update-all ()
|
|
570 "Fetch and install the latest versions of all currently installed packages."
|
|
571 (interactive)
|
|
572 (package-get-require-base t)
|
|
573 ;; Load a fresh copy
|
|
574 (catch 'exit
|
|
575 (mapcar (lambda (pkg)
|
|
576 (if (not (package-get (car pkg) nil 'never))
|
|
577 (throw 'exit nil) ;; Bail out if error detected
|
|
578 ))
|
707
|
579 packages-package-list))
|
|
580 (package-net-update-installed-db))
|
428
|
581
|
|
582 ;;;###autoload
|
|
583 (defun package-get-all (package version &optional fetched-packages install-dir)
|
|
584 "Fetch PACKAGE with VERSION and all other required packages.
|
|
585 Uses `package-get-base' to determine just what is required and what
|
|
586 package provides that functionality. If VERSION is nil, retrieves
|
|
587 latest version. Optional argument FETCHED-PACKAGES is used to keep
|
|
588 track of packages already fetched. Optional argument INSTALL-DIR,
|
|
589 if non-nil, specifies the package directory where fetched packages
|
|
590 should be installed.
|
|
591
|
|
592 Returns nil upon error."
|
|
593 (interactive (package-get-interactive-package-query t nil))
|
|
594 (let* ((the-package (package-get-info-find-package package-get-base
|
|
595 package))
|
|
596 (this-package (package-get-info-version
|
|
597 the-package version))
|
|
598 (this-requires (package-get-info-prop this-package 'requires))
|
|
599 )
|
|
600 (catch 'exit
|
|
601 (setq version (package-get-info-prop this-package 'version))
|
|
602 (unless (package-get-installedp package version)
|
|
603 (if (not (package-get package version nil install-dir))
|
|
604 (progn
|
|
605 (setq fetched-packages nil)
|
|
606 (throw 'exit nil))))
|
|
607 (setq fetched-packages
|
|
608 (append (list package)
|
|
609 (package-get-info-prop this-package 'provides)
|
|
610 fetched-packages))
|
|
611 ;; grab everything that this package requires plus recursively
|
|
612 ;; grab everything that the requires require. Keep track
|
|
613 ;; in `fetched-packages' the list of things provided -- this
|
|
614 ;; keeps us from going into a loop
|
|
615 (while this-requires
|
|
616 (if (not (member (car this-requires) fetched-packages))
|
|
617 (let* ((reqd-package (package-get-package-provider
|
|
618 (car this-requires) t))
|
|
619 (reqd-version (cadr reqd-package))
|
|
620 (reqd-name (car reqd-package)))
|
|
621 (if (null reqd-name)
|
|
622 (error "Unable to find a provider for %s"
|
|
623 (car this-requires)))
|
|
624 (if (not (setq fetched-packages
|
|
625 (package-get-all reqd-name reqd-version
|
|
626 fetched-packages
|
|
627 install-dir)))
|
|
628 (throw 'exit nil)))
|
|
629 )
|
|
630 (setq this-requires (cdr this-requires)))
|
|
631 )
|
|
632 fetched-packages
|
|
633 ))
|
|
634
|
|
635 ;;;###autoload
|
|
636 (defun package-get-dependencies (packages)
|
|
637 "Compute dependencies for PACKAGES.
|
|
638 Uses `package-get-base' to determine just what is required and what
|
|
639 package provides that functionality. Returns the list of packages
|
|
640 required by PACKAGES."
|
|
641 (package-get-require-base t)
|
|
642 (let ((orig-packages packages)
|
|
643 dependencies provided)
|
|
644 (while packages
|
|
645 (let* ((package (car packages))
|
|
646 (the-package (package-get-info-find-package
|
|
647 package-get-base package))
|
|
648 (this-package (package-get-info-version
|
|
649 the-package nil))
|
|
650 (this-requires (package-get-info-prop this-package 'requires))
|
|
651 (new-depends (set-difference
|
|
652 (mapcar
|
|
653 #'(lambda (reqd)
|
|
654 (let* ((reqd-package (package-get-package-provider reqd))
|
|
655 (reqd-name (car reqd-package)))
|
|
656 (if (null reqd-name)
|
|
657 (error "Unable to find a provider for %s" reqd))
|
|
658 reqd-name))
|
|
659 this-requires)
|
|
660 dependencies))
|
|
661 (this-provides (package-get-info-prop this-package 'provides)))
|
|
662 (setq dependencies
|
|
663 (union dependencies new-depends))
|
|
664 (setq provided
|
|
665 (union provided (union (list package) this-provides)))
|
|
666 (setq packages
|
|
667 (union new-depends (cdr packages)))))
|
|
668 (set-difference dependencies orig-packages)))
|
|
669
|
|
670 (defun package-get-load-package-file (lispdir file)
|
|
671 (let (pathname)
|
|
672 (setq pathname (expand-file-name file lispdir))
|
793
|
673 (with-trapping-errors
|
|
674 :operation (format "loading package file \"%s\"" pathname)
|
|
675 :error-form nil
|
|
676 (load pathname t)
|
|
677 t)))
|
428
|
678
|
|
679 (defun package-get-init-package (lispdir)
|
|
680 "Initialize the package.
|
|
681 This really assumes that the package has never been loaded. Updating
|
|
682 a newer package can cause problems, due to old, obsolete functions in
|
|
683 the old package.
|
|
684
|
|
685 Return `t' upon complete success, `nil' if any errors occurred."
|
|
686 (progn
|
|
687 (if (and lispdir
|
|
688 (file-accessible-directory-p lispdir))
|
|
689 (progn
|
|
690 ;; Add lispdir to load-path if it doesn't already exist.
|
|
691 ;; NOTE: this does not take symlinks, etc., into account.
|
|
692 (if (let ( (dirs load-path) )
|
|
693 (catch 'done
|
|
694 (while dirs
|
|
695 (if (string-equal (car dirs) lispdir)
|
|
696 (throw 'done nil))
|
|
697 (setq dirs (cdr dirs))
|
|
698 )
|
|
699 t))
|
|
700 (setq load-path (cons lispdir load-path)))
|
|
701 (if (not (package-get-load-package-file lispdir "auto-autoloads"))
|
|
702 (package-get-load-package-file lispdir "_pkg"))
|
|
703 t)
|
|
704 nil)
|
|
705 ))
|
|
706
|
|
707 ;;;###autoload
|
|
708 (defun package-get (package &optional version conflict install-dir)
|
|
709 "Fetch PACKAGE from remote site.
|
|
710 Optional arguments VERSION indicates which version to retrieve, nil
|
|
711 means most recent version. CONFLICT indicates what happens if the
|
|
712 package is already installed. Valid values for CONFLICT are:
|
|
713 'always always retrieve the package even if it is already installed
|
|
714 'never do not retrieve the package if it is installed.
|
|
715 INSTALL-DIR, if non-nil, specifies the package directory where
|
|
716 fetched packages should be installed.
|
|
717
|
442
|
718 The value of `package-get-base' is used to determine what files should
|
428
|
719 be retrieved. The value of `package-get-remote' is used to determine
|
|
720 where a package should be retrieved from. The sites are tried in
|
|
721 order so one is better off listing easily reached sites first.
|
|
722
|
|
723 Once the package is retrieved, its md5 checksum is computed. If that
|
|
724 sum does not match that stored in `package-get-base' for this version
|
|
725 of the package, an error is signalled.
|
|
726
|
|
727 Returns `t' upon success, the symbol `error' if the package was
|
|
728 successfully installed but errors occurred during initialization, or
|
|
729 `nil' upon error."
|
|
730 (interactive (package-get-interactive-package-query nil t))
|
|
731 (catch 'skip-update
|
|
732 (let* ((this-package
|
|
733 (package-get-info-version
|
|
734 (package-get-info-find-package package-get-base
|
|
735 package) version))
|
|
736 (latest (package-get-info-prop this-package 'version))
|
|
737 (installed (package-get-key package :version))
|
|
738 (this-requires (package-get-info-prop this-package 'requires))
|
|
739 (found nil)
|
|
740 (search-dirs package-get-remote)
|
|
741 (base-filename (package-get-info-prop this-package 'filename))
|
|
742 (package-status t)
|
|
743 filenames full-package-filename)
|
|
744 (if (null this-package)
|
|
745 (if package-get-remote
|
|
746 (error "Couldn't find package %s with version %s"
|
|
747 package version)
|
|
748 (error "No download sites or local package locations specified.")))
|
|
749 (if (null base-filename)
|
|
750 (error "No filename associated with package %s, version %s"
|
|
751 package version))
|
|
752 (setq install-dir
|
|
753 (package-admin-get-install-dir package install-dir
|
|
754 (or (eq package 'mule-base) (memq 'mule-base this-requires))))
|
|
755
|
|
756 ;; If they asked for the latest using version=nil, don't get an older
|
|
757 ;; version than we already have.
|
|
758 (if installed
|
|
759 (if (> (if (stringp installed)
|
|
760 (string-to-number installed)
|
|
761 installed)
|
|
762 (if (stringp latest)
|
|
763 (string-to-number latest)
|
|
764 latest))
|
|
765 (if (not (null version))
|
825
|
766 (warn "Installing %s package version %s, you had a newer version %s"
|
793
|
767 package latest installed)
|
825
|
768 (warn "Skipping %s package, you have a newer version %s"
|
793
|
769 package installed)
|
428
|
770 (throw 'skip-update t))))
|
|
771
|
|
772 ;; Contrive a list of possible package filenames.
|
|
773 ;; Ugly. Is there a better way to do this?
|
|
774 (setq filenames (cons base-filename nil))
|
|
775 (if (string-match "^\\(..*\\)\.tar\.gz$" base-filename)
|
|
776 (setq filenames (append filenames
|
|
777 (list (concat (match-string 1 base-filename)
|
|
778 ".tgz")))))
|
|
779
|
|
780 (setq version latest)
|
|
781 (unless (and (eq conflict 'never)
|
|
782 (package-get-installedp package version))
|
|
783 ;; Find the package from the search list in package-get-remote
|
|
784 ;; and copy it into the staging directory. Then validate
|
|
785 ;; the checksum. Finally, install the package.
|
|
786 (catch 'done
|
|
787 (let (search-filenames current-dir-entry host dir current-filename
|
|
788 dest-filename)
|
|
789 ;; In each search directory ...
|
|
790 (while search-dirs
|
|
791 (setq current-dir-entry (car search-dirs)
|
|
792 host (car current-dir-entry)
|
|
793 dir (car (cdr current-dir-entry))
|
|
794 search-filenames filenames
|
|
795 )
|
|
796
|
|
797 ;; Look for one of the possible package filenames ...
|
|
798 (while search-filenames
|
|
799 (setq current-filename (car search-filenames)
|
|
800 dest-filename (package-get-staging-dir current-filename))
|
|
801 (cond
|
|
802 ;; No host means look on the current system.
|
|
803 ( (null host)
|
|
804 (setq full-package-filename
|
|
805 (substitute-in-file-name
|
|
806 (expand-file-name current-filename
|
|
807 (file-name-as-directory dir))))
|
|
808 )
|
|
809
|
|
810 ;; If it's already on the disk locally, and the size is
|
|
811 ;; greater than zero ...
|
|
812 ( (and (file-exists-p dest-filename)
|
|
813 (let (attrs)
|
|
814 ;; file-attributes could return -1 for LARGE files,
|
|
815 ;; but, hopefully, packages won't be that large.
|
|
816 (and (setq attrs (file-attributes dest-filename))
|
|
817 (> (nth 7 attrs) 0))))
|
|
818 (setq full-package-filename dest-filename)
|
|
819 )
|
|
820
|
|
821 ;; If the file exists on the remote system ...
|
|
822 ( (file-exists-p (package-get-remote-filename
|
|
823 current-dir-entry current-filename))
|
|
824 ;; Get it
|
|
825 (setq full-package-filename dest-filename)
|
442
|
826 (message "Retrieving package `%s' ..."
|
428
|
827 current-filename)
|
|
828 (sit-for 0)
|
|
829 (copy-file (package-get-remote-filename current-dir-entry
|
|
830 current-filename)
|
|
831 full-package-filename t)
|
|
832 )
|
|
833 )
|
|
834
|
|
835 ;; If we found it, we're done.
|
|
836 (if (and full-package-filename
|
|
837 (file-exists-p full-package-filename))
|
|
838 (throw 'done nil))
|
|
839 ;; Didn't find it. Try the next possible filename.
|
|
840 (setq search-filenames (cdr search-filenames))
|
|
841 )
|
|
842 ;; Try looking in the next possible directory ...
|
|
843 (setq search-dirs (cdr search-dirs))
|
|
844 )
|
|
845 ))
|
|
846
|
|
847 (if (or (not full-package-filename)
|
|
848 (not (file-exists-p full-package-filename)))
|
|
849 (if package-get-remote
|
|
850 (error "Unable to find file %s" base-filename)
|
|
851 (error
|
|
852 "No download sites or local package locations specified.")))
|
|
853 ;; Validate the md5 checksum
|
|
854 ;; Doing it with XEmacs removes the need for an external md5 program
|
|
855 (message "Validating checksum for `%s'..." package) (sit-for 0)
|
|
856 (with-temp-buffer
|
442
|
857 (insert-file-contents-literally full-package-filename)
|
428
|
858 (if (not (string= (md5 (current-buffer))
|
|
859 (package-get-info-prop this-package
|
|
860 'md5sum)))
|
|
861 (error "Package %s does not match md5 checksum" base-filename)))
|
|
862
|
|
863 (package-admin-delete-binary-package package install-dir)
|
|
864
|
|
865 (message "Installing package `%s' ..." package) (sit-for 0)
|
|
866 (let ((status
|
|
867 (package-admin-add-binary-package full-package-filename
|
|
868 install-dir)))
|
|
869 (if (= status 0)
|
|
870 (progn
|
|
871 ;; clear messages so that only messages from
|
|
872 ;; package-get-init-package are seen, below.
|
|
873 (clear-message)
|
|
874 (if (package-get-init-package (package-admin-get-lispdir
|
|
875 install-dir package))
|
|
876 (progn
|
628
|
877 (run-hook-with-args 'package-install-hook package install-dir)
|
428
|
878 (message "Added package `%s'" package)
|
|
879 (sit-for 0)
|
|
880 )
|
|
881 (progn
|
|
882 ;; display message only if there isn't already one.
|
|
883 (if (not (current-message))
|
|
884 (progn
|
|
885 (message "Added package `%s' (errors occurred)"
|
|
886 package)
|
|
887 (sit-for 0)
|
|
888 ))
|
|
889 (if package-status
|
|
890 (setq package-status 'errors))
|
|
891 ))
|
|
892 )
|
|
893 (message "Installation of package %s failed." base-filename)
|
|
894 (sit-for 0)
|
|
895 (switch-to-buffer package-admin-temp-buffer)
|
|
896 (setq package-status nil)
|
|
897 ))
|
|
898 (setq found t))
|
|
899 (if (and found package-get-remove-copy)
|
|
900 (delete-file full-package-filename))
|
|
901 package-status
|
|
902 )))
|
|
903
|
|
904 (defun package-get-info-find-package (which name)
|
|
905 "Look in WHICH for the package called NAME and return all the info
|
|
906 associated with it. See `package-get-base' for info on the format
|
|
907 returned.
|
|
908
|
|
909 To access fields returned from this, use
|
|
910 `package-get-info-version' to return information about particular a
|
442
|
911 version. Use `package-get-info-find-prop' to find particular property
|
428
|
912 from a version returned by `package-get-info-version'."
|
|
913 (interactive "xPackage list: \nsPackage Name: ")
|
|
914 (if which
|
|
915 (if (eq (caar which) name)
|
|
916 (cdar which)
|
|
917 (if (cdr which)
|
|
918 (package-get-info-find-package (cdr which) name)))))
|
|
919
|
|
920 (defun package-get-info-version (package version)
|
|
921 "In PACKAGE, return the plist associated with a particular VERSION of the
|
|
922 package. PACKAGE is typically as returned by
|
442
|
923 `package-get-info-find-package'. If VERSION is nil, then return the
|
428
|
924 first (aka most recent) version. Use `package-get-info-find-prop'
|
|
925 to retrieve a particular property from the value returned by this."
|
|
926 (interactive (package-get-interactive-package-query t t))
|
|
927 (while (and version package (not (string= (plist-get (car package) 'version) version)))
|
|
928 (setq package (cdr package)))
|
|
929 (if package (car package)))
|
|
930
|
|
931 (defun package-get-info-prop (package-version property)
|
|
932 "In PACKAGE-VERSION, return the value associated with PROPERTY.
|
|
933 PACKAGE-VERSION is typically returned by `package-get-info-version'
|
|
934 and PROPERTY is typically (although not limited to) one of the
|
|
935 following:
|
|
936
|
|
937 version - version of this package
|
|
938 provides - list of symbols provided
|
|
939 requires - list of symbols that are required.
|
|
940 These in turn are provided by other packages.
|
|
941 size - size of the bundled package
|
|
942 md5sum - computed md5 checksum"
|
|
943 (interactive "xPackage Version: \nSProperty")
|
|
944 (plist-get package-version property))
|
|
945
|
|
946 (defun package-get-info-version-prop (package-list package version property)
|
|
947 "In PACKAGE-LIST, search for PACKAGE with this VERSION and return
|
|
948 PROPERTY value."
|
|
949 (package-get-info-prop
|
|
950 (package-get-info-version
|
|
951 (package-get-info-find-package package-list package) version) property))
|
|
952
|
|
953 (defun package-get-set-version-prop (package-list package version
|
|
954 property value)
|
|
955 "A utility to make it easier to add a VALUE for a specific PROPERTY
|
|
956 in this VERSION of a specific PACKAGE kept in the PACKAGE-LIST.
|
|
957 Returns the modified PACKAGE-LIST. Any missing fields are created."
|
|
958 )
|
|
959
|
|
960 (defun package-get-staging-dir (filename)
|
|
961 "Return a good place to stash FILENAME when it is retrieved.
|
|
962 Use `package-get-dir' for directory to store stuff.
|
629
|
963 Creates `package-get-dir' if it doesn't exist."
|
428
|
964 (interactive "FPackage filename: ")
|
|
965 (if (not (file-exists-p package-get-dir))
|
|
966 (make-directory package-get-dir))
|
|
967 (expand-file-name
|
776
|
968 (file-name-nondirectory (or (and-fboundp 'efs-ftp-path
|
|
969 (nth 2 (efs-ftp-path filename)))
|
428
|
970 filename))
|
|
971 (file-name-as-directory package-get-dir)))
|
|
972
|
|
973 (defun package-get-remote-filename (search filename)
|
|
974 "Return FILENAME as a remote filename.
|
|
975 It first checks if FILENAME already is a remote filename. If it is
|
|
976 not, then it uses the (car search) as the remote site-name and the (cadr
|
|
977 search) as the remote-directory and concatenates filename. In other
|
|
978 words
|
|
979 site-name:remote-directory/filename.
|
|
980
|
|
981 If (car search) is nil, (cadr search is interpreted as a local directory).
|
|
982 "
|
|
983 (if (file-remote-p filename)
|
|
984 filename
|
|
985 (let ((dir (cadr search)))
|
|
986 (concat (when (car search)
|
|
987 (concat
|
|
988 (if (string-match "@" (car search))
|
|
989 "/"
|
|
990 "/anonymous@")
|
|
991 (car search) ":"))
|
|
992 (if (string-match "/$" dir)
|
|
993 dir
|
|
994 (concat dir "/"))
|
|
995 filename))))
|
|
996
|
|
997
|
|
998 (defun package-get-installedp (package version)
|
|
999 "Determine if PACKAGE with VERSION has already been installed.
|
442
|
1000 I'm not sure if I want to do this by searching directories or checking
|
428
|
1001 some built in variables. For now, use packages-package-list."
|
|
1002 ;; Use packages-package-list which contains name and version
|
|
1003 (equal (plist-get
|
|
1004 (package-get-info-find-package packages-package-list
|
|
1005 package) ':version)
|
|
1006 (if (floatp version) version (string-to-number version))))
|
|
1007
|
|
1008 ;;;###autoload
|
|
1009 (defun package-get-package-provider (sym &optional force-current)
|
|
1010 "Search for a package that provides SYM and return the name and
|
|
1011 version. Searches in `package-get-base' for SYM. If SYM is a
|
442
|
1012 consp, then it must match a corresponding (provide (SYM VERSION)) from
|
428
|
1013 the package.
|
|
1014
|
|
1015 If FORCE-CURRENT is non-nil make sure the database is up to date. This might
|
|
1016 lead to Emacs accessing remote sites."
|
|
1017 (interactive "SSymbol: ")
|
|
1018 (package-get-require-base force-current)
|
|
1019 (let ((packages package-get-base)
|
|
1020 (done nil)
|
|
1021 (found nil))
|
|
1022 (while (and (not done) packages)
|
|
1023 (let* ((this-name (caar packages))
|
|
1024 (this-package (cdr (car packages)))) ;strip off package name
|
|
1025 (while (and (not done) this-package)
|
|
1026 (if (or (eq this-name sym)
|
|
1027 (eq (cons this-name
|
|
1028 (package-get-info-prop (car this-package) 'version))
|
|
1029 sym)
|
|
1030 (member sym
|
|
1031 (package-get-info-prop (car this-package) 'provides)))
|
|
1032 (progn (setq done t)
|
|
1033 (setq found
|
|
1034 (list (caar packages)
|
|
1035 (package-get-info-prop (car this-package) 'version))))
|
|
1036 (setq this-package (cdr this-package)))))
|
|
1037 (setq packages (cdr packages)))
|
|
1038 (when (interactive-p)
|
|
1039 (if found
|
|
1040 (message "%S" found)
|
|
1041 (message "No appropriate package found")))
|
|
1042 found))
|
|
1043
|
|
1044 (defun package-get-ever-installed-p (pkg &optional notused)
|
|
1045 (string-match "-package$" (symbol-name pkg))
|
442
|
1046 (custom-initialize-set
|
|
1047 pkg
|
|
1048 (if (package-get-info-find-package
|
|
1049 packages-package-list
|
428
|
1050 (intern (substring (symbol-name pkg) 0 (match-beginning 0))))
|
|
1051 t)))
|
|
1052
|
|
1053
|
|
1054 (provide 'package-get)
|
|
1055 ;;; package-get.el ends here
|