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