Subject: bug#11356: automake 1.12 and (C) 2011

From: Stefano Lattarini <[email-masked]>
Date: Tue, 01 May 2012 12:46:57 +0200

Hi Peter, thanks for the feedback.

On 05/01/2012 02:23 AM, Peter Johansson wrote:
> Hi Stefano,
> 
> Sorry about this late reply.
> 
> On 04/28/2012 12:34 AM, Stefano Lattarini wrote:
> 
> --- a/bootstrap
> +++ b/bootstrap
> @@ -77,6 +77,8 @@ dosubst ()
>  {
>    rm -f $2
>    in=`echo $1 | sed 's,^.*/,,'`
> +  current_year=`date +%Y`&&  test -n "$current_year" \
> +    || { echo "$me: cannot get current year">&2; exit 1; }
>    sed -e "s%@APIVERSION@%$APIVERSION%g" \
>        -e "s%@PACKAGE@%$PACKAGE%g" \
>        -e "s%@PERL@%$PERL%g" \
> @@ -84,6 +86,7 @@ dosubst ()
>        -e "s%@SHELL@%$BOOTSTRAP_SHELL%g" \
>        -e "s%@VERSION@%$VERSION%g" \
>        -e "s%@datadir@%$datadir%g" \
> +      -e "s%@RELEASE_YEAR@%$current_year%g" \
>        -e"s%@configure_input@%Generated from $in; do not edit by hand.%g"  \
>        $1>  $2
>    chmod a-w $2
> diff --git a/configure.ac b/configure.ac
> index 22a158f..2829fd4 100644
> 
> 
> IIUC, this implies that if I choose to boostrap Automake 1.12.1, in say,
> five years, $RELEASE_YEAR will be set to 2017.
>
True, but it will be later be reset to 2012 when you run
"./configure && make && make dist", so no big deal.

Though, we might be even nicer, and make bootstrap.sh pre-processed
by "make update-copyright" so that the value of $RELEASE_YEAR will
always be correct, even in the bootstrap phase.  This is what I've
done with the attached patch (pushed to maint).

> I'm not an expert on what these copyright years mean [legally], but I
> find this a bit odd as nothing has changed the last five four years
> (depending on when 1.12.1 will be released). In my projects, I've used
> an approach that updates the copyright year only when something is
> modified according to the VCS. With subversion this is trivial and I
> suspect it wouldn't be harder with git. I store this information in
> a separate file, '.release_year', which is extracted at configure time
> although, in theory, it could be done at autoconf time, I guess.
> 
> Cheers,
> Peter

Thanks,
  Stefano
>From c1c27cf134f49bbe71ae919bf8c39dd9467795b9 Mon Sep 17 00:00:00 2001
Message-Id: <c1c27cf13[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Tue, 1 May 2012 12:43:22 +0200
Subject: [PATCH] bootstrap: consistently use correct copyright year

Suggested by Peter Johansson in the discussion about automake bug#11356:
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11356#41>

* boostrap.sh (dosubst): Don't initialize the substituted value for the
release year from the current year (using `date +%Y`); instead, do it
through ...
($RELEASE_YEAR): ... this new statically-defined variable.  To ensure it
won't get out-of-sync, it will be automatically updated ...
* Makefile.am (update-copyright): ... by this target's recipe.
Since are at it, fix a botched output redirection for an error message,
i.e., use ">&2" instead of ">&1".

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 Makefile.am  |    5 +++--
 bootstrap.sh |    7 ++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 37b44cf..aab2786 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -862,8 +862,9 @@ update_copyright_env = \
 update-copyright:
 	$(AM_V_GEN)set -e; \
 	current_year=`date +%Y` && test -n "$$current_year" \
-	  || { echo "$@: cannot get current year" >&1; exit 1; }; \
-	sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" configure.ac; \
+	  || { echo "$@: cannot get current year" >&2; exit 1; }; \
+	sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" \
+	  bootstrap.sh configure.ac; \
 	excluded_re=`echo $(FETCHFILES) \
 	  | sed -e 's|^|lib/|' -e 's| | lib/|g' -e 's, ,|,g'`; \
 	$(GIT) ls-files \
diff --git a/bootstrap.sh b/bootstrap.sh
index 1cede01..683b9e9 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -36,6 +36,9 @@ VERSION=`sed -ne '/AC_INIT/s/^[^[]*\[[^[]*\[\([^]]*\)\].*$/\1/p' configure.ac`
 PACKAGE=automake
 datadir=.
 PERL_THREADS=0
+# This should be automatically updated by the 'update-copyright'
+# rule of our Makefile.
+RELEASE_YEAR=2012
 
 # Override SHELL.  This is required on DJGPP so that Perl's system()
 # uses bash, not COMMAND.COM which doesn't quote arguments properly.
@@ -77,8 +80,6 @@ dosubst ()
 {
   rm -f $2
   in=`echo $1 | sed 's,^.*/,,'`
-  current_year=`date +%Y` && test -n "$current_year" \
-    || { echo "$me: cannot get current year" >&2; exit 1; }
   sed -e "s%@APIVERSION@%$APIVERSION%g" \
       -e "s%@PACKAGE@%$PACKAGE%g" \
       -e "s%@PERL@%$PERL%g" \
@@ -86,7 +87,7 @@ dosubst ()
       -e "s%@SHELL@%$BOOTSTRAP_SHELL%g" \
       -e "s%@VERSION@%$VERSION%g" \
       -e "s%@datadir@%$datadir%g" \
-      -e "s%@RELEASE_YEAR@%$current_year%g" \
+      -e "s%@RELEASE_YEAR@%$RELEASE_YEAR%G" \
       -e "s%@configure_input@%Generated from $in; do not edit by hand.%g" \
       $1 > $2
   chmod a-w $2
-- 
1.7.9.5