summaryrefslogtreecommitdiffstats
path: root/rescue/restore_ms_boot
blob: 1f8cc2907b9e852833900e9e18749a3d268dd92f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/perl
#
# Guillaume Cottenceau, Pixel
#
# Copyright 2002-2005 Mandriva
#
# This software may be freely redistributed under the terms of the GNU
# public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

use lib qw(/usr/lib/libDrakX);
use common;
use bootloader;
use fs;
use fs::proc_partitions;
use partition_table::raw;


my @choices = map {
    my $type = partition_table::raw::typeOfMBR($_->{dev});
    if_($type && member($type, bootloader::main_method_choices()) , [ $_->{dev}, $type ]);
} fs::proc_partitions::read_raw();

my $choice;

if (!@choices) {
    print "No known Linux bootloader has been found, nothing to do.\n";
} elsif (@choices == 1) {
    print "I've found a Linux bootloader only on <$choices[0][0]>.\n\n";
    $choice = $choices[0];
} else {
    print "I've found the following Linux bootloaders:\n",
      (map_index { "\t" . $::i . ": <$_->[1]> \ton <$_->[0]>\n" } @choices),
      "\n",
      "Which disk/partition do you want to overwrite with the Windows bootloader?\n",
      "\t<enter the number or press 'n' and Enter to cancel> ";
    if (<STDIN> =~ /^(\d+)$/i && $1 >= 1) {
	$choice = $choices[$1 - 1];
    }
}

if ($choice) {
    print "I'm going to overwrite bootloader on <$choice->[0]> with
Windows bootloader.

Ok? <press Enter to continue, 'n' and Enter to cancel> ";
    <STDIN> =~ /^n/i and exit 0;
    
    system('dd', 'if=/usr/lib/extipl/aldebaran.bin', "of=/dev/$choice->[0]") == 0 
      or print "\tFailed!\n";
}

#-------------------------------------------------
#- $Log$
#- Revision 1.5  2005/06/13 04:33:50  prigaux
#- move functions using /proc/partitions out of fsedit to fs::proc_partitions
#-
#- Revision 1.4  2005/05/19 08:59:54  prigaux
#- rewrite using DrakX modules
#-
#- Revision 1.3  2005/04/19 12:49:39  prigaux
#- update copyright
#-
#- Revision 1.2  2004/07/20 02:42:12  prigaux
#- MandrakeSoft -> Mandrakesoft
#-
#- Revision 1.1  2002/02/27 13:31:30  gc
#- add "restore Windows Boot Loader" to rescue
#-
#-
> * updateThierry Vignaud2005-11-071-4/+4 * Updated French translationChristophe Berthelé2005-11-021-29/+44 * *** empty log message ***José Melo2005-10-301-181/+98 * Updated Malay translationSharuzzaman Ahmat Raslan2005-10-291-2316/+2718 * Updated POT file.Funda Wang2005-10-2871-13205/+12964 * updated Walloon filePablo Saratxaga2005-10-281-128/+156 * updated po fileShiva Huang2005-10-251-71/+82 * 1 fuzzy and 1 not translated strings.1 fuzzy and 1 not translated strings.1 f...renato2005-10-241-179/+93 * Updated Contact InfoWilly Sudiarto Raharjo2005-10-241-5/+8 * updated po fileShiva Huang2005-10-231-34/+52 * Updated Malay translationSharuzzaman Ahmat Raslan2005-10-231-2320/+2719 * Translation updateTomasz Bednarski2005-10-221-156/+83 * Updated POT file.Funda Wang2005-10-2271-6927/+8162 * updatesKeld Simonsen2005-10-211-209/+156 * Translation updatesTomasz Bednarski2005-10-201-349/+147 * Updated French translationNicolas Lécureuil2005-10-201-18/+19 * updateThierry Vignaud2005-10-201-11/+11 * Updated French translationNicolas Lécureuil2005-10-181-191/+36 * updateThierry Vignaud2005-10-171-4/+4 * UpdatedWilly Sudiarto Raharjo2005-10-171-3/+3 * jorgeJosé Jorge2005-10-171-222/+141 * Updated POT file.Funda Wang2005-10-1571-3127/+2909 * Updated Malay translationSharuzzaman Ahmat Raslan2005-10-141-2442/+2761 * *** empty log message ***José Melo2005-10-141-325/+117 * Solved some fuzzy and not translated strings.renato2005-10-101-376/+162 * fix typo (reported by PierreLag)Olivier Blin2005-10-101-2/+2 * Updated Estonian translation.Marek Laane2005-10-101-92/+72 * UpdatedWilly Sudiarto Raharjo2005-10-091-64/+76 * Updated POT fileFunda Wang2005-10-08