I know there was discussion of this, and that it shouldn't go into the next fink release because of the amount of testing it would take, but if anyone's interested, I've taken an initial stab at changing fink to make patch/compile/etc be executed as a single posix shell script rather than line-by-line. It seems to be working just fine on the test packages I've run it on, but I would appreciate feedback as to whether this looks OK and is the right way to go in the future.
-- Benjamin Reed a.k.a. Ranger Rick ([EMAIL PROTECTED]) http://ranger.befunk.com/ An ice cream has its unique frequency.... Are you hungry for this ice cream? Or not? -- Alex Chiu, Immortality Inventor
Index: perlmod/Fink/PkgVersion.pm =================================================================== RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v retrieving revision 1.60 diff -u -b -r1.60 PkgVersion.pm --- perlmod/Fink/PkgVersion.pm 21 Mar 2002 19:49:56 -0000 1.60 +++ perlmod/Fink/PkgVersion.pm 23 Mar 2002 18:36:17 -0000 @@ -1058,13 +1058,9 @@ ### patch $self->set_env(); - foreach $cmd (split(/\n/,$patch_script)) { - next unless $cmd; # skip empty lines - - if (&execute($cmd)) { + if (&execute($patch_script) > 0) { die "patching ".$self->get_fullname()." failed\n"; } - } } ### compile @@ -1110,13 +1106,9 @@ ### compile $self->set_env(); - foreach $cmd (split(/\n/,$compile_script)) { - next unless $cmd; # skip empty lines - - if (&execute($cmd)) { + if (&execute($compile_script) > 0) { die "compiling ".$self->get_fullname()." failed\n"; } - } } ### install @@ -1224,12 +1216,8 @@ ### install $self->set_env(); - foreach $cmd (split(/\n/,$install_script)) { - next unless $cmd; # skip empty lines - - if (&execute($cmd)) { + if (&execute($install_script) > 0) { die "installing ".$self->get_fullname()." failed\n"; - } } ### splitoffs Index: perlmod/Fink/Services.pm =================================================================== RCS file: /cvsroot/fink/fink/perlmod/Fink/Services.pm,v retrieving revision 1.18 diff -u -b -r1.18 Services.pm --- perlmod/Fink/Services.pm 16 Mar 2002 11:22:39 -0000 1.18 +++ perlmod/Fink/Services.pm 23 Mar 2002 18:36:17 -0000 @@ -200,16 +200,53 @@ sub execute { my $cmd = shift; my $quiet = shift || 0; - my ($retval, $prog); + my ($retval, $prog, $commandname, $tempfile); + $cmd =~ s/[\r\n]+$//s; + if ($cmd =~ /\n/) { + # multiline, make a tempfile and execute + $tempfile = mktemp(); + open (OUT, ">$tempfile") or die "unable to write to $tempfile: $!"; + print OUT "$cmd\n"; + close (OUT) or die "an unexpected error occurred closing $tempfile: $!"; + $retval = system("/bin/sh -v $tempfile"); + $commandname = $tempfile; + } elsif (defined $cmd and $cmd ne "") { + # otherwise, just exec the command print "$cmd\n"; - $retval = system($cmd); + $retval = system("$cmd"); + ($commandname) = split(/\s+/, $cmd); + } else { + # command is empty -- assuming it's OK + return 0; + } $retval >>= 8 if defined $retval and $retval >= 256; if ($retval and not $quiet) { - ($prog) = split(/\s+/, $cmd); - print "### $prog failed, exit code $retval\n"; + print "### execute of $commandname failed, exit code $retval\n"; + } else { + unlink($tempfile) if (defined $tempfile and -f $tempfile); } return $retval; +} + +### create a temporary file + +sub mktemp { + # I'm being paranoid, since if anything goes wrong here, bad things happen + + my $tmpdir = $ENV{TMPDIR}; + if (not defined $tmpdir or $tmpdir !~ /\//) { + $tmpdir = '/tmp'; + } + open (MKTEMP, "mktemp $tmpdir/fink.XXXXXXXX |") or die "can't run mktemp in +$tmpdir: $!"; + my $tempfile = <MKTEMP>; + chomp($tempfile); + close(MKTEMP) or die "an unexpected error occurred closing mktemp: $!"; + if (defined $tempfile and $tempfile ne "") { + return $tempfile; + } else { + return; + } } ### do % substitutions on a string