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