|
1 | 1 | #!/bin/sh |
2 | | -# |
3 | | -# This script is called from the post-update hook, and when |
4 | | -# the master branch is updated, run in $HOME/git-doc, like |
5 | | -# this: |
6 | | -: <<\END_OF_COMMENTARY |
7 | 2 |
|
8 | | -$ cat >hooks/post-update |
9 | | -#!/bin/sh |
10 | | -case " $* " in |
11 | | -*' refs/heads/master '*) |
12 | | - echo $HOME/git-doc/dodoc.sh | at now |
13 | | - ;; |
14 | | -esac |
15 | | -exec git update-server-info |
16 | | -$ chmod +x hooks/post-update |
17 | | -
|
18 | | -END_OF_COMMENTARY |
| 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. |
19 | 9 |
|
20 | | -# $HOME/git-doc is a clone of the git.git repository and |
21 | | -# has the master branch checkd out. We update the working |
22 | | -# tree and build pre-formatted documentation pages, install |
23 | | -# in doc-htmlpages and doc-manapges subdirectory here. |
24 | | -# These two are their own git repository, and when they are |
25 | | -# updated the updates are pushed back into their own branches |
26 | | -# in git.git repository. |
| 10 | +unset GIT_DIR |
27 | 11 |
|
28 | | -ID=`git rev-parse --verify refs/heads/master` || exit $? |
| 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/ |
29 | 16 |
|
30 | | -unset GIT_DIR |
| 17 | +target_repo () { |
| 18 | + TARGETVAR=$(echo "$1"REPO | tr 'a-z' 'A-Z') && |
| 19 | + eval "echo \$$TARGETVAR" |
| 20 | +} |
31 | 21 |
|
32 | | -: ${PUBLIC=/pub/software/scm/git/docs} && |
33 | | -: ${MASTERREPO=`pwd`} && |
34 | | -: ${DOCREPO=`dirname "$0"`} && |
35 | | -test "$DOCREPO" != "" && |
36 | | -cd "$DOCREPO" || exit $? |
| 22 | +DOCREPO=$(pwd) ;# "git-doc" |
| 23 | +exec >:doc.log 2>&1 |
37 | 24 |
|
38 | | -DOCREPO=`pwd` |
| 25 | +ID=$(cd "$MASTERREPO" && git rev-parse --verify refs/heads/master) || exit $? |
39 | 26 |
|
40 | 27 | tmp=`pwd`/.doctmp-$$ |
41 | 28 | trap 'rm -f "$tmp".*' 0 |
42 | 29 |
|
43 | 30 | ( |
44 | | - git pull "$MASTERREPO" master && |
45 | | - git fetch --tags "$MASTERREPO" |
46 | | -) >/dev/null 2>/dev/null || exit $? |
47 | | -test $(git rev-parse --verify refs/heads/master) == "$ID" && |
| 31 | + git pull --ff-only "$MASTERREPO" master && |
| 32 | + git fetch --tags "$MASTERREPO" |
| 33 | +) || exit $? |
| 34 | + |
| 35 | +test $(git rev-parse --verify refs/heads/master) = "$ID" && |
48 | 36 | NID=$(git describe --abbrev=4 "$ID") && |
49 | | -test '' != "$NID" || exit $? |
| 37 | +test -n "$NID" || exit $? |
| 38 | + |
| 39 | +git reset --hard |
50 | 40 |
|
51 | 41 | # Set up subrepositories |
52 | 42 | for type in man html |
53 | 43 | do |
54 | | - test -d doc-${type}pages || ( |
55 | | - mkdir doc-${type}pages && |
56 | | - cd doc-${type}pages && |
57 | | - git init-db || exit $? |
58 | | - |
59 | | - git fetch-pack "$MASTERREPO" ${type} | |
60 | | - while read sha1 name |
61 | | - do |
62 | | - case "$name" in |
63 | | - refs/heads/${type}) |
64 | | - git update-ref HEAD $sha1 && |
65 | | - git checkout || exit $? |
66 | | - break |
67 | | - ;; |
68 | | - esac |
69 | | - done || exit $? |
70 | | - ) || exit |
71 | | - rm -fr doc-$type-inst |
| 44 | + test -d doc-${type}pages && continue |
| 45 | + ( |
| 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 && |
| 53 | + ( |
| 54 | + cd doc-${type}pages && git archive HEAD |
| 55 | + ) | |
| 56 | + ( |
| 57 | + cd doc-$type-inst && tar xf - |
| 58 | + ) |
72 | 59 | done |
73 | 60 |
|
74 | | -dd='ASCIIDOC_NO_ROFF=YesPlease |
75 | | -ASCIIDOC8=YesPlease |
76 | | -MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/" |
77 | | -BLK_SHA1=YesPlease |
78 | | -GNU_ROFF=YesPlease' |
| 61 | +dd=' |
| 62 | + ASCIIDOC_NO_ROFF=YesPlease |
| 63 | + ASCIIDOC8=YesPlease |
| 64 | + MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/" |
| 65 | + BLK_SHA1=YesPlease |
| 66 | + GNU_ROFF=YesPlease |
| 67 | +' |
79 | 68 |
|
80 | 69 | case "$NID" in |
81 | 70 | ?*-?*) ;; |
|
89 | 78 | DIFF=diff |
90 | 79 | export DIFF |
91 | 80 |
|
92 | | -make >./:html.log 2>&1 \ |
| 81 | +make \ |
93 | 82 | -C Documentation -j 2 $dd \ |
94 | 83 | WEBDOC_DEST="$DOCREPO/doc-html-inst" install-webdoc || exit |
95 | 84 |
|
96 | | -make >./:man.log 2>&1 \ |
| 85 | +make \ |
97 | 86 | -C Documentation -j 2 $dd \ |
98 | 87 | man1="$DOCREPO/doc-man-inst/man1" \ |
99 | 88 | man5="$DOCREPO/doc-man-inst/man5" \ |
|
138 | 127 |
|
139 | 128 | if git commit -a -m "Autogenerated $TYPE for $NID" |
140 | 129 | then |
141 | | - git send-pack "$MASTERREPO" master:refs/heads/$type \ |
142 | | - >/dev/null 2>&1 |
| 130 | + TARGETREPO=$(target_repo $type) && |
| 131 | + git push "$TARGETREPO" master:master |
143 | 132 | else |
144 | 133 | echo "* No changes in $type docs" |
145 | 134 | fi |
146 | 135 | ) || exit |
147 | 136 | done |
148 | 137 |
|
149 | | -if test -d $PUBLIC |
150 | | -then |
151 | | - # This is iffy... |
152 | | - mv Documentation/git.html Documentation/saved-git-html |
153 | | - make >>./:html.log 2>&1 \ |
154 | | - -C Documentation \ |
155 | | - WEBDOC_DEST="$PUBLIC" ASCIIDOC_EXTRA='-a stalenotes' \ |
156 | | - install-webdoc && |
157 | | - mv Documentation/saved-git-html Documentation/git.html |
158 | | -else |
159 | | - echo "* No public html at $PUBLIC" |
160 | | -fi || exit $? |
161 | | - |
162 | 138 | echo ' |
163 | 139 |
|
164 | 140 | *** ALL DONE *** |
165 | | -' >>./:html.log |
| 141 | +' |
0 commit comments