Ah, it's worse than that. We actually need to exit with whatever the original exit code should have been. I think the only way to fix the windows version is to write out a temporary batch file that deletes itself as the last step. The following block attempts to correct the exit code problem on both platforms. I'm having problems with the test suite in general, so I'm not confident this passes the tests.
END { if ($ENV{PAR_CLEAN}) {
my $topdir = File::Basename::dirname($par_temp);
unlink @tmpfile;
if (rmdir $par_temp) {
rmdir $topdir;
} else {
# Something went wrong unlinking the temporary directory. This
# typically happens on platforms that disallow unlinking shared
# libraries and executables that are in use.
#
# Try unlinking with an exec'ed shell command so the files are no
# longer in use by this process. Note that this will terminate the
# current process so no further END block processing will follow.
my $cmd;
if ($^O =~ m/win32/i) {
my $tmp = new File::Temp(
TEMPLATE => 'tmpXXXXX',
DIR => File::Basename::dirname($topdir),
SUFFIX => '.bat',
UNLINK => 0 );
print $tmp "
rmdir /q /s \"$par_temp\"
rmdir \"$topdir\"
rm \"" . $tmp->filename . "\" && exit $?
";
$cmd = $tmp->filename . " >nul 2>nul ";
close $tmp;
} else {
$cmd = "rm -rf '" . $par_temp . "' >/dev/null 2>&1 ; rmdir '"
. $topdir . "' >/dev/null 2>&1; exit $?";
}
outs(qq(Unable to remove all temp files, using exec($cmd)));
exec($cmd);
}
} }
Show quoted text-----Original Message-----
From: Steffen Müller via RT [mailto:bug-PAR-Packer@rt.cpan.org]
Sent: Friday, October 12, 2007 3:27 AM
To: Scott Stanton
Subject: [rt.cpan.org #29933] Errors from --clean packed application on HP-UX
<URL:
http://rt.cpan.org/Ticket/Display.html?id=29933 >
Thanks, applied.
I did one important change, though: If the cleanup-shell-script is run,
it needs to return something "true". Otherwise, the tests fail. I
couldn't fix it for WIndows, since I don't know the shell well enough.
The "&&" between the commands there prohibits anything similar since the
second rmdir is allowed to fail. I'll keep the ticket open in case you
have a solution.
my $cmd;
if ($^O =~ m/win32/i) {
$cmd = 'rmdir /q /s "' . $par_temp . '" >nul 2>nul && rmdir "'
. $topdir . '" >nul 2>nul ';
} else {
$cmd = "rm -rf '" . $par_temp . "' >/dev/null 2>&1 ; rmdir '"
. $topdir . "' >/dev/null 2>&1 ; true";
}
Best regards,
Steffen