1 ;;; admin.el --- utilities for Emacs administration
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 ;; 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/>.
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.
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
))
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
)
45 (unless (string-match "/gnus/" log
)
47 (goto-char (point-min))
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 ?
,)))
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/man/emacs.1" version
80 (rx (and ".TH EMACS" (1+ not-newline
)
81 "GNU Emacs" (1+ space
)
82 (submatch (1+ (in "0-9."))))))
83 (set-version-in-file root
"doc/misc/faq.texi" version
84 (rx (and "VER" (1+ space
)
85 (submatch (1+ (in "0-9."))))))
86 (set-version-in-file root
"lib-src/makefile.w32-in" version
87 (rx (and "VERSION" (0+ space
) "=" (0+ space
)
88 (submatch (1+ (in "0-9."))))))
89 ;; nt/emacs.rc also contains the version number, but in an awkward
90 ;; format. It must contain four components, separated by commas, and
91 ;; in two places those commas are followed by space, in two other
92 ;; places they are not.
93 (let* ((version-components (append (split-string version
"\\.")
96 (concat (car version-components
) ","
97 (cadr version-components
) ","
98 (cadr (cdr version-components
)) ","
99 (cadr (cdr (cdr version-components
)))))
101 (concat (car version-components
) ", "
102 (cadr version-components
) ", "
103 (cadr (cdr version-components
)) ", "
104 (cadr (cdr (cdr version-components
))))))
105 (set-version-in-file root
"nt/emacs.rc" comma-version
106 (rx (and "FILEVERSION" (1+ space
)
107 (submatch (1+ (in "0-9,"))))))
108 (set-version-in-file root
"nt/emacs.rc" comma-version
109 (rx (and "PRODUCTVERSION" (1+ space
)
110 (submatch (1+ (in "0-9,"))))))
111 (set-version-in-file root
"nt/emacs.rc" comma-space-version
112 (rx (and "\"FileVersion\"" (0+ space
) ?
, (0+ space
)
113 ?
\" (submatch (1+ (in "0-9, "))) "\\0\"")))
114 (set-version-in-file root
"nt/emacs.rc" comma-space-version
115 (rx (and "\"ProductVersion\"" (0+ space
) ?
,
116 (0+ space
) ?
\" (submatch (1+ (in "0-9, ")))
118 ;; Some files in the "mac" subdirectory also contain the version
121 root
"mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
122 version
(rx (and "CFBundleShortVersionString" (0+ space
) ?
= (0+ space
) ?
\"
123 (submatch (1+ (in "0-9."))))))
125 root
"mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
126 version
(rx (and "CFBundleGetInfoString" (0+ space
) ?
= (0+ space
) ?
\"
127 (submatch (1+ (in "0-9."))))))
128 (set-version-in-file root
"mac/src/Emacs.r" (car version-components
)
129 (rx (and "GNU Emacs " (submatch (1+ (in "0-9")))
131 (set-version-in-file root
"mac/src/Emacs.r" (car version-components
)
132 (rx (and (submatch (1+ (in "0-9"))) (0+ space
) ?\
,
133 (0+ space
) "/* Major revision in BCD */")))
134 (set-version-in-file root
"mac/src/Emacs.r" (cadr version-components
)
135 (rx (and (submatch (1+ (in "0-9"))) (0+ space
) ?\
,
136 (0+ space
) "/* Minor revision in BCD */")))
137 (set-version-in-file root
"mac/src/Emacs.r" (cadr (cdr version-components
))
138 (rx (and (submatch (1+ (in "0-9"))) (0+ space
) ?\
,
139 (0+ space
) "/* Non-final release # */")))
140 (set-version-in-file root
"mac/src/Emacs.r" version
141 (rx (and (submatch (1+ (in "0-9."))) (0+ space
) ?
\" ?\
,
142 (0+ space
) "/* Short version number */")))
143 (set-version-in-file root
"mac/src/Emacs.r" version
144 (rx (and "/* Short version number */" (0+ space
) ?
\"
145 (submatch (1+ (in "0-9."))))))
146 (let* ((third-component (string-to-number (cadr (cdr version-components
))))
147 (release (cond ((>= third-component
90) "alpha")
148 ((>= third-component
50) "development")
151 root
"mac/src/Emacs.r" release
152 (rx (and (submatch (1+ (in "a-z"))) (0+ space
) ?\
, (0+ space
)
153 "/* development, alpha, beta, or final (release) */"))))))
155 ;; Note this makes some assumptions about form of short copyright.
156 ;; FIXME add the \year in the refcards/*.tex files.
157 (defun set-copyright (root copyright
)
158 "Set Emacs short copyright to COPYRIGHT in relevant files under ROOT.
159 Root must be the root of an Emacs source tree."
161 (read-directory-name "Emacs root directory: " nil nil t
)
163 "Short copyright string: "
164 (format "Copyright (C) %s Free Software Foundation, Inc."
165 (format-time-string "%Y")))))
166 (unless (file-exists-p (expand-file-name "src/emacs.c" root
))
167 (error "%s doesn't seem to be the root of an Emacs source tree" root
))
168 (set-version-in-file root
"lisp/version.el" copyright
169 (rx (and "emacs-copyright" (0+ space
)
170 ?
\" (submatch (1+ (not (in ?
\")))) ?
\")))
171 (set-version-in-file root
"lib-src/ebrowse.c" copyright
172 (rx (and "emacs_copyright" (0+ (not (in ?
\")))
173 ?
\" (submatch (1+ (not (in ?
\")))) ?
\")))
174 (set-version-in-file root
"lib-src/etags.c" copyright
175 (rx (and "emacs_copyright" (0+ (not (in ?
\")))
176 ?
\" (submatch (1+ (not (in ?
\")))) ?
\")))
177 (set-version-in-file root
"lib-src/rcs2log" copyright
178 (rx (and "Copyright" (0+ space
) ?
= (0+ space
)
179 ?
\' (submatch (1+ nonl
)))))
181 root
"mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
182 copyright
(rx (and "CFBundleGetInfoString" (0+ space
) ?
= (0+ space
) ?
\"
184 (submatch "Copyright" (1+ (not (in ?
\")))))))
185 ;; This one is a nuisance, as it needs to be split over two lines.
186 (string-match "\\(.*[0-9]\\{4\\} *\\)\\(.*\\)" copyright
)
187 (let ((csign "\\0xa9")
188 (cyear (match-string 1 copyright
)) ; "Copyright (C) 2007 "
189 (owner (match-string 2 copyright
))) ; "Free Software Foundation, Inc."
190 (set-version-in-file root
"mac/src/Emacs.r"
192 (replace-regexp-in-string "(C)"
193 (regexp-quote csign
) cyear
))
195 (submatch "Copyright" (0+ space
) (eval csign
)
197 (0+ (not (in ?
\")))) ?
\")))
198 (set-version-in-file root
"mac/src/Emacs.r" owner
200 (submatch (1+ (not (in ?
\"))))
202 "/* Long version number */")))))
206 ;;; arch-tag: 4ea83636-2293-408b-884e-ad64f22a3bf5
207 ;; admin.el ends here.