[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib-tool --version [was: Problems with stdio.h]
From: |
Eric Blake |
Subject: |
gnulib-tool --version [was: Problems with stdio.h] |
Date: |
Fri, 14 Mar 2008 14:30:21 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Bruno Haible <bruno <at> clisp.org> writes:
> > gnulib-tool (GNU gnulib) 2007-09-17
>
> All fine. (Except that the "gnulib-tool --version" result did not change
> since we moved from CVS to git. We need to fix this...)
Done as follows. Yes, it means that "gnulib-tool --version" now has a
noticeable delay, since it is forking a lot more processes, but it gives better
results, so I'm okay with it. I went ahead and committed this (pardon the line
wrappings from gmane). The diff looks a lot bigger than it really is, since
the bulk of it is moving and re-indenting a big chunk of code.
From: Eric Blake <address@hidden>
Date: Fri, 14 Mar 2008 08:24:29 -0600
Subject: [PATCH] Fix 'gnulib-tool --version' output to work with git.
* gnulib-tool (func_gnulib_dir): New function, extracted from...
(startup): ...here.
(func_version): Use it to invoke git-version-gen, rather than
relying on CVS keyword expansion. Modernize wording.
(cvsdatestamp, last_checkin_date, version): Kill unused
variables.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 10 ++++
gnulib-tool | 168 +++++++++++++++++++++++++++++++----------------------------
2 files changed, 98 insertions(+), 80 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 11152c8..214c64c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-03-14 Eric Blake <address@hidden>
+
+ Fix 'gnulib-tool --version' output to work with git.
+ * gnulib-tool (func_gnulib_dir): New function, extracted from...
+ (startup): ...here.
+ (func_version): Use it to invoke git-version-gen, rather than
+ relying on CVS keyword expansion. Modernize wording.
+ (cvsdatestamp, last_checkin_date, version): Kill unused
+ variables.
+
2008-03-12 Jim Meyering <address@hidden>
Recognize optional cast of the argument to free.
diff --git a/gnulib-tool b/gnulib-tool
index 2580a30..523812b 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -1,6 +1,6 @@
#! /bin/sh
#
-# Copyright (C) 2002-2007 Free Software Foundation, Inc.
+# Copyright (C) 2002-2008 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,11 +21,6 @@
progname=$0
package=gnulib
-cvsdatestamp='$Date: 2007-09-17 10:26:33 $'
-last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
-# Sometimes last_checkin_date is "YYYY/MM/DD ...", sometimes "YYYY-MM-DD ...".
-version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
-# version is in YYYY-MM-DD format.
nl='
'
IFS=" "" $nl"
@@ -199,12 +194,16 @@ Report bugs to <address@hidden>."
# outputs to stdout the --version message.
func_version ()
{
- year=`echo "$version" | sed -e 's,-.*$,,'`
+ func_gnulib_dir
+ version=`"$gnulib_dir"/build-aux/git-version-gen /dev/null`
+ year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
echo "\
$progname (GNU $package) $version
Copyright (C) $year 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.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+
Written by" "Bruno Haible" "and" "Simon Josefsson"
}
@@ -230,6 +229,85 @@ func_exit ()
(exit $1); exit $1
}
+# func_gnulib_dir
+# locates the directory where the gnulib repository lives
+# Sets variables
+# - self_abspathname absolute pathname of gnulib-tool
+# - gnulib_dir absolute pathname of gnulib repository
+func_gnulib_dir ()
+{
+ case "$0" in
+ /*) self_abspathname="$0" ;;
+ */*) self_abspathname=`pwd`/"$0" ;;
+ *)
+ # Look in $PATH.
+ # Iterate through the elements of $PATH.
+ # We use IFS=: instead of
+ # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
+ # because the latter does not work when some PATH element contains
spaces.
+ # We use a canonicalized $pathx instead of $PATH, because empty PATH
+ # elements are by definition equivalent to '.', however field splitting
+ # according to IFS=: loses empty fields in many shells:
+ # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
+ # beginning, at the end, and in the middle),
+ # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
+ # at the beginning and at the end,
+ # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
+ # Solaris lose empty fields at the end.
+ # The 'case' statement is an optimization, to avoid evaluating the
+ # explicit canonicalization command when $PATH contains no empty fields.
+ self_abspathname=
+ if test "${PATH_SEPARATOR+set}" != set; then
+ func_tmpdir
+ { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
+ chmod +x "$tmp"/conf.sh
+ if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -rf "$tmp"
+ fi
+ if test "$PATH_SEPARATOR" = ";"; then
+ # On Windows, programs are searched in "." before $PATH.
+ pathx=".;$PATH"
+ else
+ # On Unix, we have to convert empty PATH elements to ".".
+ pathx="$PATH"
+ case :$PATH: in
+ *::*)
+ pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -
e 's/:\$//'`
+ ;;
+ esac
+ fi
+ save_IFS="$IFS"
+ IFS="$PATH_SEPARATOR"
+ for d in $pathx; do
+ IFS="$save_IFS"
+ test -z "$d" && d=.
+ if test -x "$d/$0" && test ! -d "$d/$0"; then
+ self_abspathname="$d/$0"
+ break
+ fi
+ done
+ IFS="$save_IFS"
+ if test -z "$self_abspathname"; then
+ func_fatal_error "could not locate the gnulib-tool program - how did
you invoke it?"
+ fi
+ ;;
+ esac
+ while test -h "$self_abspathname"; do
+ # Resolve symbolic link.
+ linkval=`func_readlink "$self_abspathname"`
+ test -n "$linkval" || break
+ case "$linkval" in
+ /* ) self_abspathname="$linkval" ;;
+ * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]
*$,,'`/"$linkval" ;;
+ esac
+ done
+ gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
+}
+
# func_tmpdir
# creates a temporary directory.
# Sets variable
@@ -966,77 +1044,7 @@ fi
esac
}
-case "$0" in
- /*) self_abspathname="$0" ;;
- */*) self_abspathname=`pwd`/"$0" ;;
- *)
- # Look in $PATH.
- # Iterate through the elements of $PATH.
- # We use IFS=: instead of
- # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
- # because the latter does not work when some PATH element contains spaces.
- # We use a canonicalized $pathx instead of $PATH, because empty PATH
- # elements are by definition equivalent to '.', however field splitting
- # according to IFS=: loses empty fields in many shells:
- # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
- # beginning, at the end, and in the middle),
- # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
- # at the beginning and at the end,
- # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
- # Solaris lose empty fields at the end.
- # The 'case' statement is an optimization, to avoid evaluating the
- # explicit canonicalization command when $PATH contains no empty fields.
- self_abspathname=
- if test "${PATH_SEPARATOR+set}" != set; then
- func_tmpdir
- { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
- chmod +x "$tmp"/conf.sh
- if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -rf "$tmp"
- fi
- if test "$PATH_SEPARATOR" = ";"; then
- # On Windows, programs are searched in "." before $PATH.
- pathx=".;$PATH"
- else
- # On Unix, we have to convert empty PATH elements to ".".
- pathx="$PATH"
- case :$PATH: in
- *::*)
- pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -
e 's/:\$//'`
- ;;
- esac
- fi
- save_IFS="$IFS"
- IFS="$PATH_SEPARATOR"
- for d in $pathx; do
- IFS="$save_IFS"
- test -z "$d" && d=.
- if test -x "$d/$0" && test ! -d "$d/$0"; then
- self_abspathname="$d/$0"
- break
- fi
- done
- IFS="$save_IFS"
- if test -z "$self_abspathname"; then
- func_fatal_error "could not locate the gnulib-tool program - how did you
invoke it?"
- fi
- ;;
-esac
-while test -h "$self_abspathname"; do
- # Resolve symbolic link.
- linkval=`func_readlink "$self_abspathname"`
- test -n "$linkval" || break
- case "$linkval" in
- /* ) self_abspathname="$linkval" ;;
- * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]
*$,,'`/"$linkval" ;;
- esac
-done
-gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
-
+func_gnulib_dir
func_tmpdir
trap 'exit_status=$?
if test "$signal" != 0; then
--
1.5.4
- Problems with stdio.h, Gabriele Bartolini, 2008/03/13
- Re: Problems with stdio.h, Bruno Haible, 2008/03/13
- R: Problems with stdio.h, Gabriele Bartolini, 2008/03/14
- gnulib-tool --version [was: Problems with stdio.h],
Eric Blake <=
- Re: gnulib-tool --version, Eric Blake, 2008/03/14
- Re: gnulib-tool --version, Bruno Haible, 2008/03/14
- Re: gnulib-tool --version, Eric Blake, 2008/03/14
- Re: gnulib-tool --version, Bruno Haible, 2008/03/14
- Re: gnulib-tool --version, Bruno Haible, 2008/03/15
- Re: gnulib-tool --version, Eric Blake, 2008/03/15
- Re: gnulib-tool --version, Bob Proulx, 2008/03/15
- Re: gnulib-tool --version, Jim Meyering, 2008/03/15
- Re: gnulib-tool --version, Bruno Haible, 2008/03/23
- Re: gnulib-tool --version, Jim Meyering, 2008/03/23