adf6c5179cfda1747a8ba96aa79a0d26a754b28e
[gnulib.git] / build-aux / gnu-web-doc-update
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/
4 # This script must be run from the top-level directory,
5 # assumes you're using git for revision control,
6 # and requires a .prev-version file as well as a Makefile,
7 # from which it extracts the version number and package name, respectively.
8 # Also, it assumes all documentation is in the doc/ sub-directory.
9
10 VERSION=2009-07-21.16; # UTC
11
12 # Copyright (C) 2009 Free Software Foundation, Inc.
13
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
18
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23
24 # You should have received a copy of the GNU General Public License
25 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
26
27 # Requirements: everything required to bootstrap your package,
28 # plus these: git, cvs, cvsu, rsync, mktemp
29
30 ME=`basename "$0"`
31 warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
32 die() { warn "$*"; exit 1; }
33
34 help_version()
35 {
36   case $1 in
37     --help) cat <<EOF
38 Usage: $ME
39
40 Output a list of version-controlled files in DIR (default .), relative to
41 SRCDIR (default .).  SRCDIR must be the top directory of a checkout.
42
43 Options:
44   --help     print this help, then exit
45   --version  print version number, then exit
46
47 Report bugs and patches to <bug-gnulib@gnu.org>.
48 EOF
49       exit ;;
50
51     --version)
52       year=`echo "$VERSION" | sed 's/[^0-9].*//'`
53       cat <<EOF
54 $ME $VERSION
55 Copyright (C) $year Free Software Foundation, Inc,
56 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
57 This is free software: you are free to change and redistribute it.
58 There is NO WARRANTY, to the extent permitted by law.
59 EOF
60       exit ;;
61
62   *) die "unrecognized option: $1";;
63   esac
64 }
65
66 case $# in
67   0) ;;
68   1) help_version $1 ;;
69   *) die "$ME: too many options" ;;
70 esac
71
72 prev=.prev-version
73 version=$(cat $prev) || die "$ME: no $prev file?"
74 pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' Makefile) || die "$ME: no Makefile?"
75 tmp_branch=web-doc-$version-$$
76
77 cleanup()
78 {
79   __st=$?;
80   rm -rf "$tmp"
81   git checkout master
82   git branch -d $tmp_branch
83   exit $__st
84 }
85 trap cleanup 0
86 trap 'exit $?' 1 2 13 15
87
88 # We must build using sources for which --version reports the
89 # just-released version number, not some string like 7.6.18-20761.
90 # That version string propagates into all documentation.
91 git checkout -b $tmp_branch v$version
92 ./bootstrap && ./configure && make && make web-manual
93
94 tmp=$(mktemp -d --tmpdir=. web-doc-update.XXXXXX) || exit 1
95 ( cd $tmp \
96     && cvs -d $USER@cvs.sv.gnu.org:/webcvs/$pkg co $pkg )
97 rsync -avP doc/manual/ $tmp/$pkg/manual
98
99 (
100   cd $tmp/$pkg/manual
101
102   # Add any new files:
103   cvsu --types='?'|sed s/..// | xargs --no-run-if-empty -- cvs add -ko
104
105   cvs ci -m $version
106 )
107
108 # Local variables:
109 # eval: (add-hook 'write-file-hooks 'time-stamp)
110 # time-stamp-start: "VERSION="
111 # time-stamp-format: "%:y-%02m-%02d.%02H"
112 # time-stamp-time-zone: "UTC"
113 # time-stamp-end: "; # UTC"
114 # End: