1 ;;; package-net.el --- Installation and Maintenance of XEmacs packages
3 ;; Copyright (C) 2000 Andy Piper.
7 ;; This file is part of XEmacs.
9 ;; XEmacs is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; XEmacs is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;;; Synched up with: Not in FSF
28 ;; Manipulate packages for the netinstall setup utility
30 ;; The process should be so:
32 ;; 1. The package maintainer or release manager makes a release
35 ;; 2. For a new package releases the netinstall maintainer simply
36 ;; needs to update `ftp://ftp.xemacs.org/pub/xemacs/setup.ini'. This is
37 ;; harder than it sounds because the file also includes information
38 ;; about the binary releases. At the moment going to the netinstall
39 ;; directory and typing:
41 ;; `make XEMACS=<current executable location> setup.ini'
43 ;; will do the right thing provided that:
45 ;; (a) `package-net-cygwin32-binary-size' and
46 ;; `package-net-win32-binary-size' are set correctly.
48 ;; (b) The binary pointed to by `XEMACS' has a current
49 ;; `package-index.LATEST.pgp' file. If you don't specify the XEMACS=
50 ;; part then you will get whatever is current for your build tree -
51 ;; which is probably not what you want.
53 ;; You can run `package-net-convert-index-to-ini' manually and specify
54 ;; REMOTE but I generally found that to be inconvenient and error-prone.
56 ;; 3. For package releases that's all you need to do. For binary
57 ;; releases you need to build both cygwin and win32 binaries and put
58 ;; them in appropriate tarballs:
60 ;; For cygwin, configure, make and install and then do (this is for
64 ;; tar cvzf xemacs-i686-pc-cygwin32-21.1.13.tar.gz \
65 ;; ./bin/i686-pc-cygwin32 ./lib/xemacs-21.1.13 \
66 ;; ./lib/xemacs/lock ./man/man1/xemacs.1 \
67 ;; ./man/man1/ctags.1 ./man/man1/gnu*.1'
69 ;; Note that the naming of the package is important. Don't be tempted
70 ;; to change the order in any way.
72 ;; For win32 build and install the release and then (again for
76 ;; tar cvzf xemacs-i386-pc-win32-21.1.13.tar.gz ./XEmacs-21.1.13
78 ;; The binaries should be uploaded to
79 ;; `ftp://ftp.xemacs.org/pub/xemacs/binaries/cygwin32' and
80 ;; `ftp://ftp.xemacs.org/pub/xemacs/binaries/win32' respectively. Take
81 ;; a note of their sizes and set `package-net-cygwin32-binary-size'
82 ;; and `package-net-win32-binary-size' appropriately in this file and
83 ;; then follow step 2.
85 (require 'package-admin)
86 (require 'package-get)
88 ;; What path should we use from the myriad available?
89 ;; For netinstall we just want something simple, and anyway this is only to
90 ;; bootstrap the process. This will be:
91 ;; <root>/setup/ for native windows
92 ;; <root>/lib/xemacs/setup for cygwin.
96 ;; 1. Package update functions should also update the installed
97 ;; database so that running setup.exe again does not reinstall
100 ;; 2. Generating setup.ini should be more automatic.
102 (defvar package-net-cygwin32-binary-size 6917126
103 "The size in bytes of the cygwin32 binary distribution.")
105 (defvar package-net-win32-binary-size 6563941
106 "The size in bytes of the win32 binary distribution.")
109 (defun package-net-setup-directory ()
110 (file-truename (concat data-directory "../../" (if (eq system-type 'cygwin32)
111 "xemacs/setup/" "setup/"))))
113 (defun package-net-convert-index-to-ini (&optional destdir remote version)
114 "Convert the package index to ini file format in DESTDIR.
115 DESTDIR defaults to the value of `data-directory'."
116 (package-get-require-base remote)
118 (setq destdir (file-name-as-directory (or destdir data-directory)))
119 (let ((buf (get-buffer-create "*setup.ini*")))
124 (goto-char (point-min))
125 (let ((entries package-get-base) entry plist)
126 (insert "# This file is automatically generated. If you edit it, your\n")
127 (insert "# edits will be discarded next time the file is generated.\n")
129 (insert (format "setup-timestamp: %d\n"
130 (+ (* (car (current-time)) 65536) (car (cdr (current-time))))))
131 (insert (format "setup-version: %s\n\n" (or version "1.0")))
133 (insert (format "@ %s\n" "xemacs-i386-pc-win32"))
134 (insert (format "version: %s\n" emacs-program-version))
135 (insert "type: native\n")
136 (insert (format "install: binaries/win32/%s %d\n\n"
137 (concat emacs-program-name
139 emacs-program-version ".tar.gz")
140 package-net-win32-binary-size))
142 (insert (format "@ %s\n" "xemacs-i686-pc-cygwin32"))
143 (insert (format "version: %s\n" emacs-program-version))
144 (insert "type: cygwin\n")
145 (insert (format "install: binaries/cygwin32/%s %d\n\n"
146 (concat emacs-program-name
148 emacs-program-version ".tar.gz")
149 package-net-cygwin32-binary-size))
152 (setq entry (car entries))
153 (setq plist (car (cdr entry)))
154 ;; ignore mule packages
155 (unless (or (memq 'mule-base (plist-get plist 'requires))
156 (eq 'mule-base (car entry)))
157 (insert (format "@ %s\n" (symbol-name (car entry))))
158 (insert (format "version: %s\n" (plist-get plist 'version)))
159 (insert (format "install: packages/%s %s\n" (plist-get plist 'filename)
160 (plist-get plist 'size)))
161 ;; These are not supported as yet
163 ;; (insert (format "source: %s\n" (plist-get plist 'source)))
164 ;; (insert "[prev]\n")
165 ;; (insert (format "version: %s\n" (plist-get plist 'version)))
166 ;; (insert (format "install: %s\n" (plist-get plist 'filename)))
167 ;; (insert (format "source: %s\n" (plist-get plist 'source)))
169 (setq entries (cdr entries))))
170 (insert "# setup.ini file ends here\n")
171 (write-region (point-min) (point-max) (concat destdir "setup.ini")))
174 (defun package-net-batch-convert-index-to-ini ()
175 "Convert the package index to ini file format."
176 (unless noninteractive
177 (error "`package-net-batch-convert-index-to-ini' is to be used only with -batch"))
178 (let ((dir (car command-line-args-left))
179 (version (car (cdr command-line-args-left)))
180 (package-get-require-signed-base-updates nil))
181 (package-net-convert-index-to-ini dir nil version)))
184 (defun package-net-update-installed-db (&optional destdir)
185 "Write out the installed package index in a net install suitable format.
186 If DESTDIR is non-nil then use that as the destination directory.
187 DESTDIR defaults to the value of `package-net-setup-directory'."
189 (when (or (eq system-type 'cygwin32)
190 (eq system-type 'window-nt))
191 (setq destdir (file-name-as-directory
192 (or destdir (package-net-setup-directory))))
193 (let ((buf (get-buffer-create "*installed.db*")))
198 (goto-char (point-min))
199 ;; we use packages-package-list here as we actually want to
200 ;; update relative to the installed reality
201 (let ((entries packages-package-list) entry version)
203 (setq entry (car entries))
204 (setq version (plist-get (cdr entry) :version))
205 ;; Unfortunately we can't read the size from this
206 (insert (format "%s %s-%3.2f-pkg.tar.gz 0\n" (symbol-name (car entry))
207 (symbol-name (car entry))
209 (setq entries (cdr entries))))
210 (make-directory-path destdir)
211 (write-region (point-min) (point-max) (concat destdir "installed.db")))
212 (kill-buffer buf)))))
214 (defun package-net-convert-download-sites-to-mirrors (&optional destdir)
215 "Write out the download site list in a net install suitable format.
216 If DESTDIR is non-nil then use that as the destination directory.
217 DESTDIR defaults to the value of `data-directory'."
219 (setq destdir (file-name-as-directory (or destdir data-directory)))
220 (let ((buf (get-buffer-create "*mirrors.lst*")))
225 (goto-char (point-min))
226 (let ((entries package-get-download-sites) entry)
228 (setq entry (car entries))
229 (insert (format "ftp://%s/%s;%s;%s\n"
230 (nth 1 entry) (substring (nth 2 entry) 0 -9)
231 (nth 0 entry) (nth 0 entry)))
232 (setq entries (cdr entries))))
233 (write-region (point-min) (point-max) (concat destdir "mirrors.lst")))