4 # This script updates the Docutils web site.
6 # Any .html document with a corresponding .txt file is regenerated
7 # if the .txt has changed, but no new .html files will be generated.
10 # -f Do not give feedback.
11 # -t Run the script in trace mode ("set -o xtrace").
12 # -u Regenerate .html unconditionally.
21 # make all newly created files group writeable
24 # URL for SVN project checkout:
25 svnurl
=http
://svn.berlios.de
/svnroot
/repos
/docutils
/trunk
27 basedir
=`pwd`/update-dir
28 if [ ! -e $basedir ] ; then
29 test -d $basedir || mkdir
$basedir
32 # $auxdir is non-public.
34 test -d $auxdir || mkdir
$auxdir
35 # $htdocsdest is the destination for htdocs and will be moved to
36 # another server later; so we keep it non-public (under $auxdir).
37 htdocsdest
=$auxdir/htdocs
38 test -d $htdocsdest || mkdir
$htdocsdest
39 # Where to create the snapshots (non-public).
40 snapshotdir
=$auxdir/snapshots
41 test -d $snapshotdir || mkdir
$snapshotdir
42 # # Where to publish the snapshots (public).
43 # snapshotdest=/home/groups/ftp/pub/docutils
45 test -d $bindir || mkdir
$bindir
47 htdocs_patchfile
=$auxdir/htdocs.
patch
48 htdocs_tarball
=$auxdir/htdocs.
tar
49 htdocs_new_tarball
=$auxdir/htdocs.new.
tar
50 # htdocs directory on SF.net
51 remoteproject
=/home
/groups
/d
/do
/docutils
52 remotehtdocs
=$remoteproject/htdocs
54 pylib
=$auxdir/lib
/python
60 sshhost
=docutilsupdate
,docutils@web.sourceforge.net
61 sshcommand
="ssh -i $lockdir/id_dsa
62 -o UserKnownHostsFile=$sshdir/known_hosts $sshhost"
63 # Project base URL (for sitemap) without trailing slash.
64 baseurl
="http://docutils.sourceforge.net"
66 export PYTHONPATH
=$pylib:$lib:$lib/extras
67 export PATH
=$lib/tools
:$PATH
74 while getopts ftuv opt
84 shift `expr $OPTIND - 1`
86 test $feedback && echo 'Starting docutils-update run...' || true
88 if [ $trace -eq 1 -o $verbose -eq 1 ] ; then
93 if ! mkdir
$lockdir; then
95 echo Could not create lock directory
at
98 echo Please ensure no other user is running this
script
99 echo and delete the directory.
102 # Always clean up on exit.
103 trap "rm -rf $lockdir; trap - 0; exit 1" 0 1 2 3 15
104 # Make sure the lock directory is deletable (i.e. rwx) by other group
105 # members (in case this script crashes after copying files into the
106 # directory) and un-readable by world (because we'll be storing the
111 # update library area
112 if [ -e $lib ] ; then
116 test -d $pylib || mkdir
-p $pylib
118 svn checkout
$svnurl/docutils
121 # -------------------- Snapshots: --------------------
123 # gather the materials
125 for DIR
in docutils sandbox web
; do
126 test -d $DIR || svn checkout
$svnurl/$DIR
128 svn
-q revert
$project/$project/__init__.py
129 haschanges
="`svn up docutils sandbox web | grep -v '^At revision '; true`"
131 # update __version_details__ string
132 version_details
="snapshot `date -u +%Y-%m-%d`, r`svn info docutils | grep ^Revision: | sed 's/^Revision: //'`"
133 (echo ",s/^__version_details__ = .*\$/__version_details__ = '$version_details'/";
134 echo wq
) | ed
$project/$project/__init__.py
2> /dev
/null
136 # Ensure proper directory permissions are set so that the files can be
137 # modified by several users. Changing permissions of files is
138 # probably not necessary because files can be deleted and re-created.
139 # Do not change permissions of aux directory to keep it non-public
140 # (but change permissions for all subdirectories).
141 #find $basedir -type f -print0 | xargs -0 chmod ug+rw 2> /dev/null || true
142 find $basedir -name aux
-o -type d
-print0 |
xargs -0 chmod ug
+rwxs
2> /dev
/null || true
144 # create the snapshots
145 exclude
='--exclude=.svn'
146 tar -cz $exclude -f $project-snapshot.tgz
$project
147 tar -cz $exclude -f $project-sandbox-snapshot.tgz sandbox
148 tar -cz $exclude -f $project-web-snapshot.tgz web
149 ( cd sandbox
/gschwant
;
150 tar -cz $exclude -f ..
/..
/docfactory-snapshot.tgz docfactory
)
152 # plant the snapshots
153 mv -f *snapshot.tgz
$htdocsdest
155 # revert and touch (to avoid updating the web site only because of the
157 svn
-q revert
$project/$project/__init__.py
158 touch $project/$project/__init__.py
--date \
159 "`svn info $project/$project/__init__.py | \
160 grep 'Last Changed Date:' | sed 's/[^:]*: //'`"
162 # -------------------- htdocs: --------------------
166 function copy_to_htdocsdest
() {
167 find "$@" -type d
-name .svn
-prune -o \
( -type f
-o -type l \
) -print0 | \
168 xargs -0 cp --no-dereference --update --parents \
169 --target-directory=$htdocsdest
173 copy_to_htdocsdest sandbox
174 (cd $project; copy_to_htdocsdest
*)
175 (cd web
; copy_to_htdocsdest
* .
[^.
]*)
180 if [ $trace -eq 0 ] ; then
184 for makefile
in `find .. -name Makefile.docutils-update` ; do
185 dir
=`dirname $makefile`
186 ( cd $dir ; make -f Makefile.docutils-update
-s )
189 for htmlfile
in `find .. -name '*.html'` ; do
190 dir
=`dirname $htmlfile`
191 base
=`basename $htmlfile .html`
192 txtfile
=$dir/$base.txt
193 if [ -e $txtfile ] ; then
194 if [ $unconditional -eq 1 -o $txtfile -nt $htmlfile ] ; then
195 if [ "${base:0:4}" == "pep-" ] ; then
196 test $feedback && echo "$txtfile (PEP)" || true
197 python
$lib/tools
/rstpep2html.py
--config=$dir/docutils.conf
$txtfile $htmlfile
200 test $feedback && echo $txtfile || true
201 python
$lib/tools
/rst2html.py
--config=$dir/docutils.conf
$txtfile $htmlfile
208 if [ $trace -eq 1 -o $verbose -eq 1 ] ; then
212 # -------------------- XML sitemap for search engines: --------------------
216 # Update the sitemap only if something has changed because it takes
217 # very much CPU time.
218 if test -n "$haschanges"; then
220 echo '<?xml version="1.0" encoding="UTF-8"?>'
221 echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'
222 if [ $trace -eq 0 ] ; then
225 find .
-name '.[^.]*' -prune -o -type d
-printf '%p/\n' \
226 -o \
( -type f
-o -type l \
) -print | \
228 # i is the file name.
229 if test "$i" == .
/; then
233 elif test "$i" == .
/sitemap
-o "${i: -1}" == / -a -f "${i}index.html"; then
234 # This is a directory and it has an index.html, so we
235 # don't need to include it.
241 lastmod
="`date --iso-8601=seconds -u -r "$i"`"
242 # Google wants a colon in front of the last two digits.
243 lastmod
="${lastmod::22}:00"
244 if test "${i: -5}" == .html
; then
245 # HTML files (including the home page) have highest priority.
247 elif test "${i: -4}" == .txt
; then
248 # Text files have medium priority.
251 # Everything else (source files etc.) has low priority.
254 echo "<url><loc>$url</loc><lastmod>$lastmod</lastmod><priority>$priority</priority></url>"
256 if [ $trace -eq 1 -o $verbose -eq 1 ] ; then
264 # -------------------- Push changes to remote server. --------------------
266 # sourceforge no longer allows shell access, use rsync via ssh
267 # specify your user in your .ssh/config
270 # do not use -a to avoid "failed to set permissions"
271 rsync
-e ssh -r .
/ web.sourceforge.net
:$remotehtdocs
275 test $feedback && echo '...docutils-update done.' || true
278 # indent-tabs-mode: nil