Debian Codegraph @

build-aux/gnu-web-doc-update

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