From baac6c847740b601059c3ffe114eaea290830e39 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 17 Feb 2006 16:14:18 +0000 Subject: enhance "bug" command to allow saving report.bug on usb key --- perl-install/commands.pm | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'perl-install') diff --git a/perl-install/commands.pm b/perl-install/commands.pm index ff27efa79..6719151f1 100644 --- a/perl-install/commands.pm +++ b/perl-install/commands.pm @@ -431,17 +431,39 @@ sub du { sub bug { my ($h) = getopts(\@_, "h"); - $h and die "usage: bug\nput file report.bug on fat formatted floppy\n"; + my ($o_part_device) = @_; + $h and die "usage: bug [device]\nput file report.bug on a floppy or usb key\n"; - require detect_devices; + require fsedit; require modules; - require fs; modules::load_dependencies("/modules/modules.dep"); - fs::mount::mount(devices::make(detect_devices::floppy()), '/fd0', 'vfat'); + + my $part; + if ($o_part_device) { + $part = { device => $o_part_device }; + } else { + require interactive::stdio; + my $in = interactive::stdio->new; + + eval { modules::load('usb-storage', 'sd_mod') } if detect_devices::usbStorage(); + my $all_hds = fsedit::get_hds({}, $in); + fs::get_raw_hds('', $all_hds); + + my @l1 = grep { detect_devices::isKeyUsb($_) } @{$all_hds->{hds}}; + my @l2 = grep { $_->{media_type} eq 'fd' || detect_devices::isKeyUsb($_) } @{$all_hds->{raw_hds}}; + my @l = (fs::get::hds_fstab(@l1), @l2); + + $part = $in->ask_from_listf('', "Which device?", \&partition_table::description, \@l) or return; + } + + warn "putting file report.bug on $part->{device}\n"; + my $fs_type = fs::type::fs_type_from_magic($part) or die "unknown fs type\n"; + + fs::mount::mount(devices::make($part->{device}), '/fd', $fs_type); require install_any; - output("/fd0/report.bug", install_any::report_bug()); - umount "/fd0"; + output('/fd/report.bug', install_any::report_bug()); + umount '/fd'; common::sync(); } -- cgit v1.2.1