3 ### upload-manuals - upload the Emacs manuals to the gnu.org website
5 ## Copyright 2018-2024 Free Software Foundation, Inc.
7 ## Author: Glenn Morris <rgm@gnu.org>
8 ## Maintainer: emacs-devel@gnu.org
10 ## This file is part of GNU Emacs.
12 ## GNU Emacs is free software: you can redistribute it and/or modify
13 ## it under the terms of the GNU General Public License as published by
14 ## the Free Software Foundation, either version 3 of the License, or
15 ## (at your option) any later version.
17 ## GNU Emacs is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ## GNU General Public License for more details.
22 ## You should have received a copy of the GNU General Public License
23 ## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
27 ## Run this on the output of make-manuals.
29 ## We assume you have already checked out a local copy of the website
30 ## following the instructions at
31 ## https://savannah.gnu.org/cvs/?group=emacs
34 ## Call from the manual/ directory created by make-manual.
35 ## upload-manuals /path/to/cvs/checkout
39 source "${0%/*}/emacs-shell-lib"
44 Usage: ${PN} [-m message] [-n] /path/to/cvs/checkout
45 Upload the Emacs manuals to the gnu.org website.
46 Call this script from the manual/ directory created by make-manuals.
47 This script destructively modifies the source directory.
49 -m: commit message to use (default "$message")
50 -n: dry-run (do not commit files)
57 version
=$
(gunzip
-c info
/emacs.info.gz
2> /dev
/null |
sed -n '0,/updated for Emacs version/s/.*updated for Emacs version \([0-9.]*\).*\.$/\1/p')
61 message
="Regenerate manuals for Emacs $version"
64 while getopts ":hm:n" option
; do
68 (m
) umessage
=t
; message
="$OPTARG" ;;
70 (n
) cvs
="echo $cvs" ;;
72 (\?) die
"Bad option -$OPTARG" ;;
74 (:) die
"Option -$OPTARG requires an argument" ;;
76 (*) die
"getopts error" ;;
84 [ -e html_mono
/emacs.html
] && [ -e html_node
/emacs
/index.html
] || \
85 die
"Current directory does not look like the manual/ directory"
87 [ "$version$umessage" ] || \
88 die
"Could not get version to use for commit message"
92 [ -e $webdir/CVS
/Entries
] && [ -e $webdir/refcards
/pdf
/refcard.pdf
] || \
93 die
"$webdir does not look like a checkout of the Emacs webpages"
96 echo "Doing refcards..."
98 mv refcards
/emacs-refcards.
tar.gz
$webdir/refcards
/
101 $cvs commit
-m "$message" emacs-refcards.
tar.gz || die
"commit error"
104 ## For refcards, we assume a missing file is due to a tex failure,
105 ## rather than a refcard that should be deleted.
106 for fmt in pdf ps.gz
; do
110 for f
in $webdir/refcards
/${fmt%.gz}/*.
$fmt; do
116 clist
="$clist ${f##*/}"
118 echo "$s seems to be missing"
123 ## Check for new files.
125 for f
in refcards
/${fmt%.gz}/*.
$fmt; do
128 clist
="$clist ${f##*/}"
131 [ "$new" ] && mv $new $webdir/refcards
/${fmt%.gz}/
136 echo "Adding new files: $new"
137 $cvs add
-kb $new || die
"add error"
138 echo "Remember to add new refcards to refcards/index.html"
140 cd refcards
/${fmt%.gz}
141 $cvs commit
-m "$message" $clist || die
"commit error"
147 echo "Doing non-html manuals..."
149 for fmt in info pdf ps texi
; do
153 for f
in $webdir/manual
/$fmt/*; do
155 [ ${f##*/} = CVS
] && continue
161 clist
="$clist ${f##*/}"
164 *_7x9
*.pdf
) continue ;;
167 echo "$s seems to be missing"
171 ## Check for new files.
173 for f
in $fmt/*.
$fmt*; do
176 clist
="$clist ${f##*/}"
179 [ "$new" ] && mv $new $webdir/manual
/$fmt/
184 echo "Adding new files: $new"
185 $cvs add
$new || die
"add error"
186 echo "Remember to add new files to the appropriate index pages"
189 $cvs commit
-m "$message" $clist || die
"commit error"
195 echo "Doing tarred html..."
199 for f
in $webdir/manual
/*html
*.
tar*; do
205 clist
="$clist ${f##*/}"
207 echo "$s seems to be missing"
211 ## Check for new files.
213 for f
in *html
*.
tar*; do
216 clist
="$clist ${f##*/}"
219 [ "$new" ] && mv $new $webdir/manual
224 echo "Adding new files: $new"
225 $cvs add
-kb $new || die
"add error"
226 echo "Remember to add new files to the appropriate index pages"
228 $cvs commit
-m "$message" $clist || die
"commit error"
232 ## This happens so rarely it would be less effort to do by hand...
235 local i
=$webdir/manual
/$t.html
# template
237 [ -r $i ] || die
"Cannot read template $i"
239 local name o mono title
246 o
=$webdir/manual
/$name.html
248 [ -e $o ] && die
"$o already exists"
250 mono
=$webdir/manual
/html_mono
/$name.html
252 [ -r $mono ] || die
"Cannot read $mono"
254 title
=$
(sed -n 's|^<title>\(.*\)</title>|\1|p' $mono)
258 echo "$title" |
grep -qi "Emacs" || title
="Emacs $title"
259 echo "$title" |
grep -qi "manual" || title
="$title Manual"
261 ## It is a pain to extract and insert a good "documenting...".
262 ## Improve it by hand if you care.
263 sed -e "s|^<title>.*\( - GNU Project\)|<title>$title\1|" \
264 -e "s|^<h2>.*|<h2>$title</h2>|" \
265 -e "s/^documenting.*/documenting \"$title\"./" \
267 -e "s/©.* Free/\© $(date +%Y) Free/" $i > $o
271 $cvs add
${o##*/} || die
"add error for $o"
279 echo "Doing html_mono..."
283 for f
in $webdir/manual
/html_mono
/*.html
; do
289 clist
="$clist ${f##*/}"
291 echo "$s seems to be missing"
295 ## Check for new files.
297 for f
in html_mono
/*.html
; do
300 clist
="$clist ${f##*/}"
303 [ "$new" ] && mv $new $webdir/manual
/html_mono
/
305 ## TODO: check for removed manuals.
310 echo "Adding new files: $new"
311 $cvs add
$new || die
"add error"
312 new_manual
$new || die
313 echo "Remember to add new entries to manual/index.html"
316 $cvs commit
-m "$message" $clist || die
"commit error"
320 echo "Doing html_node..."
322 for d
in html_node
/*; do
328 [ -e $webdir/manual
/$d ] ||
{
329 echo "New directory: $d"
330 mkdir
$webdir/manual
/$d
333 $cvs add
$d || die
"add error"
338 for f
in $d/*.html
; do
339 [ -e $webdir/manual
/$f ] || new
="$new ${f##*/}"
343 # Newly created directory will have no HTML files, so none can be
344 # "stale". But 'for' returns the original wildcard, so avoid that.
345 ls $webdir/manual
/$d/*.html
> /dev
/null
2>&1 && {
346 for f
in $webdir/manual
/$d/*.html
; do
347 [ -e ${f#$webdir/manual/} ] || stale
="$stale ${f##*/}"
351 mv $d/*.html
$webdir/manual
/$d/
356 echo "Adding new files: $new"
357 $cvs add
$new || die
"add error"
361 echo "Removing stale files: $stale"
362 $cvs remove
-f $stale || die
"remove error"
365 ## -f: create a new revision even if no change.
366 $cvs commit
-f -m "$message" *.html
$stale || die
"commit error"
372 echo "Checking for stray files..."