git/dodoc.sh

148 lines
3.4 KiB
Bash
Raw Normal View History

2005-12-27 08:04:15 +00:00
#!/bin/sh
#
# This script is called from the post-update hook, and when
2006-01-08 06:18:12 +00:00
# the master branch is updated, run in $HOME/git-doc, like
2005-12-27 08:04:15 +00:00
# this:
: <<\END_OF_COMMENTARY
$ cat >hooks/post-update
#!/bin/sh
case " $* " in
*' refs/heads/master '*)
echo $HOME/git-doc/dodoc.sh | at now
;;
esac
2007-12-15 06:43:05 +00:00
exec git update-server-info
2005-12-27 08:04:15 +00:00
$ chmod +x hooks/post-update
END_OF_COMMENTARY
2006-01-08 06:18:12 +00:00
# $HOME/git-doc is a clone of the git.git repository and
2005-12-27 08:04:15 +00:00
# has the master branch checkd out. We update the working
# tree and build pre-formatted documentation pages, install
# in doc-htmlpages and doc-manapges subdirectory here.
# These two are their own git repository, and when they are
# updated the updates are pushed back into their own branches
# in git.git repository.
2007-12-15 06:43:05 +00:00
ID=`git rev-parse --verify refs/heads/master` || exit $?
2005-12-27 08:04:15 +00:00
unset GIT_DIR
2007-03-26 09:04:42 +00:00
: ${PUBLIC=/pub/software/scm/git/docs} &&
: ${MASTERREPO=`pwd`} &&
: ${DOCREPO=`dirname "$0"`} &&
2005-12-27 08:04:15 +00:00
test "$DOCREPO" != "" &&
cd "$DOCREPO" || exit $?
DOCREPO=`pwd`
2007-03-26 09:04:42 +00:00
tmp=`pwd`/.doctmp-$$
trap 'rm -f "$tmp".*' 0
2007-11-08 10:02:59 +00:00
(
git pull "$MASTERREPO" master &&
git fetch --tags "$MASTERREPO"
) >/dev/null 2>/dev/null || exit $?
2007-12-15 06:43:05 +00:00
test $(git rev-parse --verify refs/heads/master) == "$ID" &&
NID=$(git describe --abbrev=4 "$ID") &&
2006-01-09 01:18:32 +00:00
test '' != "$NID" || exit $?
2005-12-27 08:04:15 +00:00
# Set up subrepositories
2007-03-26 09:04:42 +00:00
for type in man html
do
test -d doc-${type}pages || (
mkdir doc-${type}pages &&
cd doc-${type}pages &&
git init-db || exit $?
git fetch-pack "$MASTERREPO" ${type} |
while read sha1 name
do
case "$name" in
refs/heads/${type})
git update-ref HEAD $sha1 &&
git checkout || exit $?
break
;;
esac
done || exit $?
) || exit
rm -fr doc-$type-inst
done
2007-03-28 21:14:37 +00:00
make >./:html.log 2>&1 \
2007-03-26 09:04:42 +00:00
-C Documentation -j 2 \
WEBDOC_DEST="$DOCREPO/doc-html-inst" install-webdoc || exit
2007-03-28 21:14:37 +00:00
make >./:man.log 2>&1 \
2007-03-26 09:04:42 +00:00
-C Documentation -j 2 \
man1="$DOCREPO/doc-man-inst/man1" \
2007-04-20 00:58:34 +00:00
man5="$DOCREPO/doc-man-inst/man5" \
2007-03-26 09:04:42 +00:00
man7="$DOCREPO/doc-man-inst/man7" \
man1dir="$DOCREPO/doc-man-inst/man1" \
2007-04-20 00:58:34 +00:00
man5dir="$DOCREPO/doc-man-inst/man5" \
2007-03-26 09:04:42 +00:00
man7dir="$DOCREPO/doc-man-inst/man7" install || exit
for type in html man
do
find doc-$type-inst -type f |
while read path
do
it=$(expr "$path" : doc-$type-inst/'\(.*\)') || continue
t="doc-${type}pages/$it"
test -f "$t" && diff -q "$path" "$t" && continue
mkdir -p "$(dirname "$t")" &&
2007-03-26 09:04:42 +00:00
echo ": $t" && rm -f "$t" && ln "$path" "$t" || exit
( cd doc-${type}pages && git add "$it" )
done || exit
find doc-$type-inst -type f |
sed -e 's|^doc-'$type'-inst/||' | sort >"$tmp.1" &&
(cd doc-${type}pages && git ls-files | sort) >"$tmp.2" &&
comm -13 "$tmp.1" "$tmp.2" |
( cd doc-${type}pages && xargs rm -f -- ) || exit
(
cd doc-${type}pages
2007-03-28 21:14:37 +00:00
case "$type" in
html)
TYPE='HTML docs'
rm -f index.html
ln -sf git.html index.html
git add index.html
;;
man)
TYPE='manpages'
;;
esac
if git commit -a -m "Autogenerated $TYPE for $NID"
2007-03-26 09:04:42 +00:00
then
2007-11-08 10:02:59 +00:00
git send-pack "$MASTERREPO" master:refs/heads/$type \
>/dev/null 2>&1
2007-03-26 09:04:42 +00:00
else
echo "* No changes in $type docs"
fi
) || exit
done
2005-12-27 08:04:15 +00:00
if test -d $PUBLIC
then
2007-02-14 06:15:29 +00:00
# This is iffy...
2007-03-26 09:04:42 +00:00
mv Documentation/git.html Documentation/saved-git-html
2007-03-28 21:14:37 +00:00
make >>./:html.log 2>&1 \
2007-03-26 09:04:42 +00:00
-C Documentation \
WEBDOC_DEST="$PUBLIC" ASCIIDOC_EXTRA='-a stalenotes' \
install-webdoc &&
mv Documentation/saved-git-html Documentation/git.html
2005-12-27 08:04:15 +00:00
else
echo "* No public html at $PUBLIC"
fi || exit $?
echo '
*** ALL DONE ***
' >>./:html.log