aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtransfugdrake143
1 files changed, 86 insertions, 57 deletions
diff --git a/transfugdrake b/transfugdrake
index ce0caa7..d7aa546 100755
--- a/transfugdrake
+++ b/transfugdrake
@@ -27,23 +27,27 @@
# - Add Address Book feature
# 01/11/30 - cbelisle@mandrakesoft.com
# - 0.1-3mdk
+# 01/12/18 - cbelisle@mandrakesoft.com
+# - Move instructions in functions (read better).
+# - Add the partition chooser page.
use lib q(/usr/lib/libDrakX);
+## Includes
#use common qw(:common :file :functional :system);
use interactive;
use standalone;
#use log;
use my_gtk qw(:helpers :wrappers :ask);
+use fsedit qw(:read_partitions);
#use netconnect;
use detect_devices;
use File::NCopy;
-my $i = 0;
-my $found = 0;
-my @win = "";
-my $version = 0.1;
-my $file;
+# Variables
+my $version = 0.1; # Version number
+my $debug = 1; # Debug flag
+my $chosen_partition = ""; # Partition chosen by the user
$::isInstall and die "Not supported during install.\n";
@@ -58,34 +62,9 @@ $::Wizard_pix_up = "wiz_drakgw.png";
$::Wizard_title = _("Transfugdrake");
$::direct = /-direct/;
-# Debug flag
-my $debug = 1;
-
# Application initialization
my $in = interactive::vnew(su);
-# Get folder listing in /mnt
-my @mnt_dir_folder = split("\n", `ls /mnt/`);
-
-# Look in the array if we have a windows partition
-my $folders_count = 1;
-while(@mnt_dir_folder[$folders_count] ne "") {
- if(@mnt_dir_folder[$folders_count] =~ /win/) {
- push(@win,"/mnt/".@mnt_dir_folder[$folders_count]);
- $found = 1;
- if($debug) { print "- Found windows partition at /mnt/@mnt_dir_folder[$folders_count]\n"; }
- }
- $folders_count++;
-}
-
-# If nothing is found, print an error and exit.
-if(!$found) {
- print "- No windows partitions\n";
- $in->ask_warn(_("Can't find windows!"),
- _("Sorry, I can't find windows. Maybe it's not installed, or your windows partition is not mounted on Mandrake."));
- quit_global($in);
-}
-
#- **********************************
#- * 0th step: verify if we are already set up
begin:
@@ -107,47 +86,61 @@ email and address books from Microsoft Windows to Mandrake Linux."), 1) or quit_
#- **********************************
#- * 2nd step: win files
step_2:
-# TODO Get windows listing in a listbox and home listing in another listbox (gftp like)
+# TODO Get partition listing in a listbox and home listing in another listbox (gftp like)
+
+# Detect windows partitions
+my @mnt_win_folder = detect_partition();
-# Automatic configuration
-#if($debug) { print "- Beginning automatic configuration\n"; }
-#$wait_configuring = $in->wait_message(_("Configuring..."),
-# _("Finding all documents on your Windows partition. Can take several minutes."));
+# If we have only one partition, goto the copy page
+if(@mnt_win_folder[1] eq "") {
+ print "Prooout: @mnt_win_folder[1]\n";
+ goto step_3;
+}
+# Create radio buttons to give the user the choice of the partition.
+my $chosen_partition = $in->ask_from_list_(_("Select your windows partition"),
+ _("Please specify your windows partition from the following list"),
+ [ @mnt_win_folder ],
+ @mnt_win_folder[0]) or
+ quit_global($in, 0);
+
+#- **********************************
+#- * 3rd step: win files
+step_3:
if($debug) { print "- Ready to copy all the documents, waiting for user response\n"; }
-if(-e "@win[1]/My\ Documents") {
- print "-- @win[1]/My\ Documents found\n";
+if(-e "$chosen_partition/My\ Documents") {
+ print "-- $chosen_partition/My\ Documents found\n";
$::direct or $in->ask_okcancel(_("Transfugdrake"),
- _("Do you want to copy all the content of\n @win[1]/My Documents to $ENV{HOME}/win_backup ?"), 1) or goto step_3;
+ _("Do you want to copy all the content of\n $chosen_partition/My Documents to $ENV{HOME}/win_backup ?"), 1) or goto step_3;
$wait_configuring = $in->wait_message(_("Copying files..."),
- _("Copying all files from @win[1]/My Documents to $ENV{HOME}/win_backup."));
+ _("Copying all files from $chosen_partition/My Documents to $ENV{HOME}/win_backup."));
mkdir("$ENV{HOME}/win_backup");
$file = File::Ncopy->new(recursive => 1);
- $file->copy("@win[1]/My\ Documents", "$ENV{HOME}/win_backup");
+ $file->copy("$chosen_partition/My\ Documents", "$ENV{HOME}/win_backup");
undef $wait_configuring;
}
-elsif(-e "@win[1]/Mes\ Documents") {
- print "-- @win[1]/Mes\ Documents found\n";
+elsif(-e "$chosen_partition/Mes\ Documents") {
+ print "-- $chosen_partition/Mes\ Documents found\n";
$::direct or $in->ask_okcancel(_("Transfugdrake"),
- _("Do you want to copy all the content of\n @win[1]/My Documents to $ENV{HOME}/win_backup ?"), 1) or goto step_3;
+ _("Do you want to copy all the content of\n $chosen_partition/My Documents to $ENV{HOME}/win_backup ?"), 1) or goto step_3;
$wait_configuring = $in->wait_message(_("Copying files..."),
- _("Copying all files from @win[1]/Mes Documents to $ENV{HOME}/win_backup."));
+ _("Copying all files from $chosen_partition/Mes Documents to $ENV{HOME}/win_backup."));
mkdir("$ENV{HOME}/win_backup");
$file = File::Ncopy->new(recursive => 1);
- $file->copy("@win[1]/Mes\ Documents", "$ENV{HOME}/win_backup");
+ $file->copy("$chosen_partition/Mes\ Documents", "$ENV{HOME}/win_backup");
undef $wait_configuring;
}
-elsif(-e "@win[1]/Documents\ and\ Settings") {
- print "-- @win[1]/Documents and Settings found\n";
- my @doc_listing = split("\n", `ls @win[1]/Documents\\ and\\ Settings/`);
+elsif(-e "$chosen_partition/Documents\ and\ Settings") {
+ print "-- $chosen_partition/Documents and Settings found\n";
+ my @doc_listing = split("\n", `ls $chosen_partition/Documents\\ and\\ Settings/`);
$::direct or $in->ask_okcancel(_("Transfugdrake"),
- _("Do you want to copy all the content of\n @win[1]/Documents and Settings to $ENV{HOME} ?"), 1) or goto step_3;
+ _("Do you want to copy all the content of\n $chosen_partition/Documents and Settings to $ENV{HOME} ?"), 1) or goto step_3;
$wait_configuring = $in->wait_message(_("Copying files..."),
- _("Copying all files from @win[1]/Documents and Settings to $ENV{HOME}."));
+ _("Copying all files from $chosen_partition/Documents and Settings to $ENV{HOME}."));
mkdir("$ENV{HOME}/win_backup");
$file = File::NCopy->new(recursive => 1);
- $file->copy("@win[1]/Documents\\ and\\ Settings", "$ENV{HOME}/win_backup");
+ $file->copy("$chosen_partition/Documents\\ and\\ Settings", "$ENV{HOME}/win_backup");
# $folders_count = 1;
# while(@doc_listing[$folders_count] ne "") {
@@ -166,8 +159,8 @@ else {
}
#- *******************************
-#- * 3rd step: mail from windows
-step_3:
+#- * 4th step: mail from windows
+step_4:
$::direct or $in->ask_okcancel(_("Transfug"),
_("We will bring back your Outlook Mailboxes to a standard unix mbox\n
@@ -193,13 +186,49 @@ if (-e $oe5onwin98) {
}
#- *******************************
-#- * 4th step: address book from windows
-step_4:
+#- * 5th step: address book from windows
+step_5:
$::direct or $in->ask_okcancel(_("Transfug"),
_("We will migrate your windows address book to Mandrake (not implemented yet)"), 1) or quit_global($in, 0);
#- *******************************
-#- * 5th step: finish
-step_5:
+#- * 6th step: finish
+step_6:
$::direct or $in->ask_okcancel(_("Transfugdrake"),
_("The migration of all of your Windows data is finished."), 1) or quit_global($in, 0);
+
+#- *******************************
+#- FUNCTIONS
+#- *******************************
+sub detect_partition {
+ # Return array
+ my @win;
+
+ # TODO TODO TODO TODO TODO TODO TODO TODO
+ # - Get partitions directly by devfs
+ # - Print partition type beside the partition
+ # - Mount the partition the user want.
+
+ # Get folder listing in /mnt
+ my @mnt_dir_folder = split("\n", `ls /mnt/`);
+
+ # Look in the array if we have a windows partition
+ my $folders_count = 1;
+ while(@mnt_dir_folder[$folders_count] ne "") {
+ push(@win,"/mnt/".@mnt_dir_folder[$folders_count]);
+ $found = 1;
+ if($debug) { print "- Found windows partition at /mnt/@mnt_dir_folder[$folders_count]\n"; }
+ $folders_count++;
+ }
+
+ # If nothing is found, print an error and exit.
+ if(!$found) {
+ print "- No windows partitions\n";
+ $in->ask_warn(_("Can't find windows!"),
+ _("Sorry, I can't find windows. Maybe it's not installed, or your windows partition is not mounted on Mandrake."));
+ quit_global($in);
+ }
+ else {
+ return @win;
+ }
+}