netpbm/netpbm-tmpfile.patch
Petr Gajdos ab3fe00e48 Accepting request 134223 from home:pgajdos:libpng15
- updated to 10.59.2:
  * transition super-stable --> advanced branch
  * builds with libpng15
  * patches summary:
    ->  dropped unneeded or upstreamed patches:
       - fixes.patch
       - libpng14.patch
       - manpages.patch
       - pamscale.patch
       - pnmtopng-CAN-2978.patch
    -> left patches
       # make.patch (suse specific)
       # no-build-time.patch (suse specific)
       # missing-file-close.patch (should be upstreamed in newer 
         versions)
       # tmpfile.patch (rewritten) 
       # security-code.patch (taken from fedora, replacement of 
         former security.patch)
       # security-scripts.patch (taken from fedora, replacement of
         former security2.patch)

OBS-URL: https://build.opensuse.org/request/show/134223
OBS-URL: https://build.opensuse.org/package/show/graphics/netpbm?expand=0&rev=39
2012-09-14 06:19:47 +00:00

64 lines
1.7 KiB
Diff

Index: editor/pnmindex.csh
===================================================================
--- editor/pnmindex.csh.orig
+++ editor/pnmindex.csh
@@ -85,7 +85,7 @@ if ( $#argv == 0 ) then
goto usage
endif
-set tmpfile=/tmp/pi.tmp.$$
+set tmpfile=.pi.tmp.$$
rm -f $tmpfile
set maxformat=PBM
Index: generator/ppmrainbow
===================================================================
--- generator/ppmrainbow.orig
+++ generator/ppmrainbow
@@ -1,6 +1,7 @@
#!/usr/bin/perl -wl
use strict;
use Getopt::Long;
+use File::Temp qw{tempfile tempdir};
my ($FALSE, $TRUE) = (0,1);
@@ -47,31 +48,25 @@ if (!$norepeat) {
push @colorlist, $ARGV[0];
}
-my $ourtmp = "$tmpdir/ppmrainbow$$";
-mkdir($ourtmp, 0777) or
- die("Unable to create directory for temporary files '$ourtmp");
-
-
+my $ourtmp = tempdir("ppmrainbow.XXXX", DIR => $tmpdir, CLEANUP => 1);
my $widthRemaining;
-my $n;
my @outlist;
-$n = 0;
$widthRemaining = $Twid;
@outlist = ();
while (@colorlist >= 2) {
- my $outfile = sprintf("%s/file.%03u.ppm", $ourtmp, $n);
+ (my $tmpfh, my $outfile) = tempfile("file.XXXXXXXX", DIR => "$ourtmp", SUFFIX => '.ppm');
push(@outlist, $outfile);
my $w = int(($widthRemaining-1)/(@colorlist-1))+1;
- my $rc = system("$verboseCommand pgmramp -lr $w $Thgt | " .
- "pgmtoppm \"$colorlist[0]-$colorlist[1]\" >$outfile");
- if ($rc != 0) {
+ my $content = qx{$verboseCommand pgmramp -lr $w $Thgt |
+ pgmtoppm "$colorlist[0]-$colorlist[1]"};
+ if (! "$content") {
fatal("pgmramp|pgmtoppm failed.");
}
+ print $tmpfh $content;
$widthRemaining -= $w;
- $n++;
shift @colorlist;
}