VirtualBox

source: kBuild/trunk/src/grep/build-aux/gnu-web-doc-update

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:executable set to *
File size: 6.1 KB
Line 
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
5VERSION=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
22ME=$(basename "$0")
23warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
24die() { warn "$*"; exit 1; }
25
26help()
27{
28 cat <<EOF
29Usage: $ME
30
31Run this script from top_srcdir (no arguments) after each non-alpha
32release, to update the web documentation at
33https://www.gnu.org/software/\$pkg/manual/
34
35This script assumes you're using git for revision control, and
36requires a .prev-version file as well as a Makefile, from which it
37extracts the version number and package name, respectively. Also, it
38assumes all documentation is in the doc/ sub-directory.
39
40Options:
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
48Report bugs and patches to <[email protected]>.
49EOF
50 exit
51}
52
53version()
54{
55 year=$(echo "$VERSION" | sed 's/[^0-9].*//')
56 cat <<EOF
57$ME $VERSION
58Copyright (C) $year Free Software Foundation, Inc,
59License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
60This is free software: you are free to change and redistribute it.
61There is NO WARRANTY, to the extent permitted by law.
62EOF
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.
74find_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.
105find_tool CVS cvs
106find_tool GIT git
107find_tool RSYNC rsync
108find_tool XARGS gxargs xargs
109
110builddir=.
111dryrun=
112rm_stale='echo'
113cvs_user="$USER"
114while test $# != 0
115do
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
135done
136
137test $# = 0 \
138 || die "too many arguments"
139
140prev=.prev-version
141version=$(cat $prev) || die "no $prev file?"
142pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \
143 || die "no Makefile?"
144tmp_branch=web-doc-$version-$$
145current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}')
146
147cleanup()
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}
156trap cleanup 0
157trap '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.
162set -e
163$GIT checkout -b $tmp_branch v$version
164$GIT submodule update --recursive
165./bootstrap
166srcdir=$(pwd)
167cd "$builddir"
168builddir=$(pwd)
169 ./config.status --recheck
170 ./config.status
171 make
172 make web-manual
173cd "$srcdir"
174set +e
175
176tmp=$(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:
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette