summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-21 16:10:45 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-21 16:10:45 +0000
commit190ab2c006dd503413775aabd6af940a72df8239 (patch)
treeed9c8e5058cc5b63fb5c99f9e1beb4517de02e80 /urpm
parentc17798ddc4bf5740bbc31fd6d0e281c18f62dd26 (diff)
downloadurpmi-190ab2c006dd503413775aabd6af940a72df8239.tar
urpmi-190ab2c006dd503413775aabd6af940a72df8239.tar.gz
urpmi-190ab2c006dd503413775aabd6af940a72df8239.tar.bz2
urpmi-190ab2c006dd503413775aabd6af940a72df8239.tar.xz
urpmi-190ab2c006dd503413775aabd6af940a72df8239.zip
move open_safe, opendir_safe and syserror to urpm::sys
Diffstat (limited to 'urpm')
-rw-r--r--urpm/bug_report.pm2
-rw-r--r--urpm/sys.pm19
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__