3 ### upload-manuals - upload the Emacs manuals to the gnu.org website
5 ## Copyright 2018-2019 Free Software Foundation, Inc.
7 ## Author: Glenn Morris <rgm@gnu.org>
9 ## This file is part of GNU Emacs.
11 ## GNU Emacs is free software: you can redistribute it and/or modify
12 ## it under the terms of the GNU General Public License as published by
13 ## the Free Software Foundation, either version 3 of the License, or
14 ## (at your option) any later version.
16 ## GNU Emacs is distributed in the hope that it will be useful,
17 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ## GNU General Public License for more details.
21 ## You should have received a copy of the GNU General Public License
22 ## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
26 ## Run this on the output of make-manuals.
28 ## We assume you have already checked out a local copy of the website
29 ## following the instructions at
30 ## https://savannah.gnu.org/cvs/?group=emacs
33 ## Call from the manual/ directory created by make-manual.
34 ## upload-manuals /path/to/cvs/checkout
39 die
() # write error to stderr and exit
41 [ $# -gt 0 ] && echo "$PN: $@" >&2
45 PN
=${0##*/} # basename of script
50 Usage: ${PN} [-m message] [-n] /path/to/cvs/checkout
51 Upload the Emacs manuals to the gnu.org website.
52 Call this script from the manual/ directory created by make-manuals.
53 This script destructively modifies the source directory.
55 -m: commit message to use (default "$message")
56 -n: dry-run (do not commit files)
63 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')
67 message
="Regenerate manuals for Emacs $version"
70 while getopts ":hm:n" option
; do
74 (m
) umessage
=t
; message
="$OPTARG" ;;
76 (n
) cvs
="echo $cvs" ;;
78 (\?) die
"Bad option -$OPTARG" ;;
80 (:) die
"Option -$OPTARG requires an argument" ;;
82 (*) die
"getopts error" ;;
90 [ "$version$umessage" ] || \
91 die
"Could not get version to use for commit message"
95 [ -e $webdir/CVS
/Entries
] && [ -e $webdir/refcards
/pdf
/refcard.pdf
] || \
96 die
"$webdir does not look like a checkout of the Emacs webpages"
98 [ -e html_mono
/emacs.html
] && [ -e html_node
/emacs
/index.html
] || \
99 die
"Current directory does not like the manual/ directory"
102 echo "Doing refcards..."
104 mv refcards
/emacs-refcards.
tar.gz
$webdir/refcards
/
107 $cvs commit
-m "$message" emacs-refcards.
tar.gz || die
"commit error"
110 ## For refcards, we assume a missing file is due to a tex failure,
111 ## rather than a refcard that should be deleted.
112 for fmt in pdf ps.gz
; do
116 for f
in $webdir/refcards
/${fmt%.gz}/*.
$fmt; do
122 clist
="$clist ${f##*/}"
124 echo "$s seems to be missing"
129 ## Check for new files.
131 for f
in refcards
/${fmt%.gz}/*.
$fmt; do
134 clist
="$clist ${f##*/}"
137 [ "$new" ] && mv $new $webdir/refcards
/${fmt%.gz}/
142 echo "Adding new files: $new"
143 $cvs add
-kb $new || die
"add error"
144 echo "Remember to add new refcards to refcards/index.html"
146 cd refcards
/${fmt%.gz}
147 $cvs commit
-m "$message" $clist || die
"commit error"
153 echo "Doing non-html manuals..."
155 for fmt in info pdf ps texi
; do
159 for f
in $webdir/manual
/$fmt/*; do
161 [ ${f##*/} = CVS
] && continue
167 clist
="$clist ${f##*/}"
170 *_7x9
*.pdf
) continue ;;
173 echo "$s seems to be missing"
177 ## Check for new files.
179 for f
in $fmt/*.
$fmt*; do
182 clist
="$clist ${f##*/}"
185 [ "$new" ] && mv $new $webdir/manual
/$fmt/
190 echo "Adding new files: $new"
191 $cvs add
$new || die
"add error"
192 echo "Remember to add new files to the appropriate index pages"
195 $cvs commit
-m "$message" $clist || die
"commit error"
201 echo "Doing tarred html..."
205 for f
in $webdir/manual
/*html
*.
tar*; do
211 clist
="$clist ${f##*/}"
213 echo "$s seems to be missing"
217 ## Check for new files.
219 for f
in *html
*.
tar*; do
222 clist
="$clist ${f##*/}"
225 [ "$new" ] && mv $new $webdir/manual
230 echo "Adding new files: $new"
231 $cvs add
-kb $new || die
"add error"
232 echo "Remember to add new files to the appropriate index pages"
234 $cvs commit
-m "$message" $clist || die
"commit error"
238 ## This happens so rarely it would be less effort to do by hand...
241 local i
=$webdir/manual
/$t.html
# template
243 [ -r $i ] || die
"Cannot read template $i"
245 local name o mono title
252 o
=$webdir/manual
/$name.html
254 [ -e $o ] && die
"$o already exists"
256 mono
=$webdir/manual
/html_mono
/$name.html
258 [ -r $mono ] || die
"Cannot read $mono"
260 title
=$
(sed -n 's|^<title>\(.*\)</title>|\1|p' $mono)
264 echo "$title" |
grep -qi "Emacs" || title
="Emacs $title"
265 echo "$title" |
grep -qi "manual" || title
="$title Manual"
267 ## It is a pain to extract and insert a good "documenting...".
268 ## Improve it by hand if you care.
269 sed -e "s|^<title>.*\( - GNU Project\)|<title>$title\1|" \
270 -e "s|^<h2>.*|<h2>$title</h2>|" \
271 -e "s/^documenting.*/documenting \"$title\"./" \
273 -e "s/©.* Free/\© $(date +%Y) Free/" $i > $o
277 $cvs add
${o##*/} || die
"add error for $o"
285 echo "Doing html_mono..."
289 for f
in $webdir/manual
/html_mono
/*.html
; do
295 clist
="$clist ${f##*/}"
297 echo "$s seems to be missing"
301 ## Check for new files.
303 for f
in html_mono
/*.html
; do
306 clist
="$clist ${f##*/}"
309 [ "$new" ] && mv $new $webdir/manual
/html_mono
/
311 ## TODO: check for removed manuals.
314 cd $webdir/manual
/html_mono
316 echo "Adding new files: $new"
317 $cvs add
$new || die
"add error"
318 new_manual
$new || die
319 echo "Remember to add new entries to manual/index.html"
321 $cvs commit
-m "$message" $clist || die
"commit error"
325 echo "Doing html_node..."
327 for d
in html_node
/*; do
333 [ -e $webdir/manual
/$d ] ||
{
334 echo "New directory: $d"
335 mkdir
$webdir/manual
/$d
336 $cvs add
$webdir/manual
/$d || die
"add error"
340 for f
in $d/*.html
; do
341 [ -e $webdir/manual
/$f ] || new
="$new ${f##*/}"
345 for f
in $webdir/manual
/$d/*.html
; do
346 [ -e ${f#$webdir/manual/} ] || stale
="$stale ${f##*/}"
349 mv $d/*.html
$webdir/manual
/$d/
354 echo "Adding new files: $new"
355 $cvs add
$new || die
"add error"
359 echo "Removing stale files: $stale"
360 $cvs remove
-f $stale || die
"remove error"
363 ## -f: create a new revision even if no change.
364 $cvs commit
-f -m "$message" *.html
$stale || die
"commit error"
370 echo "Checking for stray files..."