Imported Upstream version 1.5
[debian/gzip] / 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-2012 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()
35 {
36   cat <<EOF
37 Usage: $ME
38
39 Run this script from top_srcdir (no options or arguments) after each
40 non-alpha release, to update the web documentation at
41 http://www.gnu.org/software/\$pkg/manual/ Run it from your project's
42 the top-level directory.
43
44 Options:
45   -C, --builddir=DIR  location of (configured) Makefile (default: .)
46   --help              print this help, then exit
47   --version           print version number, then exit
48
49 Report bugs and patches to <bug-gnulib@gnu.org>.
50 EOF
51   exit
52 }
53
54 version()
55 {
56   year=$(echo "$VERSION" | sed 's/[^0-9].*//')
57   cat <<EOF
58 $ME $VERSION
59 Copyright (C) $year Free Software Foundation, Inc,
60 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
61 This is free software: you are free to change and redistribute it.
62 There is NO WARRANTY, to the extent permitted by law.
63 EOF
64   exit
65 }
66
67 builddir=.
68 while test $# != 0
69 do
70   # Handle --option=value by splitting apart and putting back on argv.
71   case $1 in
72     --*=*)
73       opt=$(echo "$1" | sed -e 's/=.*//')
74       val=$(echo "$1" | sed -e 's/[^=]*=//')
75       shift
76       set dummy "$opt" "$val" ${1+"$@"}; shift
77       ;;
78   esac
79
80   case $1 in
81     --help|--version) ${1#--};;
82     -C|--builddir) shift; builddir=$1; shift ;;
83     --*) die "unrecognized option: $1";;
84     *) break;;
85   esac
86 done
87
88 test $# = 0 \
89   || die "$ME: too many arguments"
90
91 prev=.prev-version
92 version=$(cat $prev) || die "$ME: no $prev file?"
93 pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \
94   || die "$ME: no Makefile?"
95 tmp_branch=web-doc-$version-$$
96 current_branch=$(git branch | sed -ne '/^\* /{s///;p;q;}')
97
98 cleanup()
99 {
100   __st=$?
101   rm -rf "$tmp"
102   git checkout "$current_branch"
103   git submodule update --recursive
104   git branch -d $tmp_branch
105   exit $__st
106 }
107 trap cleanup 0
108 trap 'exit $?' 1 2 13 15
109
110 # We must build using sources for which --version reports the
111 # just-released version number, not some string like 7.6.18-20761.
112 # That version string propagates into all documentation.
113 set -e
114 git checkout -b $tmp_branch v$version
115 git submodule update --recursive
116 ./bootstrap
117 srcdir=$(pwd)
118 cd "$builddir"
119   ./config.status --recheck
120   ./config.status
121   make
122   make web-manual
123 cd "$srcdir"
124 set +e
125
126 tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1
127 ( cd $tmp \
128     && cvs -d $USER@cvs.sv.gnu.org:/webcvs/$pkg co $pkg )
129 rsync -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
130
131 (
132   cd $tmp/$pkg/manual
133
134   # Add any new files:
135   cvsu --types='?'|sed s/..// | xargs --no-run-if-empty -- cvs add -ko
136
137   cvs ci -m $version
138 )
139
140 # Local variables:
141 # eval: (add-hook 'write-file-hooks 'time-stamp)
142 # time-stamp-start: "VERSION="
143 # time-stamp-format: "%:y-%02m-%02d.%02H"
144 # time-stamp-time-zone: "UTC"
145 # time-stamp-end: "; # UTC"
146 # End: