annotate lisp/package-net.el @ 448:3078fd1074e8 r21-2-39

Import from CVS: tag r21-2-39
author cvs
date Mon, 13 Aug 2007 11:38:25 +0200
parents
children 3d3049ae1304
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
1 ;;; package-net.el --- Installation and Maintenance of XEmacs packages
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
2
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
3 ;; Copyright (C) 2000 Andy Piper.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
4
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
5 ;; Keywords: internal
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
6
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
8
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
12 ;; any later version.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
13
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
17 ;; General Public License for more details.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
18
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
22 ;; 02111-1307, USA.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
23
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
24 ;;; Synched up with: Not in FSF
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
25
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
26 ;;; Commentary:
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
27
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
28 ;; Manipulate packages for the netinstall setup utility
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
29
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
30 (require 'package-admin)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
31 (require 'package-get)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
32
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
33 ;; What path should we use from the myriad available?
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
34 ;; For netinstall we just want something simple, and anyway this is only to
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
35 ;; bootstrap the process. This will be:
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
36 ;; <root>/setup/ for native windows
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
37 ;; <root>/lib/xemacs/setup for cygwin.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
38 (defun package-net-setup-directory ()
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
39 (file-truename (concat data-directory "../../" (if (eq system-type 'cygwin32)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
40 "xemacs/setup/" "setup/"))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
41
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
42 (defun package-net-convert-index-to-ini (&optional destdir remote version)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
43 "Convert the package index to ini file format in DESTDIR.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
44 DESTDIR defaults to the value of `data-directory'."
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
45 (package-get-require-base remote)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
46
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
47 (setq destdir (file-name-as-directory (or destdir data-directory)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
48 (let ((buf (get-buffer-create "*setup.ini*")))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
49 (unwind-protect
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
50 (save-excursion
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
51 (set-buffer buf)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
52 (erase-buffer buf)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
53 (goto-char (point-min))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
54 (let ((entries package-get-base) entry plist)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
55 (insert "# This file is automatically generated. If you edit it, your\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
56 (insert "# edits will be discarded next time the file is generated.\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
57 (insert "#\n\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
58 (insert (format "setup-timestamp: %d\n"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
59 (+ (* (car (current-time)) 65536) (car (cdr (current-time))))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
60 (insert (format "setup-version: %s\n\n" (or version "1.0")))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
61 ;; Native version
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
62 ;; We give the package a capitalised name so that it appears at the top
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
63 (insert (format "@ %s\n" "xemacs-i586-pc-win32"))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
64 (insert (format "version: %s\n" emacs-program-version))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
65 (insert "type: native\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
66 (insert (format "install: binaries/win32/%s %d\n\n"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
67 (concat emacs-program-name
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
68 "-i586-pc-win32-"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
69 emacs-program-version ".tar.gz") 0))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
70 ;; Cygwin version
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
71 ;; We give the package a capitalised name so that it appears at the top
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
72 (insert (format "@ %s\n" "xemacs-i686-pc-cygwin32"))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
73 (insert (format "version: %s\n" emacs-program-version))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
74 (insert "type: cygwin\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
75 (insert (format "install: binaries/cygwin32/%s %d\n\n"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
76 (concat emacs-program-name
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
77 "-i686-pc-cygwin32-"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
78 emacs-program-version ".tar.gz") 6779200))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
79 ;; Standard packages
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
80 (while entries
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
81 (setq entry (car entries))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
82 (setq plist (car (cdr entry)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
83 (insert (format "@ %s\n" (symbol-name (car entry))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
84 (insert (format "version: %s\n" (plist-get plist 'version)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
85 (insert (format "install: packages/%s %s\n" (plist-get plist 'filename)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
86 (plist-get plist 'size)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
87 ;; These are not supported as yet
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
88 ;;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
89 ;; (insert (format "source: %s\n" (plist-get plist 'source)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
90 ;; (insert "[prev]\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
91 ;; (insert (format "version: %s\n" (plist-get plist 'version)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
92 ;; (insert (format "install: %s\n" (plist-get plist 'filename)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
93 ;; (insert (format "source: %s\n" (plist-get plist 'source)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
94 (insert "\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
95 (setq entries (cdr entries))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
96 (insert "# setup.ini file ends here\n")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
97 (write-region (point-min) (point-max) (concat destdir "setup.ini")))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
98 (kill-buffer buf))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
99
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
100 (defun package-net-update-installed-db (&optional destdir)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
101 "Write out the installed package index in a net install suitable format.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
102 If DESTDIR is non-nil then use that as the destination directory.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
103 DESTDIR defaults to the value of `package-net-setup-directory'."
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
104 ;; Need the local version
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
105 (package-get-require-base)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
106
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
107 (setq destdir (file-name-as-directory
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
108 (or destdir (package-net-setup-directory))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
109 (let ((buf (get-buffer-create "*installed.db*")))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
110 (unwind-protect
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
111 (save-excursion
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
112 (set-buffer buf)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
113 (erase-buffer buf)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
114 (goto-char (point-min))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
115 (let ((entries package-get-base) entry plist)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
116 (while entries
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
117 (setq entry (car entries))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
118 (setq plist (car (cdr entry)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
119 (insert (format "%s %s %s\n" (symbol-name (car entry))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
120 (plist-get plist 'filename)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
121 (plist-get plist 'size)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
122 (setq entries (cdr entries))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
123 (make-directory-path destdir)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
124 (write-region (point-min) (point-max) (concat destdir "installed.db")))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
125 (kill-buffer buf))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
126
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
127 (defun package-net-convert-download-sites-to-mirrors (&optional destdir)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
128 "Write out the download site list in a net install suitable format.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
129 If DESTDIR is non-nil then use that as the destination directory.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
130 DESTDIR defaults to the value of `data-directory'."
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
131
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
132 (setq destdir (file-name-as-directory (or destdir data-directory)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
133 (let ((buf (get-buffer-create "*mirrors.lst*")))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
134 (unwind-protect
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
135 (save-excursion
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
136 (set-buffer buf)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
137 (erase-buffer buf)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
138 (goto-char (point-min))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
139 (let ((entries package-get-download-sites) entry)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
140 (while entries
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
141 (setq entry (car entries))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
142 (insert (format "ftp://%s/%s;%s;%s\n"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
143 (nth 1 entry) (substring (nth 2 entry) 0 -9)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
144 (nth 0 entry) (nth 0 entry)))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
145 (setq entries (cdr entries))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
146 (write-region (point-min) (point-max) (concat destdir "mirrors.lst")))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
147 (kill-buffer buf))))