1 ;;; admin.el --- utilities for Emacs administration
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
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, or (at your option)
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; 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.
25 ;; add-release-logs Add ``Version X released'' change log entries.
26 ;; set-version Change Emacs version number in source tree.
27 ;; set-copyright Change emacs short copyright string (eg as
28 ;; printed by --version) in source tree.
32 (defun add-release-logs (root version
)
33 "Add \"Version VERSION released.\" change log entries in ROOT.
34 Root must be the root of an Emacs source tree."
35 (interactive "DEmacs root directory: \nNVersion number: ")
36 (setq root
(expand-file-name root
))
37 (unless (file-exists-p (expand-file-name "src/emacs.c" root
))
38 (error "%s doesn't seem to be the root of an Emacs source tree" root
))
40 (let* ((logs (process-lines "find" root
"-name" "ChangeLog"))
41 (entry (format "%s %s <%s>\n\n\t* Version %s released.\n\n"
42 (funcall add-log-time-format
)
43 (or add-log-full-name
(user-full-name))
44 (or add-log-mailing-address user-mail-address
)
47 (unless (string-match "/gnus/" log
)
49 (goto-char (point-min))
52 (defun set-version-in-file (root file version rx
)
53 (find-file (expand-file-name file root
))
54 (goto-char (point-min))
55 (unless (re-search-forward rx nil t
)
56 (error "Version not found in %s" file
))
57 (replace-match (format "%s" version
) nil nil nil
1))
59 (defun set-version (root version
)
60 "Set Emacs version to VERSION in relevant files under ROOT.
61 Root must be the root of an Emacs source tree."
62 (interactive "DEmacs root directory: \nsVersion number: ")
63 (unless (file-exists-p (expand-file-name "src/emacs.c" root
))
64 (error "%s doesn't seem to be the root of an Emacs source tree" root
))
65 (set-version-in-file root
"lisp/version.el" version
66 (rx (and "emacs-version" (0+ space
)
67 ?
\" (submatch (1+ (not (in ?
\")))) ?
\")))
68 (set-version-in-file root
"README" version
69 (rx (and "version" (1+ space
)
70 (submatch (1+ (in "0-9."))))))
71 (set-version-in-file root
"man/emacs.texi" version
72 (rx (and "EMACSVER" (1+ space
)
73 (submatch (1+ (in "0-9."))))))
74 (set-version-in-file root
"lispref/elisp.texi" version
75 (rx (and "EMACSVER" (1+ space
)
76 (submatch (1+ (in "0-9."))))))
77 (set-version-in-file root
"lib-src/makefile.w32-in" version
78 (rx (and "VERSION" (0+ space
) "=" (0+ space
)
79 (submatch (1+ (in "0-9."))))))
80 ;; nt/emacs.rc also contains the version number, but in an awkward
81 ;; format. It must contain four components, separated by commas, and
82 ;; in two places those commas are followed by space, in two other
83 ;; places they are not.
84 (let* ((version-components (append (split-string version
"\\.")
87 (concat (car version-components
) ","
88 (cadr version-components
) ","
89 (cadr (cdr version-components
)) ","
90 (cadr (cdr (cdr version-components
)))))
92 (concat (car version-components
) ", "
93 (cadr version-components
) ", "
94 (cadr (cdr version-components
)) ", "
95 (cadr (cdr (cdr version-components
))))))
96 (set-version-in-file root
"nt/emacs.rc" comma-version
97 (rx (and "FILEVERSION" (1+ space
)
98 (submatch (1+ (in "0-9,"))))))
99 (set-version-in-file root
"nt/emacs.rc" comma-version
100 (rx (and "PRODUCTVERSION" (1+ space
)
101 (submatch (1+ (in "0-9,"))))))
102 (set-version-in-file root
"nt/emacs.rc" comma-space-version
103 (rx (and "\"FileVersion\"" (0+ space
) ?
, (0+ space
)
104 ?
\" (submatch (1+ (in "0-9, "))) "\\0\"")))
105 (set-version-in-file root
"nt/emacs.rc" comma-space-version
106 (rx (and "\"ProductVersion\"" (0+ space
) ?
,
107 (0+ space
) ?
\" (submatch (1+ (in "0-9, ")))
109 ;; Some files in the "mac" subdirectory also contain the version
112 root
"mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
113 version
(rx (and "CFBundleShortVersionString" (0+ space
) ?
= (0+ space
) ?
\"
114 (submatch (1+ (in "0-9."))))))
116 root
"mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
117 version
(rx (and "CFBundleGetInfoString" (0+ space
) ?
= (0+ space
) ?
\"
118 (submatch (1+ (in "0-9."))))))
119 (set-version-in-file root
"mac/src/Emacs.r" (car version-components
)
120 (rx (and "GNU Emacs " (submatch (1+ (in "0-9")))
122 (set-version-in-file root
"mac/src/Emacs.r" (car version-components
)
123 (rx (and (submatch (1+ (in "0-9"))) (0+ space
) ?\
,
124 (0+ space
) "/* Major revision in BCD */")))
125 (set-version-in-file root
"mac/src/Emacs.r" (cadr version-components
)
126 (rx (and (submatch (1+ (in "0-9"))) (0+ space
) ?\
,
127 (0+ space
) "/* Minor revision in BCD */")))
128 (set-version-in-file root
"mac/src/Emacs.r" (cadr (cdr version-components
))
129 (rx (and (submatch (1+ (in "0-9"))) (0+ space
) ?\
,
130 (0+ space
) "/* Non-final release # */")))
131 (set-version-in-file root
"mac/src/Emacs.r" version
132 (rx (and (submatch (1+ (in "0-9."))) (0+ space
) ?
\" ?\
,
133 (0+ space
) "/* Short version number */")))
134 (set-version-in-file root
"mac/src/Emacs.r" version
135 (rx (and "/* Short version number */" (0+ space
) ?
\"
136 (submatch (1+ (in "0-9."))))))
137 (let* ((third-component (string-to-number (cadr (cdr version-components
))))
138 (release (cond ((>= third-component
90) "alpha")
139 ((>= third-component
50) "development")
142 root
"mac/src/Emacs.r" release
143 (rx (and (submatch (1+ (in "a-z"))) (0+ space
) ?\
, (0+ space
)
144 "/* development, alpha, beta, or final (release) */"))))))
146 ;; Note this makes some assumptions about form of short copyright.
147 (defun set-copyright (root copyright
)
148 "Set Emacs short copyright to COPYRIGHT in relevant files under ROOT.
149 Root must be the root of an Emacs source tree."
151 (read-directory-name "Emacs root directory: " nil nil t
)
153 "Short copyright string: "
154 (format "Copyright (C) %s Free Software Foundation, Inc."
155 (format-time-string "%Y")))))
156 (unless (file-exists-p (expand-file-name "src/emacs.c" root
))
157 (error "%s doesn't seem to be the root of an Emacs source tree" root
))
158 (set-version-in-file root
"lisp/version.el" copyright
159 (rx (and "emacs-copyright" (0+ space
)
160 ?
\" (submatch (1+ (not (in ?
\")))) ?
\")))
161 (set-version-in-file root
"lib-src/etags.c" copyright
162 (rx (and "emacs_copyright" (0+ (not (in ?
\")))
163 ?
\" (submatch (1+ (not (in ?
\")))) ?
\")))
164 (set-version-in-file root
"lib-src/rcs2log" copyright
165 (rx (and "Copyright" (0+ space
) ?
= (0+ space
)
166 ?
\' (submatch (1+ nonl
)))))
168 root
"mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
169 copyright
(rx (and "CFBundleGetInfoString" (0+ space
) ?
= (0+ space
) ?
\"
171 (submatch "Copyright" (1+ (not (in ?
\")))))))
172 ;; This one is a nuisance, as it needs to be split over two lines.
173 (string-match "\\(.*[0-9]\\{4\\} *\\)\\(.*\\)" copyright
)
174 (let ((csign "\\0xa9")
175 (cyear (match-string 1 copyright
)) ; "Copyright (C) 2007 "
176 (owner (match-string 2 copyright
))) ; "Free Software Foundation, Inc."
177 (set-version-in-file root
"mac/src/Emacs.r"
179 (replace-regexp-in-string "(C)"
180 (regexp-quote csign
) cyear
))
182 (submatch "Copyright" (0+ space
) (eval csign
)
184 (0+ (not (in ?
\")))) ?
\")))
185 (set-version-in-file root
"mac/src/Emacs.r" owner
187 (submatch (1+ (not (in ?
\"))))
189 "/* Long version number */")))))
193 ;;; arch-tag: 4ea83636-2293-408b-884e-ad64f22a3bf5
194 ;; admin.el ends here.