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