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