OLD | NEW |
1 #!/bin/bash -e | 1 #!/bin/bash -e |
2 shopt -s nullglob | 2 shopt -s nullglob |
3 | 3 |
4 cd $(dirname "$0") | 4 cd $(dirname "$0") |
5 | 5 |
6 # Script which takes all the asciidoc git-*.txt files in this directory, renders | 6 # Script which takes all the asciidoc git-*.txt files in this directory, renders |
7 # them to html + manpage format using git 1.9's doc toolchain, then puts | 7 # them to html + manpage format using git 1.9's doc toolchain, then puts |
8 # them in depot_tools to be committed. | 8 # them in depot_tools to be committed. |
9 | 9 |
10 ensure_in_path() { | 10 ensure_in_path() { |
(...skipping 24 matching lines...) Expand all Loading... |
35 GITHASH=5f95c9f850b19b368c43ae399cc831b17a26a5ac | 35 GITHASH=5f95c9f850b19b368c43ae399cc831b17a26a5ac |
36 if [[ ! -d git || $(git -C git rev-parse HEAD) != $GITHASH ]] | 36 if [[ ! -d git || $(git -C git rev-parse HEAD) != $GITHASH ]] |
37 then | 37 then |
38 echo Cloning git | 38 echo Cloning git |
39 rm -rf git | 39 rm -rf git |
40 git clone --single-branch --branch $BRANCH --depth 1 \ | 40 git clone --single-branch --branch $BRANCH --depth 1 \ |
41 https://kernel.googlesource.com/pub/scm/git/git.git 2> /dev/null | 41 https://kernel.googlesource.com/pub/scm/git/git.git 2> /dev/null |
42 | 42 |
43 # Replace the 'source' and 'package' strings. | 43 # Replace the 'source' and 'package' strings. |
44 ed git/Documentation/asciidoc.conf <<EOF | 44 ed git/Documentation/asciidoc.conf <<EOF |
45 H | 45 H |
46 81 | 46 81 |
47 s/Git/depot_tools | 47 s/Git/depot_tools |
48 +2 | 48 +2 |
49 s/Git Manual/Chromium depot_tools Manual | 49 s/Git Manual/Chromium depot_tools Manual |
50 wq | 50 wq |
51 EOF | 51 EOF |
| 52 |
| 53 # fix Makefile to include non-_-prefixed files as MAN1 entries |
| 54 { |
| 55 shopt -s extglob |
| 56 echo H |
| 57 echo 16 |
| 58 for x in "$(echo !(git-*|_*).txt)" |
| 59 do |
| 60 echo i |
| 61 echo MAN1_TXT += $x |
| 62 echo . |
| 63 done |
| 64 echo wq |
| 65 } | ed git/Documentation/Makefile |
| 66 |
| 67 # fix build-docdep.perl to ignore attributes on include::[] macros |
| 68 ed git/Documentation/build-docdep.perl <<EOF |
| 69 H |
| 70 12 |
| 71 c |
| 72 s/\[[^]]*\]//; |
| 73 . |
| 74 wq |
| 75 EOF |
| 76 |
| 77 # Add additional CSS override file |
| 78 ed git/Documentation/Makefile <<EOF |
| 79 H |
| 80 /ASCIIDOC_EXTRA |
| 81 a |
| 82 -a stylesheet=$(pwd)/git/Documentation/asciidoc-override.css |
| 83 . |
| 84 -1 |
| 85 j |
| 86 /^\$(MAN_HTML): |
| 87 a |
| 88 asciidoc-override.css |
| 89 . |
| 90 -1 |
| 91 j |
| 92 wq |
| 93 EOF |
| 94 |
52 fi | 95 fi |
53 echo Git up to date at $GITHASH \($BRANCH\) | 96 echo Git up to date at $GITHASH \($BRANCH\) |
54 | 97 |
| 98 # build directory files for 'essential' and 'helper' sections of the depot_tools |
| 99 # manpage. |
| 100 for category in helper essential |
| 101 do |
| 102 { |
| 103 PRINTED_BANNER=0 |
| 104 for x in *.${category}.txt |
| 105 do |
| 106 # If we actually have tools in the category, print the banner first. |
| 107 if [[ $PRINTED_BANNER != 1 ]] |
| 108 then |
| 109 PRINTED_BANNER=1 |
| 110 # ex. |
| 111 # CATEGORY TOOLS |
| 112 # -------------- |
| 113 BANNER=$(echo $category tools | awk '{print toupper($0)}') |
| 114 echo $BANNER |
| 115 for i in $(seq 1 ${#BANNER}) |
| 116 do |
| 117 echo -n - |
| 118 done |
| 119 echo |
| 120 echo |
| 121 fi |
| 122 |
| 123 # ex. |
| 124 # linkgit:git-tool[1]:: |
| 125 # \tinclude::_git-tool_desc.category.txt[] |
| 126 PLAIN_PATH=${x%%_desc.*.txt} |
| 127 PLAIN_PATH=${PLAIN_PATH:1} |
| 128 echo "linkgit:$PLAIN_PATH[1]::" |
| 129 echo -e "include::${x}[]" |
| 130 echo |
| 131 done |
| 132 } > __${category}.txt |
| 133 done |
| 134 |
55 HTML_TARGETS=() | 135 HTML_TARGETS=() |
56 MAN_TARGETS=() | 136 MAN_TARGETS=() |
57 for x in *.txt | 137 for x in *.txt *.css |
58 do | 138 do |
59 TO="git/Documentation/$x" | 139 TO="git/Documentation/$x" |
60 if [[ ! -f "$TO" ]] || ! cmp --silent "$x" "$TO" | 140 if [[ ! -f "$TO" ]] || ! cmp --silent "$x" "$TO" |
61 then | 141 then |
62 echo \'$x\' differs | 142 echo \'$x\' differs |
63 cp $x "$TO" | 143 cp $x "$TO" |
64 fi | 144 fi |
65 # Exclude files beginning with _ from the target list. This is useful to have | 145 # Exclude files beginning with _ from the target list. This is useful to have |
66 # includable snippet files. | 146 # includable snippet files. |
67 if [[ ${x:0:1} != _ ]] | 147 if [[ ${x:0:1} != _ && ${x:(-4)} == .txt ]] |
68 then | 148 then |
69 HTML_TARGETS+=("${x%%.txt}.html") | 149 HTML_TARGETS+=("${x%%.txt}.html") |
70 MAN_TARGETS+=("${x%%.txt}.1") | 150 MAN_TARGETS+=("${x%%.txt}.1") |
71 fi | 151 fi |
72 done | 152 done |
73 | 153 |
74 VER="v$(git rev-parse --short HEAD)" | 154 VER="v$(git rev-parse --short HEAD)" |
75 if [[ ! -f git/version ]] || ! cmp --silent git/version <(echo "$VER") | 155 if [[ ! -f git/version ]] || ! cmp --silent git/version <(echo "$VER") |
76 then | 156 then |
77 echo Version changed, cleaning. | 157 echo Version changed, cleaning. |
78 echo "$VER" > git/version | 158 echo "$VER" > git/version |
79 (cd git/Documentation && make clean) | 159 (cd git/Documentation && make clean) |
80 fi | 160 fi |
81 | 161 |
82 # This export is so that asciidoc sys snippets which invoke git run relative to | 162 # This export is so that asciidoc sys snippets which invoke git run relative to |
83 # depot_tools instead of the git clone. | 163 # depot_tools instead of the git clone. |
84 ( | 164 ( |
85 export GIT_DIR="$(git rev-parse --git-dir)" && | 165 export GIT_DIR="$(git rev-parse --git-dir)" && |
86 cd git/Documentation && | 166 cd git/Documentation && |
87 make -j"$[${#MAN_TARGETS} + ${#HTML_TARGETS}]" "${MAN_TARGETS[@]}" "${HTML_TAR
GETS[@]}" | 167 make -j"$[${#MAN_TARGETS} + ${#HTML_TARGETS}]" "${MAN_TARGETS[@]}" "${HTML_TAR
GETS[@]}" |
88 ) | 168 ) |
89 | 169 |
90 mkdir htmlout 2> /dev/null || true | 170 mkdir htmlout 2> /dev/null || true |
91 for x in "${HTML_TARGETS[@]}" | 171 for x in "${HTML_TARGETS[@]}" |
92 do | 172 do |
93 echo Copying htmlout/$x | 173 echo Copying htmlout/$x |
94 cp "git/Documentation/$x" htmlout | 174 tr -d '\015' <"git/Documentation/$x" >"htmlout/$x" |
95 done | 175 done |
96 | 176 |
97 for x in "${MAN_TARGETS[@]}" | 177 for x in "${MAN_TARGETS[@]}" |
98 do | 178 do |
99 echo Copying ../man1/$x | 179 echo Copying ../man1/$x |
100 cp "git/Documentation/$x" ../man1 | 180 cp "git/Documentation/$x" ../man1 |
101 done | 181 done |
OLD | NEW |