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