]> code.delx.au - gnu-emacs/blob - admin/admin.el
(flyspell-word): Revert last change.
[gnu-emacs] / admin / admin.el
1 ;;; admin.el --- utilities for Emacs administration
2
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 ;; Free Software Foundation, Inc.
5
6 ;; This file is part of GNU Emacs.
7
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
12
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22
23 ;;; Commentary:
24
25 ;; add-release-logs Add ``Version X released'' change log entries.
26 ;; set-version Change Emacs version number in source tree.
27
28 ;;; Code:
29
30 (defun process-lines (program &rest args)
31 "Execute PROGRAM with ARGS, returning its output as a list of lines.
32 Signal an error if the program returns with a non-zero exit status."
33 (with-temp-buffer
34 (let ((status (apply 'call-process program nil (current-buffer) nil args)))
35 (unless (eq status 0)
36 (error "%s exited with status %s" program status))
37 (goto-char (point-min))
38 (let (lines)
39 (while (not (eobp))
40 (setq lines (cons (buffer-substring-no-properties
41 (line-beginning-position)
42 (line-end-position))
43 lines))
44 (forward-line 1))
45 (nreverse lines)))))
46
47 (defun add-release-logs (root version)
48 "Add \"Version VERSION released.\" change log entries in ROOT.
49 Root must be the root of an Emacs source tree."
50 (interactive "DEmacs root directory: \nNVersion number: ")
51 (setq root (expand-file-name root))
52 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
53 (error "%s doesn't seem to be the root of an Emacs source tree" root))
54 (require 'add-log)
55 (let* ((logs (process-lines "find" root "-name" "ChangeLog"))
56 (entry (format "%s %s <%s>\n\n\t* Version %s released.\n\n"
57 (funcall add-log-time-format)
58 (or add-log-full-name (user-full-name))
59 (or add-log-mailing-address user-mail-address)
60 version)))
61 (dolist (log logs)
62 (unless (string-match "/gnus/" log)
63 (find-file log)
64 (goto-char (point-min))
65 (insert entry)))))
66
67 (defun set-version-in-file (root file version rx)
68 (find-file (expand-file-name file root))
69 (goto-char (point-min))
70 (unless (re-search-forward rx nil t)
71 (error "Version not found in %s" file))
72 (replace-match (format "%s" version) nil nil nil 1))
73
74 (defun set-version (root version)
75 "Set Emacs version to VERSION in relevant files under ROOT.
76 Root must be the root of an Emacs source tree."
77 (interactive "DEmacs root directory: \nsVersion number: ")
78 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
79 (error "%s doesn't seem to be the root of an Emacs source tree" root))
80 (set-version-in-file root "lisp/version.el" version
81 (rx (and "emacs-version" (0+ space)
82 ?\" (submatch (1+ (not (in ?\")))) ?\")))
83 (set-version-in-file root "README" version
84 (rx (and "version" (1+ space)
85 (submatch (1+ (in "0-9."))))))
86 (set-version-in-file root "man/emacs.texi" version
87 (rx (and "EMACSVER" (1+ space)
88 (submatch (1+ (in "0-9."))))))
89 (set-version-in-file root "lispref/elisp.texi" version
90 (rx (and "EMACSVER" (1+ space)
91 (submatch (1+ (in "0-9."))))))
92 (set-version-in-file root "lib-src/makefile.w32-in" version
93 (rx (and "VERSION" (0+ space) "=" (0+ space)
94 (submatch (1+ (in "0-9."))))))
95 ;; nt/emacs.rc also contains the version number, but in an awkward
96 ;; format. It must contain four components, separated by commas, and
97 ;; in two places those commas are followed by space, in two other
98 ;; places they are not.
99 (let* ((version-components (append (split-string version "\\.")
100 '("0" "0")))
101 (comma-version
102 (concat (car version-components) ","
103 (cadr version-components) ","
104 (cadr (cdr version-components)) ","
105 (cadr (cdr (cdr version-components)))))
106 (comma-space-version
107 (concat (car version-components) ", "
108 (cadr version-components) ", "
109 (cadr (cdr version-components)) ", "
110 (cadr (cdr (cdr version-components))))))
111 (set-version-in-file root "nt/emacs.rc" comma-version
112 (rx (and "FILEVERSION" (1+ space)
113 (submatch (1+ (in "0-9,"))))))
114 (set-version-in-file root "nt/emacs.rc" comma-version
115 (rx (and "PRODUCTVERSION" (1+ space)
116 (submatch (1+ (in "0-9,"))))))
117 (set-version-in-file root "nt/emacs.rc" comma-space-version
118 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
119 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
120 (set-version-in-file root "nt/emacs.rc" comma-space-version
121 (rx (and "\"ProductVersion\"" (0+ space) ?,
122 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
123 "\\0\"")))
124 ;; Likewise for emacsclient.rc
125 (set-version-in-file root "nt/emacsclient.rc" comma-version
126 (rx (and "FILEVERSION" (1+ space)
127 (submatch (1+ (in "0-9,"))))))
128 (set-version-in-file root "nt/emacsclient.rc" comma-version
129 (rx (and "PRODUCTVERSION" (1+ space)
130 (submatch (1+ (in "0-9,"))))))
131 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
132 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
133 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
134 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
135 (rx (and "\"ProductVersion\"" (0+ space) ?,
136 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
137 "\\0\"")))
138 ;; Some files in the "mac" subdirectory also contain the version
139 ;; number.
140 (set-version-in-file
141 root "mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
142 version (rx (and "CFBundleShortVersionString" (0+ space) ?= (0+ space) ?\"
143 (submatch (1+ (in "0-9."))))))
144 (set-version-in-file
145 root "mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
146 version (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space) ?\"
147 (submatch (1+ (in "0-9."))))))
148 (set-version-in-file root "mac/src/Emacs.r" (car version-components)
149 (rx (and "GNU Emacs " (submatch (1+ (in "0-9")))
150 " for Mac OS")))
151 (set-version-in-file root "mac/src/Emacs.r" (car version-components)
152 (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\,
153 (0+ space) "/* Major revision in BCD */")))
154 (set-version-in-file root "mac/src/Emacs.r" (cadr version-components)
155 (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\,
156 (0+ space) "/* Minor revision in BCD */")))
157 (set-version-in-file root "mac/src/Emacs.r" (cadr (cdr version-components))
158 (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\,
159 (0+ space) "/* Non-final release # */")))
160 (set-version-in-file root "mac/src/Emacs.r" version
161 (rx (and (submatch (1+ (in "0-9."))) (0+ space) ?\" ?\,
162 (0+ space) "/* Short version number */")))
163 (set-version-in-file root "mac/src/Emacs.r" version
164 (rx (and "/* Short version number */" (0+ space) ?\"
165 (submatch (1+ (in "0-9."))))))
166 (let* ((third-component (string-to-number (cadr (cdr version-components))))
167 (release (cond ((>= third-component 90) "alpha")
168 ((>= third-component 50) "development")
169 (t "final"))))
170 (set-version-in-file
171 root "mac/src/Emacs.r" release
172 (rx (and (submatch (1+ (in "a-z"))) (0+ space) ?\, (0+ space)
173 "/* development, alpha, beta, or final (release) */"))))))
174
175 ;;; arch-tag: 4ea83636-2293-408b-884e-ad64f22a3bf5
176 ;; admin.el ends here.