dodoc updates.

todo
Junio C Hamano 2007-03-26 02:04:42 -07:00
parent 7f1d866be5
commit 653c3f7669
1 changed files with 72 additions and 63 deletions

135
dodoc.sh
View File

@ -29,12 +29,15 @@ ID=`git-rev-parse --verify refs/heads/master` || exit $?

unset GIT_DIR

PUBLIC=/pub/software/scm/git/docs &&
MASTERREPO=`pwd` &&
DOCREPO=`dirname "$0"` &&
: ${PUBLIC=/pub/software/scm/git/docs} &&
: ${MASTERREPO=`pwd`} &&
: ${DOCREPO=`dirname "$0"`} &&
test "$DOCREPO" != "" &&
cd "$DOCREPO" || exit $?

tmp=`pwd`/.doctmp-$$
trap 'rm -f "$tmp".*' 0

git pull "$MASTERREPO" master &&
git fetch --tags "$MASTERREPO" || exit $?
test $(git-rev-parse --verify refs/heads/master) == "$ID" &&
@ -42,74 +45,80 @@ NID=$(git-describe --abbrev=4 "$ID") &&
test '' != "$NID" || exit $?

# Set up subrepositories
test -d doc-htmlpages || (
mkdir doc-htmlpages &&
cd doc-htmlpages &&
git init-db || exit $?
for type in man html
do
test -d doc-${type}pages || (
mkdir doc-${type}pages &&
cd doc-${type}pages &&
git init-db || exit $?

if SID=$(git fetch-pack "$MASTERREPO" html)
then
git update-ref HEAD `expr "$SID" : '\(.*\) .*'` &&
git checkout || exit $?
fi
)
test -d doc-manpages || (
mkdir doc-manpages &&
cd doc-manpages &&
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

if SID=$(git fetch-pack "$MASTERREPO" man)
then
git update-ref HEAD `expr "$SID" : '\(.*\) .*'` &&
git checkout || exit $?
fi
)
find doc-htmlpages doc-manpages -type d -name '.git' -prune -o \
-type f -print0 | xargs -0 rm -f
make >../:html.log 2>&1 \
-C Documentation -j 2 \
WEBDOC_DEST="$DOCREPO/doc-html-inst" install-webdoc || exit

cd Documentation &&
make WEBDOC_DEST="$DOCREPO/doc-htmlpages" install-webdoc >../:html.log 2>&1 &&
make >../:man.log 2>&1 \
-C Documentation -j 2 \
man1="$DOCREPO/doc-man-inst/man1" \
man7="$DOCREPO/doc-man-inst/man7" \
man1dir="$DOCREPO/doc-man-inst/man1" \
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

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

if git commit -a -m "Autogenerated docs for $NID"
then
git send-pack "$MASTERREPO" master:refs/heads/$type
else
echo "* No changes in $type docs"
fi
) || exit
done

if test -d $PUBLIC
then
# This is iffy...
mv git.html saved-git-html &&
make WEBDOC_DEST="$PUBLIC" ASCIIDOC_EXTRA='-a stalenotes' \
install-webdoc >>../:html.log 2>&1 &&
mv saved-git-html git.html
mv Documentation/git.html Documentation/saved-git-html
make >>../:html.log 2>&1 \
-C Documentation \
WEBDOC_DEST="$PUBLIC" ASCIIDOC_EXTRA='-a stalenotes' \
install-webdoc &&
mv Documentation/saved-git-html Documentation/git.html
else
echo "* No public html at $PUBLIC"
fi || exit $?

cd ../doc-htmlpages &&
(git add . || echo no new files -- not a big deal) &&
if git commit -a -m "Autogenerated HTML docs for $NID"
then
git-send-pack "$MASTERREPO" master:refs/heads/html || {
echo "* HTML failure"
exit 1
}
else
echo "* No changes in html docs"
fi

cd ../Documentation &&
make \
man1="$DOCREPO/doc-manpages/man1" \
man7="$DOCREPO/doc-manpages/man7" \
man1dir="$DOCREPO/doc-manpages/man1" \
man7dir="$DOCREPO/doc-manpages/man7" \
install >../:man.log 2>&1 &&

cd ../doc-manpages &&
(git add . || echo no new files -- not a big deal) &&
if git commit -a -m "Autogenerated man pages for $NID"
then
git-send-pack "$MASTERREPO" master:refs/heads/man || {
echo "* man failure"
exit 1
}
else
echo "* No changes in manual pages"
fi