annotate lisp/package-get.el @ 410:de805c49cfc1 r21-2-35

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