]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* autoupdate.in (&mktmpdir): New.
authorAkim Demaille <akim@epita.fr>
Sun, 25 Feb 2001 10:45:02 +0000 (10:45 +0000)
committerAkim Demaille <akim@epita.fr>
Sun, 25 Feb 2001 10:45:02 +0000 (10:45 +0000)
(&END): Remove $tmp.
(&parse_args): Handle -d and -l.

ChangeLog
autoupdate.in
autoupdate.sh
bin/autoupdate.in

index 463baf84a18c75c398628b137ef391630480c32f..30c1ba330390af6fb300b0f80700383454fa3013 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-02-25  Akim Demaille  <akim@epita.fr>
+
+       * autoupdate.in (&mktmpdir): New.
+       (&END): Remove $tmp.
+       (&parse_args): Handle -d and -l.
+
 2001-02-25  Akim Demaille  <akim@epita.fr>
 
        * acgeneral.m4 (_AC_INIT_PREPARE): Remove conf$$* on exit.
index 961ef50ea8b93ce45f297c957a316423be470f0c..f4184c1a38fd9c5f9ccd87c363dd341964513b18 100644 (file)
@@ -28,18 +28,14 @@ use strict;
 
 # Lib files.
 my $autoconf_dir = $ENV{"AC_MACRODIR"} || "@datadir@";
-
 my $autoconf = '';
 my $debug = 0;
 my $localdir = '.';
 # m4.
 my $m4 = $ENV{"M4"} || "@M4@";
-my $status = 0;
-# FIXME: Ahem....
-my $tmp = '/tmp/autoupdate.tmp';
-mkdir $tmp, 0700;
 my $verbose = 0;
 my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
+my $tmp;
 
 
 ## ---------- ##
@@ -47,12 +43,42 @@ my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
 ## ---------- ##
 
 
+# &mktmpdir ()
+# ------------
+sub mktmpdir ()
+{
+  my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
+
+  # If mktemp supports dirs, use it to please Marc E.
+  $tmp = `(umask 077 && mktemp -d -q "$TMPDIR/auXXXXXX") 2>/dev/null`;
+
+  if (!$tmp || !-d $tmp)
+    {
+      $tmp = "$TMPDIR/au" . int (rand 10000) . ".$$";
+      mkdir $tmp, 0700
+       or die "$me: cannot create $tmp: $!\n";
+    }
+
+  print STDERR "$me:$$: working in $tmp\n"
+    if $debug;
+}
+
+
 # END
 # ---
 # Exit nonzero whenever closing STDOUT fails.
 sub END
 {
   use POSIX qw (_exit);
+
+  if (!$debug && -d $tmp)
+    {
+      unlink <$tmp/*>
+       or die "$me: cannot empty $tmp: $!\n";
+      rmdir $tmp
+       or die "$me: cannot remove $tmp: $!\n";
+    }
+
   # This is required if the code might send any output to stdout
   # E.g., even --version or --help.  So it's best to do it unconditionally.
   close STDOUT
@@ -80,11 +106,11 @@ Operation modes:
 
 Library directories:
   -A, --autoconf-dir=ACDIR  Autoconf's macro files location (rarely needed)
-  -l, --localdir=DIR        location of \`aclocal.m4' and \`acconfig.h'
+  -l, --localdir=DIR        location of \`aclocal.m4'
 
 Environment variables:
-  M4         GNU M4 is required.
-  AUTOCONF   autoconf.
+  M4         GNU M4 1.4 or above
+  AUTOCONF   autoconf @VERSION@
 
 Report bugs to <bug-autoconf\@gnu.org>.
 ";
@@ -143,6 +169,8 @@ sub parse_args ()
   @ARGV = grep !/^-$/, @ARGV;
   Getopt::Long::config ("bundling");
   Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
+                           'l|localdir=s' => \$localdir,
+                           'd|debug'      => \$debug,
                            'h|help'    => \&print_usage,
                            'V|version' => \&print_version,
                            'v|verbose' => \$verbose)
@@ -192,8 +220,9 @@ sub find_slaves ()
 ## -------------- ##
 find_slaves;
 parse_args;
-$autoconf .= " -l $localdir";
-$ENV{'autoconf_dir'} = $autoconf_dir;
+mktmpdir;
+$autoconf .= " --autoconf-dir $autoconf_dir --localdir $localdir";
+
 
 # @M4_BUILTINS -- M4 builtins and a useful comment.
 open M4_BUILTINS, "echo dumpdef | $m4 2>&1 >/dev/null |"
@@ -402,10 +431,11 @@ EOF
     $input_m4 =~ s/^      //mg;
 
     # prepared input -- input, but reenables the quote before each AU macro.
-    open INPUT_M4, ">$tmp/input.m4";
-    print INPUT_M4 "$input_m4";
+    open INPUT_M4, ">$tmp/input.m4"
+       or die "$me: cannot open: $!\n";
     open FILE, "<$file"
        or die "$me: cannot open: $!\n";
+    print INPUT_M4 "$input_m4";
     while (<FILE>)
        {
         eval $au_changequote;
@@ -417,7 +447,7 @@ EOF
        or die "$me: cannot close: $!\n";
 
     # Now ask m4 to perform the update.
-    print STDERR "$me: running $m4 $tmp/input.m4"
+    print STDERR "$me: running $m4 $tmp/input.m4\n"
        if $verbose;
     if (system ("$m4 $tmp/input.m4 >$tmp/updated"))
        {
@@ -445,7 +475,7 @@ EOF
           }
         else
           {
-            die "$me: cannot update \`$file'";
+            die "$me: cannot update \`$file'\n";
           }
        }
   }
index 961ef50ea8b93ce45f297c957a316423be470f0c..f4184c1a38fd9c5f9ccd87c363dd341964513b18 100644 (file)
@@ -28,18 +28,14 @@ use strict;
 
 # Lib files.
 my $autoconf_dir = $ENV{"AC_MACRODIR"} || "@datadir@";
-
 my $autoconf = '';
 my $debug = 0;
 my $localdir = '.';
 # m4.
 my $m4 = $ENV{"M4"} || "@M4@";
-my $status = 0;
-# FIXME: Ahem....
-my $tmp = '/tmp/autoupdate.tmp';
-mkdir $tmp, 0700;
 my $verbose = 0;
 my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
+my $tmp;
 
 
 ## ---------- ##
@@ -47,12 +43,42 @@ my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
 ## ---------- ##
 
 
+# &mktmpdir ()
+# ------------
+sub mktmpdir ()
+{
+  my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
+
+  # If mktemp supports dirs, use it to please Marc E.
+  $tmp = `(umask 077 && mktemp -d -q "$TMPDIR/auXXXXXX") 2>/dev/null`;
+
+  if (!$tmp || !-d $tmp)
+    {
+      $tmp = "$TMPDIR/au" . int (rand 10000) . ".$$";
+      mkdir $tmp, 0700
+       or die "$me: cannot create $tmp: $!\n";
+    }
+
+  print STDERR "$me:$$: working in $tmp\n"
+    if $debug;
+}
+
+
 # END
 # ---
 # Exit nonzero whenever closing STDOUT fails.
 sub END
 {
   use POSIX qw (_exit);
+
+  if (!$debug && -d $tmp)
+    {
+      unlink <$tmp/*>
+       or die "$me: cannot empty $tmp: $!\n";
+      rmdir $tmp
+       or die "$me: cannot remove $tmp: $!\n";
+    }
+
   # This is required if the code might send any output to stdout
   # E.g., even --version or --help.  So it's best to do it unconditionally.
   close STDOUT
@@ -80,11 +106,11 @@ Operation modes:
 
 Library directories:
   -A, --autoconf-dir=ACDIR  Autoconf's macro files location (rarely needed)
-  -l, --localdir=DIR        location of \`aclocal.m4' and \`acconfig.h'
+  -l, --localdir=DIR        location of \`aclocal.m4'
 
 Environment variables:
-  M4         GNU M4 is required.
-  AUTOCONF   autoconf.
+  M4         GNU M4 1.4 or above
+  AUTOCONF   autoconf @VERSION@
 
 Report bugs to <bug-autoconf\@gnu.org>.
 ";
@@ -143,6 +169,8 @@ sub parse_args ()
   @ARGV = grep !/^-$/, @ARGV;
   Getopt::Long::config ("bundling");
   Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
+                           'l|localdir=s' => \$localdir,
+                           'd|debug'      => \$debug,
                            'h|help'    => \&print_usage,
                            'V|version' => \&print_version,
                            'v|verbose' => \$verbose)
@@ -192,8 +220,9 @@ sub find_slaves ()
 ## -------------- ##
 find_slaves;
 parse_args;
-$autoconf .= " -l $localdir";
-$ENV{'autoconf_dir'} = $autoconf_dir;
+mktmpdir;
+$autoconf .= " --autoconf-dir $autoconf_dir --localdir $localdir";
+
 
 # @M4_BUILTINS -- M4 builtins and a useful comment.
 open M4_BUILTINS, "echo dumpdef | $m4 2>&1 >/dev/null |"
@@ -402,10 +431,11 @@ EOF
     $input_m4 =~ s/^      //mg;
 
     # prepared input -- input, but reenables the quote before each AU macro.
-    open INPUT_M4, ">$tmp/input.m4";
-    print INPUT_M4 "$input_m4";
+    open INPUT_M4, ">$tmp/input.m4"
+       or die "$me: cannot open: $!\n";
     open FILE, "<$file"
        or die "$me: cannot open: $!\n";
+    print INPUT_M4 "$input_m4";
     while (<FILE>)
        {
         eval $au_changequote;
@@ -417,7 +447,7 @@ EOF
        or die "$me: cannot close: $!\n";
 
     # Now ask m4 to perform the update.
-    print STDERR "$me: running $m4 $tmp/input.m4"
+    print STDERR "$me: running $m4 $tmp/input.m4\n"
        if $verbose;
     if (system ("$m4 $tmp/input.m4 >$tmp/updated"))
        {
@@ -445,7 +475,7 @@ EOF
           }
         else
           {
-            die "$me: cannot update \`$file'";
+            die "$me: cannot update \`$file'\n";
           }
        }
   }
index 961ef50ea8b93ce45f297c957a316423be470f0c..f4184c1a38fd9c5f9ccd87c363dd341964513b18 100644 (file)
@@ -28,18 +28,14 @@ use strict;
 
 # Lib files.
 my $autoconf_dir = $ENV{"AC_MACRODIR"} || "@datadir@";
-
 my $autoconf = '';
 my $debug = 0;
 my $localdir = '.';
 # m4.
 my $m4 = $ENV{"M4"} || "@M4@";
-my $status = 0;
-# FIXME: Ahem....
-my $tmp = '/tmp/autoupdate.tmp';
-mkdir $tmp, 0700;
 my $verbose = 0;
 my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
+my $tmp;
 
 
 ## ---------- ##
@@ -47,12 +43,42 @@ my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
 ## ---------- ##
 
 
+# &mktmpdir ()
+# ------------
+sub mktmpdir ()
+{
+  my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
+
+  # If mktemp supports dirs, use it to please Marc E.
+  $tmp = `(umask 077 && mktemp -d -q "$TMPDIR/auXXXXXX") 2>/dev/null`;
+
+  if (!$tmp || !-d $tmp)
+    {
+      $tmp = "$TMPDIR/au" . int (rand 10000) . ".$$";
+      mkdir $tmp, 0700
+       or die "$me: cannot create $tmp: $!\n";
+    }
+
+  print STDERR "$me:$$: working in $tmp\n"
+    if $debug;
+}
+
+
 # END
 # ---
 # Exit nonzero whenever closing STDOUT fails.
 sub END
 {
   use POSIX qw (_exit);
+
+  if (!$debug && -d $tmp)
+    {
+      unlink <$tmp/*>
+       or die "$me: cannot empty $tmp: $!\n";
+      rmdir $tmp
+       or die "$me: cannot remove $tmp: $!\n";
+    }
+
   # This is required if the code might send any output to stdout
   # E.g., even --version or --help.  So it's best to do it unconditionally.
   close STDOUT
@@ -80,11 +106,11 @@ Operation modes:
 
 Library directories:
   -A, --autoconf-dir=ACDIR  Autoconf's macro files location (rarely needed)
-  -l, --localdir=DIR        location of \`aclocal.m4' and \`acconfig.h'
+  -l, --localdir=DIR        location of \`aclocal.m4'
 
 Environment variables:
-  M4         GNU M4 is required.
-  AUTOCONF   autoconf.
+  M4         GNU M4 1.4 or above
+  AUTOCONF   autoconf @VERSION@
 
 Report bugs to <bug-autoconf\@gnu.org>.
 ";
@@ -143,6 +169,8 @@ sub parse_args ()
   @ARGV = grep !/^-$/, @ARGV;
   Getopt::Long::config ("bundling");
   Getopt::Long::GetOptions ('A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
+                           'l|localdir=s' => \$localdir,
+                           'd|debug'      => \$debug,
                            'h|help'    => \&print_usage,
                            'V|version' => \&print_version,
                            'v|verbose' => \$verbose)
@@ -192,8 +220,9 @@ sub find_slaves ()
 ## -------------- ##
 find_slaves;
 parse_args;
-$autoconf .= " -l $localdir";
-$ENV{'autoconf_dir'} = $autoconf_dir;
+mktmpdir;
+$autoconf .= " --autoconf-dir $autoconf_dir --localdir $localdir";
+
 
 # @M4_BUILTINS -- M4 builtins and a useful comment.
 open M4_BUILTINS, "echo dumpdef | $m4 2>&1 >/dev/null |"
@@ -402,10 +431,11 @@ EOF
     $input_m4 =~ s/^      //mg;
 
     # prepared input -- input, but reenables the quote before each AU macro.
-    open INPUT_M4, ">$tmp/input.m4";
-    print INPUT_M4 "$input_m4";
+    open INPUT_M4, ">$tmp/input.m4"
+       or die "$me: cannot open: $!\n";
     open FILE, "<$file"
        or die "$me: cannot open: $!\n";
+    print INPUT_M4 "$input_m4";
     while (<FILE>)
        {
         eval $au_changequote;
@@ -417,7 +447,7 @@ EOF
        or die "$me: cannot close: $!\n";
 
     # Now ask m4 to perform the update.
-    print STDERR "$me: running $m4 $tmp/input.m4"
+    print STDERR "$me: running $m4 $tmp/input.m4\n"
        if $verbose;
     if (system ("$m4 $tmp/input.m4 >$tmp/updated"))
        {
@@ -445,7 +475,7 @@ EOF
           }
         else
           {
-            die "$me: cannot update \`$file'";
+            die "$me: cannot update \`$file'\n";
           }
        }
   }