Subject: Re: AMTAR brokenness
From: Alexandre Duret-Lutz <[email-masked]>
To: Paul Eggert <[email-masked]>, [email-masked]
Cc: [email-masked]
Date: Fri, 23 Apr 2004 23:57:16 +0200

>>> "Paul" == Paul Eggert <[email-masked]> writes:

 Paul> Alexandre Duret-Lutz <[email-masked]> writes:
 >> I've prepared this.  However I'm not really proud of the name
 >> `filenames-99'.  Maybe someone can suggest some nicer name?

 Paul> I don't know what the rules are for Automake option spelling, but how
 Paul> about "filename-length-max=99"?  This is because the obvious
 Paul> generalization is to be able to specify whatever length you like.

Thanks for the suggestion.  I'm checking this in and will close the PR.

2004-04-23  Alexandre Duret-Lutz  <[email-masked]>

	For PR automake/414:
	Introduce option filename-length-max=99.
	* doc/automake.texi (Options): Document it.
	* configure.ac (AM_INIT_AUTOMAKE): Use it.
	* lib/Automake/Options.pm (_process_option_list): Recognize it.
	* automake.in (handle_dist): Set FILENAME_FILTER.
	* lib/am/distdir.am (distdir) [FILENAME_FILTER]: Diagnose long
	filenames.
	* tests/fn99.test: New file.
	* tests/Makefile.am (TESTS): Add fn99.test.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.268
diff -u -r1.268 NEWS
--- NEWS	19 Apr 2004 23:20:07 -0000	1.268
+++ NEWS	23 Apr 2004 21:55:04 -0000
@@ -45,8 +45,8 @@
 * Diagnose AC_CONFIG_AUX_DIR calls following AM_INIT_AUTOMAKE. (PR/49)
 
 * Tar format can be chosen with the new options tar-v7, tar-ustar, and
-  tar-pax.
-
+  tar-pax.  The new option filename-length-max=99 helps diagnosing
+  filenames that are too long for tar-v7.
 
 New in 1.8:
 
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1553
diff -u -r1.1553 automake.in
--- automake.in	17 Apr 2004 18:46:05 -0000	1.1553
+++ automake.in	23 Apr 2004 21:55:08 -0000
@@ -3498,9 +3498,13 @@
     if rule 'dist-hook';
   $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
 
+  my $flm = option ('filename-length-max');
+  my $filename_filter = $flm ? '.' x $flm->[1] : '';
+
   $output_rules .= &file_contents ('distdir',
 				   new Automake::Location,
-				   %transform);
+				   %transform,
+				   FILENAME_FILTER => $filename_filter);
 }

Index: configure.ac
===================================================================
RCS file: /cvs/automake/automake/configure.ac,v
retrieving revision 1.14
diff -u -r1.14 configure.ac
--- configure.ac	10 Apr 2004 17:18:01 -0000	1.14
+++ configure.ac	23 Apr 2004 21:55:10 -0000
@@ -1,6 +1,6 @@
 # Process this file with autoconf to produce a configure script.
 
-# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 # Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -36,7 +36,7 @@
 # bothered by `missing'.
 am_AUTOCONF=${AUTOCONF-autoconf}
 
-AM_INIT_AUTOMAKE([1.6 dist-bzip2])
+AM_INIT_AUTOMAKE([1.6 dist-bzip2 filename-length-max=99])
 
 # The API version is the base version.  We must guarantee
 # compatibility for all releases with the same API version.
Index: doc/automake.texi
===================================================================
RCS file: /cvs/automake/automake/doc/automake.texi,v
retrieving revision 1.32
diff -u -r1.32 automake.texi
--- doc/automake.texi	19 Apr 2004 23:20:07 -0000	1.32
+++ doc/automake.texi	23 Apr 2004 21:55:16 -0000
@@ -5812,6 +5812,16 @@
 Hook @code{dist-tarZ} to @code{dist}.
 @trindex dist-tarZ
 
+@item @code{filename-length-max=99}
+@cindex Option, filename-length-max=99
+@trindex filename-length-max=99
+Abort if filenames longer than 99 characters are found during
+@code{make dist}.  Such long filenames are generally considered not to
+be portable in tarballs.  See the @code{tar-v7} and @code{tar-ustar}
+options below.  This option should be used in the top-level
+@file{Makefile.am} or as an argument of @code{AM_INIT_AUTOMAKE} in
+@file{configure.ac}, it will be ignored otherwise.
+
 @item @code{no-define}
 @cindex Option, no-define
 This options is meaningful only when passed as an argument to
@@ -5919,6 +5929,17 @@
 @item @code{tar-v7}
 @itemx @code{tar-ustar}
 @itemx @code{tar-pax}
+@cindex Option, tar-v7
+@cindex Option, tar-ustar
+@cindex Option, tar-pax
+@cindex tar formats
+@cindex v7 tar format
+@cindex ustar format
+@cindex pax format
+@trindex tar-v7
+@trindex tar-ustar
+@trindex tar-pax
+
 These three mutually exclusive options select the tar format to use
 when generating tarballs with @code{make dist}.  (The tar file created
 is then compressed according to the set of @code{no-dist-gzip},
@@ -5935,7 +5956,8 @@
 given longer filenames some tar implementations will diagnose the
 problem while other will generate broken tarballs or use non-portable
 extensions.  Furthermore, the V7 format cannot store empty
-directories.
+directories.  When using this format, consider using the
+@code{filename-length-max=99} option to catch filenames too long.
 
 @code{tar-ustar} selects the ustar format defined by POSIX
 1003.1-1988.  This format is believed to be old enough to be portable.
Index: lib/Automake/Options.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/Options.pm,v
retrieving revision 1.3
diff -u -r1.3 Options.pm
--- lib/Automake/Options.pm	19 Apr 2004 23:20:07 -0000	1.3
+++ lib/Automake/Options.pm	23 Apr 2004 21:55:16 -0000
@@ -271,6 +271,11 @@
 	{
 	  # Explicitly recognize these.
 	}
+      elsif ($_ =~ /^filename-length-max=(\d+)$/)
+	{
+	  delete $options->{$_};
+	  $options->{'filename-length-max'} = [$_, $1];
+	}
       elsif ($_ eq 'tar-v7' || $_ eq 'tar-ustar' || $_ eq 'tar-pax')
 	{
 	  error ($where,
Index: lib/am/distdir.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/distdir.am,v
retrieving revision 1.57
diff -u -r1.57 distdir.am
--- lib/am/distdir.am	19 Apr 2004 23:20:08 -0000	1.57
+++ lib/am/distdir.am	23 Apr 2004 21:55:16 -0000
@@ -212,8 +212,14 @@
 	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
 	  ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
 	|| chmod -R a+r $(distdir)
+if %?FILENAME_FILTER%
+	@if find $(distdir) -type f -print | \
+	  grep '^%FILENAME_FILTER%' 1>&2; then \
+	  echo 'error: the above filenames are too long' 1>&2; \
+	  exit 1; \
+	else :; fi
+endif %?FILENAME_FILTER%
 endif %?TOPDIR_P%
-

 
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.557
diff -u -r1.557 Makefile.am
--- tests/Makefile.am	19 Apr 2004 23:20:08 -0000	1.557
+++ tests/Makefile.am	23 Apr 2004 21:55:16 -0000
@@ -217,6 +217,7 @@
 extra7.test \
 f90only.test \
 flibs.test \
+fn99.test \
 fnoc.test \
 fo.test	\
 fonly.test \
Index: tests/fn99.test
===================================================================
RCS file: tests/fn99.test
diff -N tests/fn99.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/fn99.test	23 Apr 2004 21:55:16 -0000
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2004  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check the filename-length-max=99 option.
+
+. ./defs || exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = filename-length-max=99
+EXTRA_DIST = 12345678
+END
+
+(for i in 1 2 3 4 5 6 7 8 9
+do
+  mkdir -p 12345678 || exit 77
+  cd 12345678
+  touch x
+done)
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+(for i in 1 2 3 4 5 6 7 8 9 10 11
+do
+  mkdir -p 12345678 || exit 77
+  cd 12345678
+  touch x
+done)
+
+$MAKE dist 2>stderr && exit 1
+cat stderr
+grep 'filenames are too long' stderr
+test 2 = `grep 12345678 stderr | wc -l`
+:

-- 
Alexandre Duret-Lutz