Home | History | Annotate | Download | only in build-aux
      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 ME=$(basename "$0")
     28 warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
     29 die() { warn "$*"; exit 1; }
     30 
     31 help()
     32 {
     33   cat <<EOF
     34 Usage: $ME
     35 
     36 Run this script from top_srcdir (no arguments) after each non-alpha
     37 release, to update the web documentation at
     38 http://www.gnu.org/software/\$pkg/manual/
     39 
     40 Options:
     41   -C, --builddir=DIR  location of (configured) Makefile (default: .)
     42   --help              print this help, then exit
     43   --version           print version number, then exit
     44 
     45 Report bugs and patches to <bug-gnulib@gnu.org>.
     46 EOF
     47   exit
     48 }
     49 
     50 version()
     51 {
     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 
     63 # find_tool ENVVAR NAMES...
     64 # -------------------------
     65 # Search for a required program.  Use the value of ENVVAR, if set,
     66 # otherwise find the first of the NAMES that can be run (i.e.,
     67 # supports --version).  If found, set ENVVAR to the program name,
     68 # die otherwise.
     69 #
     70 # FIXME: code duplication, see also bootstrap.
     71 find_tool ()
     72 {
     73   find_tool_envvar=$1
     74   shift
     75   find_tool_names=$@
     76   eval "find_tool_res=\$$find_tool_envvar"
     77   if test x"$find_tool_res" = x; then
     78     for i
     79     do
     80       if ($i --version </dev/null) >/dev/null 2>&1; then
     81        find_tool_res=$i
     82        break
     83       fi
     84     done
     85   else
     86     find_tool_error_prefix="\$$find_tool_envvar: "
     87   fi
     88   test x"$find_tool_res" != x \
     89     || die "one of these is required: $find_tool_names"
     90   ($find_tool_res --version </dev/null) >/dev/null 2>&1 \
     91     || die "${find_tool_error_prefix}cannot run $find_tool_res --version"
     92   eval "$find_tool_envvar=\$find_tool_res"
     93   eval "export $find_tool_envvar"
     94 }
     95 
     96 ## ------ ##
     97 ## Main.  ##
     98 ## ------ ##
     99 
    100 # Requirements: everything required to bootstrap your package, plus
    101 # these.
    102 find_tool CVS cvs
    103 find_tool CVSU cvsu
    104 find_tool GIT git
    105 find_tool RSYNC rsync
    106 find_tool XARGS gxargs xargs
    107 
    108 builddir=.
    109 while test $# != 0
    110 do
    111   # Handle --option=value by splitting apart and putting back on argv.
    112   case $1 in
    113     --*=*)
    114       opt=$(echo "$1" | sed -e 's/=.*//')
    115       val=$(echo "$1" | sed -e 's/[^=]*=//')
    116       shift
    117       set dummy "$opt" "$val" ${1+"$@"}; shift
    118       ;;
    119   esac
    120 
    121   case $1 in
    122     --help|--version) ${1#--};;
    123     -C|--builddir) shift; builddir=$1; shift ;;
    124     --*) die "unrecognized option: $1";;
    125     *) break;;
    126   esac
    127 done
    128 
    129 test $# = 0 \
    130   || die "too many arguments"
    131 
    132 prev=.prev-version
    133 version=$(cat $prev) || die "no $prev file?"
    134 pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \
    135   || die "no Makefile?"
    136 tmp_branch=web-doc-$version-$$
    137 current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}')
    138 
    139 cleanup()
    140 {
    141   __st=$?
    142   rm -rf "$tmp"
    143   $GIT checkout "$current_branch"
    144   $GIT submodule update --recursive
    145   $GIT branch -d $tmp_branch
    146   exit $__st
    147 }
    148 trap cleanup 0
    149 trap 'exit $?' 1 2 13 15
    150 
    151 # We must build using sources for which --version reports the
    152 # just-released version number, not some string like 7.6.18-20761.
    153 # That version string propagates into all documentation.
    154 set -e
    155 $GIT checkout -b $tmp_branch v$version
    156 $GIT submodule update --recursive
    157 ./bootstrap
    158 srcdir=$(pwd)
    159 cd "$builddir"
    160   ./config.status --recheck
    161   ./config.status
    162   make
    163   make web-manual
    164 cd "$srcdir"
    165 set +e
    166 
    167 tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1
    168 ( cd $tmp \
    169     && $CVS -d $USER@cvs.sv.gnu.org:/webcvs/$pkg co $pkg )
    170 $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
    171 
    172 (
    173   cd $tmp/$pkg/manual
    174 
    175   # Add any new files:
    176   $CVSU --types='?'                             \
    177     | sed s/..//                                \
    178     | $XARGS --no-run-if-empty -- $CVS add -ko
    179 
    180   $CVS ci -m $version
    181 )
    182 
    183 # Local variables:
    184 # eval: (add-hook 'write-file-hooks 'time-stamp)
    185 # time-stamp-start: "VERSION="
    186 # time-stamp-format: "%:y-%02m-%02d.%02H"
    187 # time-stamp-time-zone: "UTC"
    188 # time-stamp-end: "; # UTC"
    189 # End:
    190