annotate lisp/package-get.el @ 294:4b85ae5eabfb r21-0b45

Import from CVS: tag r21-0b45
author cvs
date Mon, 13 Aug 2007 10:38:01 +0200
parents 6cb5e14cd98e
children 70ad99077275
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>
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
6 ;; Keywords: internal
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
7
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
9
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
13 ;; any later version.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
14
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
18 ;; General Public License for more details.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
19
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
24
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
26
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
27 ;;; Commentary:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
28
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
29 ;; package-get -
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
30 ;; Retrieve a package and any other required packages from an archive
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
31 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
32 ;; The idea:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
33 ;; A new XEmacs lisp-only release is generated with the following steps:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
34 ;; 1. The maintainer runs some yet to be written program that
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
35 ;; generates all the dependency information. This should
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
36 ;; determine all the require and provide statements and associate
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
37 ;; them with a package.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
38 ;; 2. All the packages are then bundled into their own tar balls
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
39 ;; (or whatever format)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
40 ;; 3. Maintainer automatically generates a new `package-get-base'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
41 ;; data structure which contains information such as the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
42 ;; package name, the file to be retrieved, an md5 checksum,
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
43 ;; etc (see `package-get-base').
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
44 ;; 4. The maintainer posts an announcement with the new version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
45 ;; of `package-get-base'.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
46 ;; 5. A user/system manager saves this posting and runs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
47 ;; `package-get-update' which uses the previously saved list
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
48 ;; of packages, `package-get-here' that the user/site
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
49 ;; wants to determine what new versions to download and
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
50 ;; install.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
51 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
52 ;; A user/site manager can generate a new `package-get-here' structure
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
53 ;; by using `package-get-setup' which generates a customize like
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
54 ;; interface to the list of packages. The buffer looks something
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
55 ;; like:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
56 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
57 ;; gnus - a mail and news reader
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
58 ;; [] Always install
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
59 ;; [] Needs updating
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
60 ;; [] Required by other [packages]
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
61 ;; version: 2.0
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
62 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
63 ;; vm - a mail reader
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
64 ;; [] Always install
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
65 ;; [] Needs updating
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
66 ;; [] Required by other [packages]
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
67 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
68 ;; Where `[]' indicates a toggle box
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
69 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
70 ;; - Clicking on "Always install" puts this into
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
71 ;; `package-get-here' list. "Needs updating" indicates a new
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
72 ;; version is available. Anything already in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
73 ;; `package-get-here' has this enabled.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
74 ;; - "Required by other" means some other packages are going to force
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
75 ;; this to be installed. Clicking on [packages] gives a list
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
76 ;; of packages that require this.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
77 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
78 ;; The `package-get-base' should be installed in a file in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
79 ;; `data-directory'. The `package-get-here' should be installed in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
80 ;; site-lisp. Both are then read at run time.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
81 ;;
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
82 ;; TODO:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
83 ;; - Implement `package-get-setup'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
84 ;; - Actually put `package-get-base' and `package-get-here' into
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
85 ;; files that are read.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
86 ;; - Allow users to have their own packages that they want installed
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
87 ;; in ~/.xemacs/.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
88 ;; - SOMEONE needs to write the programs that generate the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
89 ;; provides/requires database and makes it into a lisp data
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
90 ;; structure suitable for `package-get-base'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
91 ;; - Handle errors such as no package providing a required symbol.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
92 ;; - Tie this into the `require' function to download packages
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
93 ;; transparently.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
94
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
95 ;;; Change Log
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
96
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
97 ;;; Code:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
98
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
99 (require 'package-admin)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
100
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
101 (defvar package-get-base nil
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
102 "List of packages that are installed at this site.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
103 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
104 a plist containing information about the package. Typical fields
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
105 kept in the plist are:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
106
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
107 version - version of this package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
108 provides - list of symbols provided
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
109 requires - list of symbols that are required.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
110 These in turn are provided by other packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
111 filename - name of the file.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
112 size - size of the file (aka the bundled package)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
113 md5sum - computed md5 checksum
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
114 description - What this package is for.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
115 type - Whether this is a 'binary (default) or 'single file package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
116
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
117 More fields may be added as needed. An example:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
118
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
119 '(
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
120 (name
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
121 (version \"<version 2>\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
122 file \"filename\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
123 description \"what this package is about.\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
124 provides (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
125 requires (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
126 size <integer-bytes>
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
127 md5sum \"<checksum\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
128 type single
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
129 )
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
130 (version \"<version 1>\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
131 file \"filename\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
132 description \"what this package is about.\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
133 provides (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
134 requires (<list>)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
135 size <integer-bytes>
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
136 md5sum \"<checksum\"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
137 type single
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
138 )
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
139 ...
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
140 ))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
141
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
142 For version information, it is assumed things are listed in most
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
143 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
144 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
145 one version of a package available.")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
146
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
147 (defvar package-get-dir (temp-directory)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
148 "*Where to store temporary files for staging.")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
149
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
150 (defvar package-get-remote
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
151 '(
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 263
diff changeset
152 ("ftp.xemacs.org" "/pub/xemacs/beta/xemacs-21.0/packages/binary-packages")
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 263
diff changeset
153 ("ftp.xemacs.org" "/pub/xemacs/beta/xemacs-21.0/packages/single-file-packages")
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
154 ("ftp.xemacs.org" "/pub/xemacs/package"))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
155 "*List of remote sites to contact for downloading packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
156 List format is '(site-name directory-on-site). Each site is tried in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
157 order until the package is found.")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
158
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
159 (defvar package-get-remove-copy nil
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
160 "*After copying and installing a package, if this is T, then remove the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
161 copy. Otherwise, keep it around.")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
162
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
163 ;;;###autoload
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
164 (defun package-get-update-all ()
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
165 "Fetch and install the latest versions of all currently installed packages."
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
166 (interactive)
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
167 ;; Load a fresh copy
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
168 (load "package-get-base.el")
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
169 (mapcar (lambda (pkg)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
170 (package-get-all
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
171 (car pkg) nil))
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
172 packages-package-list))
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
173
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
174 ;;;###autoload
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
175 (defun package-get-all (package version &optional fetched-packages)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
176 "Fetch PACKAGE with VERSION and all other required packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
177 Uses `package-get-base' to determine just what is required and what
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
178 package provides that functionality. If VERSION is nil, retrieves
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
179 latest version. Optional argument FETCHED-PACKAGES is used to keep
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
180 track of packages already fetched."
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
181 (interactive "sPackage: \nsVersion: ")
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
182 (load "package-get-base.el")
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
183 (let* ((the-package (package-get-info-find-package package-get-base
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
184 package))
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
185 (this-package (package-get-info-version
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
186 the-package version))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
187 (this-requires (package-get-info-prop this-package 'requires))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
188 )
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
189 (setq version (package-get-info-prop this-package 'version))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
190 (unless (package-get-installedp package version)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
191 (package-get package version))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
192 (setq fetched-packages
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
193 (append (list package)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
194 (package-get-info-prop this-package 'provides)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
195 fetched-packages))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
196 ;; grab everything that this package requires plus recursively
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
197 ;; grab everything that the requires require. Keep track
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
198 ;; in `fetched-packages' the list of things provided -- this
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
199 ;; keeps us from going into a loop
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
200 (while this-requires
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
201 (if (not (member (car this-requires) fetched-packages))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
202 (let* ((reqd-package (package-get-package-provider
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
203 (car this-requires)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
204 (reqd-version (cadr reqd-package))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
205 (reqd-name (car reqd-package)))
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
206 (if (null reqd-name)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
207 (error "Unable to find a provider for %s" (car this-requires)))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
208 (setq fetched-packages
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
209 (package-get-all reqd-name reqd-version fetched-packages)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
210 )
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
211 (setq this-requires (cdr this-requires)))
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
212 fetched-packages
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
213 ))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
214
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
215 ;;;###autoload
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
216 (defun package-get (package &optional version conflict)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
217 "Fetch PACKAGE from remote site.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
218 Optional arguments VERSION indicates which version to retrieve, nil
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
219 means most recent version. CONFLICT indicates what happens if the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
220 package is already installed. Valid values for CONFLICT are:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
221 'always always retrieve the package even if it is already installed
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
222 'never do not retrieve the package if it is installed.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
223
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
224 The value of `package-get-base' is used to determine what files should
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
225 be retrieved. The value of `package-get-remote' is used to determine
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
226 where a package should be retrieved from. The sites are tried in
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
227 order so one is better off listing easily reached sites first.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
228
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
229 Once the package is retrieved, its md5 checksum is computed. If that
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
230 sum does not match that stored in `package-get-base' for this version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
231 of the package, an error is signalled."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
232 (interactive "xPackage List: ")
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
233 (load "package-get-base.el")
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
234 (let* ((this-package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
235 (package-get-info-version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
236 (package-get-info-find-package package-get-base
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
237 package) version))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
238 (found nil)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
239 (search-dirs package-get-remote)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
240 (filename (package-get-info-prop this-package 'filename)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
241 (if (null this-package)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
242 (error "Couldn't find package %s with version %s"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
243 package version))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
244 (if (null filename)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
245 (error "No filename associated with package %s, version %s"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
246 package version))
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
247 (setq version (package-get-info-prop this-package 'version))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
248 (unless (and (eq conflict 'never)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
249 (package-get-installedp package version))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
250 ;; Find the package from search list in package-get-remote
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
251 ;; and copy it into the staging directory. Then validate
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
252 ;; the checksum. Finally, install the package.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
253 (while (and search-dirs
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
254 (not (file-exists-p (package-get-staging-dir filename))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
255 (if (file-exists-p (package-get-remote-filename
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
256 (car search-dirs) filename))
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
257 (copy-file (package-get-remote-filename (car search-dirs) filename)
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
258 (package-get-staging-dir filename))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
259 (setq search-dirs (cdr search-dirs))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
260 ))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
261 (if (not (file-exists-p (package-get-staging-dir filename)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
262 (error "Unable to find file %s" filename))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
263 ;; Validate the md5 checksum
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
264 ;; Doing it with XEmacs removes the need for an external md5 program
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
265 (with-temp-buffer
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
266 ;; What ever happened to i-f-c-literally
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
267 (let (file-name-handler-alist)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
268 (insert-file-contents-internal (package-get-staging-dir filename)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
269 (if (not (string= (md5 (current-buffer))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
270 (package-get-info-prop this-package
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 278
diff changeset
271 'md5sum)))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
272 (error "Package %s does not match md5 checksum" filename)))
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
273 (message "Retrieved package %s" filename) (sit-for 0)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
274 (let ((status
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
275 (package-admin-add-binary-package
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
276 (package-get-staging-dir filename))))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
277 (when (not (= status 0))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
278 (message "Package failed.")
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
279 (switch-to-buffer package-admin-temp-buffer)))
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
280 (sit-for 0)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
281 (message "Added package") (sit-for 0)
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
282 (setq found t))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
283 (if (and found package-get-remove-copy)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
284 (delete-file (package-get-staging-dir filename)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
285 ))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
286
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
287 (defun package-get-info-find-package (which name)
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
288 "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
289 associated with it. See `package-get-base' for info on the format
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
290 returned.
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
291
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
292 To access fields returned from this, use
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
293 `package-get-info-version' to return information about particular a
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
294 version. Use `package-get-info-find-prop' to find particular property
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
295 from a version returned by `package-get-info-version'."
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
296 (interactive "xPackage list: \nsPackage Name: ")
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
297 (if which
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
298 (if (eq (caar which) name)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
299 (cdar which)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
300 (if (cdr which)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
301 (package-get-info-find-package (cdr which) name)))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
302
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
303 (defun package-get-info-version (package version)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
304 "In PACKAGE, return the plist associated with a particular VERSION of the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
305 package. PACKAGE is typically as returned by
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
306 `package-get-info-find-package'. If VERSION is nil, then return the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
307 first (aka most recent) version. Use `package-get-info-find-prop'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
308 to retrieve a particular property from the value returned by this."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
309 (interactive "xPackage Info: \nsVersion: ")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
310 (while (and version package (not (string= (plist-get (car package) 'version) version)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
311 (setq package (cdr package)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
312 (if package (car package)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
313
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
314 (defun package-get-info-prop (package-version property)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
315 "In PACKAGE-VERSION, return the value associated with PROPERTY.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
316 PACKAGE-VERSION is typically returned by `package-get-info-version'
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
317 and PROPERTY is typically (although not limited to) one of the
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
318 following:
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
319
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
320 version - version of this package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
321 provides - list of symbols provided
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
322 requires - list of symbols that are required.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
323 These in turn are provided by other packages.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
324 size - size of the bundled package
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
325 md5sum - computed md5 checksum"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
326 (interactive "xPackage Version: \nSProperty")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
327 (plist-get package-version property))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
328
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
329 (defun package-get-info-version-prop (package-list package version property)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
330 "In PACKAGE-LIST, search for PACKAGE with this VERSION and return
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
331 PROPERTY value."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
332 (package-get-info-prop
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
333 (package-get-info-version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
334 (package-get-info-find-package package-list package) version) property))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
335
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
336 (defun package-get-set-version-prop (package-list package version
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
337 property value)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
338 "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
339 in this VERSION of a specific PACKAGE kept in the PACKAGE-LIST.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
340 Returns the modified PACKAGE-LIST. Any missing fields are created."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
341 )
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
342
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
343 (defun package-get-staging-dir (filename)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
344 "Return a good place to stash FILENAME when it is retrieved.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
345 Use `package-get-dir' for directory to store stuff.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
346 Creates `package-get-dir' it it doesn't exist."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
347 (interactive "FPackage filename: ")
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
348 (if (not (file-exists-p package-get-dir))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
349 (make-directory package-get-dir))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
350 (concat
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
351 (file-name-as-directory package-get-dir)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
352 (file-name-nondirectory (or (nth 2 (efs-ftp-path filename)) filename))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
353
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
354
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
355 (defun package-get-remote-filename (search filename)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
356 "Return FILENAME as a remote filename.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
357 It first checks if FILENAME already is a remote filename. If it is
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
358 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
359 search) as the remote-directory and concatenates filename. In other
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
360 words
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
361 site-name:remote-directory/filename
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
362 "
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
363 (if (efs-ftp-path filename)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
364 filename
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
365 (concat "/"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
366 (car search) ":"
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
367 (file-name-as-directory (cadr search))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
368 filename)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
369
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
370
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
371 (defun package-get-installedp (package version)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
372 "Determine if PACKAGE with VERSION has already been installed.
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
373 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
374 some built in variables. For now, use packages-package-list."
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 237
diff changeset
375 ;; Use packages-package-list which contains name and version
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
376 (equal (plist-get
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
377 (package-get-info-find-package packages-package-list
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
378 package) ':version)
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
379 (if (floatp version) version (string-to-number version))))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
380
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
381 ;;;###autoload
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
382 (defun package-get-package-provider (sym)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
383 "Search for a package that provides SYM and return the name and
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
384 version. Searches in `package-get-base' for SYM. If SYM is a
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
385 consp, then it must match a corresponding (provide (SYM VERSION)) from
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
386 the package."
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
387 (interactive "SSymbol: ")
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
388 (load "package-get-base.el")
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
389 (let ((packages package-get-base)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
390 (done nil)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
391 (found nil))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
392 (while (and (not done) packages)
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
393 (let* ((this-name (caar packages))
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
394 (this-package (cdr (car packages)))) ;strip off package name
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
395 (while (and (not done) this-package)
237
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
396 (if (or (eq this-name sym)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
397 (eq (cons this-name
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
398 (package-get-info-prop (car this-package) 'version))
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
399 sym)
89ec2bb86eea Import from CVS: tag r20-5b17
cvs
parents: 235
diff changeset
400 (member sym (package-get-info-prop (car this-package) 'provides)))
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
401 (progn (setq done t)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
402 (setq found (list (caar packages)
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
403 (package-get-info-prop (car this-package) 'version))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
404 (setq this-package (cdr this-package)))))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
405 (setq packages (cdr packages)))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
406 found))
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
407
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
408 ;;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
409 ;; customize interfaces.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
410 ;; 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
411 ;;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
412 (defgroup packages nil
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
413 "Configure XEmacs packages."
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
414 :group 'emacs)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
415
292
6cb5e14cd98e Import from CVS: tag r21-0b44
cvs
parents: 288
diff changeset
416 ;;;###autoload
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
417 (defun package-get-custom ()
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
418 "Fetch and install the latest versions of all customized packages."
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
419 (interactive)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
420 ;; Load a fresh copy
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
421 (load "package-get-base.el")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
422 (load "package-get-custom.el")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
423 (mapcar (lambda (pkg)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
424 (if (eval (intern (concat (symbol-name (car pkg)) "-package")))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
425 (package-get-all (car pkg) nil))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
426 t)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
427 package-get-base))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
428
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
429 (defun package-get-ever-installed-p (pkg &optional notused)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
430 (string-match "-package$" (symbol-name pkg))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
431 (custom-initialize-set
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
432 pkg
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
433 (if (package-get-info-find-package
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
434 packages-package-list
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
435 (intern (substring (symbol-name pkg) 0 (match-beginning 0))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
436 t)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
437
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
438 (defun package-get-file-installed-p (file &optional paths)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
439 "Return absolute-path of FILE if FILE exists in PATHS.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
440 If PATHS is omitted, `load-path' is used."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
441 (if (null paths)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
442 (setq paths load-path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
443 )
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
444 (catch 'tag
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
445 (let (path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
446 (while paths
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
447 (setq path (expand-file-name file (car paths)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
448 (if (file-exists-p path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
449 (throw 'tag path)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
450 )
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
451 (setq paths (cdr paths))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
452 ))))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
453
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
454 (defun package-get-create-custom ()
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
455 "Creates a package customization file package-get-custom.el.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
456 Entries in the customization file are retrieved from package-get-base.el."
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
457 (interactive)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
458 ;; Load a fresh copy
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
459 (load "package-get-base.el")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
460 (let ((custom-buffer (find-file-noselect
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
461 (or (package-get-file-installed-p
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
462 "package-get-custom.el")
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
463 (concat (file-name-directory
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
464 (package-get-file-installed-p
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
465 "package-get-base.el"))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
466 "package-get-custom.el"))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
467 (pkg-groups nil))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
468
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
469 ;; clear existing stuff
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
470 (delete-region (point-min custom-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
471 (point-max custom-buffer) custom-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
472 (insert-string "(require 'package-get)\n" custom-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
473
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
474 (mapcar (lambda (pkg)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
475 (let ((category (plist-get (car (cdr pkg)) 'category)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
476 (or (memq (intern category) pkg-groups)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
477 (progn
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
478 (setq pkg-groups (cons (intern category) pkg-groups))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
479 (insert-string
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
480 (concat "(defgroup " category "-packages nil\n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
481 " \"" category " package group\"\n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
482 " :group 'packages)\n\n") custom-buffer)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
483
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
484 (insert-string
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
485 (concat "(defcustom " (symbol-name (car pkg))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
486 "-package nil \n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
487 " \"" (plist-get (car (cdr pkg)) 'description) "\"\n"
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
488 " :group '" category "-packages\n"
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
489 " :initialize 'package-get-ever-installed-p\n"
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
490 " :type 'boolean)\n\n") custom-buffer)))
294
4b85ae5eabfb Import from CVS: tag r21-0b45
cvs
parents: 292
diff changeset
491 package-get-base) custom-buffer)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
492 )
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
493
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
494 ;; need this first to avoid infinite dependency loops
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
495 (provide 'package-get)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
496
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
497 ;; potentially update the custom dependencies every time we load this
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
498 (let ((custom-file (package-get-file-installed-p "package-get-custom.el"))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
499 (package-file (package-get-file-installed-p "package-get-base.el")))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
500 ;; update custom file if it doesn't exist
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
501 (if (or (not custom-file)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
502 (and (< (car (nth 5 (file-attributes custom-file)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
503 (car (nth 5 (file-attributes package-file))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
504 (< (car (nth 5 (file-attributes custom-file)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
505 (car (nth 5 (file-attributes package-file))))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
506 (save-excursion
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
507 (message "generating package customizations...")
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
508 (set-buffer (package-get-create-custom))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
509 (save-buffer)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
510 (message "generating package customizations...done")))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
511 (load "package-get-custom.el"))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
512
235
85a06df23a9a Import from CVS: tag r20-5b16
cvs
parents:
diff changeset
513 ;;; package-get.el ends here