Point MAN_BASE_URL to git-htmldocs/ for now
[git/jnareb-git.git] / dodoc.sh
blob69cc9026b44665abe1ca6636d9a5d8b957389b5f
1 #!/bin/sh
3 # "git-doc" is a clone of the git.git repository and has the master
4 # branch checked out. We update the working tree and prepare
5 # preformatted documentation pages, and install them in doc-htmlpages
6 # and doc-manapges subdirectories. When they are updated, they are
7 # pushed back into their own repositories next to the git.git
8 # repository.
10 unset GIT_DIR
12 MASTERREPO=/srv/project/git/git.git/
13 DOCREFHIER=refs/docs
14 MANREPO=/srv/project/git/git-manpages.git/
15 HTMLREPO=/srv/project/git/git-htmldocs.git/
17 target_repo () {
18 TARGETVAR=$(echo "$1"REPO | tr 'a-z' 'A-Z') &&
19 eval "echo \$$TARGETVAR"
22 DOCREPO=$(pwd) ;# "git-doc"
23 exec >:doc.log 2>&1
25 ID=$(cd "$MASTERREPO" && git rev-parse --verify refs/heads/master) || exit $?
27 tmp=`pwd`/.doctmp-$$
28 trap 'rm -f "$tmp".*' 0
31 git pull --ff-only "$MASTERREPO" master &&
32 git fetch --tags "$MASTERREPO"
33 ) || exit $?
35 test $(git rev-parse --verify refs/heads/master) = "$ID" &&
36 NID=$(git describe --abbrev=4 "$ID") &&
37 test -n "$NID" || exit $?
39 git reset --hard
41 # Set up subrepositories
42 for type in man html
44 test -d doc-${type}pages && continue
46 git init doc-${type}pages &&
47 cd doc-${type}pages || exit
48 TARGETREPO=$(target_repo $type) &&
49 git pull "$TARGETREPO" master
50 ) &&
51 rm -fr doc-$type-inst &&
52 mkdir -p doc-$type-inst &&
54 cd doc-${type}pages && git archive HEAD
55 ) |
57 cd doc-$type-inst && tar xf -
59 done
61 # The below used to contain this instead...
62 # MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
63 dd='
64 ASCIIDOC_NO_ROFF=YesPlease
65 ASCIIDOC8=YesPlease
66 MAN_BASE_URL="git-htmldocs/"
67 BLK_SHA1=YesPlease
68 GNU_ROFF=YesPlease
71 case "$NID" in
72 ?*-?*) ;;
73 ?*)
74 make clean &&
75 rm -fr doc-html-inst doc-man-inst &&
76 mkdir doc-html-inst doc-man-inst || exit
78 esac
80 DIFF=diff
81 export DIFF
83 make \
84 -C Documentation -j 2 $dd \
85 WEBDOC_DEST="$DOCREPO/doc-html-inst" install-webdoc || exit
87 make \
88 -C Documentation -j 2 $dd \
89 man1="$DOCREPO/doc-man-inst/man1" \
90 man5="$DOCREPO/doc-man-inst/man5" \
91 man7="$DOCREPO/doc-man-inst/man7" \
92 man1dir="$DOCREPO/doc-man-inst/man1" \
93 man5dir="$DOCREPO/doc-man-inst/man5" \
94 man7dir="$DOCREPO/doc-man-inst/man7" install || exit
96 for type in html man
98 find doc-$type-inst -type f |
99 while read path
101 it=$(expr "$path" : doc-$type-inst/'\(.*\)') || continue
102 t="doc-${type}pages/$it"
103 test -f "$t" && diff -q "$path" "$t" && continue
104 mkdir -p "$(dirname "$t")" &&
105 echo ": $t" && rm -f "$t" && ln "$path" "$t" || exit
106 ( cd doc-${type}pages && git add "$it" )
107 done || exit
109 find doc-$type-inst -type f |
110 sed -e 's|^doc-'$type'-inst/||' | sort >"$tmp.1" &&
111 (cd doc-${type}pages && git ls-files | sort) >"$tmp.2" &&
112 comm -13 "$tmp.1" "$tmp.2" |
113 ( cd doc-${type}pages && xargs rm -f -- ) || exit
116 cd doc-${type}pages
118 case "$type" in
119 html)
120 TYPE='HTML docs'
121 rm -f index.html
122 ln -sf git.html index.html
123 git add index.html
125 man)
126 TYPE='manpages'
128 esac
130 if git commit -a -m "Autogenerated $TYPE for $NID"
131 then
132 TARGETREPO=$(target_repo $type) &&
133 git push "$TARGETREPO" master:master
134 else
135 echo "* No changes in $type docs"
137 ) || exit
138 done
140 echo '
142 *** ALL DONE ***