summaryrefslogtreecommitdiffstats
path: root/perl-install/install/commands.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/install/commands.pm')
-rw-r--r--perl-install/install/commands.pm45
1 files changed, 19 insertions, 26 deletions
diff --git a/perl-install/install/commands.pm b/perl-install/install/commands.pm
index 4f19a1a2d..79f49b980 100644
--- a/perl-install/install/commands.pm
+++ b/perl-install/install/commands.pm
@@ -1,11 +1,11 @@
-package install::commands; # $Id$
+package install::commands;
#-########################################################################
#- This file implement many common shell commands:
-#- true, false, cat, which, dirname, basename, rmdir, lsmod, grep, tr,
+#- true, false, cat, which, dirname, basename, rmdir, grep, tr,
#- mount, mkdir, mknod, ln, rm, chmod, chown, swapon,
#- swapoff, ls, cp, ps, dd, head, tail, strings, hexdump, more,
-#- modprobe, route, df, kill, lspci, lssbus, dmesg, sort, du,
+#- route, df, kill, lspci, lssbus, dmesg, sort, du,
#-########################################################################
use diagnostics;
@@ -37,8 +37,7 @@ sub false() { exit 1 }
sub cat { @ARGV = @_; print while <> }
sub dirname_ { print dirname(@_), "\n" }
sub basename_ { print basename(@_), "\n" }
-sub rmdir_ { foreach (@_) { rmdir $_ or die "rmdir: can not remove $_\n" } }
-sub lsmod() { print "Module Size Used by\n"; cat("/proc/modules") }
+sub rmdir_ { foreach (@_) { rmdir $_ or die "rmdir: cannot remove $_\n" } }
sub which {
ARG: foreach (@_) { foreach my $c (split /:/, $ENV{PATH}) { -x "$c/$_" and print("$c/$_\n"), next ARG } }
}
@@ -97,7 +96,7 @@ sub rm {
if (!-l $_ && -d $_) {
$rec or die "$_ is a directory\n";
&$rm(glob_($_));
- rmdir $_ or die "can not remove directory $_: $!\n";
+ rmdir $_ or die "cannot remove directory $_: $!\n";
} else { unlink $_ or die "rm of $_ failed: $!\n" }
}
};
@@ -160,7 +159,7 @@ sub ls {
@_ == 1 && -d $_[0] and @_ = glob_($_[0]);
foreach (sort @_) {
if ($l) {
- my @s = lstat or warn("can not stat file $_\n"), next;
+ my @s = lstat or warn("cannot stat file $_\n"), next;
formline(
"@<<<<<<<<< @<<<<<<< @<<<<<<< @>>>>>>>> @>>>>>>>>>>>>>>> @*\n",
rights($s[2]), getpwuid $s[4] || $s[4], getgrgid $s[5] || $s[5],
@@ -208,21 +207,21 @@ sub dd {
my $u = "usage: dd [-h] [-p] [if=<file>] [of=<file>] [bs=<number>] [count=<number>]\n";
my ($help, $percent) = getopts(\@_, qw(hp));
die $u if $help;
- my %h = (if => *STDIN, of => *STDOUT, bs => 512, count => undef);
+ my %h = (if => \*STDIN, of => \*STDOUT, bs => 512, count => undef);
foreach (@_) {
/(.*?)=(.*)/ && exists $h{$1} or die $u;
$h{$1} = $2;
}
local (*IF, *OF); my ($tmp, $nb, $read);
- ref($h{if}) eq 'GLOB' ? (*IF = $h{if}) : sysopen(IF, $h{if}, 0) || die "error: can not open file $h{if}\n";
- ref($h{of}) eq 'GLOB' ? (*OF = $h{of}) : sysopen(OF, $h{of}, c::O_CREAT()|c::O_WRONLY()) || die "error: can not open file $h{of}\n";
+ ref($h{if}) eq 'GLOB' ? (*IF = $h{if}) : sysopen(IF, $h{if}, 0) || die "error: cannot open file $h{if}\n";
+ ref($h{of}) eq 'GLOB' ? (*OF = $h{of}) : sysopen(OF, $h{of}, c::O_CREAT()|c::O_WRONLY()) || die "error: cannot open file $h{of}\n";
$h{bs} = removeXiBSuffix($h{bs});
for ($nb = 0; !$h{count} || $nb < $h{count}; $nb++) {
printf "\r%02.1d%%", 100 * $nb / $h{count} if $h{count} && $percent;
- $read = sysread(IF, $tmp, $h{bs}) or ($h{count} ? die "error: can not read block $nb\n" : last);
- syswrite(OF, $tmp) or die "error: can not write block $nb\n";
+ $read = sysread(IF, $tmp, $h{bs}) or ($h{count} ? die "error: cannot read block $nb\n" : last);
+ syswrite(OF, $tmp) or die "error: cannot write block $nb\n";
$read < $h{bs} and $read = 1, last;
}
print STDERR "\r$nb+$read records in\n";
@@ -233,7 +232,7 @@ sub head_tail {
my ($h, $n) = getopts(\@_, qw(hn));
$h || @_ < to_bool($n) and die "usage: $0 [-h] [-n lines] [<file>]\n";
$n = $n ? shift : 10;
- my $fh = @_ ? common::open_file($_[0]) || die "error: can not open file $_[0]\n" : *STDIN;
+ my $fh = @_ ? common::open_file($_[0]) || die "error: cannot open file $_[0]\n" : *STDIN;
if ($0 eq 'head') {
local $_;
@@ -276,9 +275,9 @@ sub hexdump {
sub more {
@ARGV = @_;
require devices;
- my $tty = devices::make('tty');
+ my $tty = '/dev/tty';
my $n = 0;
- open(my $IN, $tty) or die "can not open $tty\n";
+ open(my $IN, $tty) or die "cannot open $tty\n";
local $_;
while (<>) {
if (++$n == 25) {
@@ -290,15 +289,6 @@ sub more {
}
}
-sub modprobe {
- my ($h) = getopts(\@_, qw(h));
- $h || @_ == 0 and die "usage: modprobe <module> [options]\n";
- my $name = shift;
- require modules;
- list_modules::load_default_moddeps();
- modules::load_with_options([ $name ], { $name => join(' ', @_) });
-}
-
sub route {
@_ == 0 or die "usage: route\nsorry, no modification handled\n";
my ($titles, @l) = cat_("/proc/net/route");
@@ -373,7 +363,7 @@ sub dmesg() { print cat_("/tmp/syslog") }
sub sort {
my ($n, $h) = getopts(\@_, qw(nh));
$h and die "usage: sort [-n] [<file>]\n";
- my $fh = @_ ? common::open_file($_[0]) || die "error: can not open file $_[0]\n" : *STDIN;
+ my $fh = @_ ? common::open_file($_[0]) || die "error: cannot open file $_[0]\n" : *STDIN;
if ($n) {
print(sort { $a <=> $b } <$fh>);
} else {
@@ -411,8 +401,11 @@ sub bug {
my $in = interactive::stdio->new;
require install::any;
+ my @devs = install::any::removable_media__early_in_install();
+ @devs or die "You need to plug a removable medium (USB key, floppy, ...)\n";
+
$part = $in->ask_from_listf('', "Which device?", \&partition_table::description,
- [ install::any::removable_media__early_in_install() ] ) or return;
+ \@devs) or return;
}
warn "putting file report.bug on $part->{device}\n";