Implement dots and dashes on Android
[emacs.git] / admin / upload-manuals
blob2e6d03e6bc6879bc26705cc355235887dd491504
1 #!/bin/bash
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/>.
25 ### Commentary:
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
33 ## Usage:
34 ## Call from the manual/ directory created by make-manual.
35 ## upload-manuals /path/to/cvs/checkout
37 ### Code:
39 source "${0%/*}/emacs-shell-lib"
41 usage ()
43 cat 1>&2 <<EOF
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.
48 Options:
49 -m: commit message to use (default "$message")
50 -n: dry-run (do not commit files)
51 EOF
52 exit 1
56 ## Parameters
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')
59 ## Defaults
60 cvs=cvs
61 message="Regenerate manuals for Emacs $version"
62 umessage=
64 while getopts ":hm:n" option ; do
65 case $option in
66 (h) usage ;;
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" ;;
77 esac
78 done
79 shift $(( --OPTIND ))
80 OPTIND=1
82 [ $# -eq 1 ] || usage
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"
90 webdir=$1
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/
100 cd $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
108 clist=
110 for f in $webdir/refcards/${fmt%.gz}/*.$fmt; do
112 s=${f#$webdir/}
114 if [ -e $s ]; then
115 mv $s $f
116 clist="$clist ${f##*/}"
117 else
118 echo "$s seems to be missing"
120 done
123 ## Check for new files.
124 new=
125 for f in refcards/${fmt%.gz}/*.$fmt; do
126 [ -e $f ] || break
127 new="$new $f"
128 clist="$clist ${f##*/}"
129 done
131 [ "$new" ] && mv $new $webdir/refcards/${fmt%.gz}/
133 [ "$clist" ] && (
134 cd $webdir
135 [ "$new" ] && {
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"
144 done # $fmt
147 echo "Doing non-html manuals..."
149 for fmt in info pdf ps texi; do
151 clist=
153 for f in $webdir/manual/$fmt/*; do
155 [ ${f##*/} = CVS ] && continue
157 s=$fmt/${f##*/}
159 if [ -e $s ]; then
160 mv $s $f
161 clist="$clist ${f##*/}"
162 else
163 case ${f##*/} in
164 *_7x9*.pdf) continue ;;
165 esac
167 echo "$s seems to be missing"
169 done
171 ## Check for new files.
172 new=
173 for f in $fmt/*.$fmt*; do
174 [ -e $f ] || break
175 new="$new $f"
176 clist="$clist ${f##*/}"
177 done
179 [ "$new" ] && mv $new $webdir/manual/$fmt/
181 [ "$clist" ] && (
182 cd $webdir/manual
183 [ "$new" ] && {
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"
188 cd $fmt
189 $cvs commit -m "$message" $clist || die "commit error"
192 done
195 echo "Doing tarred html..."
197 clist=
199 for f in $webdir/manual/*html*.tar*; do
201 s=${f##*/}
203 if [ -e $s ]; then
204 mv $s $f
205 clist="$clist ${f##*/}"
206 else
207 echo "$s seems to be missing"
209 done
211 ## Check for new files.
212 new=
213 for f in *html*.tar*; do
214 [ -e $f ] || break
215 new="$new $f"
216 clist="$clist ${f##*/}"
217 done
219 [ "$new" ] && mv $new $webdir/manual
221 [ "$clist" ] && (
222 cd $webdir/manual
223 [ "$new" ] && {
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...
233 new_manual () {
234 local t=eww
235 local i=$webdir/manual/$t.html # template
237 [ -r $i ] || die "Cannot read template $i"
239 local name o mono title
241 for name; do
243 name=${name##*/}
244 name=${name%.html}
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)
256 : ${title:?}
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\"./" \
266 -e "s/$t/$name/" \
267 -e "s/&copy;.* Free/\&copy; $(date +%Y) Free/" $i > $o
270 cd $webdir/manual
271 $cvs add ${o##*/} || die "add error for $o"
273 done
275 return 0
279 echo "Doing html_mono..."
281 clist=
283 for f in $webdir/manual/html_mono/*.html; do
285 s=${f##*manual/}
287 if [ -e $s ]; then
288 mv $s $f
289 clist="$clist ${f##*/}"
290 else
291 echo "$s seems to be missing"
293 done
295 ## Check for new files.
296 new=
297 for f in html_mono/*.html; do
298 [ -e $f ] || break
299 new="$new $f"
300 clist="$clist ${f##*/}"
301 done
303 [ "$new" ] && mv $new $webdir/manual/html_mono/
305 ## TODO: check for removed manuals.
307 [ "$clist" ] && (
308 cd $webdir/manual
309 [ "$new" ] && {
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"
315 cd html_mono
316 $cvs commit -m "$message" $clist || die "commit error"
320 echo "Doing html_node..."
322 for d in html_node/*; do
324 [ -e $d ] || break
326 echo "Doing $d..."
328 [ -e $webdir/manual/$d ] || {
329 echo "New directory: $d"
330 mkdir $webdir/manual/$d
332 cd $webdir/manual
333 $cvs add $d || die "add error"
337 new=
338 for f in $d/*.html; do
339 [ -e $webdir/manual/$f ] || new="$new ${f##*/}"
340 done
342 stale=
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##*/}"
348 done
351 mv $d/*.html $webdir/manual/$d/
354 cd $webdir/manual/$d
355 [ "$new" ] && {
356 echo "Adding new files: $new"
357 $cvs add $new || die "add error"
360 [ "$stale" ] && {
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"
369 done
372 echo "Checking for stray files..."
373 find -type f
376 echo "Finished"
378 exit 0