summaryrefslogtreecommitdiffstats
path: root/lib/MGA/DrakISO/Utils.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MGA/DrakISO/Utils.pm')
-rw-r--r--lib/MGA/DrakISO/Utils.pm31
1 files changed, 12 insertions, 19 deletions
diff --git a/lib/MGA/DrakISO/Utils.pm b/lib/MGA/DrakISO/Utils.pm
index dcccf0b..f98e46d 100644
--- a/lib/MGA/DrakISO/Utils.pm
+++ b/lib/MGA/DrakISO/Utils.pm
@@ -28,7 +28,6 @@ use strict;
use MDK::Common;
use common;
use fs;
-use run_program;
use IPC::Open3;
use IO::Select;
@@ -52,27 +51,21 @@ sub glob__ {
}
sub run_ {
- my $options = ref $_[0] eq 'HASH' ? shift @_ : {};
my @cmd = @_;
- $options->{timeout} ||= 'never';
- if (arch() !~ /^arm/) {
- my $targetarch = delete $options->{targetarch};
- unshift @cmd, 'setarch', $targetarch if $targetarch;
- }
- print "running " . (exists $options->{root} && "(in chroot) ") . join(' ', @cmd) . "\n" if $::verbose > 1;
- run_program::raw($options, @cmd);
+
+ print "@cmd\n" if $::verbose > 2;
+ system(@cmd) == 0;
}
sub run_as_root {
- my (@cmd) = @_;
+ my @cmd = @_;
if (@cmd > 1) {
unshift @cmd, $sudo if $sudo;
} else {
@cmd[0] = join(' ', $sudo, @cmd[0]);
}
- print "@cmd\n" if $::verbose > 2;
- system(@cmd) == 0;
+ run_(@cmd);
}
sub run_in_root {
@@ -124,18 +117,18 @@ sub copy_or_link {
}
sub mount {
- my ($dst, $src, $o_options) = @_;
+ my ($dst, $src, @o_options) = @_;
mkdir_p($dst);
- system(join(' ', 'sudo mount', $o_options, $src, $dst)) == 0
+ run_as_root('mount', @o_options, $src, $dst)
or die "ERROR: failed to mount $src on $dst\n";
}
sub mount_system_fs {
my ($root) = @_;
- mount($root . '/dev', '/dev', '--bind -o ro');
- mount($root . '/proc', 'none', '-t proc');
- mount($root . '/sys', 'none', '-t sysfs');
- mount($root . '/run', 'none', '-t tmpfs');
+ mount($root . '/dev', '/dev', '--bind', '-o', 'ro');
+ mount($root . '/proc', 'none', '-t', 'proc');
+ mount($root . '/sys', 'none', '-t', 'sysfs');
+ mount($root . '/run', 'none', '-t', 'tmpfs');
}
sub umount_all_in_root {
@@ -144,7 +137,7 @@ sub umount_all_in_root {
my @mounts = grep { $_ =~ $root } split("\n", cat_('/proc/mounts'));
foreach (reverse(@mounts)) {
my @field = split(' ' , $_);
- system(join(' ', 'sudo umount', $field[1]));
+ run_as_root('umount', $field[1]);
}
}