forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdodoc.sh
More file actions
executable file
·162 lines (139 loc) · 3.66 KB
/
dodoc.sh
File metadata and controls
executable file
·162 lines (139 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
#
# This script is called from the post-update hook, and when
# the master branch is updated, run in $HOME/git-doc, like
# this:
: <<\END_OF_COMMENTARY
$ cat >hooks/post-update
#!/bin/sh
case " $* " in
*' refs/heads/master '*)
echo $HOME/git-doc/dodoc.sh | at now
;;
esac
exec git update-server-info
$ chmod +x hooks/post-update
END_OF_COMMENTARY
# $HOME/git-doc is a clone of the git.git repository and
# 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.
ID=`git rev-parse --verify refs/heads/master` || exit $?
unset GIT_DIR
: ${PUBLIC=/pub/software/scm/git/docs} &&
: ${MASTERREPO=`pwd`} &&
: ${DOCREPO=`dirname "$0"`} &&
test "$DOCREPO" != "" &&
cd "$DOCREPO" || exit $?
DOCREPO=`pwd`
tmp=`pwd`/.doctmp-$$
trap 'rm -f "$tmp".*' 0
(
git pull "$MASTERREPO" master &&
git fetch --tags "$MASTERREPO"
) >/dev/null 2>/dev/null || exit $?
test $(git rev-parse --verify refs/heads/master) == "$ID" &&
NID=$(git describe --abbrev=4 "$ID") &&
test '' != "$NID" || exit $?
# Set up subrepositories
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
dd='ASCIIDOC_NO_ROFF=YesPlease
ASCIIDOC8=YesPlease
MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
BLK_SHA1=YesPlease
GNU_ROFF=YesPlease'
case "$NID" in
?*-?*) ;;
?*)
make clean &&
rm -fr doc-html-inst doc-man-inst &&
mkdir doc-html-inst doc-man-inst || exit
;;
esac
make >./:html.log 2>&1 \
-C Documentation -j 2 $dd \
WEBDOC_DEST="$DOCREPO/doc-html-inst" install-webdoc || exit
make >./:man.log 2>&1 \
-C Documentation -j 2 $dd \
man1="$DOCREPO/doc-man-inst/man1" \
man5="$DOCREPO/doc-man-inst/man5" \
man7="$DOCREPO/doc-man-inst/man7" \
man1dir="$DOCREPO/doc-man-inst/man1" \
man5dir="$DOCREPO/doc-man-inst/man5" \
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")" &&
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
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"
then
git send-pack "$MASTERREPO" master:refs/heads/$type \
>/dev/null 2>&1
else
echo "* No changes in $type docs"
fi
) || exit
done
if test -d $PUBLIC
then
# This is iffy...
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 $?
echo '
*** ALL DONE ***
' >>./:html.log