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.
17 # - Checked out trunk at $snapshotdir.
18 # - Checked out main tree at $lib, no longer necessary.
23 # make all newly created files group writeable
26 # URL for SVN project checkout:
27 svnurl
=http
://svn.berlios.de
/svnroot
/repos
/docutils
/trunk
/docutils
29 basedir
=/home
/groups
/docutils
/htdocs
30 if [ ! -e $basedir ] ; then
31 basedir
=`pwd`/update-dir
32 test -d $basedir || mkdir
$basedir
35 # $auxdir is non-public.
37 test -d $auxdir || mkdir
$auxdir
38 # $htdocsdest is the destination for htdocs and will be moved to
39 # another server later; so we keep it non-public (under $auxdir).
40 htdocsdest
=$auxdir/htdocs
41 test -d $htdocsdest || mkdir
$htdocsdest
42 # Where to create the snapshots (non-public).
43 snapshotdir
=$auxdir/snapshots
44 test -d $snapshotdir || mkdir
$snapshotdir
45 # # Where to publish the snapshots (public).
46 # snapshotdest=/home/groups/ftp/pub/docutils
48 test -d $bindir || mkdir
$bindir
50 htdocs_patchfile
=$auxdir/htdocs.
patch
51 htdocs_tarball
=$auxdir/htdocs.
tar
52 htdocs_new_tarball
=$auxdir/htdocs.new.
tar
53 # htdocs directory on SF.net
54 remoteproject
=/home
/groups
/d
/do
/docutils
55 remotehtdocs
=$remoteproject/htdocs
57 pylib
=$auxdir/lib
/python
63 sshhost
=docutilsupdate@shell.sourceforge.net
64 sshhost
=docutilsupdate
,docutils@web.sourceforge.net
65 sshcommand
="ssh -i $lockdir/id_dsa
66 -o UserKnownHostsFile=$sshdir/known_hosts $sshhost"
67 # Project base URL (for sitemap) without trailing slash.
68 baseurl
="http://docutils.sourceforge.net"
70 export PYTHONPATH
=$pylib:$lib:$lib/extras
71 export PATH
=$lib/tools
:$PATH
78 while getopts ftuv opt
88 shift `expr $OPTIND - 1`
90 test $feedback && echo 'Starting docutils-update run...' || true
92 if [ $trace -eq 1 -o $verbose -eq 1 ] ; then
97 if ! mkdir
$lockdir; then
99 echo Could not create lock directory
at
102 echo Please ensure no other user is running this
script
103 echo and delete the directory.
106 # Always clean up on exit.
107 trap "rm -rf $lockdir; trap - 0; exit 1" 0 1 2 3 15
108 # Make sure the lock directory is deletable (i.e. rwx) by other group
109 # members (in case this script crashes after copying files into the
110 # directory) and un-readable by world (because we'll be storing the
115 # update library area
116 if [ -e $lib ] ; then
120 test -d $pylib || mkdir
-p $pylib
125 # -------------------- Snapshots: --------------------
127 # gather the materials
129 svn
-q revert
$project/$project/__init__.py
130 haschanges
="`svn up docutils sandbox web | grep -v '^At revision '; true`"
132 # update __version_details__ string
133 version_details
="snapshot `date --utc --iso`, r`svn info docutils | grep ^Revision: | sed 's/^Revision: //'`"
134 (echo ",s/^__version_details__ = .*\$/__version_details__ = '$version_details'/";
135 echo wq
) | ed
$project/$project/__init__.py
2> /dev
/null
137 # Ensure proper directory permissions are set so that the files can be
138 # modified by several users. Changing permissions of files is
139 # probably not necessary because files can be deleted and re-created.
140 # Do not change permissions of aux directory to keep it non-public
141 # (but change permissions for all subdirectories).
142 #find $basedir -type f -print0 | xargs -0 chmod ug+rw 2> /dev/null || true
143 find $basedir -name aux
-o -type d
-print0 |
xargs -0 chmod ug
+rwxs
2> /dev
/null || true
145 # create the snapshots
146 exclude
='--exclude=.svn'
147 tar -cz $exclude -f $project-snapshot.tgz
$project
148 tar -cz $exclude -f $project-sandbox-snapshot.tgz sandbox
149 tar -cz $exclude -f $project-web-snapshot.tgz web
150 ( cd sandbox
/gschwant
;
151 tar -cz $exclude -f ..
/..
/docfactory-snapshot.tgz docfactory
)
153 # plant the snapshots
154 mv -f *snapshot.tgz
$htdocsdest
156 # if [ -d $snapshotdest ] ; then
157 # mv -f *snapshot.tgz $snapshotdest
159 # echo "Skip snapshots, directory $snapshotdest does not exist"
162 # revert and touch (to avoid updating the web site only because of the
164 svn
-q revert
$project/$project/__init__.py
165 touch $project/$project/__init__.py
--date \
166 "`svn info $project/$project/__init__.py | \
167 grep 'Last Changed Date:' | sed 's/[^:]*: //'`"
169 # -------------------- htdocs: --------------------
173 function copy_to_htdocsdest
() {
174 find "$@" -type d
-name .svn
-prune -o \
( -type f
-o -type l \
) -print0 | \
175 xargs -0 cp --no-dereference --update --parents \
176 --target-directory=$htdocsdest
180 copy_to_htdocsdest sandbox
181 (cd $project; copy_to_htdocsdest
*)
182 (cd web
; copy_to_htdocsdest
* .
[^.
]*)
187 if [ $trace -eq 0 ] ; then
191 for makefile
in `find .. -name Makefile.docutils-update` ; do
192 dir
=`dirname $makefile`
193 ( cd $dir ; make -f Makefile.docutils-update
-s )
196 for htmlfile
in `find .. -name '*.html'` ; do
197 dir
=`dirname $htmlfile`
198 base
=`basename $htmlfile .html`
199 txtfile
=$dir/$base.txt
200 if [ -e $txtfile ] ; then
201 if [ $unconditional -eq 1 -o $txtfile -nt $htmlfile ] ; then
202 if [ "${base:0:4}" == "pep-" ] ; then
203 test $feedback && echo "$txtfile (PEP)" || true
204 python
$lib/tools
/rstpep2html.py
--config=$dir/docutils.conf
$txtfile $htmlfile
207 test $feedback && echo $txtfile || true
208 python
$lib/tools
/rst2html.py
--config=$dir/docutils.conf
$txtfile $htmlfile
215 if [ $trace -eq 1 -o $verbose -eq 1 ] ; then
219 # -------------------- XML sitemap for search engines: --------------------
223 # Update the sitemap only if something has changed because it takes
224 # very much CPU time.
225 if test -n "$haschanges"; then
227 echo '<?xml version="1.0" encoding="UTF-8"?>'
228 echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'
229 if [ $trace -eq 0 ] ; then
232 find .
-name '.[^.]*' -prune -o -type d
-printf '%p/\n' \
233 -o \
( -type f
-o -type l \
) -print | \
235 # i is the file name.
236 if test "$i" == .
/; then
240 elif test "$i" == .
/sitemap
-o "${i: -1}" == / -a -f "${i}index.html"; then
241 # This is a directory and it has an index.html, so we
242 # don't need to include it.
248 lastmod
="`date --iso-8601=seconds -u -r "$i"`"
249 # Google wants a colon in front of the last two digits.
250 lastmod
="${lastmod::22}:00"
251 if test "${i: -5}" == .html
; then
252 # HTML files (including the home page) have highest priority.
254 elif test "${i: -4}" == .txt
; then
255 # Text files have medium priority.
258 # Everything else (source files etc.) has low priority.
261 echo "<url><loc>$url</loc><lastmod>$lastmod</lastmod><priority>$priority</priority></url>"
263 if [ $trace -eq 1 -o $verbose -eq 1 ] ; then
271 # -------------------- Push changes to remote server. --------------------
273 # sourceforge no longer allows shell access, use rsync via ssh
274 # specify your user in your .ssh/config
277 # do not use -a to avoid "failed to set permissions"
278 rsync
-e ssh -r .
/ web.sourceforge.net
:$remotehtdocs
282 test $feedback && echo '...docutils-update done.' || true
285 # indent-tabs-mode: nil