Commit | Line | Data |
---|---|---|
c84bdaf6 LC |
1 | #!/bin/sh |
2 | # Run this after each non-alpha release, to update the web documentation at | |
3 | # http://www.gnu.org/software/$pkg/manual/ | |
c84bdaf6 | 4 | |
af07e104 | 5 | VERSION=2012-12-16.14; # UTC |
c84bdaf6 | 6 | |
5e69ceb7 | 7 | # Copyright (C) 2009-2014 Free Software Foundation, Inc. |
c84bdaf6 LC |
8 | |
9 | # This program is free software: you can redistribute it and/or modify | |
10 | # it under the terms of the GNU General Public License as published by | |
11 | # the Free Software Foundation, either version 3 of the License, or | |
12 | # (at your option) any later version. | |
13 | ||
14 | # This program is distributed in the hope that it will be useful, | |
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | # GNU General Public License for more details. | |
18 | ||
19 | # You should have received a copy of the GNU General Public License | |
20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
005de2e8 | 22 | ME=$(basename "$0") |
c84bdaf6 LC |
23 | warn() { printf '%s: %s\n' "$ME" "$*" >&2; } |
24 | die() { warn "$*"; exit 1; } | |
25 | ||
005de2e8 | 26 | help() |
c84bdaf6 | 27 | { |
005de2e8 | 28 | cat <<EOF |
c84bdaf6 LC |
29 | Usage: $ME |
30 | ||
7ae4e75a LC |
31 | Run this script from top_srcdir (no arguments) after each non-alpha |
32 | release, to update the web documentation at | |
33 | http://www.gnu.org/software/\$pkg/manual/ | |
c84bdaf6 | 34 | |
af07e104 AW |
35 | This script assumes you're using git for revision control, and |
36 | requires a .prev-version file as well as a Makefile, from which it | |
37 | extracts the version number and package name, respectively. Also, it | |
38 | assumes all documentation is in the doc/ sub-directory. | |
39 | ||
c84bdaf6 | 40 | Options: |
005de2e8 | 41 | -C, --builddir=DIR location of (configured) Makefile (default: .) |
af07e104 | 42 | -n, --dry-run don't actually commit anything |
005de2e8 LC |
43 | --help print this help, then exit |
44 | --version print version number, then exit | |
c84bdaf6 LC |
45 | |
46 | Report bugs and patches to <bug-gnulib@gnu.org>. | |
47 | EOF | |
005de2e8 LC |
48 | exit |
49 | } | |
c84bdaf6 | 50 | |
005de2e8 LC |
51 | version() |
52 | { | |
53 | year=$(echo "$VERSION" | sed 's/[^0-9].*//') | |
54 | cat <<EOF | |
c84bdaf6 LC |
55 | $ME $VERSION |
56 | Copyright (C) $year Free Software Foundation, Inc, | |
57 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | |
58 | This is free software: you are free to change and redistribute it. | |
59 | There is NO WARRANTY, to the extent permitted by law. | |
60 | EOF | |
005de2e8 LC |
61 | exit |
62 | } | |
63 | ||
7ae4e75a LC |
64 | # find_tool ENVVAR NAMES... |
65 | # ------------------------- | |
66 | # Search for a required program. Use the value of ENVVAR, if set, | |
67 | # otherwise find the first of the NAMES that can be run (i.e., | |
68 | # supports --version). If found, set ENVVAR to the program name, | |
69 | # die otherwise. | |
70 | # | |
71 | # FIXME: code duplication, see also bootstrap. | |
72 | find_tool () | |
73 | { | |
74 | find_tool_envvar=$1 | |
75 | shift | |
76 | find_tool_names=$@ | |
77 | eval "find_tool_res=\$$find_tool_envvar" | |
78 | if test x"$find_tool_res" = x; then | |
79 | for i | |
80 | do | |
81 | if ($i --version </dev/null) >/dev/null 2>&1; then | |
82 | find_tool_res=$i | |
83 | break | |
84 | fi | |
85 | done | |
86 | else | |
87 | find_tool_error_prefix="\$$find_tool_envvar: " | |
88 | fi | |
89 | test x"$find_tool_res" != x \ | |
90 | || die "one of these is required: $find_tool_names" | |
91 | ($find_tool_res --version </dev/null) >/dev/null 2>&1 \ | |
92 | || die "${find_tool_error_prefix}cannot run $find_tool_res --version" | |
93 | eval "$find_tool_envvar=\$find_tool_res" | |
94 | eval "export $find_tool_envvar" | |
95 | } | |
96 | ||
97 | ## ------ ## | |
98 | ## Main. ## | |
99 | ## ------ ## | |
100 | ||
101 | # Requirements: everything required to bootstrap your package, plus | |
102 | # these. | |
103 | find_tool CVS cvs | |
7ae4e75a LC |
104 | find_tool GIT git |
105 | find_tool RSYNC rsync | |
106 | find_tool XARGS gxargs xargs | |
107 | ||
005de2e8 | 108 | builddir=. |
af07e104 | 109 | dryrun= |
005de2e8 LC |
110 | while test $# != 0 |
111 | do | |
112 | # Handle --option=value by splitting apart and putting back on argv. | |
113 | case $1 in | |
114 | --*=*) | |
115 | opt=$(echo "$1" | sed -e 's/=.*//') | |
116 | val=$(echo "$1" | sed -e 's/[^=]*=//') | |
117 | shift | |
118 | set dummy "$opt" "$val" ${1+"$@"}; shift | |
119 | ;; | |
120 | esac | |
c84bdaf6 | 121 | |
005de2e8 LC |
122 | case $1 in |
123 | --help|--version) ${1#--};; | |
124 | -C|--builddir) shift; builddir=$1; shift ;; | |
af07e104 | 125 | -n|--dry-run) dryrun=echo; shift;; |
005de2e8 LC |
126 | --*) die "unrecognized option: $1";; |
127 | *) break;; | |
c84bdaf6 | 128 | esac |
005de2e8 | 129 | done |
c84bdaf6 | 130 | |
005de2e8 | 131 | test $# = 0 \ |
7ae4e75a | 132 | || die "too many arguments" |
c84bdaf6 LC |
133 | |
134 | prev=.prev-version | |
7ae4e75a | 135 | version=$(cat $prev) || die "no $prev file?" |
005de2e8 | 136 | pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \ |
7ae4e75a | 137 | || die "no Makefile?" |
c84bdaf6 | 138 | tmp_branch=web-doc-$version-$$ |
7ae4e75a | 139 | current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}') |
c84bdaf6 LC |
140 | |
141 | cleanup() | |
142 | { | |
005de2e8 | 143 | __st=$? |
af07e104 | 144 | $dryrun rm -rf "$tmp" |
7ae4e75a LC |
145 | $GIT checkout "$current_branch" |
146 | $GIT submodule update --recursive | |
147 | $GIT branch -d $tmp_branch | |
c84bdaf6 LC |
148 | exit $__st |
149 | } | |
150 | trap cleanup 0 | |
151 | trap 'exit $?' 1 2 13 15 | |
152 | ||
153 | # We must build using sources for which --version reports the | |
154 | # just-released version number, not some string like 7.6.18-20761. | |
155 | # That version string propagates into all documentation. | |
005de2e8 | 156 | set -e |
7ae4e75a LC |
157 | $GIT checkout -b $tmp_branch v$version |
158 | $GIT submodule update --recursive | |
005de2e8 LC |
159 | ./bootstrap |
160 | srcdir=$(pwd) | |
161 | cd "$builddir" | |
162 | ./config.status --recheck | |
163 | ./config.status | |
164 | make | |
165 | make web-manual | |
166 | cd "$srcdir" | |
167 | set +e | |
168 | ||
169 | tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1 | |
c84bdaf6 | 170 | ( cd $tmp \ |
7ae4e75a LC |
171 | && $CVS -d $USER@cvs.sv.gnu.org:/webcvs/$pkg co $pkg ) |
172 | $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual | |
c84bdaf6 LC |
173 | |
174 | ( | |
175 | cd $tmp/$pkg/manual | |
176 | ||
af07e104 AW |
177 | # Add all the files. This is simpler than trying to add only the |
178 | # new ones because of new directories: it would require iterating on | |
179 | # adding the outer directories, and then their contents. | |
180 | # | |
181 | # find guarantees that we add outer directories first. | |
182 | find . -name CVS -prune -o -print \ | |
183 | | $XARGS --no-run-if-empty -- $dryrun $CVS add -ko | |
c84bdaf6 | 184 | |
af07e104 | 185 | $dryrun $CVS ci -m $version |
c84bdaf6 LC |
186 | ) |
187 | ||
188 | # Local variables: | |
189 | # eval: (add-hook 'write-file-hooks 'time-stamp) | |
190 | # time-stamp-start: "VERSION=" | |
191 | # time-stamp-format: "%:y-%02m-%02d.%02H" | |
192 | # time-stamp-time-zone: "UTC" | |
193 | # time-stamp-end: "; # UTC" | |
194 | # End: |