I'm not sure what happened to my last email. Please unblock nvidia-cg-toolkit 2.0.0015.deb3.
On Thursday 23 October 2008 04:04:26 am Marc 'HE' Brockschmidt wrote: > "Andres Mejia" <[EMAIL PROTECTED]> writes: > > I have a fix for this (and similar issues I found with perlcritic) > > ready for upload. Could an exception be made for this kind of fix? > > Patch? If this is a one-liner or something similar, I approve of getting > rid of the annoying warnings. > > Marc I took care of this problem by taking care of the gentle warnings produced by Perl::Critic. It's not a one-liner, but I thought the other lines could pose a problem in the future anyway, so I corrected them as well. Just in case it's already been forgotten, I'm asking for a freeze exception on nvidia-cg-toolkit (2.0.0015.deb3). -- Regards, Andres
diff --git a/debian/changelog b/debian/changelog index 2d25617..c869395 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +nvidia-cg-toolkit (2.0.0015.deb3) unstable; urgency=low + + * Fixed all gentle warnings in script found with Perl::Critic. + * This also fixes some bugs reporting Perl warnings. + (Closes: #502234) + (Closes: #503331) + + -- Andres Mejia <[EMAIL PROTECTED]> Sun, 16 Nov 2008 10:07:18 -0500 + nvidia-cg-toolkit (2.0.0015.deb2) unstable; urgency=low * Adding Japanese translations. (Closes: #493566) diff --git a/nvidia-cg-toolkit-installer b/nvidia-cg-toolkit-installer index bc16e3d..ca2d893 100755 --- a/nvidia-cg-toolkit-installer +++ b/nvidia-cg-toolkit-installer @@ -29,7 +29,6 @@ use File::Temp qw/ tempfile tempdir /; # For temporary files and directories. use File::Path 'rmtree'; # Needed for removing directories recursively. use File::Copy; # Needed for copying files. use File::Basename; # Used in retrieving the basename/dirname of a file. -use File::Glob ':glob'; # Needed for selecting specific files from a directory. use Compress::Zlib; # Needed for compressing files in gzip format. use Digest::MD5; # Needed to verify MD5 checksums. use Time::HiRes qw ( time ); # Needed for high resolution timers @@ -133,7 +132,7 @@ sub download { my $percent; # The percentage downloaded my $tick; # Used for counting. my $start_time = time; # Record of the start time - open(FILE, '>', $file); # Destination file to download content to + open(my $fh, '>', $file); # Destination file to download content to my $response = $ua->get($url, ":content_cb" => sub { my ($chunk, $response) = @_; @@ -180,20 +179,20 @@ sub download { } # Write the contents of the download to our specified file if ($response->is_success) { - print FILE $chunk; # Print content to file + print $fh $chunk; # Print content to file } else { # Print message upon failure during download print STDERR "\n" . $response->status_line . "\n"; - return undef; + return 0; } } ); # Our GET request - close FILE; # Close the destination file + close $fh; # Close the destination file # Print error message in case we couldn't get a response at all. if (!$response->is_success) { print $response->status_line . "\n"; - return undef; + return 0; } # At this point, the download should have been successful. Print a success @@ -209,7 +208,7 @@ sub download { sub getProxy { # Determine if a proxy is going to be used at all if ($no_proxy) { - return undef; + return 0; } # Determine if the proxy option was specified in the command line. @@ -219,10 +218,8 @@ sub getProxy { } # Attempt to acquire a proxy URL from apt-config. - if (open(APT_CONFIG, "apt-config dump |")) { - my @apt_config = <APT_CONFIG>; - close(APT_CONFIG); - foreach my $tmp (@apt_config) { + if (open(my $apt_config_output, '-|', '/usr/bin/apt-config dump')) { + foreach my $tmp (<$apt_config_output>) { if ($tmp =~ m/^.*Acquire::http::Proxy\s+/) { $proxy = $tmp; chomp($proxy); @@ -231,15 +228,14 @@ sub getProxy { return $proxy; } } + close $apt_config_output; } # Attempt to acquire a proxy URL from the user's or system's wgetrc # configuration. # First try the user's wgetrc - if (open(WGETRC, '<', "$ENV{'HOME'}/.wgetrc")) { - my @wgetrc = <WGETRC>; - close(WGETRC); - foreach my $tmp (@wgetrc) { + if (open(my $wgetrc, '<', "$ENV{'HOME'}/.wgetrc")) { + foreach my $tmp (<$wgetrc>) { if ($tmp =~ m/^[^#]*http_proxy/) { $proxy = $tmp; chomp($proxy); @@ -248,12 +244,11 @@ sub getProxy { return $proxy; } } + close($wgetrc); } # Now try the system's wgetrc - if (open(WGETRC, '<', '/etc/wgetrc')) { - my @wgetrc = <WGETRC>; - close(WGETRC); - foreach my $tmp (@wgetrc) { + if (open(my $wgetrc, '<', '/etc/wgetrc')) { + foreach my $tmp (<$wgetrc>) { if ($tmp =~ m/^[^#]*http_proxy/) { $proxy = $tmp; chomp($proxy); @@ -262,10 +257,11 @@ sub getProxy { return $proxy; } } + close($wgetrc); } # At this point there should be no proxy settings. Return undefined. - return undef; + return 0; } # This method is used to search for the NVIDIA Cg Toolkit and the Spec File in a @@ -298,11 +294,11 @@ sub copyUtil { push(@manifest, $new . '/'); $total_size = $total_size + (stat($new))[7]; # Add to size } - opendir(DIR, $orig) or die "Couldn't open $orig: $!"; - foreach my $tmp (grep(!/^\.{1,2}$/, readdir(DIR))) { + opendir(my $dh, $orig) or die "Couldn't open $orig: $!"; + foreach my $tmp (grep(!/^\.{1,2}$/, readdir($dh))) { copyUtil($orig . '/' . $tmp, $new . '/' . $tmp, $compress_size); } - closedir DIR; + closedir $dh; } else { # Use copy() for regular files. Compress files if they are bigger than # the specified size. @@ -331,17 +327,17 @@ sub verifyMD5 { my($data, $correct_md5) = @_; # Open the data and read it as a binary (or text if applicable). - open(DATA, $data) or die "Can't open '$data': $!"; - binmode(DATA); + open(my $datahandle, '<', $data) or die "Can't open '$data': $!"; + binmode($datahandle); # Check if the computed MD5 matches the correct MD5 and return an # appropriate value. - if (Digest::MD5->new->addfile(*DATA)->hexdigest eq $correct_md5) { - close DATA; + if (Digest::MD5->new->addfile($datahandle)->hexdigest eq $correct_md5) { + close $datahandle; return 1; } else { - close DATA; - return undef; + close $datahandle; + return 0; } } @@ -360,22 +356,21 @@ sub gzipCompress { } # Attempt to open the file. - if (!open(SOURCE, '<', $file)) { - die "Couldn't open source file $file: $!"; - } + open(my $fh, '<', $file) or + die "Couldn't open file $file for compressing: $!"; # Read the contents of the file and write them to the compressed file. while (1) { my $buffer; - my $bytesread = read SOURCE, $buffer, 4096; + my $bytesread = read $fh, $buffer, 4096; if (!defined $bytesread) { - close SOURCE; + close $fh; die "Error reading from '$file': $!"; } last if $bytesread == 0; my $byteswritten = $gz->gzwrite($buffer); if ($byteswritten < $bytesread) { - close SOURCE; + close $fh; die "Error gzwriting to temporary file: " . $gz->gzerror; } } @@ -384,13 +379,13 @@ sub gzipCompress { # occurred. my $gzflush = $gz->gzflush(Z_FINISH); if (($gzflush != Z_OK) and ($gzflush != Z_STREAM_END)) { - close SOURCE; + close $fh; die "Error flushing compressed file: " . $gz->gzerror; } # Close the file and compressed file and return the path of the compressed # file. - close SOURCE; + close $fh; $gz->gzclose; return $tmpfilename; } @@ -480,7 +475,7 @@ sub install { # Here we pass the compression size parameter to compress files bigger than # 4kb (512B). print STDERR "documentation, "; - foreach my $tmp (<$tempdir/usr/local/Cg/docs/*.pdf>) { + foreach my $tmp (glob($tempdir.'/usr/local/Cg/docs/*.pdf')) { copyUtil($tmp, '/usr/share/doc/nvidia-cg-toolkit/' . fileparse($tmp), 512); } @@ -499,17 +494,17 @@ sub install { # Install manual pages for the NVIDIA Cg Toolkit. We compress the manual # pages first before installing them. print STDERR "manual pages, "; - foreach my $tmp (<$tempdir/usr/share/man/man3/*>) { + foreach my $tmp (glob($tempdir.'/usr/share/man/man3/*')) { copyUtil(gzipCompress($tmp), '/usr/share/man/man3/' . fileparse($tmp) . 'Cg.gz'); } - foreach my $tmp (<$tempdir/usr/share/man/manCg/*>) { + foreach my $tmp (glob($tempdir.'/usr/share/man/manCg/*')) { my $tmpname = fileparse($tmp); $tmpname =~ s/Cg$//; # Takes out 'Cg' extension in file name. copyUtil(gzipCompress($tmp), '/usr/share/man/man3/' . $tmpname . '3Cg.gz'); } - foreach my $tmp (<$tempdir/usr/share/man/manCgFX/*>) { + foreach my $tmp (glob($tempdir.'/usr/share/man/manCgFX/*')) { my $tmpname = fileparse($tmp); $tmpname =~ s/CgFX$//; # Takes out 'CgFX' extension in file name. copyUtil(gzipCompress($tmp), @@ -536,16 +531,17 @@ sub install { # Generate a manifest file if it was requested. if ($generate_manifest) { @manifest = sort(@manifest); # Sort manifest - open (MANIFEST, '>', '/tmp/nvidia-cg-toolkit-manifest'); - print MANIFEST "Manifest for nvidia-cg-toolkit $arch package.\n"; + open (my $manifesth, '>', '/tmp/nvidia-cg-toolkit-manifest') or + die "Couldn't open file to write manifest: $!"; + print $manifesth "Manifest for nvidia-cg-toolkit $arch package.\n"; # Convert total size from bytes to kilobytes. my $msg = "Combined total size of all files installed is "; $msg .= sprintf("%.0f", $total_size/1024) ." KB.\n\n"; - print MANIFEST $msg; + print $manifesth $msg; foreach my $tmp (@manifest) { - print MANIFEST "$tmp\n"; + print $manifesth "$tmp\n"; } - close MANIFEST; + close $manifesth; } # Delete the NVIDIA Cg Toolkit and the spec file if it was requested to do
signature.asc
Description: This is a digitally signed message part.