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