gnu-web-doc-update 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. VERSION=2012-12-16.14; # UTC
  5. # Copyright (C) 2009-2014 Free Software Foundation, Inc.
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ME=$(basename "$0")
  17. warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
  18. die() { warn "$*"; exit 1; }
  19. help()
  20. {
  21. cat <<EOF
  22. Usage: $ME
  23. Run this script from top_srcdir (no arguments) after each non-alpha
  24. release, to update the web documentation at
  25. http://www.gnu.org/software/\$pkg/manual/
  26. This script assumes you're using git for revision control, and
  27. requires a .prev-version file as well as a Makefile, from which it
  28. extracts the version number and package name, respectively. Also, it
  29. assumes all documentation is in the doc/ sub-directory.
  30. Options:
  31. -C, --builddir=DIR location of (configured) Makefile (default: .)
  32. -n, --dry-run don't actually commit anything
  33. --help print this help, then exit
  34. --version print version number, then exit
  35. Report bugs and patches to <bug-gnulib@gnu.org>.
  36. EOF
  37. exit
  38. }
  39. version()
  40. {
  41. year=$(echo "$VERSION" | sed 's/[^0-9].*//')
  42. cat <<EOF
  43. $ME $VERSION
  44. Copyright (C) $year Free Software Foundation, Inc,
  45. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  46. This is free software: you are free to change and redistribute it.
  47. There is NO WARRANTY, to the extent permitted by law.
  48. EOF
  49. exit
  50. }
  51. # find_tool ENVVAR NAMES...
  52. # -------------------------
  53. # Search for a required program. Use the value of ENVVAR, if set,
  54. # otherwise find the first of the NAMES that can be run (i.e.,
  55. # supports --version). If found, set ENVVAR to the program name,
  56. # die otherwise.
  57. #
  58. # FIXME: code duplication, see also bootstrap.
  59. find_tool ()
  60. {
  61. find_tool_envvar=$1
  62. shift
  63. find_tool_names=$@
  64. eval "find_tool_res=\$$find_tool_envvar"
  65. if test x"$find_tool_res" = x; then
  66. for i
  67. do
  68. if ($i --version </dev/null) >/dev/null 2>&1; then
  69. find_tool_res=$i
  70. break
  71. fi
  72. done
  73. else
  74. find_tool_error_prefix="\$$find_tool_envvar: "
  75. fi
  76. test x"$find_tool_res" != x \
  77. || die "one of these is required: $find_tool_names"
  78. ($find_tool_res --version </dev/null) >/dev/null 2>&1 \
  79. || die "${find_tool_error_prefix}cannot run $find_tool_res --version"
  80. eval "$find_tool_envvar=\$find_tool_res"
  81. eval "export $find_tool_envvar"
  82. }
  83. ## ------ ##
  84. ## Main. ##
  85. ## ------ ##
  86. # Requirements: everything required to bootstrap your package, plus
  87. # these.
  88. find_tool CVS cvs
  89. find_tool GIT git
  90. find_tool RSYNC rsync
  91. find_tool XARGS gxargs xargs
  92. builddir=.
  93. dryrun=
  94. while test $# != 0
  95. do
  96. # Handle --option=value by splitting apart and putting back on argv.
  97. case $1 in
  98. --*=*)
  99. opt=$(echo "$1" | sed -e 's/=.*//')
  100. val=$(echo "$1" | sed -e 's/[^=]*=//')
  101. shift
  102. set dummy "$opt" "$val" ${1+"$@"}; shift
  103. ;;
  104. esac
  105. case $1 in
  106. --help|--version) ${1#--};;
  107. -C|--builddir) shift; builddir=$1; shift ;;
  108. -n|--dry-run) dryrun=echo; shift;;
  109. --*) die "unrecognized option: $1";;
  110. *) break;;
  111. esac
  112. done
  113. test $# = 0 \
  114. || die "too many arguments"
  115. prev=.prev-version
  116. version=$(cat $prev) || die "no $prev file?"
  117. pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' $builddir/Makefile) \
  118. || die "no Makefile?"
  119. tmp_branch=web-doc-$version-$$
  120. current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}')
  121. cleanup()
  122. {
  123. __st=$?
  124. $dryrun rm -rf "$tmp"
  125. $GIT checkout "$current_branch"
  126. $GIT submodule update --recursive
  127. $GIT branch -d $tmp_branch
  128. exit $__st
  129. }
  130. trap cleanup 0
  131. trap 'exit $?' 1 2 13 15
  132. # We must build using sources for which --version reports the
  133. # just-released version number, not some string like 7.6.18-20761.
  134. # That version string propagates into all documentation.
  135. set -e
  136. $GIT checkout -b $tmp_branch v$version
  137. $GIT submodule update --recursive
  138. ./bootstrap
  139. srcdir=$(pwd)
  140. cd "$builddir"
  141. ./config.status --recheck
  142. ./config.status
  143. make
  144. make web-manual
  145. cd "$srcdir"
  146. set +e
  147. tmp=$(mktemp -d web-doc-update.XXXXXX) || exit 1
  148. ( cd $tmp \
  149. && $CVS -d $USER@cvs.sv.gnu.org:/webcvs/$pkg co $pkg )
  150. $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
  151. (
  152. cd $tmp/$pkg/manual
  153. # Add all the files. This is simpler than trying to add only the
  154. # new ones because of new directories: it would require iterating on
  155. # adding the outer directories, and then their contents.
  156. #
  157. # find guarantees that we add outer directories first.
  158. find . -name CVS -prune -o -print \
  159. | $XARGS --no-run-if-empty -- $dryrun $CVS add -ko
  160. $dryrun $CVS ci -m $version
  161. )
  162. # Local variables:
  163. # eval: (add-hook 'write-file-hooks 'time-stamp)
  164. # time-stamp-start: "VERSION="
  165. # time-stamp-format: "%:y-%02m-%02d.%02H"
  166. # time-stamp-time-zone: "UTC"
  167. # time-stamp-end: "; # UTC"
  168. # End: