1#! /bin/sh 2 3# edit-readme-alpha - edit README file for alpha releases 4# Copyright (C) 2010-2015 Free Software Foundation, Inc. 5# Written by Gary V. Vaughan, 2010 6# 7# This file is part of GNU Libtool. 8# 9# GNU Libtool is free software; you can redistribute it and/or 10# modify it under the terms of the GNU General Public License as 11# published by the Free Software Foundation; either version 2 of 12# the License, or (at your option) any later version. 13# 14# GNU Libtool is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with GNU Libtool; see the file COPYING. If not, a copy 21# can be downloaded from http://www.gnu.org/licenses/gpl.html, 22# or obtained by writing to the Free Software Foundation, Inc., 23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24#### 25 26# We used to maintain separate (but extremely similiar!) README and 27# README.alpha files, and had 'make dist' include the right one in a 28# distribution based on the contests of '$(VERSION)'. 29# 30# Now, we have 'make dist' call this script to tweak the first paragraph 31# of README in situ, to be more suitable for an alpha quality release. 32 33EXIT_SUCCESS=0 34EXIT_FAILURE=1 35 36# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 37# is ksh but when the shell is invoked as "sh" and the current value of 38# the _XPG environment variable is not equal to 1 (one), the special 39# positional parameter $0, within a function call, is the name of the 40# function. 41progpath=$0 42 43# The name of this program: 44progname=`echo "$progpath" |sed 's|^.*/||'` 45 46 47# func_fatal_error ARG... 48# ----------------------- 49# Echo program name prefixed message to standard error, and exit. 50func_fatal_error () 51{ 52 echo "$progname: $*" >&2 53 exit $EXIT_FAILURE 54} 55 56 57for file in "$@"; do 58 # Assume that read-only README indicates that we are running inside 59 # the latter part of a 'make distcheck'. 60 test -w "$file" || { 61 echo "$progname: not editing non-writeable '$file' (distcheck?)" >&2 62 continue 63 } 64 65 # Make sure the paragraph we are matching has not been edited since 66 # this script was written. 67 matched=`sed -n -e '/^\[GNU Libtool\]\[libtool\] is/,/^consistent, portable interface\.$/p' $file \ 68 |wc -l |sed 's|^ *||'` 69 70 # Unless, of course, it was edited by this script already. 71 test 3 = "$matched" \ 72 || matched=`sed -n -e '/^This is an alpha testing release/,/a consistent, portable interface\.$/p' $file \ 73 |wc -l |sed 's|^ *||'` 74 75 test 3 = "$matched" \ 76 || func_fatal_error "$file format has changed, please fix '$0'" 77 78 # Don't leave file droppings. 79 trap 'x=$?; rm $file.T; exit $x' 1 2 13 15 80 81 # Edit the first paragraph to be suitable for an alpha release. 82 sed -n '/^\[GNU Libtool\]\[libtool\] is/,/^consistent, portable interface\.$/c\ 83This is an alpha testing release of [GNU Libtool][libtool], a generic\ 84library support script. [Libtool][] hides the complexity of using shared\ 85libraries behind a consistent, portable interface.' $file > $file.T 86 87 # Diagnose redirection failure. 88 test -f "$file.T" || func_fatal_error "Unable to write $file.T" 89 90 # Overwrite the original file with our edited version. 91 mv $file.T $file || func_fatal_error "Unable to edit $file" 92done 93 94exit $EXIT_SUCCESS 95