OSDN Git Service

* update_web_docs (WWWBASE_PREFORMATTED, PREPROCESS): New
[pf3gnuchains/gcc-fork.git] / maintainer-scripts / update_web_docs
1 #!/bin/sh -x
2
3 # Run this from /tmp.
4 CVSROOT=/cvs/gcc
5 export CVSROOT
6
7 PATH=/usr/local/bin:$PATH
8
9 WWWBASE=/www/gcc/htdocs
10 WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted
11 PREPROCESS=/www/gcc/bin/preprocess
12
13 # Process options -rrelease and -ddirectory
14 RELEASE=""
15 SUBDIR=""
16
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
23       fi
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
31         fi
32       fi
33       ;;
34     -d*)
35       if [ -n "$SUBDIR" ]; then
36         echo "Multiple subdirectories specified" >&2
37         exit 1
38       fi
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
46         fi
47       fi
48       ;;
49     *)
50       echo "Unknown argument \"$1\"" >&2
51       exit 1
52       ;;
53   esac
54   shift
55 done
56
57 if [ -n "$RELEASE" ] && [ -z "$SUBDIR" ]; then
58   echo "Release specified without subdirectory" >&2
59   exit 1
60 fi
61
62 if [ -z "$SUBDIR" ]; then
63   DOCSDIR=$WWWBASE/onlinedocs
64 else
65   DOCSDIR=$WWWBASE/onlinedocs/$SUBDIR
66 fi
67
68 if [ ! -d $DOCSDIR ]; then
69   mkdir $DOCSDIR
70 fi
71
72 if [ -z "$RELEASE" ]; then
73   RELEASE=HEAD
74   DO_THANKS_HTML=y
75 else
76   DO_THANKS_HTML=n
77 fi
78
79 WORKDIR=/tmp/gcc-doc-update.$$
80
81 /bin/rm -rf $WORKDIR
82 /bin/mkdir $WORKDIR
83 cd $WORKDIR
84
85 # Find all the texi files in the repository, except those in directories
86 # we do not care about (Attic, 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 > FILES
88
89
90 # Checkout all the texi files and get them into a single directory.
91 # If we ever have texi files with the same name we'll have to do this
92 # differently.
93 cvs -Q co -r$RELEASE `cat FILES` gcc/gcc/doc/install.texi2html
94 mv `find . -name \*.texi -print` .
95
96 # Now convert the relevant files from texi to html.
97 for file in c-tree cpp chill cppinternals gcc gcj g77 objc-features porting; do
98   if [ -e ${file}.texi ]; then
99     /usr/local/bin/texi2html -glossary -menu -split_chapter ${file}.texi
100   fi
101 done
102
103 # Then build a gzipped copy of each of the resulting .html files
104 for file in *.html; do
105   cat $file | gzip --best > $file.gz
106 done
107
108 # On the 15th of the month, wipe all the old files from the
109 # web server.
110 today=`date +%d`
111 if test $today = 15; then
112   find $DOCSDIR -type f -maxdepth 1 -print | grep -v index.html | xargs rm
113 fi
114
115 # And copy the resulting html files to the web server
116 for file in *.html; do
117   cat $DOCSDIR/$file | 
118     sed -e '/^<!-- Created on/d' \
119         -e '/^by <I>GCC Administrator<\/I> on/d' > file1
120   cat $file |
121     sed -e '/^<!-- Created on/d' \
122         -e '/^by <I>GCC Administrator<\/I> on/d' > file2
123   if cmp -s file1 file2; then
124     :
125   else
126     cp $file ${file}.gz $DOCSDIR
127   fi
128 done
129
130 news_file=`grep "News About GNU Fortran" $DOCSDIR/g77_toc.html | sed -e '/HREF=.*[^.]/  s#^.*HREF="##g' | sed -e 's%#SEC.*%%g'`
131 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'`
132 contrib_file=`grep "Contributors to GCC" $DOCSDIR/gcc_toc.html | sed -e '/HREF=.*[^.]/  s#^.*HREF="##g' | sed -e 's%#SEC.*%%g'`
133
134 cd $DOCSDIR
135
136 rm -f g77_news.html
137 rm -f g77_bugs.html
138 rm -f g77_news.html.gz
139 rm -f g77_bugs.html.gz
140 ln $news_file g77_news.html
141 ln $bugs_file g77_bugs.html
142 ln ${news_file}.gz g77_news.html.gz
143 ln ${bugs_file}.gz g77_bugs.html.gz
144
145 if [ "$DO_THANKS_HTML" = y ]; then
146   cd $WWWBASE
147   rm -f thanks.html
148   rm -f thanks.html.gz
149   ln onlinedocs/$contrib_file thanks.html
150   ln onlinedocs/${contrib_file}.gz thanks.html.gz
151 fi
152
153 # Finally, generate the installation documentation.
154 SOURCEDIR=$WORKDIR
155 DESTDIR=$WWWBASE_PREFORMATTED/install
156 export SOURCEDIR
157 export DESTDIR
158 $WORKDIR/gcc/gcc/doc/install.texi2html
159
160 for file in `ls $DESTDIR`
161 do
162   $PREPROCESS install/$file
163 done 
164
165 # Clean up behind us.
166
167 rm -rf $WORKDIR