Commit | Line | Data |
---|---|---|
74499542 GM |
1 | ;;; admin.el --- utilities for Emacs administration |
2 | ||
a70c9a7a | 3 | ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
4e6835db | 4 | ;; Free Software Foundation, Inc. |
74499542 GM |
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 | |
4a9f99bd | 10 | ;; the Free Software Foundation; either version 3, or (at your option) |
74499542 GM |
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 | |
0d07bc90 LK |
20 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | ;; Boston, MA 02110-1301, USA. | |
74499542 GM |
22 | |
23 | ;;; Commentary: | |
24 | ||
54381691 LK |
25 | ;; add-release-logs Add ``Version X released'' change log entries. |
26 | ;; set-version Change Emacs version number in source tree. | |
a3045b7e GM |
27 | ;; set-copyright Change emacs short copyright string (eg as |
28 | ;; printed by --version) in source tree. | |
74499542 GM |
29 | |
30 | ;;; Code: | |
31 | ||
74499542 GM |
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: ") | |
3f4a4bdf | 36 | (setq root (expand-file-name root)) |
74499542 GM |
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)) | |
54381691 | 39 | (require 'add-log) |
74499542 GM |
40 | (let* ((logs (process-lines "find" root "-name" "ChangeLog")) |
41 | (entry (format "%s %s <%s>\n\n\t* Version %s released.\n\n" | |
3f4a4bdf FP |
42 | (funcall add-log-time-format) |
43 | (or add-log-full-name (user-full-name)) | |
44 | (or add-log-mailing-address user-mail-address) | |
45 | version))) | |
74499542 | 46 | (dolist (log logs) |
e568708b | 47 | (unless (string-match "/gnus/" log) |
74499542 GM |
48 | (find-file log) |
49 | (goto-char (point-min)) | |
50 | (insert entry))))) | |
51 | ||
74499542 GM |
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)) | |
58 | ||
74499542 GM |
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." | |
91ebb8c9 | 62 | (interactive "DEmacs root directory: \nsVersion number: ") |
74499542 GM |
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.")))))) | |
24bbe01e GM |
71 | (set-version-in-file root "configure.in" version |
72 | (rx (and "AC_INIT" (1+ (not (in ?,))) | |
73 | ?, (0+ space) | |
74 | (submatch (1+ (in "0-9.")))))) | |
75 | (set-version-in-file root "doc/emacs/emacs.texi" version | |
49e3fad2 LK |
76 | (rx (and "EMACSVER" (1+ space) |
77 | (submatch (1+ (in "0-9.")))))) | |
24bbe01e | 78 | (set-version-in-file root "doc/lispref/elisp.texi" version |
74499542 | 79 | (rx (and "EMACSVER" (1+ space) |
95f76284 | 80 | (submatch (1+ (in "0-9.")))))) |
1fe1ef05 JB |
81 | (set-version-in-file root "lib-src/makefile.w32-in" version |
82 | (rx (and "VERSION" (0+ space) "=" (0+ space) | |
83 | (submatch (1+ (in "0-9.")))))) | |
95f76284 JR |
84 | ;; nt/emacs.rc also contains the version number, but in an awkward |
85 | ;; format. It must contain four components, separated by commas, and | |
86 | ;; in two places those commas are followed by space, in two other | |
87 | ;; places they are not. | |
88 | (let* ((version-components (append (split-string version "\\.") | |
89 | '("0" "0"))) | |
90 | (comma-version | |
91 | (concat (car version-components) "," | |
92 | (cadr version-components) "," | |
d0834a5c | 93 | (cadr (cdr version-components)) "," |
95f76284 JR |
94 | (cadr (cdr (cdr version-components))))) |
95 | (comma-space-version | |
96 | (concat (car version-components) ", " | |
97 | (cadr version-components) ", " | |
d0834a5c | 98 | (cadr (cdr version-components)) ", " |
95f76284 JR |
99 | (cadr (cdr (cdr version-components)))))) |
100 | (set-version-in-file root "nt/emacs.rc" comma-version | |
101 | (rx (and "FILEVERSION" (1+ space) | |
102 | (submatch (1+ (in "0-9,")))))) | |
103 | (set-version-in-file root "nt/emacs.rc" comma-version | |
104 | (rx (and "PRODUCTVERSION" (1+ space) | |
105 | (submatch (1+ (in "0-9,")))))) | |
106 | (set-version-in-file root "nt/emacs.rc" comma-space-version | |
107 | (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space) | |
108 | ?\" (submatch (1+ (in "0-9, "))) "\\0\""))) | |
109 | (set-version-in-file root "nt/emacs.rc" comma-space-version | |
110 | (rx (and "\"ProductVersion\"" (0+ space) ?, | |
111 | (0+ space) ?\" (submatch (1+ (in "0-9, "))) | |
d0834a5c YM |
112 | "\\0\""))) |
113 | ;; Some files in the "mac" subdirectory also contain the version | |
114 | ;; number. | |
115 | (set-version-in-file | |
116 | root "mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings" | |
117 | version (rx (and "CFBundleShortVersionString" (0+ space) ?= (0+ space) ?\" | |
118 | (submatch (1+ (in "0-9.")))))) | |
119 | (set-version-in-file | |
120 | root "mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings" | |
121 | version (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space) ?\" | |
122 | (submatch (1+ (in "0-9.")))))) | |
123 | (set-version-in-file root "mac/src/Emacs.r" (car version-components) | |
124 | (rx (and "GNU Emacs " (submatch (1+ (in "0-9"))) | |
125 | " for Mac OS"))) | |
126 | (set-version-in-file root "mac/src/Emacs.r" (car version-components) | |
127 | (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\, | |
128 | (0+ space) "/* Major revision in BCD */"))) | |
129 | (set-version-in-file root "mac/src/Emacs.r" (cadr version-components) | |
130 | (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\, | |
131 | (0+ space) "/* Minor revision in BCD */"))) | |
132 | (set-version-in-file root "mac/src/Emacs.r" (cadr (cdr version-components)) | |
133 | (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\, | |
134 | (0+ space) "/* Non-final release # */"))) | |
135 | (set-version-in-file root "mac/src/Emacs.r" version | |
136 | (rx (and (submatch (1+ (in "0-9."))) (0+ space) ?\" ?\, | |
137 | (0+ space) "/* Short version number */"))) | |
138 | (set-version-in-file root "mac/src/Emacs.r" version | |
139 | (rx (and "/* Short version number */" (0+ space) ?\" | |
140 | (submatch (1+ (in "0-9.")))))) | |
141 | (let* ((third-component (string-to-number (cadr (cdr version-components)))) | |
142 | (release (cond ((>= third-component 90) "alpha") | |
143 | ((>= third-component 50) "development") | |
144 | (t "final")))) | |
145 | (set-version-in-file | |
146 | root "mac/src/Emacs.r" release | |
147 | (rx (and (submatch (1+ (in "a-z"))) (0+ space) ?\, (0+ space) | |
148 | "/* development, alpha, beta, or final (release) */")))))) | |
3f4a4bdf | 149 | |
a3045b7e GM |
150 | ;; Note this makes some assumptions about form of short copyright. |
151 | (defun set-copyright (root copyright) | |
152 | "Set Emacs short copyright to COPYRIGHT in relevant files under ROOT. | |
153 | Root must be the root of an Emacs source tree." | |
154 | (interactive (list | |
155 | (read-directory-name "Emacs root directory: " nil nil t) | |
156 | (read-string | |
157 | "Short copyright string: " | |
158 | (format "Copyright (C) %s Free Software Foundation, Inc." | |
159 | (format-time-string "%Y"))))) | |
160 | (unless (file-exists-p (expand-file-name "src/emacs.c" root)) | |
161 | (error "%s doesn't seem to be the root of an Emacs source tree" root)) | |
162 | (set-version-in-file root "lisp/version.el" copyright | |
163 | (rx (and "emacs-copyright" (0+ space) | |
164 | ?\" (submatch (1+ (not (in ?\")))) ?\"))) | |
a70c9a7a GM |
165 | (set-version-in-file root "lib-src/ebrowse.c" copyright |
166 | (rx (and "emacs_copyright" (0+ (not (in ?\"))) | |
167 | ?\" (submatch (1+ (not (in ?\")))) ?\"))) | |
a3045b7e GM |
168 | (set-version-in-file root "lib-src/etags.c" copyright |
169 | (rx (and "emacs_copyright" (0+ (not (in ?\"))) | |
170 | ?\" (submatch (1+ (not (in ?\")))) ?\"))) | |
171 | (set-version-in-file root "lib-src/rcs2log" copyright | |
172 | (rx (and "Copyright" (0+ space) ?= (0+ space) | |
173 | ?\' (submatch (1+ nonl))))) | |
174 | (set-version-in-file | |
175 | root "mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings" | |
176 | copyright (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space) ?\" | |
177 | (1+ anything) | |
178 | (submatch "Copyright" (1+ (not (in ?\"))))))) | |
179 | ;; This one is a nuisance, as it needs to be split over two lines. | |
180 | (string-match "\\(.*[0-9]\\{4\\} *\\)\\(.*\\)" copyright) | |
181 | (let ((csign "\\0xa9") | |
182 | (cyear (match-string 1 copyright)) ; "Copyright (C) 2007 " | |
183 | (owner (match-string 2 copyright))) ; "Free Software Foundation, Inc." | |
184 | (set-version-in-file root "mac/src/Emacs.r" | |
185 | (regexp-quote | |
186 | (replace-regexp-in-string "(C)" | |
187 | (regexp-quote csign) cyear)) | |
188 | (rx (and | |
189 | (submatch "Copyright" (0+ space) (eval csign) | |
190 | (0+ space) (= 4 num) | |
191 | (0+ (not (in ?\")))) ?\"))) | |
192 | (set-version-in-file root "mac/src/Emacs.r" owner | |
193 | (rx (and ?\" | |
194 | (submatch (1+ (not (in ?\")))) | |
195 | ?\" (0+ space) | |
196 | "/* Long version number */"))))) | |
197 | ||
69c52df1 GM |
198 | (provide 'admin) |
199 | ||
ab5796a9 | 200 | ;;; arch-tag: 4ea83636-2293-408b-884e-ad64f22a3bf5 |
74499542 | 201 | ;; admin.el ends here. |