* doc/misc/eshell.texi: Fill most of the missing sections.
[emacs.git] / admin / admin.el
blob31dc74891ed7d6886d2b44197f6e00012b6b6ced
1 ;;; admin.el --- utilities for Emacs administration
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 ;; 2010, 2011, 2012 Free Software Foundation, Inc.
6 ;; This file is part of GNU Emacs.
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.
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.
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/>.
21 ;;; Commentary:
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.
28 ;;; Code:
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)))))
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))
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 "lisp/version.el" version
64 (rx (and "emacs-version" (0+ space)
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/emacs.texi" version
74 (rx (and "EMACSVER" (1+ space)
75 (submatch (1+ (in "0-9."))))))
76 (set-version-in-file root "doc/lispref/elisp.texi" version
77 (rx (and "EMACSVER" (1+ space)
78 (submatch (1+ (in "0-9."))))))
79 (set-version-in-file root "doc/lispref/vol1.texi" version
80 (rx (and "EMACSVER" (1+ space)
81 (submatch (1+ (in "0-9."))))))
82 (set-version-in-file root "doc/lispref/vol2.texi" version
83 (rx (and "EMACSVER" (1+ space)
84 (submatch (1+ (in "0-9."))))))
85 (set-version-in-file root "doc/lispref/book-spine.texinfo" version
86 (rx (and "Emacs Version" (1+ space)
87 (submatch (1+ (in "0-9."))))))
88 (set-version-in-file root "doc/man/emacs.1" version
89 (rx (and ".TH EMACS" (1+ not-newline)
90 "GNU Emacs" (1+ space)
91 (submatch (1+ (in "0-9."))))))
92 (set-version-in-file root "doc/misc/faq.texi" version
93 (rx (and "VER" (1+ space)
94 (submatch (1+ (in "0-9."))))))
95 (set-version-in-file root "lib-src/makefile.w32-in" version
96 (rx (and "VERSION" (0+ space) "=" (0+ space)
97 (submatch (1+ (in "0-9."))))))
98 ;; nt/emacs.rc also contains the version number, but in an awkward
99 ;; format. It must contain four components, separated by commas, and
100 ;; in two places those commas are followed by space, in two other
101 ;; places they are not.
102 (let* ((version-components (append (split-string version "\\.")
103 '("0" "0")))
104 (comma-version
105 (concat (car version-components) ","
106 (cadr version-components) ","
107 (cadr (cdr version-components)) ","
108 (cadr (cdr (cdr version-components)))))
109 (comma-space-version
110 (concat (car version-components) ", "
111 (cadr version-components) ", "
112 (cadr (cdr version-components)) ", "
113 (cadr (cdr (cdr version-components))))))
114 (set-version-in-file root "nt/emacs.rc" comma-version
115 (rx (and "FILEVERSION" (1+ space)
116 (submatch (1+ (in "0-9,"))))))
117 (set-version-in-file root "nt/emacs.rc" comma-version
118 (rx (and "PRODUCTVERSION" (1+ space)
119 (submatch (1+ (in "0-9,"))))))
120 (set-version-in-file root "nt/emacs.rc" comma-space-version
121 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
122 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
123 (set-version-in-file root "nt/emacs.rc" comma-space-version
124 (rx (and "\"ProductVersion\"" (0+ space) ?,
125 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
126 "\\0\"")))
127 ;; Likewise for emacsclient.rc
128 (set-version-in-file root "nt/emacsclient.rc" comma-version
129 (rx (and "FILEVERSION" (1+ space)
130 (submatch (1+ (in "0-9,"))))))
131 (set-version-in-file root "nt/emacsclient.rc" comma-version
132 (rx (and "PRODUCTVERSION" (1+ space)
133 (submatch (1+ (in "0-9,"))))))
134 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
135 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
136 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
137 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
138 (rx (and "\"ProductVersion\"" (0+ space) ?,
139 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
140 "\\0\""))))
141 ;; nextstep.
142 (set-version-in-file
143 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
144 version (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
145 (submatch (1+ (in "0-9."))))))
146 (set-version-in-file
147 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
148 version (rx (and "CFBundleShortVersionString" (1+ not-newline) ?\n
149 (0+ not-newline) "<string>" (0+ space)
150 (submatch (1+ (in "0-9."))))))
151 (set-version-in-file
152 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
153 version (rx (and "CFBundleShortVersionString" (0+ space) ?= (0+ space)
154 ?\" (0+ space) "Version" (1+ space)
155 (submatch (1+ (in "0-9."))))))
156 (set-version-in-file
157 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
158 version (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space)
159 ?\" (0+ space) "Emacs version" (1+ space)
160 (submatch (1+ (in "0-9."))))))
161 (set-version-in-file
162 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
163 version (rx (and "ApplicationRelease" (0+ space) ?= (0+ space)
164 ?\" (0+ space) (submatch (1+ (in "0-9."))))))
165 (set-version-in-file
166 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
167 version (rx (and "FullVersionID" (0+ space) ?= (0+ space)
168 ?\" (0+ space) "Emacs" (1+ space)
169 (submatch (1+ (in "0-9."))))))
170 (set-version-in-file
171 root "nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop"
172 version (rx (and "Version=" (submatch (1+ (in "0-9.")))))))
174 ;; Note this makes some assumptions about form of short copyright.
175 (defun set-copyright (root copyright)
176 "Set Emacs short copyright to COPYRIGHT in relevant files under ROOT.
177 Root must be the root of an Emacs source tree."
178 (interactive (list
179 (read-directory-name "Emacs root directory: " nil nil t)
180 (read-string
181 "Short copyright string: "
182 (format "Copyright (C) %s Free Software Foundation, Inc."
183 (format-time-string "%Y")))))
184 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
185 (error "%s doesn't seem to be the root of an Emacs source tree" root))
186 (set-version-in-file root "lisp/version.el" copyright
187 (rx (and "emacs-copyright" (0+ space)
188 ?\" (submatch (1+ (not (in ?\")))) ?\")))
189 (set-version-in-file root "lib-src/ebrowse.c" copyright
190 (rx (and "emacs_copyright" (0+ (not (in ?\")))
191 ?\" (submatch (1+ (not (in ?\")))) ?\")))
192 (set-version-in-file root "lib-src/etags.c" copyright
193 (rx (and "emacs_copyright" (0+ (not (in ?\")))
194 ?\" (submatch (1+ (not (in ?\")))) ?\")))
195 (set-version-in-file root "lib-src/rcs2log" copyright
196 (rx (and "Copyright" (0+ space) ?= (0+ space)
197 ?\' (submatch (1+ nonl)))))
198 ;; This one is a nuisance, as it needs to be split over two lines.
199 (string-match "\\(.*[0-9]\\{4\\} *\\)\\(.*\\)" copyright)
200 ;; nextstep.
201 (set-version-in-file
202 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
203 copyright (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
204 (1+ (in "0-9.")) (1+ space)
205 (submatch (1+ (not (in ?\<)))))))
206 (set-version-in-file
207 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
208 copyright (rx (and "NSHumanReadableCopyright" (0+ space) ?\= (0+ space)
209 ?\" (submatch (1+ (not (in ?\")))))))
210 (set-version-in-file
211 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
212 copyright (rx (and "Copyright" (0+ space) ?\= (0+ space)
213 ?\" (submatch (1+ (not (in ?\")))))))
214 (when (string-match "\\([0-9]\\{4\\}\\)" copyright)
215 (setq copyright (match-string 1 copyright))
216 (dolist (file (directory-files (expand-file-name "etc/refcards" root)
217 t "\\.tex\\'"))
218 (unless (string-match "gnus-refcard\\.tex" file)
219 (set-version-in-file
220 root file copyright
221 (concat (if (string-match "ru-refcard\\.tex" file)
222 "\\\\newcommand{\\\\cyear}\\[0\\]{"
223 "\\\\def\\\\year{")
224 "\\([0-9]\\{4\\}\\)}.+%.+copyright year"))))))
226 (provide 'admin)
228 ;;; admin.el ends here