428
|
1 ;;; package-get.el --- Retrieve XEmacs package
|
|
2
|
|
3 ;; Copyright (C) 1998 by Pete Ware
|
793
|
4 ;; Copyright (C) 2002 Ben Wing.
|
1410
|
5 ;; Copyright (C) 2003, Steve Youngs
|
428
|
6
|
|
7 ;; Author: Pete Ware <ware@cis.ohio-state.edu>
|
|
8 ;; Heavy-Modifications: Greg Klanderman <greg@alphatech.com>
|
|
9 ;; Jan Vroonhof <vroonhof@math.ethz.ch>
|
1410
|
10 ;; Steve Youngs <youngs@xemacs.org>
|
428
|
11 ;; Keywords: internal
|
|
12
|
|
13 ;; This file is part of XEmacs.
|
|
14
|
|
15 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
16 ;; under the terms of the GNU General Public License as published by
|
|
17 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
18 ;; any later version.
|
|
19
|
|
20 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
23 ;; General Public License for more details.
|
|
24
|
|
25 ;; You should have received a copy of the GNU General Public License
|
|
26 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
27 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
28 ;; 02111-1307, USA.
|
|
29
|
|
30 ;;; Synched up with: Not in FSF
|
|
31
|
|
32 ;;; Commentary:
|
|
33
|
|
34 ;; package-get -
|
|
35 ;; Retrieve a package and any other required packages from an archive
|
|
36 ;;
|
|
37 ;;
|
440
|
38 ;; Note (JV): Most of this no longer applies!
|
428
|
39 ;;
|
|
40 ;; The idea:
|
|
41 ;; A new XEmacs lisp-only release is generated with the following steps:
|
|
42 ;; 1. The maintainer runs some yet to be written program that
|
|
43 ;; generates all the dependency information. This should
|
|
44 ;; determine all the require and provide statements and associate
|
|
45 ;; them with a package.
|
|
46 ;; 2. All the packages are then bundled into their own tar balls
|
|
47 ;; (or whatever format)
|
|
48 ;; 3. Maintainer automatically generates a new `package-get-base'
|
|
49 ;; data structure which contains information such as the
|
|
50 ;; package name, the file to be retrieved, an md5 checksum,
|
|
51 ;; etc (see `package-get-base').
|
|
52 ;; 4. The maintainer posts an announcement with the new version
|
|
53 ;; of `package-get-base'.
|
|
54 ;; 5. A user/system manager saves this posting and runs
|
|
55 ;; `package-get-update' which uses the previously saved list
|
|
56 ;; of packages, `package-get-here' that the user/site
|
|
57 ;; wants to determine what new versions to download and
|
|
58 ;; install.
|
|
59 ;;
|
|
60 ;; A user/site manager can generate a new `package-get-here' structure
|
|
61 ;; by using `package-get-setup' which generates a customize like
|
|
62 ;; interface to the list of packages. The buffer looks something
|
|
63 ;; like:
|
|
64 ;;
|
|
65 ;; gnus - a mail and news reader
|
|
66 ;; [] Always install
|
|
67 ;; [] Needs updating
|
|
68 ;; [] Required by other [packages]
|
|
69 ;; version: 2.0
|
|
70 ;;
|
|
71 ;; vm - a mail reader
|
|
72 ;; [] Always install
|
|
73 ;; [] Needs updating
|
442
|
74 ;; [] Required by other [packages]
|
428
|
75 ;;
|
|
76 ;; Where `[]' indicates a toggle box
|
|
77 ;;
|
|
78 ;; - Clicking on "Always install" puts this into
|
|
79 ;; `package-get-here' list. "Needs updating" indicates a new
|
|
80 ;; version is available. Anything already in
|
|
81 ;; `package-get-here' has this enabled.
|
|
82 ;; - "Required by other" means some other packages are going to force
|
|
83 ;; this to be installed. Clicking on [packages] gives a list
|
|
84 ;; of packages that require this.
|
442
|
85 ;;
|
428
|
86 ;; The `package-get-base' should be installed in a file in
|
|
87 ;; `data-directory'. The `package-get-here' should be installed in
|
|
88 ;; site-lisp. Both are then read at run time.
|
|
89 ;;
|
|
90 ;; TODO:
|
|
91 ;; - Implement `package-get-setup'
|
|
92 ;; - Actually put `package-get-base' and `package-get-here' into
|
|
93 ;; files that are read.
|
|
94 ;; - Allow users to have their own packages that they want installed
|
|
95 ;; in ~/.xemacs/.
|
|
96 ;; - SOMEONE needs to write the programs that generate the
|
|
97 ;; provides/requires database and makes it into a lisp data
|
|
98 ;; structure suitable for `package-get-base'
|
|
99 ;; - Handle errors such as no package providing a required symbol.
|
|
100 ;; - Tie this into the `require' function to download packages
|
|
101 ;; transparently.
|
|
102
|
|
103 ;;; Change Log
|
|
104
|
|
105 ;;; Code:
|
|
106
|
|
107 (require 'package-admin)
|
|
108 ;; (require 'package-get-base)
|
|
109
|
|
110 (defgroup package-tools nil
|
|
111 "Tools to manipulate packages."
|
|
112 :group 'emacs)
|
|
113
|
|
114 (defgroup package-get nil
|
|
115 "Automatic Package Fetcher and Installer."
|
|
116 :prefix "package-get"
|
|
117 :group 'package-tools)
|
|
118
|
442
|
119 ;;;###autoload
|
428
|
120 (defvar package-get-base nil
|
|
121 "List of packages that are installed at this site.
|
|
122 For each element in the alist, car is the package name and the cdr is
|
|
123 a plist containing information about the package. Typical fields
|
|
124 kept in the plist are:
|
|
125
|
|
126 version - version of this package
|
|
127 provides - list of symbols provided
|
|
128 requires - list of symbols that are required.
|
|
129 These in turn are provided by other packages.
|
|
130 filename - name of the file.
|
|
131 size - size of the file (aka the bundled package)
|
|
132 md5sum - computed md5 checksum
|
|
133 description - What this package is for.
|
|
134 type - Whether this is a 'binary (default) or 'single file package
|
|
135
|
|
136 More fields may be added as needed. An example:
|
|
137
|
|
138 '(
|
|
139 (name
|
|
140 (version \"<version 2>\"
|
|
141 file \"filename\"
|
|
142 description \"what this package is about.\"
|
|
143 provides (<list>)
|
|
144 requires (<list>)
|
|
145 size <integer-bytes>
|
|
146 md5sum \"<checksum\"
|
|
147 type single
|
|
148 )
|
|
149 (version \"<version 1>\"
|
|
150 file \"filename\"
|
|
151 description \"what this package is about.\"
|
|
152 provides (<list>)
|
|
153 requires (<list>)
|
|
154 size <integer-bytes>
|
|
155 md5sum \"<checksum\"
|
|
156 type single
|
|
157 )
|
|
158 ...
|
|
159 ))
|
|
160
|
|
161 For version information, it is assumed things are listed in most
|
|
162 recent to least recent -- in other words, the version names don't have to
|
|
163 be lexically ordered. It is debatable if it makes sense to have more than
|
|
164 one version of a package available.")
|
|
165
|
|
166 (defcustom package-get-dir (temp-directory)
|
|
167 "*Where to store temporary files for staging."
|
|
168 :tag "Temporary directory"
|
|
169 :type 'directory
|
|
170 :group 'package-get)
|
|
171
|
1378
|
172 ;;;###autoload
|
1483
|
173 (defcustom package-get-package-index-file-location
|
1563
|
174 (car (split-path (or (getenv "EMACSPACKAGEPATH") user-init-directory)))
|
1483
|
175 "*The directory where the package-index file can be found."
|
|
176 :type 'directory
|
|
177 :group 'package-get)
|
|
178
|
|
179 ;;;###autoload
|
1378
|
180 (defcustom package-get-install-to-user-init-directory nil
|
|
181 "*If non-nil install packages under `user-init-directory'."
|
|
182 :type 'boolean
|
|
183 :group 'package-get)
|
|
184
|
428
|
185 (define-widget 'host-name 'string
|
|
186 "A Host name."
|
|
187 :tag "Host")
|
|
188
|
|
189 (defcustom package-get-remote nil
|
1365
|
190 "*The remote site to contact for downloading packages.
|
|
191 Format is '(site-name directory-on-site). As a special case, `site-name'
|
|
192 can be `nil', in which case `directory-on-site' is treated as a local
|
|
193 directory."
|
428
|
194 :tag "Package repository"
|
1365
|
195 :type '(set (choice (const :tag "None" nil)
|
|
196 (list :tag "Local" (const :tag "Local" nil) directory)
|
|
197 (list :tag "Remote" host-name directory)))
|
428
|
198 :group 'package-get)
|
|
199
|
|
200 ;;;###autoload
|
|
201 (defcustom package-get-download-sites
|
|
202 '(
|
1365
|
203 ;; Main XEmacs Site (ftp.xemacs.org)
|
1368
|
204 ("US (Main XEmacs Site)"
|
1365
|
205 "ftp.xemacs.org" "pub/xemacs/packages")
|
|
206 ;; In alphabetical order of Country, our mirrors...
|
3013
|
207 ("Argentina (xmundo.net)" "xemacs.xmundo.net" "pub/mirrors/xemacs/packages")
|
1365
|
208 ("Australia (aarnet.edu.au)" "mirror.aarnet.edu.au" "pub/xemacs/packages")
|
|
209 ("Australia (au.xemacs.org)" "ftp.au.xemacs.org" "pub/xemacs/packages")
|
|
210 ("Austria (at.xemacs.org)" "ftp.at.xemacs.org" "editors/xemacs/packages")
|
|
211 ("Belgium (be.xemacs.org)" "ftp.be.xemacs.org" "xemacs/packages")
|
|
212 ("Brazil (br.xemacs.org)" "ftp.br.xemacs.org" "pub/xemacs/packages")
|
|
213 ("Canada (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/packages")
|
|
214 ("Canada (crc.ca)" "ftp.crc.ca" "pub/packages/editors/xemacs/packages")
|
3013
|
215 ("Canada (nrc.ca)" "ftp.nrc.ca" "pub/packages/editors/xemacs/packages")
|
1365
|
216 ("Czech Republic (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/packages")
|
|
217 ("Denmark (dk.xemacs.org)" "ftp.dk.xemacs.org" "pub/emacs/xemacs/packages")
|
|
218 ("Finland (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/packages")
|
|
219 ("France (fr.xemacs.org)" "ftp.fr.xemacs.org" "pub/xemacs/packages")
|
1368
|
220 ("France (mirror.cict.fr)" "mirror.cict.fr" "xemacs/packages")
|
1365
|
221 ("France (pasteur.fr)" "ftp.pasteur.fr" "pub/computing/xemacs/packages")
|
|
222 ("Germany (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/packages")
|
3013
|
223 ("Iceland (is.xemacs.org)" "ftp.is.xemacs.org" "pub/xemacs/packages")
|
1365
|
224 ("Ireland (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/packages")
|
3013
|
225 ("Ireland (heanet.ie)" "ftp.heanet.ie" "mirrors/ftp.xemacs.org/packages")
|
1365
|
226 ("Italy (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/packages")
|
|
227 ("Japan (aist.go.jp)" "ring.aist.go.jp" "pub/text/xemacs/packages")
|
|
228 ("Japan (asahi-net.or.jp)" "ring.asahi-net.or.jp" "pub/text/xemacs/packages")
|
|
229 ("Japan (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/packages")
|
|
230 ("Japan (jaist.ac.jp)" "ftp.jaist.ac.jp" "pub/GNU/xemacs/packages")
|
|
231 ("Japan (jp.xemacs.org)" "ftp.jp.xemacs.org" "pub/GNU/xemacs/packages")
|
3013
|
232 ; ("Japan (nucba.ac.jp)" "mirror.nucba.ac.jp" "mirror/xemacs/packages")
|
1365
|
233 ("Japan (sut.ac.jp)" "sunsite.sut.ac.jp" "pub/archives/packages/xemacs/packages")
|
1374
|
234 ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/packages")
|
1368
|
235 ("New Zealand (nz.xemacs.org)" "ftp.nz.xemacs.org" "mirror/ftp.xemacs.org/packages")
|
1365
|
236 ("Norway (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/packages")
|
|
237 ("Poland (pl.xemacs.org)" "ftp.pl.xemacs.org" "pub/unix/editors/xemacs/packages")
|
|
238 ("Russia (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/xemacs/packages")
|
|
239 ("South Africa (za.xemacs.org)" "ftp.za.xemacs.org" "mirrorsites/ftp.xemacs.org/packages")
|
|
240 ("Sweden (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/packages")
|
|
241 ("Switzerland (ch.xemacs.org)" "ftp.ch.xemacs.org" "mirror/xemacs/packages")
|
|
242 ("UK (uk.xemacs.org)" "ftp.uk.xemacs.org" "sites/ftp.xemacs.org/pub/xemacs/packages")
|
|
243 ("US (ibiblio.org)" "ibiblio.org" "pub/packages/editors/xemacs/packages")
|
|
244 ("US (stealth.net)" "ftp.stealth.net" "pub/mirrors/ftp.xemacs.org/pub/xemacs/packages")
|
1368
|
245 ("US (unc.edu)" "metalab.unc.edu" "pub/packages/editors/xemacs/packages")
|
|
246 ("US (us.xemacs.org)" "ftp.us.xemacs.org" "pub/xemacs/packages")
|
|
247 ("US (utk.edu)" "ftp.sunsite.utk.edu" "pub/xemacs/packages")
|
|
248 )
|
428
|
249 "*List of remote sites available for downloading packages.
|
|
250 List format is '(site-description site-name directory-on-site).
|
|
251 SITE-DESCRIPTION is a textual description of the site. SITE-NAME
|
|
252 is the internet address of the download site. DIRECTORY-ON-SITE
|
|
253 is the directory on the site in which packages may be found.
|
|
254 This variable is used to initialize `package-get-remote', the
|
|
255 variable actually used to specify package download sites."
|
|
256 :tag "Package download sites"
|
442
|
257 :type '(repeat (list (string :tag "Name") host-name directory))
|
428
|
258 :group 'package-get)
|
|
259
|
1365
|
260 ;;;###autoload
|
|
261 (defcustom package-get-pre-release-download-sites
|
|
262 '(
|
|
263 ;; Main XEmacs Site (ftp.xemacs.org)
|
1368
|
264 ("Pre-Releases (Main XEmacs Site)" "ftp.xemacs.org"
|
1365
|
265 "pub/xemacs/beta/experimental/packages")
|
|
266 ;; In alphabetical order of Country, our mirrors...
|
3013
|
267 ("Argentina Pre-Releases (xmundo.net)" "xemacs.xmundo.net"
|
|
268 "pub/mirrors/xemacs/beta/experimental/packages")
|
1368
|
269 ("Australia Pre-Releases (aarnet.edu.au)" "mirror.aarnet.edu.au"
|
1365
|
270 "pub/xemacs/beta/experimental/packages")
|
1368
|
271 ("Australia Pre-Releases (au.xemacs.org)" "ftp.au.xemacs.org"
|
1365
|
272 "pub/xemacs/beta/experimental/packages")
|
1368
|
273 ("Austria Pre-Releases (at.xemacs.org)" "ftp.at.xemacs.org"
|
3013
|
274 "editors/xemacs/beta/experimental/packages")
|
|
275 ("Belgium (be.xemacs.org)" "ftp.be.xemacs.org"
|
|
276 "xemacs/beta/experimental/packages")
|
1368
|
277 ("Brazil Pre-Releases (br.xemacs.org)" "ftp.br.xemacs.org"
|
1365
|
278 "pub/xemacs/xemacs-21.5/experimental/packages")
|
1368
|
279 ("Canada Pre-Releases (ca.xemacs.org)" "ftp.ca.xemacs.org"
|
1365
|
280 "pub/Mirror/xemacs/beta/experimental/packages")
|
1368
|
281 ("Canada Pre-Releases (crc.ca)" "ftp.crc.ca"
|
1365
|
282 "pub/packages/editors/xemacs/beta/experimental/packages")
|
3013
|
283 ("Canada Pre-Releases (nrc.ca)" "ftp.nrc.ca"
|
|
284 "pub/packages/editors/xemacs/beta/experimental/packages")
|
1368
|
285 ("Czech Republic Pre-Releases (cz.xemacs.org)" "ftp.cz.xemacs.org"
|
1365
|
286 "MIRRORS/ftp.xemacs.org/pub/xemacs/xemacs-21.5/experimental/packages")
|
1368
|
287 ("Denmark Pre-Releases (dk.xemacs.org)" "ftp.dk.xemacs.org"
|
1365
|
288 "pub/emacs/xemacs/beta/experimental/packages")
|
1368
|
289 ("Finland Pre-Releases (fi.xemacs.org)" "ftp.fi.xemacs.org"
|
1365
|
290 "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/beta/experimental/packages")
|
1368
|
291 ("France Pre-Releases (fr.xemacs.org)" "ftp.fr.xemacs.org"
|
1365
|
292 "pub/xemacs/beta/experimental/packages")
|
1368
|
293 ("France Pre-Releases (mirror.cict.fr)" "mirror.cict.fr"
|
|
294 "xemacs/beta/experimental/packages")
|
|
295 ("France Pre-Releases (pasteur.fr)" "ftp.pasteur.fr"
|
1365
|
296 "pub/computing/xemacs/beta/experimental/packages")
|
1368
|
297 ("Germany Pre-Releases (de.xemacs.org)" "ftp.de.xemacs.org"
|
1365
|
298 "pub/ftp.xemacs.org/tux/xemacs/beta/experimental/packages")
|
3013
|
299 ("Iceland Pre-Releases (is.xemacs.org)" "ftp.is.xemacs.org"
|
|
300 "pub/xemacs/beta/experimental/packages")
|
1368
|
301 ("Ireland Pre-Releases (ie.xemacs.org)" "ftp.ie.xemacs.org"
|
1365
|
302 "mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages")
|
3013
|
303 ("Ireland Pre-Releases (heanet.ie)" "ftp.heanet.ie"
|
|
304 "mirrors/ftp.xemacs.org/beta/experimental/packages")
|
1368
|
305 ("Italy Pre-Releases (it.xemacs.org)" "ftp.it.xemacs.org"
|
1365
|
306 "unix/packages/XEMACS/beta/experimental/packages")
|
1368
|
307 ("Japan Pre-Releases (aist.go.jp)" "ring.aist.go.jp"
|
1365
|
308 "pub/text/xemacs/beta/experimental/packages")
|
1368
|
309 ("Japan Pre-Releases (asahi-net.or.jp)" "ring.asahi-net.or.jp"
|
1365
|
310 "pub/text/xemacs/beta/experimental/packages")
|
1368
|
311 ("Japan Pre-Releases (dti.ad.jp)" "ftp.dti.ad.jp"
|
1365
|
312 "pub/unix/editor/xemacs/beta/experimental/packages")
|
1368
|
313 ("Japan Pre-Releases (jaist.ac.jp)" "ftp.jaist.ac.jp"
|
1365
|
314 "pub/GNU/xemacs/beta/experimental/packages")
|
1368
|
315 ("Japan Pre-Releases (jp.xemacs.org)" "ftp.jp.xemacs.org"
|
1365
|
316 "pub/GNU/xemacs/beta/experimental/packages")
|
1368
|
317 ("Japan Pre-Releases (sut.ac.jp)" "sunsite.sut.ac.jp"
|
1365
|
318 "pub/archives/packages/xemacs/xemacs-21.5/experimental/packages")
|
3013
|
319 ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org"
|
|
320 "pub/tools/emacs/xemacs/beta/experimental/packages")
|
|
321 ("New Zealand Pre-Releases (nz.xemacs.org)" "ftp.nz.xemacs.org"
|
|
322 "mirror/ftp.xemacs.org/packages")
|
1368
|
323 ("Norway Pre-Releases (no.xemacs.org)" "ftp.no.xemacs.org"
|
1365
|
324 "pub/xemacs/beta/experimental/packages")
|
1368
|
325 ("Poland Pre-Releases (pl.xemacs.org)" "ftp.pl.xemacs.org"
|
1365
|
326 "pub/unix/editors/xemacs/beta/experimental/packages")
|
1368
|
327 ("Russia Pre-Releases (ru.xemacs.org)" "ftp.ru.xemacs.org"
|
1365
|
328 "pub/xemacs/beta/experimental/packages")
|
1368
|
329 ("South Africa Pre-Releases (za.xemacs.org)" "ftp.za.xemacs.org"
|
1365
|
330 "mirrorsites/ftp.xemacs.org/beta/experimental/packages")
|
1368
|
331 ("Sweden Pre-Releases (se.xemacs.org)" "ftp.se.xemacs.org"
|
1365
|
332 "pub/gnu/xemacs/beta/experimental/packages")
|
1368
|
333 ("Switzerland Pre-Releases (ch.xemacs.org)" "ftp.ch.xemacs.org"
|
1365
|
334 "mirror/xemacs/beta/experimental/packages")
|
1368
|
335 ("UK Pre-Releases (uk.xemacs.org)" "ftp.uk.xemacs.org"
|
1365
|
336 "sites/ftp.xemacs.org/pub/xemacs/beta/experimental/packages")
|
1368
|
337 ("US Pre-Releases (ibiblio.org)" "ibiblio.org"
|
1365
|
338 "pub/packages/editors/xemacs/beta/experimental/packages")
|
1368
|
339 ("US Pre-Releases (stealth.net)" "ftp.stealth.net"
|
1365
|
340 "pub/mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages")
|
1368
|
341 ("US Pre-Releases (unc.edu)" "metalab.unc.edu"
|
|
342 "pub/packages/editors/xemacs/beta/experimental/packages")
|
|
343 ("US Pre-Releases (us.xemacs.org)" "ftp.us.xemacs.org"
|
|
344 "pub/xemacs/beta/experimental/packages")
|
|
345 ("US Pre-Releases (utk.edu)" "ftp.sunsite.utk.edu"
|
1365
|
346 "pub/xemacs/beta/experimental/packages"))
|
|
347 "*List of remote sites available for downloading \"Pre-Release\" packages.
|
|
348 List format is '(site-description site-name directory-on-site).
|
|
349 SITE-DESCRIPTION is a textual description of the site. SITE-NAME
|
|
350 is the internet address of the download site. DIRECTORY-ON-SITE
|
|
351 is the directory on the site in which packages may be found.
|
|
352 This variable is used to initialize `package-get-remote', the
|
|
353 variable actually used to specify package download sites."
|
|
354 :tag "Pre-Release Package download sites"
|
|
355 :type '(repeat (list (string :tag "Name") host-name directory))
|
|
356 :group 'package-get)
|
|
357
|
1374
|
358 ;;;###autoload
|
|
359 (defcustom package-get-site-release-download-sites
|
|
360 nil
|
|
361 "*List of remote sites available for downloading \"Site Release\" packages.
|
|
362 List format is '(site-description site-name directory-on-site).
|
|
363 SITE-DESCRIPTION is a textual description of the site. SITE-NAME
|
|
364 is the internet address of the download site. DIRECTORY-ON-SITE
|
|
365 is the directory on the site in which packages may be found.
|
|
366 This variable is used to initialize `package-get-remote', the
|
|
367 variable actually used to specify package download sites."
|
|
368 :tag "Site Release Package download sites"
|
|
369 :type '(repeat (list (string :tag "Name") host-name directory))
|
|
370 :group 'package-get)
|
|
371
|
428
|
372 (defcustom package-get-remove-copy t
|
|
373 "*After copying and installing a package, if this is t, then remove the
|
|
374 copy. Otherwise, keep it around."
|
|
375 :type 'boolean
|
|
376 :group 'package-get)
|
|
377
|
|
378 ;; #### it may make sense for this to be a list of names.
|
|
379 ;; #### also, should we rename "*base*" to "*index*" or "*db*"?
|
|
380 ;; "base" is a pretty poor name.
|
681
|
381 (defcustom package-get-base-filename "package-index.LATEST.gpg"
|
428
|
382 "*Name of the default package-get database file.
|
|
383 This may either be a relative path, in which case it is interpreted
|
|
384 with respect to `package-get-remote', or an absolute path."
|
|
385 :type 'file
|
|
386 :group 'package-get)
|
|
387
|
|
388 (defcustom package-get-always-update nil
|
|
389 "*If Non-nil always make sure we are using the latest package index (base).
|
|
390 Otherwise respect the `force-current' argument of `package-get-require-base'."
|
|
391 :type 'boolean
|
|
392 :group 'package-get)
|
|
393
|
1410
|
394 (defun package-get-pgp-available-p ()
|
|
395 "Checks the availability of Mailcrypt and PGP executable.
|
|
396
|
|
397 Returns t if both are found, nil otherwise. As a side effect, set
|
|
398 `mc-default-scheme' dependent on the PGP executable found."
|
|
399 (let (result)
|
|
400 (when (featurep 'mailcrypt-autoloads)
|
|
401 (autoload 'mc-setversion "mc-setversion"))
|
|
402 (when-fboundp 'mc-setversion
|
|
403 (cond ((locate-file "gpg" exec-path
|
|
404 '("" ".btm" ".bat" ".cmd" ".exe" ".com")
|
|
405 'executable)
|
|
406 (mc-setversion "gpg")
|
|
407 (setq result t))
|
|
408 ((locate-file "pgpe" exec-path
|
|
409 '("" ".btm" ".bat" ".cmd" ".exe" ".com")
|
|
410 'executable)
|
|
411 (mc-setversion "5.0")
|
|
412 (setq result t))
|
|
413 ((locate-file "pgp" exec-path
|
|
414 '("" ".btm" ".bat" ".cmd" ".exe" ".com")
|
|
415 'executable)
|
|
416 (mc-setversion "2.6")
|
|
417 (setq result t))))
|
|
418 (if result
|
|
419 result
|
|
420 nil)))
|
|
421
|
1479
|
422 (defcustom package-get-require-signed-base-updates (package-get-pgp-available-p)
|
1410
|
423 "*If non-nil, try to verify the package index database via PGP.
|
|
424
|
|
425 If nil, no PGP verification is done. If the package index database
|
|
426 entries are not PGP signed and this variable is non-nil, require user
|
|
427 confirmation to continue with the package-get procedure.
|
|
428
|
|
429 The default for this variable is the return value of
|
|
430 `package-get-pgp-available-p', non-nil if both the \"Mailcrypt\"
|
|
431 package and a suitable PGP executable are available, nil otherwise."
|
428
|
432 :type 'boolean
|
|
433 :group 'package-get)
|
|
434
|
681
|
435 (defvar package-entries-are-signed nil
|
|
436 "Non-nil when the package index file has been PGP signed.")
|
|
437
|
|
438 (defvar package-get-continue-update-base nil
|
|
439 "Non-nil update the index even if it hasn't been signed.")
|
|
440
|
428
|
441 (defvar package-get-was-current nil
|
|
442 "Non-nil we did our best to fetch a current database.")
|
|
443
|
|
444 ;;;###autoload
|
|
445 (defun package-get-require-base (&optional force-current)
|
|
446 "Require that a package-get database has been loaded.
|
|
447 If the optional FORCE-CURRENT argument or the value of
|
|
448 `package-get-always-update' is Non-nil, try to update the database
|
|
449 from a location in `package-get-remote'. Otherwise a local copy is used
|
|
450 if available and remote access is never done.
|
|
451
|
|
452 Please use FORCE-CURRENT only when the user is explictly dealing with packages
|
|
453 and remote access is likely in the near future."
|
|
454 (setq force-current (or force-current package-get-always-update))
|
|
455 (unless (and (boundp 'package-get-base)
|
|
456 package-get-base
|
|
457 (or (not force-current) package-get-was-current))
|
|
458 (package-get-update-base nil force-current))
|
|
459 (if (or (not (boundp 'package-get-base))
|
|
460 (not package-get-base))
|
1410
|
461 (error 'void-variable
|
|
462 "Package-get database not loaded")
|
428
|
463 (setq package-get-was-current force-current)))
|
|
464
|
|
465 (defconst package-get-pgp-signed-begin-line "^-----BEGIN PGP SIGNED MESSAGE-----"
|
|
466 "Text for start of PGP signed messages.")
|
|
467 (defconst package-get-pgp-signature-begin-line "^-----BEGIN PGP SIGNATURE-----"
|
|
468 "Text for beginning of PGP signature.")
|
|
469 (defconst package-get-pgp-signature-end-line "^-----END PGP SIGNATURE-----"
|
|
470 "Text for end of PGP signature.")
|
|
471
|
|
472 ;;;###autoload
|
|
473 (defun package-get-update-base-entry (entry)
|
|
474 "Update an entry in `package-get-base'."
|
|
475 (let ((existing (assq (car entry) package-get-base)))
|
|
476 (if existing
|
|
477 (setcdr existing (cdr entry))
|
824
|
478 (setq package-get-base (cons entry package-get-base)))))
|
428
|
479
|
|
480 (defun package-get-locate-file (file &optional nil-if-not-found no-remote)
|
|
481 "Locate an existing FILE with respect to `package-get-remote'.
|
|
482 If FILE is an absolute path or is not found, simply return FILE.
|
|
483 If optional argument NIL-IF-NOT-FOUND is non-nil, return nil
|
|
484 if FILE can not be located.
|
|
485 If NO-REMOTE is non-nil never search remote locations."
|
|
486 (if (file-name-absolute-p file)
|
|
487 file
|
1365
|
488 (let ((site package-get-remote)
|
428
|
489 (expanded nil))
|
1365
|
490 (when site
|
|
491 (unless (and no-remote (caar (list site)))
|
|
492 (let ((expn (package-get-remote-filename (car (list site)) file)))
|
428
|
493 (if (and expn (file-exists-p expn))
|
1365
|
494 (setq site nil
|
|
495 expanded expn)))))
|
428
|
496 (or expanded
|
|
497 (and (not nil-if-not-found)
|
|
498 file)))))
|
|
499
|
|
500 (defun package-get-locate-index-file (no-remote)
|
1483
|
501 "Locate the package-get index file.
|
|
502
|
|
503 Do not return remote paths if NO-REMOTE is non-nil. If the index
|
|
504 file doesn't exist in `package-get-package-index-file-location', ask
|
|
505 the user if one should be created using the index file in core as a
|
|
506 template."
|
428
|
507 (or (package-get-locate-file package-get-base-filename t no-remote)
|
1483
|
508 (if (file-exists-p (expand-file-name package-get-base-filename
|
|
509 package-get-package-index-file-location))
|
|
510 (expand-file-name package-get-base-filename
|
|
511 package-get-package-index-file-location)
|
|
512 (if (y-or-n-p (format "No index file, shall I create one in %s? "
|
|
513 package-get-package-index-file-location))
|
|
514 (progn
|
|
515 (save-excursion
|
|
516 (set-buffer
|
|
517 (find-file-noselect (expand-file-name
|
|
518 package-get-base-filename
|
|
519 package-get-package-index-file-location)))
|
|
520 (let ((coding-system-for-write 'binary))
|
|
521 (erase-buffer)
|
|
522 (insert-file-contents-literally
|
|
523 (locate-data-file package-get-base-filename))
|
|
524 (save-buffer (current-buffer))
|
|
525 (kill-buffer (current-buffer))))
|
|
526 (expand-file-name package-get-base-filename
|
|
527 package-get-package-index-file-location))
|
|
528 (error 'search-failed
|
|
529 "Can't locate a package index file.")))))
|
428
|
530
|
|
531 (defun package-get-maybe-save-index (filename)
|
|
532 "Offer to save the current buffer as the local package index file,
|
|
533 if different."
|
|
534 (let ((location (package-get-locate-index-file t)))
|
|
535 (unless (and filename (equal filename location))
|
|
536 (unless (and location
|
|
537 (equal (md5 (current-buffer))
|
|
538 (with-temp-buffer
|
|
539 (insert-file-contents-literally location)
|
|
540 (md5 (current-buffer)))))
|
1483
|
541 (when (not (file-writable-p location))
|
|
542 (if (y-or-n-p (format "Sorry, %s is read-only, can I use %s? "
|
|
543 location user-init-directory))
|
|
544 (setq location (expand-file-name
|
|
545 package-get-base-filename
|
|
546 package-get-package-index-file-location))
|
|
547 (error 'file-error
|
|
548 (format "%s is read-only" location))))
|
434
|
549 (when (y-or-n-p (concat "Update package index in " location "? "))
|
442
|
550 (let ((coding-system-for-write 'binary))
|
|
551 (write-file location)))))))
|
|
552
|
428
|
553 ;;;###autoload
|
|
554 (defun package-get-update-base (&optional db-file force-current)
|
|
555 "Update the package-get database file with entries from DB-FILE.
|
|
556 Unless FORCE-CURRENT is non-nil never try to update the database."
|
|
557 (interactive
|
|
558 (let ((dflt (package-get-locate-index-file nil)))
|
|
559 (list (read-file-name "Load package-get database: "
|
|
560 (file-name-directory dflt)
|
|
561 dflt
|
|
562 t
|
|
563 (file-name-nondirectory dflt)))))
|
|
564 (setq db-file (expand-file-name (or db-file
|
|
565 (package-get-locate-index-file
|
|
566 (not force-current)))))
|
|
567 (if (not (file-exists-p db-file))
|
1410
|
568 (error 'file-error
|
|
569 (format "Package-get database file `%s' does not exist" db-file)))
|
428
|
570 (if (not (file-readable-p db-file))
|
1410
|
571 (error 'file-error
|
|
572 (format "Package-get database file `%s' not readable" db-file)))
|
428
|
573 (let ((buf (get-buffer-create "*package database*")))
|
|
574 (unwind-protect
|
|
575 (save-excursion
|
|
576 (set-buffer buf)
|
|
577 (erase-buffer buf)
|
442
|
578 (insert-file-contents-literally db-file)
|
428
|
579 (package-get-update-base-from-buffer buf)
|
|
580 (if (file-remote-p db-file)
|
|
581 (package-get-maybe-save-index db-file)))
|
|
582 (kill-buffer buf))))
|
|
583
|
|
584 ;;;###autoload
|
|
585 (defun package-get-update-base-from-buffer (&optional buf)
|
|
586 "Update the package-get database with entries from BUFFER.
|
|
587 BUFFER defaults to the current buffer. This command can be
|
|
588 used interactively, for example from a mail or news buffer."
|
|
589 (interactive)
|
|
590 (setq buf (or buf (current-buffer)))
|
1937
|
591 (let ((coding-system-for-read 'binary)
|
|
592 (coding-system-for-write 'binary)
|
|
593 content-beg content-end)
|
428
|
594 (save-excursion
|
|
595 (set-buffer buf)
|
|
596 (goto-char (point-min))
|
|
597 (setq content-beg (point))
|
|
598 (setq content-end (save-excursion (goto-char (point-max)) (point)))
|
|
599 (when (re-search-forward package-get-pgp-signed-begin-line nil t)
|
|
600 (setq content-beg (match-end 0)))
|
|
601 (when (re-search-forward package-get-pgp-signature-begin-line nil t)
|
681
|
602 (setq content-end (match-beginning 0))
|
|
603 (setq package-entries-are-signed t))
|
1365
|
604 (re-search-forward package-get-pgp-signature-end-line nil t)
|
681
|
605 (setq package-get-continue-update-base t)
|
1410
|
606 ;; This is a little overkill because the default value of
|
|
607 ;; `package-get-require-signed-base-updates' is the return of
|
|
608 ;; `package-get-pgp-available-p', but we have to allow for
|
|
609 ;; someone explicitly setting
|
|
610 ;; `package-get-require-signed-base-updates' to t. --SY
|
|
611 (when (and package-get-require-signed-base-updates
|
|
612 (package-get-pgp-available-p))
|
|
613 (if package-entries-are-signed
|
|
614 (let (good-sig)
|
1365
|
615 (setq package-get-continue-update-base nil)
|
1410
|
616 (autoload 'mc-verify "mc-toplev")
|
|
617 (when (declare-fboundp (mc-verify))
|
|
618 (setq good-sig t))
|
|
619 (if good-sig
|
|
620 (setq package-get-continue-update-base t)
|
|
621 (error 'process-error
|
|
622 "GnuPG error. Package database not updated")))
|
|
623 (if (yes-or-no-p
|
|
624 "Package Index is not PGP signed. Continue anyway? ")
|
|
625 (setq package-get-continue-update-base t)
|
|
626 (setq package-get-continue-update-base nil)
|
|
627 (warn "Package database not updated"))))
|
440
|
628 ;; ToDo: We should call package-get-maybe-save-index on the region
|
1410
|
629 (when package-get-continue-update-base
|
|
630 (package-get-update-base-entries content-beg content-end)
|
|
631 (message "Updated package database")))))
|
428
|
632
|
444
|
633 (defun package-get-update-base-entries (start end)
|
428
|
634 "Update the package-get database with the entries found between
|
444
|
635 START and END in the current buffer."
|
428
|
636 (save-excursion
|
444
|
637 (goto-char start)
|
428
|
638 (if (not (re-search-forward "^(package-get-update-base-entry" nil t))
|
1410
|
639 (error 'search-failed
|
|
640 "Buffer does not contain package-get database entries"))
|
428
|
641 (beginning-of-line)
|
|
642 (let ((count 0))
|
|
643 (while (and (< (point) end)
|
|
644 (re-search-forward "^(package-get-update-base-entry" nil t))
|
|
645 (beginning-of-line)
|
|
646 (let ((entry (read (current-buffer))))
|
|
647 (if (or (not (consp entry))
|
|
648 (not (eq (car entry) 'package-get-update-base-entry)))
|
1410
|
649 (error 'syntax-error
|
|
650 "Invalid package-get database entry found"))
|
428
|
651 (package-get-update-base-entry
|
|
652 (car (cdr (car (cdr entry)))))
|
|
653 (setq count (1+ count))))
|
|
654 (message "Got %d package-get database entries" count))))
|
|
655
|
|
656 ;;;###autoload
|
|
657 (defun package-get-save-base (file)
|
|
658 "Write the package-get database to FILE.
|
|
659
|
|
660 Note: This database will be unsigned of course."
|
|
661 (interactive "FSave package-get database to: ")
|
|
662 (package-get-require-base t)
|
|
663 (let ((buf (get-buffer-create "*package database*")))
|
|
664 (unwind-protect
|
|
665 (save-excursion
|
|
666 (set-buffer buf)
|
|
667 (erase-buffer buf)
|
|
668 (goto-char (point-min))
|
|
669 (let ((entries package-get-base) entry plist)
|
|
670 (insert ";; Package Index file -- Do not edit manually.\n")
|
|
671 (insert ";;;@@@\n")
|
|
672 (while entries
|
|
673 (setq entry (car entries))
|
|
674 (setq plist (car (cdr entry)))
|
|
675 (insert "(package-get-update-base-entry (quote\n")
|
|
676 (insert (format "(%s\n" (symbol-name (car entry))))
|
|
677 (while plist
|
|
678 (insert (format " %s%s %S\n"
|
|
679 (if (eq plist (car (cdr entry))) "(" " ")
|
|
680 (symbol-name (car plist))
|
|
681 (car (cdr plist))))
|
|
682 (setq plist (cdr (cdr plist))))
|
|
683 (insert "))\n))\n;;;@@@\n")
|
|
684 (setq entries (cdr entries))))
|
|
685 (insert ";; Package Index file ends here\n")
|
|
686 (write-region (point-min) (point-max) file))
|
|
687 (kill-buffer buf))))
|
|
688
|
|
689 (defun package-get-interactive-package-query (get-version package-symbol)
|
|
690 "Perform interactive querying for package and optional version.
|
|
691 Query for a version if GET-VERSION is non-nil. Return package name as
|
|
692 a symbol instead of a string if PACKAGE-SYMBOL is non-nil.
|
|
693 The return value is suitable for direct passing to `interactive'."
|
|
694 (package-get-require-base t)
|
442
|
695 (let ((table (mapcar #'(lambda (item)
|
|
696 (let ((name (symbol-name (car item))))
|
|
697 (cons name name)))
|
|
698 package-get-base))
|
|
699 package package-symbol default-version version)
|
428
|
700 (save-window-excursion
|
|
701 (setq package (completing-read "Package: " table nil t))
|
|
702 (setq package-symbol (intern package))
|
|
703 (if get-version
|
|
704 (progn
|
442
|
705 (setq default-version
|
|
706 (package-get-info-prop
|
428
|
707 (package-get-info-version
|
|
708 (package-get-info-find-package package-get-base
|
|
709 package-symbol) nil)
|
|
710 'version))
|
|
711 (while (string=
|
|
712 (setq version (read-string "Version: " default-version))
|
1365
|
713 ""))
|
428
|
714 (if package-symbol
|
|
715 (list package-symbol version)
|
1365
|
716 (list package version)))
|
428
|
717 (if package-symbol
|
|
718 (list package-symbol)
|
442
|
719 (list package))))))
|
428
|
720
|
|
721 ;;;###autoload
|
|
722 (defun package-get-delete-package (package &optional pkg-topdir)
|
|
723 "Delete an installation of PACKAGE below directory PKG-TOPDIR.
|
|
724 PACKAGE is a symbol, not a string.
|
|
725 This is just an interactive wrapper for `package-admin-delete-binary-package'."
|
|
726 (interactive (package-get-interactive-package-query nil t))
|
|
727 (package-admin-delete-binary-package package pkg-topdir))
|
|
728
|
|
729 ;;;###autoload
|
|
730 (defun package-get-update-all ()
|
|
731 "Fetch and install the latest versions of all currently installed packages."
|
|
732 (interactive)
|
|
733 (package-get-require-base t)
|
|
734 ;; Load a fresh copy
|
|
735 (catch 'exit
|
|
736 (mapcar (lambda (pkg)
|
|
737 (if (not (package-get (car pkg) nil 'never))
|
1365
|
738 (throw 'exit nil))) ;; Bail out if error detected
|
707
|
739 packages-package-list))
|
|
740 (package-net-update-installed-db))
|
428
|
741
|
|
742 ;;;###autoload
|
|
743 (defun package-get-all (package version &optional fetched-packages install-dir)
|
|
744 "Fetch PACKAGE with VERSION and all other required packages.
|
|
745 Uses `package-get-base' to determine just what is required and what
|
|
746 package provides that functionality. If VERSION is nil, retrieves
|
|
747 latest version. Optional argument FETCHED-PACKAGES is used to keep
|
|
748 track of packages already fetched. Optional argument INSTALL-DIR,
|
|
749 if non-nil, specifies the package directory where fetched packages
|
|
750 should be installed.
|
|
751
|
|
752 Returns nil upon error."
|
|
753 (interactive (package-get-interactive-package-query t nil))
|
|
754 (let* ((the-package (package-get-info-find-package package-get-base
|
|
755 package))
|
|
756 (this-package (package-get-info-version
|
|
757 the-package version))
|
1365
|
758 (this-requires (package-get-info-prop this-package 'requires)))
|
428
|
759 (catch 'exit
|
|
760 (setq version (package-get-info-prop this-package 'version))
|
|
761 (unless (package-get-installedp package version)
|
|
762 (if (not (package-get package version nil install-dir))
|
|
763 (progn
|
|
764 (setq fetched-packages nil)
|
|
765 (throw 'exit nil))))
|
|
766 (setq fetched-packages
|
|
767 (append (list package)
|
|
768 (package-get-info-prop this-package 'provides)
|
|
769 fetched-packages))
|
|
770 ;; grab everything that this package requires plus recursively
|
|
771 ;; grab everything that the requires require. Keep track
|
|
772 ;; in `fetched-packages' the list of things provided -- this
|
|
773 ;; keeps us from going into a loop
|
|
774 (while this-requires
|
|
775 (if (not (member (car this-requires) fetched-packages))
|
|
776 (let* ((reqd-package (package-get-package-provider
|
|
777 (car this-requires) t))
|
|
778 (reqd-version (cadr reqd-package))
|
|
779 (reqd-name (car reqd-package)))
|
|
780 (if (null reqd-name)
|
1410
|
781 (error 'search-failed
|
|
782 (format "Unable to find a provider for %s"
|
|
783 (car this-requires))))
|
428
|
784 (if (not (setq fetched-packages
|
|
785 (package-get-all reqd-name reqd-version
|
|
786 fetched-packages
|
|
787 install-dir)))
|
1365
|
788 (throw 'exit nil))))
|
|
789 (setq this-requires (cdr this-requires))))
|
|
790 fetched-packages))
|
428
|
791
|
|
792 ;;;###autoload
|
|
793 (defun package-get-dependencies (packages)
|
|
794 "Compute dependencies for PACKAGES.
|
|
795 Uses `package-get-base' to determine just what is required and what
|
|
796 package provides that functionality. Returns the list of packages
|
|
797 required by PACKAGES."
|
|
798 (package-get-require-base t)
|
|
799 (let ((orig-packages packages)
|
|
800 dependencies provided)
|
|
801 (while packages
|
|
802 (let* ((package (car packages))
|
|
803 (the-package (package-get-info-find-package
|
|
804 package-get-base package))
|
|
805 (this-package (package-get-info-version
|
|
806 the-package nil))
|
|
807 (this-requires (package-get-info-prop this-package 'requires))
|
|
808 (new-depends (set-difference
|
|
809 (mapcar
|
|
810 #'(lambda (reqd)
|
|
811 (let* ((reqd-package (package-get-package-provider reqd))
|
|
812 (reqd-name (car reqd-package)))
|
|
813 (if (null reqd-name)
|
1410
|
814 (error 'search-failed
|
|
815 (format "Unable to find a provider for %s" reqd)))
|
428
|
816 reqd-name))
|
|
817 this-requires)
|
|
818 dependencies))
|
|
819 (this-provides (package-get-info-prop this-package 'provides)))
|
|
820 (setq dependencies
|
|
821 (union dependencies new-depends))
|
|
822 (setq provided
|
|
823 (union provided (union (list package) this-provides)))
|
|
824 (setq packages
|
|
825 (union new-depends (cdr packages)))))
|
|
826 (set-difference dependencies orig-packages)))
|
|
827
|
|
828 (defun package-get-load-package-file (lispdir file)
|
|
829 (let (pathname)
|
|
830 (setq pathname (expand-file-name file lispdir))
|
793
|
831 (with-trapping-errors
|
|
832 :operation (format "loading package file \"%s\"" pathname)
|
|
833 :error-form nil
|
|
834 (load pathname t)
|
|
835 t)))
|
428
|
836
|
|
837 (defun package-get-init-package (lispdir)
|
|
838 "Initialize the package.
|
|
839 This really assumes that the package has never been loaded. Updating
|
|
840 a newer package can cause problems, due to old, obsolete functions in
|
|
841 the old package.
|
|
842
|
|
843 Return `t' upon complete success, `nil' if any errors occurred."
|
|
844 (progn
|
|
845 (if (and lispdir
|
|
846 (file-accessible-directory-p lispdir))
|
|
847 (progn
|
|
848 ;; Add lispdir to load-path if it doesn't already exist.
|
|
849 ;; NOTE: this does not take symlinks, etc., into account.
|
2802
|
850 (add-to-list 'load-path (file-name-as-directory lispdir))
|
428
|
851 (if (not (package-get-load-package-file lispdir "auto-autoloads"))
|
|
852 (package-get-load-package-file lispdir "_pkg"))
|
|
853 t)
|
1365
|
854 nil)))
|
|
855
|
2151
|
856 (defun package-get-info-name-array ()
|
|
857 "Internal, used by `package-get-info'."
|
|
858 (let ((pkgs package-get-base)
|
|
859 names)
|
|
860 (while pkgs
|
|
861 (setq names (let ((name (caar pkgs)))
|
|
862 (push (cons (format "%s" name) name) names)))
|
|
863 (setq pkgs (cdr pkgs)))
|
|
864 names))
|
|
865
|
|
866 (defconst package-get-info-info-array
|
|
867 '(("standards-version" . standards-version)
|
|
868 ("version" . version)
|
|
869 ("author-version" . author-version)
|
|
870 ("date" . date)
|
|
871 ("build-date" . build-date)
|
|
872 ("maintainer" . maintainer)
|
|
873 ("distribution" . distribution)
|
|
874 ("priority" . priority)
|
|
875 ("category" . category)
|
|
876 ("dump" . dump)
|
|
877 ("description" . description)
|
|
878 ("filename" . filename)
|
|
879 ("md5sum" . md5sum)
|
|
880 ("size" . size)
|
|
881 ("provides" . provides)
|
|
882 ("requires" . requires)
|
|
883 ("type" . type))
|
|
884 "Internal, used by `package-get-info'.")
|
|
885
|
1365
|
886 ;;;###autoload
|
|
887 (defun package-get-info (package information &optional arg remote)
|
|
888 "Get information about a package.
|
|
889
|
|
890 Quite similar to `package-get-info-prop', but can retrieve a lot more
|
|
891 information.
|
|
892
|
|
893 Argument PACKAGE is the name of an XEmacs package (a symbol). It must
|
|
894 be a valid package, ie, a member of `package-get-base'.
|
|
895
|
|
896 Argument INFORMATION is a symbol that can be any one of:
|
|
897
|
|
898 standards-version Package system version (not used).
|
|
899 version Version of the XEmacs package.
|
|
900 author-version The upstream version of the package.
|
|
901 date The date the package was last modified.
|
|
902 build-date The date the package was last built.
|
|
903 maintainer The maintainer of the package.
|
|
904 distribution Will always be \"xemacs\" (not used).
|
|
905 priority \"low\", \"medium\", or \"high\" (not used).
|
|
906 category Either \"standard\", \"mule\", or \"unsupported\"..
|
|
907 dump Is the package dumped (not used).
|
|
908 description A description of the package.
|
|
909 filename The filename of the binary tarball of the package.
|
|
910 md5sum The md5sum of filename.
|
|
911 size The size in bytes of filename.
|
|
912 provides A list of symbols that this package provides.
|
|
913 requires A list of packages that this package requires.
|
|
914 type Can be either \"regular\" or \"single-file\".
|
|
915
|
2151
|
916 Optional argument ARG is a prefix arg. Without a value, ie, just
|
|
917 doing `C-u M-x package-get-info' will insert the information at point
|
|
918 in the current buffer using a local package list.
|
|
919
|
|
920 ARG can also be given a value of 2 or 3. If 2, use a remote package
|
|
921 list, displaying the information in the minubuffer. If 3, use a remote
|
|
922 package list and insert the information at point in the current buffer.
|
1365
|
923
|
|
924 If optional argument REMOTE is non-nil use a package list from a
|
2151
|
925 remote site.
|
|
926
|
|
927 To use a remote package list, either via the prefix argument ARG or
|
|
928 via the REMOTE argument `package-get-remote' must be non-nil. If
|
|
929 `package-get-remote' is nil, the local package list will be used.
|
1365
|
930
|
|
931 If this function is called interactively it will display INFORMATION
|
|
932 in the minibuffer."
|
2151
|
933 (interactive "i\ni\np")
|
|
934 (if (and package-get-remote
|
|
935 (or (eq arg 2)
|
|
936 (eq arg 3)
|
|
937 remote))
|
|
938 (package-get-require-base t)
|
|
939 (package-get-require-base nil))
|
|
940 (let ((all-pkgs package-get-base)
|
|
941 (package (or package
|
|
942 (intern (completing-read
|
|
943 "Package: "
|
|
944 (package-get-info-name-array) nil t))))
|
|
945 (information (or information
|
|
946 (intern (completing-read
|
|
947 "Info: "
|
|
948 package-get-info-info-array nil t))))
|
|
949 info)
|
1365
|
950 (loop until (equal package (caar all-pkgs))
|
|
951 do (setq all-pkgs (cdr all-pkgs))
|
|
952 do (if (not all-pkgs)
|
1410
|
953 (error 'invalid-argument
|
|
954 (format "%s is not a valid package" package))))
|
1365
|
955 (setq info (plist-get (cadar all-pkgs) information))
|
|
956 (if (interactive-p)
|
2151
|
957 (if (or (eq arg 3)
|
|
958 (eq arg 4))
|
1365
|
959 (insert (format "%s" info))
|
|
960 (if (package-get-key package :version)
|
|
961 (message "%s" info)
|
|
962 (message "%s (Package: %s is not installed)" info package)))
|
2151
|
963 info)))
|
428
|
964
|
|
965 ;;;###autoload
|
1832
|
966 (defun package-get-list-packages-where (item field &optional arg)
|
|
967 "Return a list of packages that fulfill certain criteria.
|
|
968
|
|
969 Argument ITEM, a symbol, is what you want to check for. ITEM must be a
|
|
970 symbol even when it doesn't make sense to be a symbol \(think, searching
|
|
971 maintainers, descriptions, etc\). The function will convert the symbol
|
|
972 to a string if a string is what is needed. The downside to this is that
|
|
973 ITEM can only ever be a single word.
|
|
974
|
|
975 Argument FIELD, a symbol, is the field to check in. You can specify
|
|
976 any one of:
|
|
977
|
|
978 Field Sane or Allowable Content
|
|
979 description any single word
|
|
980 category `standard' or `mule'
|
|
981 maintainer any single word
|
|
982 build-date yyyy-mm-dd
|
|
983 date yyyy-mm-dd
|
|
984 type `regular' or `single'
|
|
985 requires any package name
|
|
986 provides any symbol
|
|
987 priority `low', `medium', or `high'
|
|
988
|
|
989 Optional Argument ARG, a prefix arg, insert output at point in the
|
|
990 current buffer."
|
2151
|
991 (interactive
|
|
992 (list (intern (read-string "List packages that contain (text): "))
|
|
993 (intern (completing-read "in their package-info field (completion available): "
|
|
994 '(("description" . description)
|
|
995 ("category" . category)
|
|
996 ("maintainer" . maintainer)
|
|
997 ("build-date" . build-date)
|
|
998 ("date" . date)
|
|
999 ("type" . type)
|
|
1000 ("requires" . requires)
|
|
1001 ("provides" . provides)
|
|
1002 ("priority" . priority)) nil t))
|
|
1003 current-prefix-arg))
|
1832
|
1004 (package-get-require-base nil)
|
|
1005 (let ((pkgs package-get-base)
|
|
1006 (strings '(description category maintainer build-date date))
|
|
1007 (symbols '(type requires provides priority))
|
|
1008 results)
|
|
1009 (cond ((memq field strings)
|
|
1010 (setq item (symbol-name item))
|
|
1011 (while pkgs
|
|
1012 (when (string-match item (package-get-info (caar pkgs) field))
|
|
1013 (setq results (push (caar pkgs) results)))
|
|
1014 (setq pkgs (cdr pkgs))))
|
|
1015 ((memq field symbols)
|
|
1016 (if (or (eq field 'type)
|
|
1017 (eq field 'priority))
|
|
1018 (while pkgs
|
|
1019 (when (eq item (package-get-info (caar pkgs) field))
|
|
1020 (setq results (push (caar pkgs) results)))
|
|
1021 (setq pkgs (cdr pkgs)))
|
|
1022 (while pkgs
|
|
1023 (when (memq item (package-get-info (caar pkgs) field))
|
|
1024 (setq results (push (caar pkgs) results)))
|
|
1025 (setq pkgs (cdr pkgs)))))
|
|
1026 (t
|
|
1027 (error 'wrong-type-argument field)))
|
|
1028 (if (interactive-p)
|
|
1029 (if arg
|
|
1030 (insert (format "%s" results))
|
|
1031 (message "%s" results)))
|
|
1032 results))
|
|
1033
|
|
1034 ;;;###autoload
|
428
|
1035 (defun package-get (package &optional version conflict install-dir)
|
|
1036 "Fetch PACKAGE from remote site.
|
|
1037 Optional arguments VERSION indicates which version to retrieve, nil
|
|
1038 means most recent version. CONFLICT indicates what happens if the
|
|
1039 package is already installed. Valid values for CONFLICT are:
|
|
1040 'always always retrieve the package even if it is already installed
|
|
1041 'never do not retrieve the package if it is installed.
|
|
1042 INSTALL-DIR, if non-nil, specifies the package directory where
|
|
1043 fetched packages should be installed.
|
|
1044
|
442
|
1045 The value of `package-get-base' is used to determine what files should
|
428
|
1046 be retrieved. The value of `package-get-remote' is used to determine
|
1365
|
1047 where a package should be retrieved from.
|
428
|
1048
|
|
1049 Once the package is retrieved, its md5 checksum is computed. If that
|
|
1050 sum does not match that stored in `package-get-base' for this version
|
|
1051 of the package, an error is signalled.
|
|
1052
|
|
1053 Returns `t' upon success, the symbol `error' if the package was
|
|
1054 successfully installed but errors occurred during initialization, or
|
|
1055 `nil' upon error."
|
|
1056 (interactive (package-get-interactive-package-query nil t))
|
|
1057 (catch 'skip-update
|
|
1058 (let* ((this-package
|
|
1059 (package-get-info-version
|
|
1060 (package-get-info-find-package package-get-base
|
|
1061 package) version))
|
|
1062 (latest (package-get-info-prop this-package 'version))
|
|
1063 (installed (package-get-key package :version))
|
|
1064 (found nil)
|
1365
|
1065 (search-dir package-get-remote)
|
428
|
1066 (base-filename (package-get-info-prop this-package 'filename))
|
|
1067 (package-status t)
|
|
1068 filenames full-package-filename)
|
1365
|
1069 (if (and (equal (package-get-info package 'category) "mule")
|
|
1070 (not (featurep 'mule)))
|
1410
|
1071 (error 'invalid-state
|
|
1072 "Mule packages can't be installed with a non-Mule XEmacs"))
|
428
|
1073 (if (null this-package)
|
|
1074 (if package-get-remote
|
1410
|
1075 (error 'search-failed
|
|
1076 (format "Couldn't find package %s with version %s"
|
|
1077 package version))
|
|
1078 (error 'syntax-error
|
|
1079 "No download site or local package location specified.")))
|
428
|
1080 (if (null base-filename)
|
1410
|
1081 (error 'syntax-error
|
|
1082 (format "No filename associated with package %s, version %s"
|
|
1083 package version)))
|
1378
|
1084 (setq install-dir (package-admin-get-install-dir package install-dir))
|
428
|
1085
|
|
1086 ;; If they asked for the latest using version=nil, don't get an older
|
|
1087 ;; version than we already have.
|
|
1088 (if installed
|
|
1089 (if (> (if (stringp installed)
|
|
1090 (string-to-number installed)
|
|
1091 installed)
|
|
1092 (if (stringp latest)
|
|
1093 (string-to-number latest)
|
|
1094 latest))
|
|
1095 (if (not (null version))
|
825
|
1096 (warn "Installing %s package version %s, you had a newer version %s"
|
793
|
1097 package latest installed)
|
825
|
1098 (warn "Skipping %s package, you have a newer version %s"
|
793
|
1099 package installed)
|
428
|
1100 (throw 'skip-update t))))
|
|
1101
|
|
1102 ;; Contrive a list of possible package filenames.
|
|
1103 ;; Ugly. Is there a better way to do this?
|
|
1104 (setq filenames (cons base-filename nil))
|
|
1105 (if (string-match "^\\(..*\\)\.tar\.gz$" base-filename)
|
|
1106 (setq filenames (append filenames
|
|
1107 (list (concat (match-string 1 base-filename)
|
|
1108 ".tgz")))))
|
|
1109
|
|
1110 (setq version latest)
|
|
1111 (unless (and (eq conflict 'never)
|
|
1112 (package-get-installedp package version))
|
|
1113 ;; Find the package from the search list in package-get-remote
|
|
1114 ;; and copy it into the staging directory. Then validate
|
|
1115 ;; the checksum. Finally, install the package.
|
|
1116 (catch 'done
|
1365
|
1117 (let (search-filenames host dir current-filename dest-filename)
|
428
|
1118 ;; In each search directory ...
|
1365
|
1119 (when search-dir
|
|
1120 (setq host (car search-dir)
|
|
1121 dir (car (cdr search-dir))
|
|
1122 search-filenames filenames)
|
428
|
1123
|
|
1124 ;; Look for one of the possible package filenames ...
|
|
1125 (while search-filenames
|
|
1126 (setq current-filename (car search-filenames)
|
|
1127 dest-filename (package-get-staging-dir current-filename))
|
|
1128 (cond
|
|
1129 ;; No host means look on the current system.
|
1365
|
1130 ((null host)
|
|
1131 (setq full-package-filename
|
|
1132 (substitute-in-file-name
|
|
1133 (expand-file-name current-filename
|
|
1134 (file-name-as-directory dir)))))
|
428
|
1135
|
|
1136 ;; If it's already on the disk locally, and the size is
|
1365
|
1137 ;; correct
|
|
1138 ((and (file-exists-p dest-filename)
|
|
1139 (eq (nth 7 (file-attributes dest-filename))
|
|
1140 (package-get-info package 'size)))
|
|
1141 (setq full-package-filename dest-filename))
|
428
|
1142
|
|
1143 ;; If the file exists on the remote system ...
|
1365
|
1144 ((file-exists-p (package-get-remote-filename
|
|
1145 search-dir current-filename))
|
|
1146 ;; Get it
|
|
1147 (setq full-package-filename dest-filename)
|
|
1148 (message "Retrieving package `%s' ..."
|
|
1149 current-filename)
|
|
1150 (sit-for 0)
|
|
1151 (copy-file (package-get-remote-filename search-dir
|
|
1152 current-filename)
|
|
1153 full-package-filename t)))
|
428
|
1154
|
|
1155 ;; If we found it, we're done.
|
|
1156 (if (and full-package-filename
|
|
1157 (file-exists-p full-package-filename))
|
|
1158 (throw 'done nil))
|
|
1159 ;; Didn't find it. Try the next possible filename.
|
1365
|
1160 (setq search-filenames (cdr search-filenames))))))
|
428
|
1161
|
|
1162 (if (or (not full-package-filename)
|
|
1163 (not (file-exists-p full-package-filename)))
|
|
1164 (if package-get-remote
|
1410
|
1165 (error 'search-failed
|
|
1166 (format "Unable to find file %s" base-filename))
|
|
1167 (error 'syntax-error
|
|
1168 "No download sites or local package locations specified.")))
|
428
|
1169 ;; Validate the md5 checksum
|
|
1170 ;; Doing it with XEmacs removes the need for an external md5 program
|
|
1171 (message "Validating checksum for `%s'..." package) (sit-for 0)
|
|
1172 (with-temp-buffer
|
442
|
1173 (insert-file-contents-literally full-package-filename)
|
428
|
1174 (if (not (string= (md5 (current-buffer))
|
|
1175 (package-get-info-prop this-package
|
|
1176 'md5sum)))
|
1365
|
1177 (progn
|
|
1178 (delete-file full-package-filename)
|
1410
|
1179 (error 'process-error
|
|
1180 (format "Package %s does not match md5 checksum %s has been deleted"
|
|
1181 base-filename full-package-filename)))))
|
428
|
1182
|
|
1183 (package-admin-delete-binary-package package install-dir)
|
|
1184
|
|
1185 (message "Installing package `%s' ..." package) (sit-for 0)
|
|
1186 (let ((status
|
|
1187 (package-admin-add-binary-package full-package-filename
|
|
1188 install-dir)))
|
|
1189 (if (= status 0)
|
|
1190 (progn
|
|
1191 ;; clear messages so that only messages from
|
|
1192 ;; package-get-init-package are seen, below.
|
|
1193 (clear-message)
|
|
1194 (if (package-get-init-package (package-admin-get-lispdir
|
|
1195 install-dir package))
|
|
1196 (progn
|
628
|
1197 (run-hook-with-args 'package-install-hook package install-dir)
|
428
|
1198 (message "Added package `%s'" package)
|
1365
|
1199 (sit-for 0))
|
428
|
1200 (progn
|
|
1201 ;; display message only if there isn't already one.
|
|
1202 (if (not (current-message))
|
|
1203 (progn
|
|
1204 (message "Added package `%s' (errors occurred)"
|
|
1205 package)
|
1365
|
1206 (sit-for 0)))
|
428
|
1207 (if package-status
|
1365
|
1208 (setq package-status 'errors)))))
|
428
|
1209 (message "Installation of package %s failed." base-filename)
|
|
1210 (sit-for 0)
|
|
1211 (switch-to-buffer package-admin-temp-buffer)
|
1365
|
1212 (delete-file full-package-filename)
|
|
1213 (setq package-status nil)))
|
428
|
1214 (setq found t))
|
|
1215 (if (and found package-get-remove-copy)
|
|
1216 (delete-file full-package-filename))
|
1365
|
1217 package-status)))
|
428
|
1218
|
|
1219 (defun package-get-info-find-package (which name)
|
|
1220 "Look in WHICH for the package called NAME and return all the info
|
|
1221 associated with it. See `package-get-base' for info on the format
|
|
1222 returned.
|
|
1223
|
|
1224 To access fields returned from this, use
|
|
1225 `package-get-info-version' to return information about particular a
|
442
|
1226 version. Use `package-get-info-find-prop' to find particular property
|
428
|
1227 from a version returned by `package-get-info-version'."
|
|
1228 (interactive "xPackage list: \nsPackage Name: ")
|
|
1229 (if which
|
|
1230 (if (eq (caar which) name)
|
|
1231 (cdar which)
|
|
1232 (if (cdr which)
|
|
1233 (package-get-info-find-package (cdr which) name)))))
|
|
1234
|
|
1235 (defun package-get-info-version (package version)
|
|
1236 "In PACKAGE, return the plist associated with a particular VERSION of the
|
|
1237 package. PACKAGE is typically as returned by
|
442
|
1238 `package-get-info-find-package'. If VERSION is nil, then return the
|
428
|
1239 first (aka most recent) version. Use `package-get-info-find-prop'
|
|
1240 to retrieve a particular property from the value returned by this."
|
|
1241 (interactive (package-get-interactive-package-query t t))
|
|
1242 (while (and version package (not (string= (plist-get (car package) 'version) version)))
|
|
1243 (setq package (cdr package)))
|
|
1244 (if package (car package)))
|
|
1245
|
|
1246 (defun package-get-info-prop (package-version property)
|
|
1247 "In PACKAGE-VERSION, return the value associated with PROPERTY.
|
|
1248 PACKAGE-VERSION is typically returned by `package-get-info-version'
|
|
1249 and PROPERTY is typically (although not limited to) one of the
|
|
1250 following:
|
|
1251
|
|
1252 version - version of this package
|
|
1253 provides - list of symbols provided
|
|
1254 requires - list of symbols that are required.
|
|
1255 These in turn are provided by other packages.
|
|
1256 size - size of the bundled package
|
|
1257 md5sum - computed md5 checksum"
|
|
1258 (interactive "xPackage Version: \nSProperty")
|
|
1259 (plist-get package-version property))
|
|
1260
|
|
1261 (defun package-get-info-version-prop (package-list package version property)
|
|
1262 "In PACKAGE-LIST, search for PACKAGE with this VERSION and return
|
|
1263 PROPERTY value."
|
|
1264 (package-get-info-prop
|
|
1265 (package-get-info-version
|
|
1266 (package-get-info-find-package package-list package) version) property))
|
|
1267
|
|
1268 (defun package-get-staging-dir (filename)
|
|
1269 "Return a good place to stash FILENAME when it is retrieved.
|
|
1270 Use `package-get-dir' for directory to store stuff.
|
629
|
1271 Creates `package-get-dir' if it doesn't exist."
|
428
|
1272 (interactive "FPackage filename: ")
|
|
1273 (if (not (file-exists-p package-get-dir))
|
|
1274 (make-directory package-get-dir))
|
|
1275 (expand-file-name
|
776
|
1276 (file-name-nondirectory (or (and-fboundp 'efs-ftp-path
|
|
1277 (nth 2 (efs-ftp-path filename)))
|
428
|
1278 filename))
|
|
1279 (file-name-as-directory package-get-dir)))
|
|
1280
|
|
1281 (defun package-get-remote-filename (search filename)
|
|
1282 "Return FILENAME as a remote filename.
|
|
1283 It first checks if FILENAME already is a remote filename. If it is
|
|
1284 not, then it uses the (car search) as the remote site-name and the (cadr
|
|
1285 search) as the remote-directory and concatenates filename. In other
|
|
1286 words
|
|
1287 site-name:remote-directory/filename.
|
|
1288
|
|
1289 If (car search) is nil, (cadr search is interpreted as a local directory).
|
|
1290 "
|
|
1291 (if (file-remote-p filename)
|
|
1292 filename
|
|
1293 (let ((dir (cadr search)))
|
|
1294 (concat (when (car search)
|
|
1295 (concat
|
|
1296 (if (string-match "@" (car search))
|
|
1297 "/"
|
|
1298 "/anonymous@")
|
|
1299 (car search) ":"))
|
|
1300 (if (string-match "/$" dir)
|
|
1301 dir
|
|
1302 (concat dir "/"))
|
|
1303 filename))))
|
|
1304
|
|
1305 (defun package-get-installedp (package version)
|
|
1306 "Determine if PACKAGE with VERSION has already been installed.
|
442
|
1307 I'm not sure if I want to do this by searching directories or checking
|
428
|
1308 some built in variables. For now, use packages-package-list."
|
|
1309 ;; Use packages-package-list which contains name and version
|
|
1310 (equal (plist-get
|
|
1311 (package-get-info-find-package packages-package-list
|
|
1312 package) ':version)
|
1368
|
1313 (if (floatp version)
|
|
1314 version
|
1365
|
1315 (string-to-number version))))
|
428
|
1316
|
|
1317 ;;;###autoload
|
|
1318 (defun package-get-package-provider (sym &optional force-current)
|
|
1319 "Search for a package that provides SYM and return the name and
|
|
1320 version. Searches in `package-get-base' for SYM. If SYM is a
|
442
|
1321 consp, then it must match a corresponding (provide (SYM VERSION)) from
|
428
|
1322 the package.
|
|
1323
|
|
1324 If FORCE-CURRENT is non-nil make sure the database is up to date. This might
|
|
1325 lead to Emacs accessing remote sites."
|
|
1326 (interactive "SSymbol: ")
|
|
1327 (package-get-require-base force-current)
|
|
1328 (let ((packages package-get-base)
|
|
1329 (done nil)
|
|
1330 (found nil))
|
|
1331 (while (and (not done) packages)
|
|
1332 (let* ((this-name (caar packages))
|
|
1333 (this-package (cdr (car packages)))) ;strip off package name
|
|
1334 (while (and (not done) this-package)
|
|
1335 (if (or (eq this-name sym)
|
|
1336 (eq (cons this-name
|
|
1337 (package-get-info-prop (car this-package) 'version))
|
|
1338 sym)
|
|
1339 (member sym
|
|
1340 (package-get-info-prop (car this-package) 'provides)))
|
|
1341 (progn (setq done t)
|
|
1342 (setq found
|
|
1343 (list (caar packages)
|
|
1344 (package-get-info-prop (car this-package) 'version))))
|
|
1345 (setq this-package (cdr this-package)))))
|
|
1346 (setq packages (cdr packages)))
|
|
1347 (when (interactive-p)
|
|
1348 (if found
|
|
1349 (message "%S" found)
|
|
1350 (message "No appropriate package found")))
|
|
1351 found))
|
|
1352
|
|
1353 (defun package-get-ever-installed-p (pkg &optional notused)
|
|
1354 (string-match "-package$" (symbol-name pkg))
|
442
|
1355 (custom-initialize-set
|
|
1356 pkg
|
|
1357 (if (package-get-info-find-package
|
|
1358 packages-package-list
|
428
|
1359 (intern (substring (symbol-name pkg) 0 (match-beginning 0))))
|
|
1360 t)))
|
|
1361
|
|
1362 (provide 'package-get)
|
|
1363 ;;; package-get.el ends here
|