Raw
1 #!/bin/sh
2
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.
9
10 unset GIT_DIR
11
12 : ${TOP=/srv/project/git}
13
14 MASTERREPO=$TOP/git.git/
15 MANREPO=$TOP/git-manpages.git/
16 HTMLREPO=$TOP/git-htmldocs.git/
17
18 target_repo () {
19 TARGETVAR=$(echo "$1"REPO | tr 'a-z' 'A-Z') &&
20 eval "echo \$$TARGETVAR"
21 }
22
23 DOCREPO=$(pwd) ;# "git-doc"
24 exec >:doc.log 2>&1
25
26 ID=$(cd "$MASTERREPO" && git rev-parse --verify refs/heads/master) || exit $?
27
28 tmp=`pwd`/.doctmp-$$
29 trap 'rm -f "$tmp".*' 0
30
31 (
32 git pull --ff-only "$MASTERREPO" master &&
33 git fetch --tags --force "$MASTERREPO"
34 ) || exit $?
35
36 test $(git rev-parse --verify refs/heads/master) = "$ID" &&
37 NID=$(git describe --abbrev=4 "$ID") &&
38 test -n "$NID" || exit $?
39
40 git reset --hard
41
42 # Set up subrepositories
43 for type in man html
44 do
45 test -d doc-${type}pages && continue
46 (
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 &&
54 (
55 cd doc-${type}pages && git archive HEAD
56 ) |
57 (
58 cd doc-$type-inst && tar xf -
59 )
60 done
61
62 # The below used to contain this instead...
63 # MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
64 dd='
65 MAN_BASE_URL="git-htmldocs/"
66 BLK_SHA1=YesPlease
67 USE_ASCIIDOCTOR=YesPlease
68 '
69
70 if test -z "$DOC_FROM_SCRATCH"
71 then
72 case "$NID" in
73 ?*-g*) ;;
74 ?*) DOC_FROM_SCRATCH=yes ;;
75 esac
76 fi
77 if test -n "$DOC_FROM_SCRATCH"
78 then
79 make clean &&
80 rm -fr doc-html-inst doc-man-inst &&
81 mkdir doc-html-inst doc-man-inst || exit
82 fi
83
84 DIFF=diff
85 export DIFF
86
87 make \
88 -C Documentation -j 2 $dd \
89 WEBDOC_DEST="$DOCREPO/doc-html-inst" install-webdoc || exit
90
91 make \
92 -C Documentation -j 2 $dd \
93 man1="$DOCREPO/doc-man-inst/man1" \
94 man5="$DOCREPO/doc-man-inst/man5" \
95 man7="$DOCREPO/doc-man-inst/man7" \
96 man1dir="$DOCREPO/doc-man-inst/man1" \
97 man5dir="$DOCREPO/doc-man-inst/man5" \
98 man7dir="$DOCREPO/doc-man-inst/man7" install || exit
99
100 for type in html man
101 do
102 find doc-$type-inst -type f |
103 while read path
104 do
105 it=$(expr "$path" : doc-$type-inst/'\(.*\)') || continue
106 t="doc-${type}pages/$it"
107 test -f "$t" && diff -q "$path" "$t" && continue
108 mkdir -p "$(dirname "$t")" &&
109 echo ": $t" && rm -f "$t" && ln "$path" "$t" || exit
110 ( cd doc-${type}pages && git add "$it" )
111 done || exit
112
113 find doc-$type-inst -type f |
114 sed -e 's|^doc-'$type'-inst/||' | sort >"$tmp.1" &&
115 (cd doc-${type}pages && git ls-files | sort) >"$tmp.2" &&
116 comm -13 "$tmp.1" "$tmp.2" |
117 ( cd doc-${type}pages && xargs rm -f -- ) || exit
118
119 (
120 cd doc-${type}pages
121
122 case "$type" in
123 html)
124 TYPE='HTML docs'
125 rm -f index.html
126 ln -sf git.html index.html
127 git add index.html
128 ;;
129 man)
130 TYPE='manpages'
131 ;;
132 esac
133
134 if git commit -a -m "Autogenerated $TYPE for $NID"
135 then
136 TARGETREPO=$(target_repo $type) &&
137 git push "$TARGETREPO" master:master
138 else
139 echo "* No changes in $type docs"
140 fi
141 ) || exit
142 done
143
144 echo '
145
146 *** ALL DONE ***
147 '