1#! /bin/bash
2
3function die()
4{
5    echo $* 2>&1
6    exit 1
7}
8
9if test -n "$FDUSER" ; then
10    echo "Using freedesktop.org account $FDUSER"
11    user="$FDUSER@"
12else
13    echo "Using freedesktop.org account from ~/.ssh/config, or local username"
14fi
15
16CHECKOUTDIR=`mktemp -d || echo /tmp/dbus-for-docs`
17export CVSROOT=":ext:${user}cvs.freedesktop.org:/cvs/dbus"
18
19cd $CHECKOUTDIR || die "could not changedir to $CHECKOUTDIR"
20
21echo "Checking out to directory "`pwd`
22
23/bin/rm -rf dbus/doc || true ## get rid of old doxygen, etc.
24cvs co dbus || die "failed to cvs update"
25cd dbus || die "could not cd to dbus"
26
27echo "Configuring and building docs"
28
29## the configure flags are explicit so if you lack xmlto, etc. 
30## you won't fail to update those docs
31./autogen.sh --enable-xml-docs=yes --enable-doxygen-docs=yes || die "could not autogen"
32doxygen Doxyfile || die "could not run Doxygen"
33make -C doc || die "could not build docs"
34
35MANFILES=`find -name "dbus*.1"`
36for M in $MANFILES ; do
37    BASENAME=`basename $M`
38    echo "Converting $M to $BASENAME.html"
39    man2html $M > doc/$BASENAME.html
40done
41
42echo "Packing docs into tarball"
43cp README HACKING AUTHORS NEWS COPYING ChangeLog doc/ || die "could not copy in assorted files"
44tar cfz dbus-docs.tar.gz doc/*.dtd doc/*.xsl doc/*.xml doc/*.html doc/*.txt doc/api/html/*.html doc/api/html/*.css doc/api/html/*.png doc/api/html/*.gif doc/HACKING doc/AUTHORS doc/NEWS doc/ChangeLog doc/TODO doc/README doc/COPYING doc/*.png doc/*.svg || die "could not tar up docs"
45
46tar tfz dbus-docs.tar.gz | sort > tarball.list || die "could not list tarball contents"
47find doc -not -type d | grep -v CVS | grep -v -E '.~[0-9.]+~' | grep -v Makefile | grep -vE '.c$' | grep -v man3dbus | grep -v .cvsignore | sort > filesystem.list || die "could not list doc/* contents"
48
49diff -u filesystem.list tarball.list || die "some files were not included"
50
51echo "Uploading docs to server"
52scp dbus-docs.tar.gz "${user}"dbus.freedesktop.org:
53ssh "${user}"dbus.freedesktop.org '(cd /srv/dbus.freedesktop.org/www/ && /bin/cp -f ~/dbus-docs.tar.gz . && tar zxf dbus-docs.tar.gz && echo "Successfully unpacked tarball on server")'
54
55echo "Uploading DTD to server"
56scp -p doc/introspect.dtd "${user}"dbus.freedesktop.org:/srv/specifications.freedesktop.org/www/dbus/1.0/introspect.dtd
57