summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-01-22 14:03:46 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-01-22 14:03:46 +0000
commit2d0b2d35e6bc0da4d08acc0020c0f725c1a8bf51 (patch)
tree24511c57f3eaec3a5832913072227752ab09522d
parent851909ddefe26609b0722bde0c9130f34a0a3c4c (diff)
downloaddrakx-2d0b2d35e6bc0da4d08acc0020c0f725c1a8bf51.tar
drakx-2d0b2d35e6bc0da4d08acc0020c0f725c1a8bf51.tar.gz
drakx-2d0b2d35e6bc0da4d08acc0020c0f725c1a8bf51.tar.bz2
drakx-2d0b2d35e6bc0da4d08acc0020c0f725c1a8bf51.tar.xz
drakx-2d0b2d35e6bc0da4d08acc0020c0f725c1a8bf51.zip
better messages for the minimal installs
-rw-r--r--perl-install/install_steps_interactive.pm30
1 files changed, 17 insertions, 13 deletions
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 912493870..d0cea804a 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -659,25 +659,29 @@ sub chooseGroups {
#- if no group have been chosen, ask for using base system only, or no X, or normal.
unless ($o->{isUpgrade} || grep { $val{$_} } keys %val) {
- my $type;
+ my $type =
+ $o->{compssUsersChoice}{X} ? 2 :
+ grep { $_ } values %{$o->{compssUsersChoice}} ? 1 : 0;
- #- search for what is currently selected.
- foreach (keys %{$o->{compssUsersChoice}}) {
- $o->{compssUsersChoice}{$_} and $type = __("No X");
- }
- $o->{compssUsersChoice}{X} and $type = __("With X");
- $type ||= __("Base system only");
+ my @choices = (
+ _("Truly minimal install (especially no urpmi)"),
+ _("Base system (no X, including urpmi)"),
+ _("With X"),
+ );
#- ask user for its choice.
- $type = $o->ask_from_list_(_("Type of install"), _("You do not have selected any group of packages
-Please choose the minimal installation you want"), [ __("Base system only"), __("No X"), __("With X"), ], $type) or return &chooseGroups;
+ $type = $o->ask_from_listf(_("Type of install"),
+ _("You do not have selected any group of packages
+Please choose the minimal installation you want"),
+ sub { $choices[$_[0]] }, [ 0 .. $#choices ], $type);
+ defined $type or return &chooseGroups;
#- reselect according to user selection.
- if ($type eq __("Base system only")) {
- $o->{compssUsersChoice}{$_} = 0 foreach keys %{$o->{compssUsersChoice}};
- } else {
+ if ($type) {
install_any::setDefaultPackages($o, 'clean');
- $o->{compssUsersChoice}{X} = $type eq 'With X';
+ $o->{compssUsersChoice}{X} = $type == 2;
+ } else {
+ $o->{compssUsersChoice}{$_} = 0 foreach keys %{$o->{compssUsersChoice}};
}
install_any::unselectMostPackages($o);
}
1, gtksignal_connect(new Gtk::Button(_("Restore Selected\nCatalog Entry")), clicked => sub {
if ($cat_entry ne '') {
- my $media_check = restore_catalog_entry($cat_entry, '');
+ my $media_check = restore_catalog_entry($cat_entry, ());
if ($media_check) {
${$central_widget}->destroy();
- button_box_restore();
- restore_do();
+# button_box_restore();
+ interactive_mode_box();
}
}
}),
@@ -3395,8 +3399,8 @@ sub catalog_restore {
my $media_check = restore_catalog_entry($cat_entry, @passed_files);
if ($media_check) {
${$central_widget}->destroy();
- button_box_restore();
- restore_do();
+# button_box_restore();
+ interactive_mode_box();
}
}
}),
@@ -3415,8 +3419,10 @@ sub catalog_restore {
);
$restore_path_entry->set_text($restore_path);
+ gtksignal_connect($restore_path_entry, changed => sub { $restore_path = $restore_path_entry->get_text() });
+
button_box_restore();
- fonction_env(\$catalog_box, \&catalog_restore, \&restore_find_media_box, "restore", \&restore_do);
+ fonction_env(\$catalog_box, \&catalog_restore, \&restore_find_media_box, "restore", \&catalog_restore);
$central_widget = \$catalog_box;
$up_box->show_all();
}
@@ -3434,7 +3440,8 @@ sub restore_catalog_entry {
my ($cat_entry, @restore_files) = @_;
my $username;
my $userpass = $passwd_user;
-
+ my $restore_result = 1;
+
my @line_data = split(':', $cat_entry);
my $backup_time = $line_data[0];
@@ -3453,6 +3460,9 @@ sub restore_catalog_entry {
$username = $login_user;
}
+ #- create a restore work directory if we don't have one
+ -d "$cfg_dir/restores" or mkdir_p "$cfg_dir/restores";
+
#- can be a device name or a path
my $dev_path = $line_data[3];
@@ -3465,9 +3475,10 @@ sub restore_catalog_entry {
show_warning("f", _("Backup files not found at %s.", $dev_path));
return(0);
} else {
- #- now we can get busy - FIXME
-
-# return(1);
+ my $save_path_org = $save_path;
+ $save_path = $dev_path;
+ $restore_result = restore_hd_or_cd($cat_entry, $dev_path, @restore_files);
+ $save_path = $save_path_org;
}
}
@@ -3479,9 +3490,7 @@ sub restore_catalog_entry {
show_warning("f", _("Not the correct CD label. Disk is labelled %s.", $vol_name));
return(0);
} else {
- #- now we can get busy - FIXME
-
-# return(1);
+ $restore_result = restore_hd_or_cd($cat_entry, '/mnt/cdrom', @restore_files);
}
}
@@ -3493,10 +3502,7 @@ sub restore_catalog_entry {
show_warning("f", _("Not the correct tape label. Tape is labelled %s.", $vol_name));
return(0);
} else {
- #- now we can get busy - FIXME
- #- calculate the record offset
-
-# return(1);
+ $restore_result = restore_tape($cat_entry, $dev_path, @restore_files);
}
}
@@ -3504,13 +3510,13 @@ sub restore_catalog_entry {
#- show the user what we know of the connection from the catalog
#- and the config file, let them override if necessary
- #- the various protocals are going to have different requirements
+ #- the various protocols are going to have different requirements
#- webdav - it should already be in sitecopyrc - compare it?
#- ssh - the only method we have enabled at the moment is with keys
#- - no passwd needed
#- - if we use expect, it is needed
#- - if we use drackbackup keys, then a different ssh call is needed
- #- rsync - uses a config file - need to check again
+ #- rsync - uses a config file with username - rsync.user
#- ftp needs all parameters entered
$in->ask_from(_("Restore Via Network"), _("Restore Via Network Protocol: %s", $media),
@@ -3540,15 +3546,210 @@ sub restore_catalog_entry {
return(0);
}
- #- now to try restoring - FIXME
-
-# return(1)
+ $restore_result = restore_ftp($cat_entry, $vol_host, $dev_path, $username, $userpass, @restore_files) if ($media eq 'ftp');
+ $restore_result = restore_rsync_ssh_webdav($cat_entry, $vol_host, $dev_path, $username, $userpass, $media, @restore_files)
+ if (($media eq 'rsync') || ($media eq 'ssh') || ($media eq 'webdav'));
+ }
+
+ # cleanup our restore dir - unlink fails here?
+ system("rm -f $cfg_dir/restores/*");
+
+ if (!$restore_result) {
+ show_warning("i", __("Files Restored..."));
+ return(0);
+ } else {
+ show_warning("f", __("Restore Failed..."));
+ return(1);
+ }
+
+}
+
+sub restore_hd_or_cd {
+ my ($cat_entry, $tarfile_dir, @restore_files) = @_;
+ my $indv_files = @restore_files;
+
+ my $wild_card = catalog_to_wildcard($cat_entry);
+
+ if ($indv_files eq 0) {
+ #- full catalog specified
+ foreach (wildcard_to_tarfile($wild_card)) {
+ system("tar -C $restore_path -xzf $tarfile_dir/$_");
+ }
+ } else {
+ #- individual files - pull from appropriate catalog
+ foreach (@restore_files) {
+ my $tarfile = file_to_tarfile($_, $wild_card);
+ $_ = substr($_, 1);
+ system("tar -C $restore_path -xzf $tarfile_dir/$tarfile $_");
+ }
+ }
+ return(0);
+}
+
+sub restore_tape {
+ my ($cat_entry, $dev_path, @restore_files) = @_;
+ my $indv_files = @restore_files;
+
+ my $wild_card = catalog_to_wildcard($cat_entry);
+ $dev_path =~ s/\/st/\/nst/;
+
+ if ($indv_files eq 0) {
+ #- full catalog specified
+ foreach (wildcard_to_tarfile($wild_card)) {
+ my $offset = find_tape_offset($cat_entry);
+ system("mt -f $dev_path rewind");
+ system("mt -f $dev_path fsf $offset");
+ system("tar -C cfg_dir/restores -xf $dev_path");
+ if (-e "$cfg_dir/restores/$_") {
+ system("tar -C $restore_path -xzf $cfg_dir/restores/$_");
+ } else {
+ return(1);
+ }
+ }
+ } else {
+ #- individual files - pull from appropriate catalog
+ foreach (@restore_files) {
+ my $tarfile = file_to_tarfile($_, $wild_card);
+ $_ = substr($_, 1);
+ if (!-e "$cfg_dir/restores/$tarfile") {
+ my $offset = find_tape_offset($cat_entry);
+ system("mt -f $dev_path rewind");
+ system("mt -f $dev_path fsf $offset");
+ system("tar -C cfg_dir/restores -xf $dev_path");
+ }
+ if (-e "$cfg_dir/restores/$tarfile") {
+ system("tar -C $restore_path -xzf $cfg_dir/restores/$tarfile $_");
+ } else {
+ return(1);
+ }
+ }
+ }
+ return(0);
+}
+
+sub restore_ftp {
+ use Net::FTP;
+ my $ftp;
+ my ($cat_entry, $hostname, $hostpath, $username, $userpass, @restore_files) = @_;
+ my $indv_files = @restore_files;
+
+ $DEBUG and print "file list to retrieve : $cat_entry\n ";
+ if ($DEBUG && $interactive) { $ftp = Net::FTP->new($hostname, Debug => 1) or return(1) }
+ elsif ($interactive) { $ftp = Net::FTP->new($hostname, Debug => 0) or return(1) }
+ else { $ftp = Net::FTP->new($hostname, Debug => 0) or return(1) }
+ $ftp->login($username, $userpass);
+ $ftp->cwd($hostpath);
+
+ my $wild_card = catalog_to_wildcard($cat_entry);
+
+ if ($indv_files eq 0) {
+ #- full catalog specified
+ foreach (wildard_to_tarfile($wild_card)) {
+ $ftp->get($_, "$cfg_dir/restores/$_");
+ system("tar -C $restore_path -xzf $cfg_dir/restores/$_");
+ }
+ } else {
+ #- individual files - pull from appropriate catalog
+ foreach (@restore_files) {
+ my $tarfile = file_to_tarfile($_, $wild_card);
+ $_ = substr($_, 1);
+ if (!-e "$cfg_dir/restores/$tarfile") {
+ $ftp->get($tarfile, "$cfg_dir/restores/$tarfile");
+ }
+ system("tar -C $restore_path -xzf $cfg_dir/restores/$tarfile $_");
+ }
}
+ $ftp->quit;
+ return(0);
+}
-# just head back for now
-show_warning("i", __("Under Development..."));
-return(0);
+sub restore_rsync_ssh_webdav {
+ my ($cat_entry, $hostname, $hostpath, $username, $userpass, $mode, @restore_files) = @_;
+ my $indv_files = @restore_files;
+
+ my $wild_card = catalog_to_wildcard($cat_entry);
+
+ if ($indv_files eq 0) {
+ #- full catalog specified
+ foreach (wildcard_to_tarfile($wild_card)) {
+ if ($mode eq 'ssh') {
+ system("scp $username\@$hostname:$hostpath/$_ $cfg_dir/restores/");
+ } elsif ($mode eq 'rsync') {
+ system("rsync --password-file=$cfg_dir/rsync.user $username\@$hostname\:\:$hostpath/$_ $cfg_dir/restores/");
+ } else {
+ system("wget http://$hostname/$hostpath/$_ -P $cfg_dir/restores/");
+ }
+ if (-e "$cfg_dir/restores/$_") {
+ system("tar -C $restore_path -xzf $cfg_dir/restores/$_");
+ } else {
+ return(1);
+ }
+ }
+ } else {
+ #- individual files - pull from appropriate catalog
+ foreach (@restore_files) {
+ my $tarfile = file_to_tarfile($_, $wild_card);
+ $_ = substr($_, 1);
+ if (!-e "$cfg_dir/restores/$tarfile") {
+ if ($mode eq 'ssh') {
+ system("scp $username\@$hostname:$hostpath/$tarfile $cfg_dir/restores/");
+ } elsif ($mode eq 'rsync') {
+ system("rsync --password-file=$cfg_dir/rsync.user $username\@$hostname\:\:$hostpath/$tarfile $cfg_dir/restores/");
+ } else {
+ system("wget http://$hostname/$hostpath/$tarfile -P $cfg_dir/restores/");
+ }
+ }
+ if (-e "$cfg_dir/restores/$tarfile") {
+ system("tar -C $restore_path -xzf $cfg_dir/restores/$tarfile $_");
+ } else {
+ return(1);
+ }
+ }
+ }
+ return(0);
+}
+
+sub catalog_to_wildcard {
+ my ($cat_entry) = @_;
+ my @line_data = split(':', $cat_entry);
+ my $wildcard = $line_data[0];
+ $wildcard;
+}
+sub wildcard_to_tarfile {
+ my ($wildcard) = @_;
+ my $tarfile = basename(glob("$save_path/*$wildcard.txt"));
+ $tarfile =~ s/txt/$tar_ext/;
+ $tarfile =~ s/list/backup/;
+ $tarfile;
+}
+
+sub file_to_tarfile {
+ my ($restore_file, $wildcard) = @_;
+ my $tarfile = `grep -l $restore_file $save_path/*$wildcard.txt`;
+ chop $tarfile;
+ $tarfile = basename($tarfile);
+ $tarfile =~ s/txt/$tar_ext/;
+ $tarfile =~ s/list/backup/;
+ $tarfile;
+}
+
+sub find_tape_offset {
+ my ($cat_entry) = @_;
+ my @line_data = split(':', $cat_entry);
+ my $label = $line_data[2];
+ my @catalog = cat_("$cfg_dir/drakbackup_catalog");
+ # always off by 1 for tape label.
+ my $offset = 1;
+ foreach (@catalog) {
+ if (instr($_, $label)) {
+ if (!instr($_, $cat_entry)) {
+ $offset++;
+ } else {
+ return($offset);
+ }
+ }
+ }
}
sub restore_box {