libtool/clcommit.m4sh
Gary V. Vaughan 56c08a521e * HACKING (Licensing Rules): Explain the various license texts
used for files distributed with Libtool, and update license text
to match.
* Makefile.am, Makefile.maint README, README.alpha, THANKS, TODO,
bootstrap, clcommit.m4sh, configure.ac, libltdl/Makefile.inc,
libltdl/README, libltdl/argz.c, libltdl/argz_.h,
libltdl/config/general.m4sh, libltdl/config/getopt.m4sh,
libltdl/config/ltmain.m4sh, libltdl/config/mailnotify.m4sh,
libltdl/config/mkstamp, libltdl/configure.ac,
libltdl/libltdl/lt__alloc.h, libltdl/libltdl/lt__dirent.h,
libltdl/libltdl/lt__glibc.h, libltdl/libltdl/lt__private.h,
libltdl/libltdl/lt__strl.h, libltdl/libltdl/lt_dlloader.h,
libltdl/libltdl/lt_error.h, libltdl/libltdl/lt_system.h,
libltdl/libltdl/slist.h, libltdl/loaders/dld_link.c,
libltdl/loaders/dlopen.c, libltdl/loaders/dyld.c,
libltdl/loaders/load_add_on.c, libltdl/loaders/loadlibrary.c,
libltdl/loaders/preopen.c, libltdl/loaders/shl_load.c,
libltdl/lt__alloc.c, libltdl/lt__dirent.c, libltdl/lt__strl.c,
libltdl/lt_dlloader.c, libltdl/lt_error.c, libltdl/ltdl.c,
libltdl/ltdl.h, libltdl/m4/argz.m4, libltdl/m4/libtool.m4,
libltdl/m4/ltdl.m4, libltdl/m4/ltoptions.m4,
libltdl/m4/ltsugar.m4, libltdl/m4/ltversion.in,
Jlibltdl/m4/ltversion.m4, libltdl/m4/lt~obsolete.m4,
libltdl/slist.c, libtoolize.m4sh, tests/am-subdir.at,
tests/cdemo-conf.test, tests/cdemo-exec.test,
tests/cdemo-make.test, tests/cdemo-shared.test,
tests/cdemo-static.test, tests/cdemo-undef.test,
tests/cdemo/Makefile.am, tests/cdemo/configure.ac,
tests/cdemo/foo.c, tests/cdemo/foo.h, tests/cdemo/main.c,
tests/cmdline_wrap.at, tests/convenience.at, tests/defs.m4sh,
tests/demo-conf.test, tests/demo-deplibs.test,
tests/demo-exec.test, tests/demo-hardcode.test,
tests/demo-inst.test, tests/demo-make.test,
tests/demo-nofast.test, tests/demo-noinst-link.test,
tests/demo-nopic.test, tests/demo-pic.test,
tests/demo-relink.test, tests/demo-shared.test,
tests/demo-static.test, tests/demo-unst.test,
tests/demo/Makefile.am, tests/demo/configure.ac,
tests/demo/dlmain.c, tests/demo/foo.c,
tests/demo/foo.h, tests/demo/hell1.c, tests/demo/hell2.c,
tests/demo/hello.c, tests/demo/main.c,
tests/depdemo-conf.test, tests/depdemo-exec.test,
tests/depdemo-inst.test, tests/depdemo-make.test,
tests/depdemo-nofast.test, tests/depdemo-relink.test,
tests/depdemo-shared.test, tests/depdemo-static.test,
tests/depdemo-unst.test, tests/depdemo/Makefile.am,
tests/depdemo/configure.ac, tests/depdemo/l1/Makefile.am,
tests/depdemo/l1/l1.c, tests/depdemo/l1/l1.h,
tests/depdemo/l2/Makefile.am, tests/depdemo/l2/l2.c,
tests/depdemo/l2/l2.h, tests/depdemo/l3/Makefile.am,
tests/depdemo/l3/l3.c, tests/depdemo/l3/l3.h,
tests/depdemo/l4/Makefile.am, tests/depdemo/l4/l4.c,
tests/depdemo/l4/l4.h, tests/depdemo/main.c,
tests/depdemo/sysdep.h, tests/deplibs-ident.at,
tests/destdir.at, tests/duplicate_conv.at,
tests/duplicate_deps.at, tests/duplicate_members.at,
tests/early-libtool.at, tests/export.at,
tests/f77demo-conf.test, tests/f77demo-exec.test,
tests/f77demo-make.test, tests/f77demo-shared.test,
tests/f77demo-static.test, tests/f77demo/Makefile.am,
tests/f77demo/configure.ac, tests/f77demo/cprogram.c,
tests/f77demo/foo.h, tests/f77demo/fooc.c,
tests/fail.at, tests/fcdemo-conf.test, tests/fcdemo-exec.test,
tests/fcdemo-make.test, tests/fcdemo-shared.test,
tests/fcdemo-static.test, tests/fcdemo/Makefile.am,
tests/fcdemo/configure.ac, tests/fcdemo/cprogram.c,
tests/fcdemo/foo.h, tests/fcdemo/fooc.c,
tests/inherited_flags.at, tests/libtoolize.at,
tests/link-2.test, tests/link-order.at, tests/link-order2.at,
tests/link.test, tests/lt_dlexit.at, tests/mdemo-conf.test,
tests/mdemo-dryrun.test, tests/mdemo-exec.test,
tests/mdemo-inst.test, tests/mdemo-make.test,
tests/mdemo-shared.test, tests/mdemo-static.test,
tests/mdemo-unst.test, tests/mdemo/Makefile.am,
tests/mdemo/configure.ac, tests/mdemo/foo.h, tests/mdemo/foo1.c,
tests/mdemo/foo2.c, tests/mdemo/main.c, tests/mdemo/mlib.c,
tests/mdemo/sub.c, tests/mdemo2-conf.test,
tests/mdemo2-exec.test, tests/mdemo2-make.test,
tests/mdemo2/Makefile.am, tests/mdemo2/configure.ac,
tests/mdemo2/main.c, tests/nomode.test, tests/nonrecursive.at,
tests/objectlist.test, tests/old-m4-iface.at,
tests/pdemo-conf.test, tests/pdemo-exec.test,
tests/pdemo-inst.test, tests/pdemo-make.test,
tests/pdemo/Makefile.am, tests/pdemo/configure.ac,
tests/pdemo/foo.h, tests/pdemo/longer_file_name_dlmain.c,
tests/pdemo/longer_file_name_foo.c,
tests/pdemo/longer_file_name_foo2.c,
tests/pdemo/longer_file_name_hell1.c,
tests/pdemo/longer_file_name_hell2.c,
tests/pdemo/longer_file_name_hello.c,
tests/pdemo/longer_file_name_main.c, tests/quote.test,
tests/recursive.at, tests/search-path.at, tests/sh.test,
tests/shlibpath.at, tests/standalone.at, tests/static.at,
tests/stresstest.at, tests/subproject.at, tests/suffix.test,
tests/tagdemo-conf.test, tests/tagdemo-exec.test,
tests/tagdemo-make.test, tests/tagdemo-shared.test,
tests/tagdemo-static.test, tests/tagdemo-undef.test,
tests/tagdemo/Makefile.am, tests/tagdemo/baz.cpp,
tests/tagdemo/baz.h, tests/tagdemo/configure.ac,
tests/tagdemo/conv.cpp, tests/tagdemo/conv.h,
tests/tagdemo/foo.cpp, tests/tagdemo/foo.h,
tests/tagdemo/main.cpp, tests/tagtrace.test,
tests/template.at, tests/testsuite.at: Apply correct license
text according to the new rules set out in HACKING.
2007-03-25 12:12:44 +00:00

528 lines
15 KiB
Plaintext

m4_define([_m4_divert(SCRIPT)], 100)
m4_divert_push([SCRIPT])#!/bin/sh
# @configure_input@
# clcommit (GNU @PACKAGE@) version 0.16
# Written by Gary V. Vaughan <gary@gnu.org>
# and Alexandre Oliva <aoliva@redhat.com>
# Copyright (C) 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions. There is NO
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Clcommit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Clcommit is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with clcommit; see the file COPYING. If not, a copy
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
# or obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Usage: $progname [OPTION]... [--] [file|dir ...]
# -C FILE --changelog=file extract commit message from specified ChangeLog
# -zN --compress=N set compression level (0-9, 0=none, 9=max)
# --debug enable verbose shell tracing
# -n --dry-run don't commit anything
# --fast same as --force --first
# -F file --file=file read commit message from file
# -1 --first extract first entry from ChangeLog, no cvs diff
# -f --force don't check (unless *followed* by -n), and just
# display commit message instead of running $PAGER
# --from=addr override default from address in commit email
# -l --local don't descend into subdirectories
# -m msg --message=msg set commit message
# --msg=msg same as -m
# -r [FILE] --rcfile[=FILE] read default option from FILE [./.clcommitrc]
# -q --quiet run cvs in quiet mode
# -s addr --sendmail=addr send a commit email of the differences to ADDR
# --signature[=FILE] add FILE to the end of the email [~/.signature]
# -S TEXT --summary=TEXT specify a TEXT subject line for the commit email
# -t --tla use tla as the scm (and cvs in a dual tree)
# -v --verbose run in verbose mode
# --version print version information
# -h,-? --help print short or long help message
# This script eases checking in changes to CVS-maintained projects
# with ChangeLog files. It will check that there have been no
# conflicting commits in the CVS repository and print which files it
# is going to commit to stderr. A list of files to compare and to
# check in can be given in the command line. If it is not given, all
# files in the current directory (and below, unless `-l' is given) are
# considered for check in.
# The commit message will be extracted from the differences between a
# file named ChangeLog* in the commit list, or named after -C, and the
# one in the repository (unless a message was specified with `-m' or
# `-F'). An empty message is not accepted (but a blank line is). If
# the message is acceptable, it will be presented for verification
# (and possible edition) using the $PAGER environment variable (or
# `more', if it is not set, or `cat', if the `-f' switch is given).
# If $PAGER exits successfully, the modified files (at that moment)
# are checked in, unless `-n' was specified, in which case nothing is
# checked in.
# Report bugs to <gary@gnu.org>
: ${CVS="cvs"}
: ${TLA="tla"}
: ${MAILNOTIFY="mailnotify"}
: ${MKSTAMP="mkstamp"}
test -f "libltdl/config/$MAILNOTIFY" && MAILNOTIFY="libltdl/config/$MAILNOTIFY"
test -f "libltdl/config/$MKSTAMP" && MKSTAMP="libltdl/config/$MKSTAMP"
PROGRAM=clcommit
AS_SHELL_SANITIZE
$as_unset CDPATH
m4_include([getopt.m4sh])
M4SH_VERBATIM([[
# Global variables:
cvs_flags=
update_flags=
commit_flags=
opt_commit=:
opt_update=:
opt_verbose=false
opt_first=false
opt_tla=false
mailnotify_flags=
sendmail_to=
exit_cmd=:
# try to find out whether read supports -r
if echo bt | tr b '\\' | { read -r line; test "X$line" = 'X\t'; } 2>/dev/null
then
read_r='read -r'
else
read_r=read
fi
# Locations for important files:
signature_file=
log_dir="`func_mktempdir`"
log_file="$log_dir/log"
trap '$RM -r "$log_dir"; exit $EXIT_FAILURE' 1 2 15
set -e
# Parse options once, thoroughly. This comes as soon as possible in
# the script to make things like `clcommit --version' happen quickly.
{
# sed scripts:
my_sed_single_opt='1s/^\(..\).*$/\1/;q'
my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
my_sed_long_arg='1s/^--[^=]*=//'
# this just eases exit handling
while test $# -gt 0; do
opt="$1"
shift
case $opt in
--debug) func_echo "enabling shell trace mode"
mailnotify_flags="$mailnotify_flags --debug"
set -x
;;
--fast) set dummy --force --first ${1+"$@"}; shift ;;
-f|--force) opt_update=false; PAGER=cat ;;
--from) test $# = 0 && func_missing_arg $opt && break
func_quote_for_eval "$1"
mailnotify_flags="$mailnotify_flags --from=$func_quote_for_eval_result"
shift
;;
-l|--local) update_flags="$update_flags -l"
commit_flags="$commit_flags -l"
;;
-m|--message|--msg)
test $# = 0 && func_missing_arg $opt && break
if $opt_first || test -f "$log_file"; then
func_error "you can have at most one of -m, -F and -1"
break
fi
echo "$1" > "$log_file"
shift
;;
-F|--file) test $# = 0 && func_missing_arg $opt && break
if $opt_first || test -f "$log_file"; then
func_error "you can have at most one of -m, -F and -1"
break
fi
if cat < "$1" > "$log_file"; then :; else
break
fi
shift
;;
-1|--first) if test -f "$log_File"; then
func_error "you can have at most one of -m, -F and -1"
break
fi
opt_first=:
;;
-C|--[cC]hange[lL]og)
test $# = 0 && func_missing_arg $opt && break
if test -f "$1"; then :; else
func_error "ChangeLog file \`$1' does not exist"
break
fi
ChangeLog="$1"
shift
;;
-n|--dry-run) opt_commit=false; opt_update=: ;;
-q|--quiet) cvs_flags="$cvs_flags -q" ;;
-r|--rcfile) rc_file="./.clcommitrc"
if test $# -gt 0; then
case $1 in
-*) ;;
*) rc_file="$1"; shift ;;
esac
fi
if test -f "$rc_file"; then :; else
func_error "rcfile \`$rc_file' does not exist"
exit_cmd=exit
break
fi
# The funny quoting allows keeping one option per
# line in $rc_file:
eval set dummy `echo \`cat $rc_file\` \\\${1+\"\\\$@\"}`
shift
;;
-s|--sendmail) test $# = 0 && func_missing_arg $opt && break
func_quote_for_eval "$1"
sendmail_to="$func_quote_for_eval_result"
shift
;;
--signature) test $# = 0 && func_missing_arg $opt && break
signature_file="$HOME/.signature"
case $1 in
-*) ;;
*) signature_file="$1"; shift ;;
esac
if test -f "$signature_file"; then :; else
func_error "\`$signature_file': file not found"
break
fi
;;
-S|--summary) test $# = 0 && func_missing_arg $opt && break
summary="$1"
shift
;;
-t|--tla) opt_tla=: ;;
-v|--verbose) opt_verbose=: ;;
-z|--compress)
test $# = 0 && func_missing_arg $opt && break
case "$1" in
[0-9]) :;;
*) func_error "invalid argument for $opt"
break
;;
esac
cvs_flags="$cvs_flags -z$1"
shift
;;
# Separate optargs to long options:
--*=*)
arg=`echo "$opt" | $SED "$my_sed_long_arg"`
opt=`echo "$opt" | $SED "$my_sed_long_opt"`
set dummy "$opt" "$arg" ${1+"$@"}
shift
;;
# Separate optargs to short options:
-m*|-F*|-C*|-S*|-s*|-z*)
arg=`echo "$opt" |$SED "$my_sed_single_rest"`
opt=`echo "$opt" |$SED "$my_sed_single_opt"`
set dummy "$opt" "$arg" ${1+"$@"}
shift
;;
# Separate non-argument short options:
-f*|-1*|-n*|-q*)
rest=`echo "$opt" |$SED "$my_sed_single_rest"`
opt=`echo "$opt" |$SED "$my_sed_single_opt"`
set dummy "$opt" "-$rest" ${1+"$@"}
shift
;;
-\?|-h) func_usage ;;
--help) func_help ;;
--version) func_version ;;
--) break ;;
-*) func_fatal_help "unrecognized option \`$opt'" ;;
*) set dummy "$opt" ${1+"$@"}; shift; break ;;
esac
done
if test -z "$sendmail_to"; then
# can't have a from address without a destination address
test -n "$sendmail_from" &&
func_error "can't use --from without --sendmail." && exit_cmd=exit
# can't use a signature file without a destination address
test -n "$signature_file" &&
func_error "can't use --signature without --sendmail." && exit_cmd=exit
fi
# Bail if the options were screwed
$exit_cmd $EXIT_FAILURE
}
# func_check_conflicts
func_check_conflicts ()
{
func_verbose "$progname: checking for conflicts..."
if $opt_tla; then
if ( $TLA changes |
while $read_r line; do
echo "$line"
echo "$line" >&3
done | grep '^C'
) 3>&1 >/dev/null; then
func_fatal_error "some conflicts were found with arch archive, aborting..."
fi
fi
if test -f CVS/Entries; then
if ( $CVS $cvs_flags -q -n update $update_flags ${1+"$@"} |
while $read_r line; do
echo "$line"
echo "$line" >&3
done | grep '^C'
) 3>&1 >/dev/null; then
func_fatal_error "some conflicts were found with CVS repository, aborting..."
fi
fi
}
# func_check_commit_msg
func_check_commit_msg ()
{
if test -z "$ChangeLog"; then
for f in ${1+"$@"}; do
case "$f" in
ChangeLog* | */ChangeLog*)
if test -z "$ChangeLog"; then
ChangeLog="$f"
else
func_fatal_error "multiple ChangeLog files: $ChangeLog and $f"
fi
;;
esac
done
fi
func_verbose "$progname: checking commit message..."
if $opt_first; then
skipping=:
$SED 's,^,+,' < ${ChangeLog-ChangeLog} |
while $read_r line; do
case "$line" in
"+") if $skipping; then skipping=false; else break; fi;;
"+ "*)
func_error "*** Warning: lines should start with tabs, not spaces; ignoring line:"
echo "$line" | $SED 's/^.//' >&2;;
"+ "*)
$skipping || echo "$line" ;;
esac
done |
$SED 's,^\+ ,,' > "$log_file" || exit $EXIT_FAILURE
else
if $opt_tla; then
cmd="$TLA file-diffs"
else
cmd="$CVS $cvs_flags diff -u"
fi
$cmd ${ChangeLog-ChangeLog} |
while $read_r line; do
case $line in
"--- "*) :;;
"-"*)
func_error "*** Warning: the following line in ChangeLog diff is suspicious:"
echo "$line" | $SED 's/^.//' >&2;;
"+ "*)
func_error "*** Warning: lines should start with tabs, not spaces; ignoring line:"
echo "$line" | $SED 's/^.//' >&2;;
"+") echo ;;
"+ "*) echo "$line";;
esac
done |
$SED -e 's,\+ ,,' -e '/./p' -e '/./d' -e '1d' -e '$d' > "$log_file" \
|| exit $EXIT_FAILURE
fi
# The sed script above removes "+TAB" from the beginning of a line, then
# deletes the first and/or the last line, when they happen to be empty
}
# func_commit
func_commit ()
{
if $opt_tla; then
tla_log=`$TLA make-log`
test -n "$summary" || summary=`$SED -e '
1{
s/^Summary: *//
q
}'`
echo "Summary: $summary" > "$tla_log$$T" &&
$SED 1d "$tla_log" >> "$tla_log$$T" &&
cat < "$log_file" >> "$tla_log$$T" &&
mv "$tla_log$$T" "$tla_log"
${PAGER-more} "$tla_log" || exit $EXIT_FAILURE
sleep 1 # give the user some time for a ^C
# Propagate any user edits back to the cvs log message
$SED -e '/^[A-Z][-a-zA-Z]*:/d' -e '1d' < $tla_log > $log_file
else
${PAGER-more} "$log_file" || exit $EXIT_FAILURE
sleep 1 # give the user some time for a ^C
subject=`cvs -nq up 2>/dev/null | $SED -n 's/^[MAD] //p'`
test $# -gt 0 && subject="$@"
fi
if test -f CVS/Entries; then
func_verbose "$CVS $cvs_flags commit $commit_flags -F $log_file ${1+$@}"
$CVS $cvs_flags commit $commit_flags -F $log_file ${1+"$@"} || exit $EXIT_FAILURE
fi
# Need to do the tla commit *after* cvs commit to make sure the
# ChangeLog timestamps stay in synch.
$opt_tla && $TLA commit
:
}
# func_mailnotify
func_mailnotify ()
{
notify_file="${log_dir}/notify"
func_verbose "Mailing commit notification to $sendmail_to"
{
echo Subject: $subject
test -f '{arch}/=tagging-method' &&
echo "Tree version: `$TLA tree-version`"
test -f CVS/Root &&
echo "CVSROOT: `$SED -e 's,.*:,,g' CVS/Root`"
test -f $MKSTAMP &&
echo "TIMESTAMP: `$SHELL $MKSTAMP < ./ChangeLog`"
test -f CVS/Repository &&
echo "Module name: `cat CVS/Repository`"
test -f CVS/Tag &&
echo "Branch: `$SED -e 's,^T,,;1q' CVS/Tag`"
test -f CVS/Root &&
echo "Changes by: `$SED -e 's,^:[a-z]*:,,;s,:.*$,,g' CVS/Root`"
echo ""
echo "Log Message:"
$SED -e 's,^, ,' "$log_file"
test -f "$signature_file" && {
echo '-- '
cat "$signature_file"
}
} > "$notify_file"
${PAGER-more} "$notify_file" || break
# Break out the subject line again
my_mail_subject=`$SED -e '
1{
s/^Subject: *//
q
}' "$notify_file"`
my_mail_body=`$SED -e '2,$p;d' "$notify_file"`
echo "$my_mail_body" > "$notify_file"
func_verbose "mailing commit notification to \"$sendmail_to\""
func_quote_for_eval "$my_mail_subject"
func_show_eval "$MAILNOTIFY $mailnotify_flags \
-s $func_quote_for_eval_result -m 'text/plain' -f '$notify_file' \
-- $sendmail_to"
}
## ----- ##
## main. ##
## ----- ##
{
$opt_update && func_check_conflicts
test -f "$log_file" || func_check_commit_msg
grep '[^ ]' < "$log_file" > /dev/null ||
func_fatal_error "empty commit message, aborting"
if grep '^$' < "$log_file" > /dev/null; then
func_error "*** Warning: blank lines should not appear within commit messages."
func_error "*** They should be used to separate distinct commits."
fi
# Do not check for empty $log_file again, even though the user might have
# zeroed it out. If s/he did, it was probably intentional.
if $opt_commit; then
func_commit ${1+"$@"}
fi
# Need to set the subject line *after* tla commit, or the
# patch revision changes underneath us!
subject="$summary"
$opt_tla && \
subject="$subject ["`$TLA tree-version|$SED $basename`--`$TLA revisions|$SED -e '$p;d'`"]"
# Send a copy of the log_file if sendmail_to was set:
if test -n "$sendmail_to"; then
func_mailnotify
fi
$RM -r "$log_dir"
}
exit $EXIT_SUCCESS
# Local Variables:
# mode:shell-script
# sh-indentation:2
# End:
]])