* update_web_docs: Allow for the same file name in different
[official-gcc.git] / maintainer-scripts / update_web_docs
blob6872a4a329d9c2896fd4b9da81316691c2fde741
1 #!/bin/sh -x
3 # Run this from /tmp.
4 CVSROOT=/cvs/gcc
5 export CVSROOT
7 PATH=/usr/local/bin:$PATH
9 WWWBASE=/www/gcc/htdocs
10 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
11 WWWPREPROCESS='/www/gcc/bin/preprocess -r'
13 # Process options -rrelease and -ddirectory
14 RELEASE=""
15 SUBDIR=""
17 while [ $# -gt 0 ]; do
18 case $1 in
19 -r*)
20 if [ -n "$RELEASE" ]; then
21 echo "Multiple releases specified" >&2
22 exit 1
24 RELEASE="${1#-r}"
25 if [ -z "$RELEASE" ]; then
26 shift
27 RELEASE="$1"
28 if [ -z "$RELEASE" ]; then
29 echo "No release specified with -r" >&2
30 exit 1
34 -d*)
35 if [ -n "$SUBDIR" ]; then
36 echo "Multiple subdirectories specified" >&2
37 exit 1
39 SUBDIR="${1#-d}"
40 if [ -z "$SUBDIR" ]; then
41 shift
42 SUBDIR="$1"
43 if [ -z "$SUBDIR" ]; then
44 echo "No subdirectory specified with -d" >&2
45 exit 1
50 echo "Unknown argument \"$1\"" >&2
51 exit 1
53 esac
54 shift
55 done
57 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
58 echo "Release specified without subdirectory" >&2
59 exit 1
62 if [ -z "$SUBDIR" ]; then
63 DOCSDIR=$WWWBASE/onlinedocs
64 else
65 DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
68 if [ ! -d $DOCSDIR ]; then
69 mkdir $DOCSDIR
72 if [ -z "$RELEASE" ]; then
73 RELEASE=HEAD
74 DO_THANKS_HTML=y
75 else
76 DO_THANKS_HTML=n
79 WORKDIR=/tmp/gcc-doc-update.$$
81 /bin/rm -rf $WORKDIR
82 /bin/mkdir $WORKDIR
83 cd $WORKDIR
85 # Find all the texi files in the repository, except those in directories
86 # we do not care about (texinfo, etc).
87 find $CVSROOT/gcc -name \*.texi,v -print | fgrep -v -f/home/gccadmin/scripts/doc_exclude | sed -e s#$CVSROOT/##g -e s#,v##g -e s#Attic/##g > FILES
90 # Checkout all the texi files.
91 cvs -Q co -r$RELEASE `cat FILES` gcc/gcc/doc/install.texi2html gcc/gcc/texinfo.tex gcc/gcc/doc/texinfo.tex gcc/gcc/doc/include/texinfo.tex
93 # Find the directory to pass to -I; this is the one with texinfo.tex
94 # and fdl.texi.
95 texitexloc=`find . -name texinfo.tex`
96 includedir=${texitexloc%/*}
98 # Now convert the relevant files from texi to HTML and PostScript.
99 for file in cpp chill cppinternals gcc gcj g77 gnat-style libiberty \
100 objc-features porting; do
101 filename=`find . -name ${file}.texi`
102 if [ "${filename}" ]; then
103 /usr/local/bin/texi2html -glossary -menu -split_chapter -I ${includedir} ${filename}
104 texi2dvi -I ${includedir} ${filename} </dev/null && dvips -o ${file}.ps ${file}.dvi
106 done
108 # Then build a gzipped copy of each of the resulting .html and .ps files
109 for file in *.html *.ps; do
110 cat $file | gzip --best > $file.gz
111 done
113 # On the 15th of the month, wipe all the old files from the
114 # web server.
115 today=`date +%d`
116 if test $today = 15; then
117 find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
120 # And copy the resulting html files to the web server
121 for file in *.html *.ps; do
122 cat $DOCSDIR/$file |
123 sed -e '/^<!-- Created on/d' \
124 -e '/^by <I>GCC Administrator<\/I> on/d' \
125 -e '/^%DVIPSSource:/d' > file1
126 cat $file |
127 sed -e '/^<!-- Created on/d' \
128 -e '/^by <I>GCC Administrator<\/I> on/d' \
129 -e '/^%DVIPSSource:/d' > file2
130 if cmp -s file1 file2; then
132 else
133 cp $file ${file}.gz $DOCSDIR
135 done
137 news_file=`grep "News About GNU Fortran" $DOCSDIR/g77_toc.html | sed -e '/HREF=.*[^.]/ s#^.*HREF="##g' | sed -e 's%#SEC.*%%g'`
138 bugs_file=`grep "Known Causes of Trouble with GNU Fortran" $DOCSDIR/g77_toc.html | sed -e '/HREF=.*[^.]/ s#^.*HREF="##g' | sed -e 's%#SEC.*%%g'`
139 contrib_file=`grep "Contributors to GCC" $DOCSDIR/gcc_toc.html | sed -e '/HREF=.*[^.]/ s#^.*HREF="##g' | sed -e 's%#SEC.*%%g'`
141 cd $DOCSDIR
143 rm -f g77_news.html
144 rm -f g77_bugs.html
145 rm -f g77_news.html.gz
146 rm -f g77_bugs.html.gz
147 ln $news_file g77_news.html
148 ln $bugs_file g77_bugs.html
149 ln ${news_file}.gz g77_news.html.gz
150 ln ${bugs_file}.gz g77_bugs.html.gz
152 if [ "$DO_THANKS_HTML" = y ]; then
153 cd $WWWBASE
154 rm -f thanks.html
155 rm -f thanks.html.gz
156 ln onlinedocs/$contrib_file thanks.html
157 ln onlinedocs/${contrib_file}.gz thanks.html.gz
160 # Finally, generate the installation documentation (but only for CVS HEAD).
161 if [ "$RELEASE" = "HEAD" ]; then
162 SOURCEDIR=$WORKDIR
163 DESTDIR=$WWWBASE_PREFORMATTED/install
164 export SOURCEDIR
165 export DESTDIR
166 $WORKDIR/gcc/gcc/doc/install.texi2html
168 # Preprocess the entire web site, not just the install docs!
169 echo "Invoking $WWWPREPROCESS"
170 $WWWPREPROCESS
173 # Clean up behind us.
175 rm -rf $WORKDIR