123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- #!/bin/sh
- VERSION=2022-01-27.18;
- ME=$(basename "$0")
- warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
- die() { warn "$*"; exit 1; }
- help()
- {
- cat <<EOF
- Usage: $ME
- Run this script from top_srcdir (no arguments) after each non-alpha
- release, to update the web documentation at
- https://www.gnu.org/software/\$pkg/manual/
- This script assumes you're using git for revision control, and
- requires a .prev-version file as well as a Makefile, from which it
- extracts the version number and package name, respectively. Also, it
- assumes all documentation is in the doc/ sub-directory.
- Options:
- -C, --builddir=DIR location of (configured) Makefile (default: .)
- -n, --dry-run don't actually commit anything
- -m, --mirror remove out of date files from document server
- -u, --user the name of the CVS user on Savannah
- --help print this help, then exit
- --version print version number, then exit
- Report bugs and patches to <bug-gnulib@gnu.org>.
- EOF
- exit
- }
- version()
- {
- year=$(echo "$VERSION" | sed 's/[^0-9].*//')
- cat <<EOF
- $ME $VERSION
- Copyright (C) $year Free Software Foundation, Inc,
- License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
- This is free software: you are free to change and redistribute it.
- There is NO WARRANTY, to the extent permitted by law.
- EOF
- exit
- }
- find_tool ()
- {
- find_tool_envvar=$1
- shift
- find_tool_names=$@
- eval "find_tool_res=\$$find_tool_envvar"
- if test x"$find_tool_res" = x; then
- for i
- do
- if ($i --version </dev/null) >/dev/null 2>&1; then
- find_tool_res=$i
- break
- fi
- done
- else
- find_tool_error_prefix="\$$find_tool_envvar: "
- fi
- test x"$find_tool_res" != x \
- || die "one of these is required: $find_tool_names"
- ($find_tool_res --version </dev/null) >/dev/null 2>&1 \
- || die "${find_tool_error_prefix}cannot run $find_tool_res --version"
- eval "$find_tool_envvar=\$find_tool_res"
- eval "export $find_tool_envvar"
- }
- find_tool CVS cvs
- find_tool GIT git
- find_tool RSYNC rsync
- find_tool XARGS gxargs xargs
- builddir=.
- dryrun=
- rm_stale='echo'
- cvs_user="$USER"
- while test $# != 0
- do
-
- case $1 in
- --*=*)
- opt=$(echo "$1" | sed -e 's/=.*//')
- val=$(echo "$1" | sed -e 's/[^=]*=//')
- shift
- set dummy "$opt" "$val" "$@"; shift
- ;;
- esac
- case $1 in
- --help|--version) ${1#--};;
- -C|--builddir) shift; builddir=$1; shift ;;
- -n|--dry-run) dryrun=echo; shift;;
- -m|--mirror) rm_stale=''; shift;;
- -u|--user) shift; cvs_user=$1; shift ;;
- --*) die "unrecognized option: $1";;
- *) break;;
- esac
- done
- test $# = 0 \
- || die "too many arguments"
- prev=.prev-version
- version=$(cat $prev) || die "no $prev file?"
- pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \
- || die "no Makefile?"
- tmp_branch=web-doc-$version-$$
- current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}')
- cleanup()
- {
- __st=$?
- $dryrun rm -rf "$tmp"
- $GIT checkout "$current_branch"
- $GIT submodule update --recursive
- $GIT branch -d $tmp_branch
- exit $__st
- }
- trap cleanup EXIT
- trap 'exit $?' HUP INT PIPE TERM
- set -e
- $GIT checkout -b $tmp_branch v$version
- $GIT submodule update --recursive
- ./bootstrap
- srcdir=$(pwd)
- cd "$builddir"
- builddir=$(pwd)
- ./config.status --recheck
- ./config.status
- make
- make web-manual
- cd "$srcdir"
- set +e
- tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1
- ( cd $tmp \
- && $CVS -d $cvs_user@cvs.sv.gnu.org:/webcvs/$pkg co $pkg )
- $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
- (
- cd $tmp/$pkg/manual
-
-
-
- find . -name CVS -prune -o -type d \! -empty -print \
- | $XARGS -n1 --no-run-if-empty -- $dryrun $CVS add -ko
-
- find . -name CVS -prune -o -type f -print \
- | $XARGS --no-run-if-empty -- $dryrun $CVS add -ko
-
-
- if test -n "$rm_stale"; then
- echo 'Consider the --mirror option if all of the manual is generated,' >&2
- echo 'which will run `cvs remove` to remove stale files.' >&2
- fi
- { find . \( -name CVS -o -type f -name '.*' \) -prune -o -type f -print
- (cd "$builddir"/doc/manual/ && find . -type f -print | sed p)
- } | sort | uniq -u \
- | $XARGS --no-run-if-empty -- ${rm_stale:-$dryrun} $CVS remove -f
- $dryrun $CVS ci -m $version
- )
|