What's cooking (2014/08 #03)
[git.git] / dodoc.sh
blobcf2b23d5ab739cb3abd9661ef79577ccbab4280e
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 : ${TOP=/srv/project/git}
14 MASTERREPO=$TOP/git.git/
15 MANREPO=$TOP/git-manpages.git/
16 HTMLREPO=$TOP/git-htmldocs.git/
18 target_repo () {
19 TARGETVAR=$(echo "$1"REPO | tr 'a-z' 'A-Z') &&
20 eval "echo \$$TARGETVAR"
23 DOCREPO=$(pwd) ;# "git-doc"
24 exec >:doc.log 2>&1
26 ID=$(cd "$MASTERREPO" && git rev-parse --verify refs/heads/master) || exit $?
28 tmp=`pwd`/.doctmp-$$
29 trap 'rm -f "$tmp".*' 0
32 git pull --ff-only "$MASTERREPO" master &&
33 git fetch --tags "$MASTERREPO"
34 ) || exit $?
36 test $(git rev-parse --verify refs/heads/master) = "$ID" &&
37 NID=$(git describe --abbrev=4 "$ID") &&
38 test -n "$NID" || exit $?
40 git reset --hard
42 # Set up subrepositories
43 for type in man html
45 test -d doc-${type}pages && continue
47 git init doc-${type}pages &&
48 cd doc-${type}pages || exit
49 TARGETREPO=$(target_repo $type) &&
50 git pull "$TARGETREPO" master
51 ) &&
52 rm -fr doc-$type-inst &&
53 mkdir -p doc-$type-inst &&
55 cd doc-${type}pages && git archive HEAD
56 ) |
58 cd doc-$type-inst && tar xf -
60 done
62 # The below used to contain this instead...
63 # MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
64 dd='
65 ASCIIDOC_NO_ROFF=YesPlease
66 ASCIIDOC8=YesPlease
67 MAN_BASE_URL="git-htmldocs/"
68 BLK_SHA1=YesPlease
69 GNU_ROFF=YesPlease
72 if test -z "$DOC_FROM_SCRATCH"
73 then
74 case "$NID" in
75 ?*-g*) ;;
76 ?*) DOC_FROM_SCRATCH=yes ;;
77 esac
79 if test -n "$DOC_FROM_SCRATCH"
80 then
81 make clean &&
82 rm -fr doc-html-inst doc-man-inst &&
83 mkdir doc-html-inst doc-man-inst || exit
86 DIFF=diff
87 export DIFF
89 make \
90 -C Documentation -j 2 $dd \
91 WEBDOC_DEST="$DOCREPO/doc-html-inst" install-webdoc || exit
93 make \
94 -C Documentation -j 2 $dd \
95 man1="$DOCREPO/doc-man-inst/man1" \
96 man5="$DOCREPO/doc-man-inst/man5" \
97 man7="$DOCREPO/doc-man-inst/man7" \
98 man1dir="$DOCREPO/doc-man-inst/man1" \
99 man5dir="$DOCREPO/doc-man-inst/man5" \
100 man7dir="$DOCREPO/doc-man-inst/man7" install || exit
102 for type in html man
104 find doc-$type-inst -type f |
105 while read path
107 it=$(expr "$path" : doc-$type-inst/'\(.*\)') || continue
108 t="doc-${type}pages/$it"
109 test -f "$t" && diff -q "$path" "$t" && continue
110 mkdir -p "$(dirname "$t")" &&
111 echo ": $t" && rm -f "$t" && ln "$path" "$t" || exit
112 ( cd doc-${type}pages && git add "$it" )
113 done || exit
115 find doc-$type-inst -type f |
116 sed -e 's|^doc-'$type'-inst/||' | sort >"$tmp.1" &&
117 (cd doc-${type}pages && git ls-files | sort) >"$tmp.2" &&
118 comm -13 "$tmp.1" "$tmp.2" |
119 ( cd doc-${type}pages && xargs rm -f -- ) || exit
122 cd doc-${type}pages
124 case "$type" in
125 html)
126 TYPE='HTML docs'
127 rm -f index.html
128 ln -sf git.html index.html
129 git add index.html
131 man)
132 TYPE='manpages'
134 esac
136 if git commit -a -m "Autogenerated $TYPE for $NID"
137 then
138 TARGETREPO=$(target_repo $type) &&
139 git push "$TARGETREPO" master:master
140 else
141 echo "* No changes in $type docs"
143 ) || exit
144 done
146 echo '
148 *** ALL DONE ***