diff options
Diffstat (limited to 'urpm')
-rw-r--r-- | urpm/bug_report.pm | 2 | ||||
-rw-r--r-- | urpm/sys.pm | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/urpm/bug_report.pm b/urpm/bug_report.pm index 858becfa..5740d64c 100644 --- a/urpm/bug_report.pm +++ b/urpm/bug_report.pm @@ -13,7 +13,7 @@ sub rpmdb_to_synthesis { local $SIG{QUIT} = $sig_handler; open my $rpmdb, "| " . ($ENV{LD_LOADER} || '') . " gzip -9 >'$synthesis'" - or $urpm->syserror("Can't fork", "gzip"); + or urpm::sys::syserror($urpm, "Can't fork", "gzip"); $db->traverse(sub { my ($p) = @_; #- this is not right but may be enough. diff --git a/urpm/sys.pm b/urpm/sys.pm index 313cf730..f6d33d78 100644 --- a/urpm/sys.pm +++ b/urpm/sys.pm @@ -232,6 +232,25 @@ sub unlock_urpmi_db { _unlock(\$LOCK_FILE); } +sub syserror { + my ($urpm, $msg, $info) = @_; + $urpm->{error}("$msg [$info] [$!]"); +} + +sub open_safe { + my ($urpm, $sense, $filename) = @_; + open my $f, $sense, $filename + or syserror($urpm, $sense eq '>' ? "Can't write file" : "Can't open file", $filename), return undef; + return $f; +} + +sub opendir_safe { + my ($urpm, $dirname) = @_; + opendir my $d, $dirname + or syserror($urpm, "Can't open directory", $dirname), return undef; + return $d; +} + 1; __END__ |