On Mon, Jun 13, 2011 at 05:58:36PM -0700, Don Armstrong wrote:
> reassign 630323 dictionaries-common
> retitle 630323 consider replacing File::Temp with IO::File::new_tmpfile() or 
> similar
> severity 630323 minor
> thanks

Hi, Don

> On Mon, 13 Jun 2011, Agustin Martin wrote:
> > On Sun, Jun 12, 2011 at 11:07:31PM +0100, Connor Lane Smith wrote:
> > > All scowl word lists depend upon dictionaries-common,
> > 
> > wamerican does not.
> 
> If you don't want perl, install wamerican. It's the default wordlist.

In other words, wamerican is a standard package that is designed to work
well either with or without optional dictionaries-common. Nothing outside
required perl-base is needed. Not true for other wordlists.

> Otherwise a mechanism of choosing between which wordlist to use needs
> to be present, and doing that requires more logic that I'm willing to
> put into the wordlist postinsts.

Thanks for reassigning, Don. Since you consider that restricting stuff to
perl-base worths I will do the change. 

By the way, when I mentioned File::Temp was because of tempdir, not
tempfile, so IO::File::new_tmpfile() is not a replacement. In my changes I
use system mktemp. While I'd prefer to stay with pure perl(-base) here, I
am afraid I have no other choice.

I am attaching changes as in my git repo, containing also some cosmetic
and debugging stuff.

Regards,

-- 
Agustin
>From 720570bc6786d3b66d425af730da357251dfcf2c Mon Sep 17 00:00:00 2001
From: Agustin Martin Domingo <[email protected]>
Date: Thu, 10 Feb 2011 18:56:24 +0100
Subject: [PATCH] Try changing things to not use File::Temp, but only stuff in
 Debian perl-base.

---
 debian/rules                        |    2 +-
 scripts/system/ispell-autobuildhash |   38 ++++++++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/debian/rules b/debian/rules
index f5f97b1..34f84aa 100755
--- a/debian/rules
+++ b/debian/rules
@@ -64,7 +64,7 @@ binary-indep: build install
 	dh_installdebconf
 	dh_fixperms
 	dh_installdeb
-	dh_perl scripts/system/*
+	dh_perl -d scripts/system/*
 	dh_gencontrol
 	dh_md5sums
 	dh_builddeb
diff --git a/scripts/system/ispell-autobuildhash b/scripts/system/ispell-autobuildhash
index 21aa1c2..07ebad3 100755
--- a/scripts/system/ispell-autobuildhash
+++ b/scripts/system/ispell-autobuildhash
@@ -33,7 +33,9 @@ my $compatdir    = "/var/lib/ispell";
 # Set tmpdir base, honouring TMPDIR. Real tmpdir is set after options parsing.
 my $tmpdir    = $ENV{'TMPDIR'} || '/tmp';
 
+# ---------------------------------------------------------------------
 sub usage {
+# ---------------------------------------------------------------------
   print STDERR "\nUsage:\tispell-autobuildhash [options]\n"
     . "\n"
     . "Options:\n"
@@ -43,11 +45,15 @@ sub usage {
     . "\t--triggered     Tell the script that is run in the triggers stage.\n";
 }
 
+# ---------------------------------------------------------------------
 sub debugprint {
+# ---------------------------------------------------------------------
   print STDERR "@_\n" if $debug;
 }
 
+# ---------------------------------------------------------------------
 sub mymessage{
+# ---------------------------------------------------------------------
   my $dict     = shift;
   my $message  = join(" ",@_);
   my $question = "dictionaries-common/ispell-autobuildhash-message";
@@ -71,16 +77,27 @@ This error was caused by package providing hash $dict, although it
 can be made evident during other package postinst. Please complain
 to the maintainer of package providing hash $dict. In the meantime
 you might need to remove package providing $dict.hash\n";
-  myclean();
+  &auto_clean;
   exit 1;
 }
 
+# ---------------------------------------------------------------------
 sub myerror {
+# ---------------------------------------------------------------------
   my $dict = shift;
   mymessage $dict,@_;
 }
 
 # ---------------------------------------------------------------------
+sub auto_clean {
+# ---------------------------------------------------------------------
+  if ( -d $tmpdir ){
+    unlink <$tmpdir/*>;
+    rmdir $tmpdir;
+  }
+}
+
+# ---------------------------------------------------------------------
 #      Handle autorebuilding
 # ---------------------------------------------------------------------
 
@@ -93,7 +110,7 @@ sub autorebuild {
 
   die "ispell-autobuildhash: No argument passed to function autorebuild.\n" unless $dict;
 
-  print STDERR "ispell-autobuildhash: Processing \'$dict\' dict\n";
+  print STDERR "ispell-autobuildhash: Processing \'$dict\' dict.\n";
 
   my $tempfile = "$tmpdir/$dict-mwl";
   if ( -e $aff ){
@@ -104,8 +121,10 @@ sub autorebuild {
 	print STDERR "$gzip_cmd\n";
 	print STDERR "$build_cmd\n";
       } else {
+	print STDERR "$gzip_cmd\n" if $debug;
 	system ("$gzip_cmd") == 0
 	  or myerror($dict,"Could not gunzip the munched wordlist for $dict");
+	print STDERR "$build_cmd\n" if $debug;
 	system ("$build_cmd") == 0
 	  or myerror($dict,"Could not build the hash file for $dict") ;
       }
@@ -115,6 +134,7 @@ sub autorebuild {
 	if ( $dry_run ) {
 	  print STDERR "$cmd\n";
 	} else {
+	  print STDERR "$cmd\n" if $debug;
 	  system ("$cmd") == 0
 	    or myerror($dict,"Problems running update-ispell-hash for $dict");
 	}
@@ -124,6 +144,7 @@ sub autorebuild {
 	if ( $dry_run ) {
 	  print STDERR "$cmd\n";
 	} else {
+	  print STDERR "$cmd\n" if $debug;
 	  system ("$cmd") == 0
 	    or myerror($dict,"Problems running update-ipolish-hash for $dict");
 	}
@@ -177,9 +198,14 @@ unless ( $triggered or $force ){
 }
 
 # Prepare temporary directory
-$tmpdir = tempdir("ispell-auto.XXXXXXXXXX",
-		  CLEANUP => ( ! $debug ), # Remove tempdir tree on exit unless $debug
-		  DIR => "$tmpdir");
+$tmpdir = `mktemp -d ispell-auto.XXXXXXXXXX --tmpdir=$tmpdir`
+      or die "Cannot make temporary directory. Aborting ...\n";
+chomp $tmpdir;
+
+$SIG{INT}     = \&auto_clean;
+$SIG{KILL}    = \&auto_clean;
+$SIG{TERM}    = \&auto_clean;
+$SIG{__DIE__} = \&auto_clean;
 
 print STDERR "ispell-autobuildhash: Using temporary directory\"$tmpdir\"\n"
   if $debug;
@@ -219,6 +245,8 @@ if ( my $ispell_compat = get_ispell_compat() ){
   debugprint "ispell-autobuildhash: no ispell compat info. ispell may not be installed. Aborting ...\n";
 }
 
+&auto_clean unless $debug;
+
 __END__
 
 =head1 NAME
-- 
1.7.5.4

Reply via email to