From 5c68828fda69e5768cdbf352e9523e4201e7d102 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sat, 23 Oct 2004 09:43:17 +0000 Subject: system() method that stores command normal output so that we can show it at end of pkg install/deinstall... use for @exec/INSTALL stuff. --- usr.sbin/pkg_add/OpenBSD/Error.pm | 18 +++++++++++++++++- usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 6 +++--- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'usr.sbin/pkg_add') diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm index 22449344d3c..49fb8d86025 100644 --- a/usr.sbin/pkg_add/OpenBSD/Error.pm +++ b/usr.sbin/pkg_add/OpenBSD/Error.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Error.pm,v 1.4 2004/10/23 09:27:48 espie Exp $ +# $OpenBSD: Error.pm,v 1.5 2004/10/23 09:43:16 espie Exp $ # # Copyright (c) 2004 Marc Espie # @@ -113,4 +113,20 @@ sub delayed_output } } +sub system +{ + my $state = shift; + if (open(my $grab, "-|", @_)) { + local $_; + while (<$grab>) { + $state->print($_); + } + if (!close $grab) { + $state->print("system(", join(", ", @_), ") failed: $! $?\n"); + } + return $?; + } else { + $state->print("system(", join(", ", @_), ") was not run: $! $?\n"); + } +} 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 7d967711c95..b642f8d3cd9 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.58 2004/10/20 11:38:57 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.59 2004/10/23 09:43:16 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie # @@ -939,7 +939,7 @@ sub run main::ensure_ldconfig($state); print $self->keyword(), " ", $self->{expanded}, "\n" if $state->{beverbose}; - System('/bin/sh', '-c', $self->{expanded}) unless $state->{not}; + $state->system('/bin/sh', '-c', $self->{expanded}) unless $state->{not}; } package OpenBSD::PackingElement::Exec; @@ -1135,7 +1135,7 @@ sub run print $self->beautify(), " script: $dir$name $pkgname ", join(' ', @args), "\n" if $state->{beverbose}; return if $not; chmod 0755, $dir.$name; - return if System($dir.$name, $pkgname, @args) == 0; + return if $state->system($dir.$name, $pkgname, @args) == 0; Fatal $self->beautify()." script borked"; } -- cgit v1.2.3