summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-02-15 16:53:42 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-02-15 16:53:42 +0000
commitab8ca4ad4729ba71c7bbade59b75f051e74b009d (patch)
treeb7b74294608b12a386181798811a9f27cb21ef77
parent770daeb5d2b473d50d67b4e9423c2e914aed718b (diff)
downloaddrakx-ab8ca4ad4729ba71c7bbade59b75f051e74b009d.tar
drakx-ab8ca4ad4729ba71c7bbade59b75f051e74b009d.tar.gz
drakx-ab8ca4ad4729ba71c7bbade59b75f051e74b009d.tar.bz2
drakx-ab8ca4ad4729ba71c7bbade59b75f051e74b009d.tar.xz
drakx-ab8ca4ad4729ba71c7bbade59b75f051e74b009d.zip
replace load/save from floppy with using media_browser()
-rw-r--r--perl-install/diskdrake/interactive.pm22
-rw-r--r--perl-install/install_any.pm89
-rw-r--r--perl-install/install_steps_gtk.pm2
-rw-r--r--perl-install/install_steps_interactive.pm22
4 files changed, 102 insertions, 33 deletions
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index 41f0e0cc2..d58dd99e8 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -371,7 +371,14 @@ sub More {
sub ReadFromFile {
my ($in, $hd) = @_;
- my $file = $::isStandalone ? $in->ask_file(N("Select file")) : devices::make("fd0") or return;
+ my ($h, $file) = ('', '');
+ if ($::isStandalone) {
+ $file = $in->ask_file(N("Select file")) or return;
+ } else {
+ undef $h; #- help perl_checker
+ my $name = $hd->{device}; $name =~ s!/!_!g;
+ ($h, $file) = install_any::media_browser($in, '', "part_$name") or return;
+ }
eval {
catch_cdie { partition_table::load($hd, $file) }
@@ -390,11 +397,14 @@ Still continue?"), 0);
sub SaveInFile {
my ($in, $hd) = @_;
- my $file = $::isStandalone ?
- $in->ask_file(N("Select file")) :
- $in->ask_okcancel(N("Warning"),
-N("Insert a floppy in drive
-All data on this floppy will be lost"), 1) && devices::make(detect_devices::floppy()) or return;
+ my ($h, $file) = ('', '');
+ if ($::isStandalone) {
+ $file = $in->ask_file(N("Select file")) or return;
+ } else {
+ undef $h; #- help perl_checker
+ my $name = $hd->{device}; $name =~ s!/!_!g;
+ ($h, $file) = install_any::media_browser($in, 'save', "part_$name") or return;
+ }
eval { partition_table::save($hd, $file) };
if (my $err = $@) {
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 17f2f8f08..fa2143d29 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -1161,28 +1161,17 @@ sub getAndSaveAutoInstallFloppies {
sub g_default_packages {
- my ($o, $b_quiet) = @_;
-
- my $floppy = detect_devices::floppy();
-
- while (1) {
- $o->ask_okcancel('', N("Insert a FAT formatted floppy in drive %s", $floppy), 1) or return;
+ my ($o) = @_;
- eval { fs::mount(devices::make($floppy), "/floppy", "vfat", 0) };
- last if !$@;
- $o->ask_warn('', N("This floppy is not FAT formatted"));
- }
+ my ($_h, $file) = media_browser($o, 'save', 'package_list.pl') or return;
require Data::Dumper;
my $str = Data::Dumper->Dump([ { default_packages => pkgs::selected_leaves($o->{packages}) } ], ['$o']);
$str =~ s/ {8}/\t/g;
- output('/floppy/auto_inst.cfg',
+ output($file,
"# You should always check the syntax with 'perl -cw auto_inst.cfg.pl'\n",
"# before testing. To use it, boot with ``linux defcfg=floppy''\n",
$str, "\0");
- fs::umount("/floppy");
-
- $b_quiet or $o->ask_warn('', N("To use this saved packages selection, boot installation with ``linux defcfg=floppy''"));
}
sub loadO {
@@ -1495,6 +1484,78 @@ sub getHds {
1;
}
+my %media_browser;
+sub media_browser {
+ my ($in, $save, $o_suggested_name) = @_;
+
+ my %media_type2text = (
+ fd => N("Floppy"),
+ hd => N("Hard Disk"),
+ cdrom => N("CDROM"),
+ );
+ my @network_protocols = (N_("HTTP"), N_("FTP"), N_("NFS"));
+
+ my $to_text = sub {
+ my ($hd) = @_;
+ ($media_type2text{$hd->{media_type}} || $hd->{media_type}) . ': ' . partition_table::description($hd);
+ };
+
+ ask_media:
+ my $all_hds = fsedit::get_hds({}, $in);
+ fs::get_raw_hds('', $all_hds);
+
+ my @raw_hds = grep { !$save || $_->{media_type} ne 'cdrom' } @{$all_hds->{raw_hds}};
+ my @dev_and_text = group_by2(
+ (map { $_ => $to_text->($_) } @raw_hds),
+ (map {
+ my $hd = $to_text->($_);
+ map { $_ => join('\1', $hd, partition_table::description($_)) } grep { isTrueFS($_) || isOtherAvailableFS($_) } fs::get::hds_fstab($_);
+ } fs::get::hds($all_hds)),
+ if_(member($::o->{method}, qw(ftp http nfs)) || install_steps::hasNetwork($::o),
+ map { $_ => join('\1', N("Network"), translate($_)) } @network_protocols),
+ );
+
+ $in->ask_from_({
+ messages => N("Please choose a media"),
+ }, [
+ { val => \$media_browser{dev}, separator => '\1', list => [ map { $_->[1] } @dev_and_text ] },
+ ]) or return;
+
+ my $dev = (find { $_->[1] eq $media_browser{dev} } @dev_and_text)->[0];
+
+ if (member($dev, @network_protocols)) {
+ install_interactive::upNetwork($::o);
+ $in->ask_warn('', 'todo');
+ } else {
+ if (!$dev->{fs_type} || $dev->{fs_type} eq 'auto' || $dev->{fs_type} =~ /:/) {
+ if (my $p = fs::type::type_subpart_from_magic($dev)) {
+ add2hash($p, $dev);
+ $dev = $p;
+ } else {
+ $in->ask_warn(N("Error"), N("Bad media %s", partition_table::description($dev)));
+ goto ask_media;
+ }
+ }
+ my $file;
+ if (my $h = any::inspect($dev, $::prefix, $save)) {
+ while (1) {
+ $file = $in->ask_filename({ save => $save,
+ directory => $h->{dir},
+ if_($o_suggested_name, file => "$h->{dir}/$o_suggested_name"),
+ }) or last;
+ if (-e $file && $save) {
+ $in->ask_yesorno('', N("File already exists. Overwrite it?")) or next;
+ }
+ return $h, $file if $save || -e $file;
+ }
+ undef $h; #- help perl
+ } else {
+ $in->ask_warn(N("Error"), formatError($@));
+ }
+ goto ask_media;
+ }
+}
+
sub log_sizes {
my ($o) = @_;
my @df = MDK::Common::System::df($o->{prefix});
diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm
index 794f84beb..f3cc15d7a 100644
--- a/perl-install/install_steps_gtk.pm
+++ b/perl-install/install_steps_gtk.pm
@@ -387,7 +387,7 @@ sub choosePackagesTree {
ok => N("Install"),
cancel => N("Previous"),
icons => [ { icon => 'floppy',
- help => N("Load/Save on floppy"),
+ help => N("Load/Save selection"),
wait_message => N("Updating package selection"),
code => sub { $o->loadSavePackagesOnFloppy($packages); 1 },
},
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index a8f9bdbf5..92b7fd7e5 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -492,19 +492,17 @@ sub choosePackagesTree {
sub loadSavePackagesOnFloppy {
my ($o, $packages) = @_;
$o->ask_from('',
-N("Please choose load or save package selection on floppy.
-The format is the same as auto_install generated floppies."),
- [ { val => \ (my $choice), list => [ N_("Load from floppy"), N_("Save on floppy") ], format => \&translate, type => 'list' } ]) or return;
+N("Please choose load or save package selection.
+The format is the same as auto_install generated files."),
+ [ { val => \ (my $choice), list => [ N_("Load"), N_("Save") ], format => \&translate, type => 'list' } ]) or return;
- if ($choice eq 'Load from floppy') {
+ if ($choice eq 'Load') {
while (1) {
- my $w = $o->wait_message(N("Package selection"), N("Loading from floppy"));
- log::l("load package selection from floppy");
- my $O = eval { install_any::loadO(undef, 'floppy') };
+ log::l("load package selection");
+ my ($_h, $file) = install_any::media_browser($o, '', 'package_list.pl') or return;
+ my $O = eval { install_any::loadO(undef, $file) };
if ($@) {
- undef $w; #- close wait message.
- $o->ask_okcancel('', N("Insert a floppy containing package selection"))
- or return;
+ $o->ask_okcancel('', N("Bad file")) or return;
} else {
install_any::unselectMostPackages($o);
foreach (@{$O->{default_packages} || []}) {
@@ -515,8 +513,8 @@ The format is the same as auto_install generated floppies."),
}
}
} else {
- log::l("save package selection to floppy");
- install_any::g_default_packages($o, 'quiet');
+ log::l("save package selection");
+ install_any::g_default_packages($o);
}
}
sub chooseGroups {