]> code.delx.au - gnu-emacs/blob - admin/admin.el
Merge from emacs-23
[gnu-emacs] / admin / admin.el
1 ;;; admin.el --- utilities for Emacs administration
2
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 ;; 2010, 2011 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 of the License, or
11 ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; add-release-logs Add ``Version X released'' change log entries.
24 ;; set-version Change Emacs version number in source tree.
25 ;; set-copyright Change emacs short copyright string (eg as
26 ;; printed by --version) in source tree.
27
28 ;;; Code:
29
30 (defun add-release-logs (root version)
31 "Add \"Version VERSION released.\" change log entries in ROOT.
32 Root must be the root of an Emacs source tree."
33 (interactive "DEmacs root directory: \nNVersion number: ")
34 (setq root (expand-file-name root))
35 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
36 (error "%s doesn't seem to be the root of an Emacs source tree" root))
37 (require 'add-log)
38 (let* ((logs (process-lines "find" root "-name" "ChangeLog"))
39 (entry (format "%s %s <%s>\n\n\t* Version %s released.\n\n"
40 (funcall add-log-time-format)
41 (or add-log-full-name (user-full-name))
42 (or add-log-mailing-address user-mail-address)
43 version)))
44 (dolist (log logs)
45 (unless (string-match "/gnus/" log)
46 (find-file log)
47 (goto-char (point-min))
48 (insert entry)))))
49
50 (defun set-version-in-file (root file version rx)
51 (find-file (expand-file-name file root))
52 (goto-char (point-min))
53 (unless (re-search-forward rx nil t)
54 (error "Version not found in %s" file))
55 (replace-match (format "%s" version) nil nil nil 1))
56
57 (defun set-version (root version)
58 "Set Emacs version to VERSION in relevant files under ROOT.
59 Root must be the root of an Emacs source tree."
60 (interactive "DEmacs root directory: \nsVersion number: ")
61 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
62 (error "%s doesn't seem to be the root of an Emacs source tree" root))
63 (set-version-in-file root "src/emacs.c" version
64 (rx (and "emacs_version" (0+ (not (in ?\")))
65 ?\" (submatch (1+ (not (in ?\")))) ?\")))
66 (set-version-in-file root "README" version
67 (rx (and "version" (1+ space)
68 (submatch (1+ (in "0-9."))))))
69 (set-version-in-file root "configure.in" version
70 (rx (and "AC_INIT" (1+ (not (in ?,)))
71 ?, (0+ space)
72 (submatch (1+ (in "0-9."))))))
73 (set-version-in-file root "doc/emacs/emacsver.texi" version
74 (rx (and "EMACSVER" (1+ space)
75 (submatch (1+ (in "0-9."))))))
76 (set-version-in-file root "doc/man/emacs.1" version
77 (rx (and ".TH EMACS" (1+ not-newline)
78 "GNU Emacs" (1+ space)
79 (submatch (1+ (in "0-9."))))))
80 (set-version-in-file root "lib-src/makefile.w32-in" version
81 (rx (and "VERSION" (0+ space) "=" (0+ space)
82 (submatch (1+ (in "0-9."))))))
83 (set-version-in-file root "nt/makefile.w32-in" version
84 (rx (and "VERSION" (0+ space) "=" (0+ space)
85 (submatch (1+ (in "0-9."))))))
86 ;; nt/emacs.rc also contains the version number, but in an awkward
87 ;; format. It must contain four components, separated by commas, and
88 ;; in two places those commas are followed by space, in two other
89 ;; places they are not.
90 (let* ((version-components (append (split-string version "\\.")
91 '("0" "0")))
92 (comma-version
93 (concat (car version-components) ","
94 (cadr version-components) ","
95 (cadr (cdr version-components)) ","
96 (cadr (cdr (cdr version-components)))))
97 (comma-space-version
98 (concat (car version-components) ", "
99 (cadr version-components) ", "
100 (cadr (cdr version-components)) ", "
101 (cadr (cdr (cdr version-components))))))
102 (set-version-in-file root "nt/emacs.rc" comma-version
103 (rx (and "FILEVERSION" (1+ space)
104 (submatch (1+ (in "0-9,"))))))
105 (set-version-in-file root "nt/emacs.rc" comma-version
106 (rx (and "PRODUCTVERSION" (1+ space)
107 (submatch (1+ (in "0-9,"))))))
108 (set-version-in-file root "nt/emacs.rc" comma-space-version
109 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
110 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
111 (set-version-in-file root "nt/emacs.rc" comma-space-version
112 (rx (and "\"ProductVersion\"" (0+ space) ?,
113 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
114 "\\0\"")))
115 ;; Likewise for emacsclient.rc
116 (set-version-in-file root "nt/emacsclient.rc" comma-version
117 (rx (and "FILEVERSION" (1+ space)
118 (submatch (1+ (in "0-9,"))))))
119 (set-version-in-file root "nt/emacsclient.rc" comma-version
120 (rx (and "PRODUCTVERSION" (1+ space)
121 (submatch (1+ (in "0-9,"))))))
122 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
123 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
124 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
125 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
126 (rx (and "\"ProductVersion\"" (0+ space) ?,
127 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
128 "\\0\""))))
129 ;; nextstep.
130 (set-version-in-file
131 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
132 version (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
133 (submatch (1+ (in "0-9."))))))
134 (set-version-in-file
135 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
136 version (rx (and "CFBundleShortVersionString" (1+ not-newline) ?\n
137 (0+ not-newline) "<string>" (0+ space)
138 (submatch (1+ (in "0-9."))))))
139 (set-version-in-file
140 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
141 version (rx (and "CFBundleShortVersionString" (0+ space) ?= (0+ space)
142 ?\" (0+ space) "Version" (1+ space)
143 (submatch (1+ (in "0-9."))))))
144 (set-version-in-file
145 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
146 version (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space)
147 ?\" (0+ space) "Emacs version" (1+ space)
148 (submatch (1+ (in "0-9."))))))
149 (set-version-in-file
150 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
151 version (rx (and "ApplicationRelease" (0+ space) ?= (0+ space)
152 ?\" (0+ space) (submatch (1+ (in "0-9."))))))
153 (set-version-in-file
154 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
155 version (rx (and "FullVersionID" (0+ space) ?= (0+ space)
156 ?\" (0+ space) "Emacs" (1+ space)
157 (submatch (1+ (in "0-9."))))))
158 (set-version-in-file
159 root "nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop"
160 version (rx (and "Version=" (submatch (1+ (in "0-9.")))))))
161
162 ;; Note this makes some assumptions about form of short copyright.
163 (defun set-copyright (root copyright)
164 "Set Emacs short copyright to COPYRIGHT in relevant files under ROOT.
165 Root must be the root of an Emacs source tree."
166 (interactive (list
167 (read-directory-name "Emacs root directory: " nil nil t)
168 (read-string
169 "Short copyright string: "
170 (format "Copyright (C) %s Free Software Foundation, Inc."
171 (format-time-string "%Y")))))
172 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
173 (error "%s doesn't seem to be the root of an Emacs source tree" root))
174 (set-version-in-file root "src/emacs.c" copyright
175 (rx (and "emacs_copyright" (0+ (not (in ?\")))
176 ?\" (submatch (1+ (not (in ?\")))) ?\")))
177 (set-version-in-file root "lib-src/ebrowse.c" copyright
178 (rx (and "emacs_copyright" (0+ (not (in ?\")))
179 ?\" (submatch (1+ (not (in ?\")))) ?\")))
180 (set-version-in-file root "lib-src/etags.c" copyright
181 (rx (and "emacs_copyright" (0+ (not (in ?\")))
182 ?\" (submatch (1+ (not (in ?\")))) ?\")))
183 (set-version-in-file root "lib-src/rcs2log" copyright
184 (rx (and "Copyright" (0+ space) ?= (0+ space)
185 ?\' (submatch (1+ nonl)))))
186 ;; This one is a nuisance, as it needs to be split over two lines.
187 (string-match "\\(.*[0-9]\\{4\\} *\\)\\(.*\\)" copyright)
188 ;; nextstep.
189 (set-version-in-file
190 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
191 copyright (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
192 (1+ (in "0-9.")) (1+ space)
193 (submatch (1+ (not (in ?\<)))))))
194 (set-version-in-file
195 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
196 copyright (rx (and "NSHumanReadableCopyright" (0+ space) ?\= (0+ space)
197 ?\" (submatch (1+ (not (in ?\")))))))
198 (set-version-in-file
199 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
200 copyright (rx (and "Copyright" (0+ space) ?\= (0+ space)
201 ?\" (submatch (1+ (not (in ?\")))))))
202 (when (string-match "\\([0-9]\\{4\\}\\)" copyright)
203 (setq copyright (match-string 1 copyright))
204 (dolist (file (directory-files (expand-file-name "etc/refcards" root)
205 t "\\.tex\\'"))
206 (unless (string-match "gnus-refcard\\.tex" file)
207 (set-version-in-file
208 root file copyright
209 (concat (if (string-match "ru-refcard\\.tex" file)
210 "\\\\newcommand{\\\\cyear}\\[0\\]{"
211 "\\\\def\\\\year{")
212 "\\([0-9]\\{4\\}\\)}.+%.+copyright year"))))))
213
214 (provide 'admin)
215
216 ;;; admin.el ends here