1 | #!/bin/sh
|
---|
2 | # Run this after each non-alpha release, to update the web documentation at
|
---|
3 | # https://www.gnu.org/software/$pkg/manual/
|
---|
4 |
|
---|
5 | VERSION=2021-01-09.09; # UTC
|
---|
6 |
|
---|
7 | # Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
---|
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 <https://www.gnu.org/licenses/>.
|
---|
21 |
|
---|
22 | ME=$(basename "$0")
|
---|
23 | warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
|
---|
24 | die() { warn "$*"; exit 1; }
|
---|
25 |
|
---|
26 | help()
|
---|
27 | {
|
---|
28 | cat <<EOF
|
---|
29 | Usage: $ME
|
---|
30 |
|
---|
31 | Run this script from top_srcdir (no arguments) after each non-alpha
|
---|
32 | release, to update the web documentation at
|
---|
33 | https://www.gnu.org/software/\$pkg/manual/
|
---|
34 |
|
---|
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 |
|
---|
40 | Options:
|
---|
41 | -C, --builddir=DIR location of (configured) Makefile (default: .)
|
---|
42 | -n, --dry-run don't actually commit anything
|
---|
43 | -m, --mirror remove out of date files from document server
|
---|
44 | -u, --user the name of the CVS user on Savannah
|
---|
45 | --help print this help, then exit
|
---|
46 | --version print version number, then exit
|
---|
47 |
|
---|
48 | Report bugs and patches to <[email protected]>.
|
---|
49 | EOF
|
---|
50 | exit
|
---|
51 | }
|
---|
52 |
|
---|
53 | version()
|
---|
54 | {
|
---|
55 | year=$(echo "$VERSION" | sed 's/[^0-9].*//')
|
---|
56 | cat <<EOF
|
---|
57 | $ME $VERSION
|
---|
58 | Copyright (C) $year Free Software Foundation, Inc,
|
---|
59 | License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
|
---|
60 | This is free software: you are free to change and redistribute it.
|
---|
61 | There is NO WARRANTY, to the extent permitted by law.
|
---|
62 | EOF
|
---|
63 | exit
|
---|
64 | }
|
---|
65 |
|
---|
66 | # find_tool ENVVAR NAMES...
|
---|
67 | # -------------------------
|
---|
68 | # Search for a required program. Use the value of ENVVAR, if set,
|
---|
69 | # otherwise find the first of the NAMES that can be run (i.e.,
|
---|
70 | # supports --version). If found, set ENVVAR to the program name,
|
---|
71 | # die otherwise.
|
---|
72 | #
|
---|
73 | # FIXME: code duplication, see also bootstrap.
|
---|
74 | find_tool ()
|
---|
75 | {
|
---|
76 | find_tool_envvar=$1
|
---|
77 | shift
|
---|
78 | find_tool_names=$@
|
---|
79 | eval "find_tool_res=\$$find_tool_envvar"
|
---|
80 | if test x"$find_tool_res" = x; then
|
---|
81 | for i
|
---|
82 | do
|
---|
83 | if ($i --version </dev/null) >/dev/null 2>&1; then
|
---|
84 | find_tool_res=$i
|
---|
85 | break
|
---|
86 | fi
|
---|
87 | done
|
---|
88 | else
|
---|
89 | find_tool_error_prefix="\$$find_tool_envvar: "
|
---|
90 | fi
|
---|
91 | test x"$find_tool_res" != x \
|
---|
92 | || die "one of these is required: $find_tool_names"
|
---|
93 | ($find_tool_res --version </dev/null) >/dev/null 2>&1 \
|
---|
94 | || die "${find_tool_error_prefix}cannot run $find_tool_res --version"
|
---|
95 | eval "$find_tool_envvar=\$find_tool_res"
|
---|
96 | eval "export $find_tool_envvar"
|
---|
97 | }
|
---|
98 |
|
---|
99 | ## ------ ##
|
---|
100 | ## Main. ##
|
---|
101 | ## ------ ##
|
---|
102 |
|
---|
103 | # Requirements: everything required to bootstrap your package, plus
|
---|
104 | # these.
|
---|
105 | find_tool CVS cvs
|
---|
106 | find_tool GIT git
|
---|
107 | find_tool RSYNC rsync
|
---|
108 | find_tool XARGS gxargs xargs
|
---|
109 |
|
---|
110 | builddir=.
|
---|
111 | dryrun=
|
---|
112 | rm_stale='echo'
|
---|
113 | cvs_user="$USER"
|
---|
114 | while test $# != 0
|
---|
115 | do
|
---|
116 | # Handle --option=value by splitting apart and putting back on argv.
|
---|
117 | case $1 in
|
---|
118 | --*=*)
|
---|
119 | opt=$(echo "$1" | sed -e 's/=.*//')
|
---|
120 | val=$(echo "$1" | sed -e 's/[^=]*=//')
|
---|
121 | shift
|
---|
122 | set dummy "$opt" "$val" "$@"; shift
|
---|
123 | ;;
|
---|
124 | esac
|
---|
125 |
|
---|
126 | case $1 in
|
---|
127 | --help|--version) ${1#--};;
|
---|
128 | -C|--builddir) shift; builddir=$1; shift ;;
|
---|
129 | -n|--dry-run) dryrun=echo; shift;;
|
---|
130 | -m|--mirror) rm_stale=''; shift;;
|
---|
131 | -u|--user) shift; cvs_user=$1; shift ;;
|
---|
132 | --*) die "unrecognized option: $1";;
|
---|
133 | *) break;;
|
---|
134 | esac
|
---|
135 | done
|
---|
136 |
|
---|
137 | test $# = 0 \
|
---|
138 | || die "too many arguments"
|
---|
139 |
|
---|
140 | prev=.prev-version
|
---|
141 | version=$(cat $prev) || die "no $prev file?"
|
---|
142 | pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \
|
---|
143 | || die "no Makefile?"
|
---|
144 | tmp_branch=web-doc-$version-$$
|
---|
145 | current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}')
|
---|
146 |
|
---|
147 | cleanup()
|
---|
148 | {
|
---|
149 | __st=$?
|
---|
150 | $dryrun rm -rf "$tmp"
|
---|
151 | $GIT checkout "$current_branch"
|
---|
152 | $GIT submodule update --recursive
|
---|
153 | $GIT branch -d $tmp_branch
|
---|
154 | exit $__st
|
---|
155 | }
|
---|
156 | trap cleanup 0
|
---|
157 | trap 'exit $?' 1 2 13 15
|
---|
158 |
|
---|
159 | # We must build using sources for which --version reports the
|
---|
160 | # just-released version number, not some string like 7.6.18-20761.
|
---|
161 | # That version string propagates into all documentation.
|
---|
162 | set -e
|
---|
163 | $GIT checkout -b $tmp_branch v$version
|
---|
164 | $GIT submodule update --recursive
|
---|
165 | ./bootstrap
|
---|
166 | srcdir=$(pwd)
|
---|
167 | cd "$builddir"
|
---|
168 | builddir=$(pwd)
|
---|
169 | ./config.status --recheck
|
---|
170 | ./config.status
|
---|
171 | make
|
---|
172 | make web-manual
|
---|
173 | cd "$srcdir"
|
---|
174 | set +e
|
---|
175 |
|
---|
176 | tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1
|
---|
177 | ( cd $tmp \
|
---|
178 | && $CVS -d $cvs_user@cvs.sv.gnu.org:/webcvs/$pkg co $pkg )
|
---|
179 | $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
|
---|
180 |
|
---|
181 | (
|
---|
182 | cd $tmp/$pkg/manual
|
---|
183 |
|
---|
184 | # Add all the files. This is simpler than trying to add only the
|
---|
185 | # new ones because of new directories
|
---|
186 | # First add non empty dirs individually
|
---|
187 | find . -name CVS -prune -o -type d \! -empty -print \
|
---|
188 | | $XARGS -n1 --no-run-if-empty -- $dryrun $CVS add -ko
|
---|
189 | # Now add all files
|
---|
190 | find . -name CVS -prune -o -type f -print \
|
---|
191 | | $XARGS --no-run-if-empty -- $dryrun $CVS add -ko
|
---|
192 |
|
---|
193 | # Report/Remove stale files
|
---|
194 | # excluding doc server specific files like CVS/* and .symlinks
|
---|
195 | if test -n "$rm_stale"; then
|
---|
196 | echo 'Consider the --mirror option if all of the manual is generated,' >&2
|
---|
197 | echo 'which will run `cvs remove` to remove stale files.' >&2
|
---|
198 | fi
|
---|
199 | { find . \( -name CVS -o -type f -name '.*' \) -prune -o -type f -print
|
---|
200 | (cd "$builddir"/doc/manual/ && find . -type f -print | sed p)
|
---|
201 | } | sort | uniq -u \
|
---|
202 | | $XARGS --no-run-if-empty -- ${rm_stale:-$dryrun} $CVS remove -f
|
---|
203 |
|
---|
204 | $dryrun $CVS ci -m $version
|
---|
205 | )
|
---|
206 |
|
---|
207 | # Local variables:
|
---|
208 | # eval: (add-hook 'before-save-hook 'time-stamp)
|
---|
209 | # time-stamp-start: "VERSION="
|
---|
210 | # time-stamp-format: "%:y-%02m-%02d.%02H"
|
---|
211 | # time-stamp-time-zone: "UTC0"
|
---|
212 | # time-stamp-end: "; # UTC"
|
---|
213 | # End:
|
---|