home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
usr
/
share
/
YaST2
/
clients
/
inst_target_selection.ycp
< prev
next >
Wrap
Text File
|
2006-11-29
|
8KB
|
292 lines
/**
* Module: inst_target_selection.ycp
*
* Authors: Klaus Kaempf (kkaempf@suse.de)
*
* Purpose: This module selects the harddisk(s) for installation.
* -Harddisk recognition
* -Selecting the harddisk for the installation by
* the user ( if possible harddisks > 1 ).
* -Write selected harddisk(s) with SetPartDisk into
* Storage
* "target_is":<devicename> (key to "targets" map)
* if custom, set "target_is":"CUSTOM"
*
* $Id: inst_target_selection.ycp 33576 2006-10-23 13:25:11Z fehr $
*/
{
textdomain "storage";
import "Arch";
import "Mode";
import "Stage";
import "Popup";
import "Partitions";
import "Wizard";
import "Storage";
include "partitioning/custom_part_helptexts.ycp";
//////////////////////////////////////////////////////
// look what inst_part_propose has said:
y2milestone( "GetPartMode %1", Storage::GetPartMode() );
if( Storage::GetPartMode() == "PROP_MODIFY" ||
Storage::GetPartMode() == "SUGGESTION" )
return Storage::GetExitKey();
//////////////////////////////////////////////////////
// if we get here in update mode it's a BUG
if( Mode::update () ) {
return `cancel;
}
/////////////////////////////////////////////////////////////////////
// MAIN:
/////////////////////////////////////////////////////////////////////
map<string,map> targetMap = Storage::GetTargetMap();
// Check the partition table for correctness
term contents = `Dummy();
boolean custom_val = (Storage::GetPartMode() == "CUSTOM");
y2milestone( "custom_val %1", custom_val );
if( size(targetMap) > 0)
{
// loop over targetMap and build radio buttons for selection
// dont use foreach here since we need a counter (as a shortcut)
// anyway
term buttonbox = `VBox();
integer dskcnt = size( filter( string d, map e, targetMap,
``(Storage::IsPartitionable( e ))));
y2milestone( "dskcnt %1", dskcnt );
if( dskcnt>10 )
{
integer i = 1;
list disklist = [];
foreach( string tname, map tdata, targetMap,
``{
if( Storage::IsPartitionable( tdata ))
{
disklist = add( disklist,
`item(`id(tname),
sformat( "%1: %2", i, tname )));
i = i + 1;
}
});
buttonbox = add( buttonbox,
`SelectionBox(`id(`disklist), `opt(`notify),
_("Available &Disks"),
disklist ));
}
else
{
integer i = 1;
foreach( string tname, map tdata, targetMap,
``{
if( Storage::IsPartitionable( tdata ))
{
string tlinename = tdata["name"]:"?";
if( tdata["type"]:`CT_UNKNOWN==`CT_DMRAID )
tlinename = "BIOS RAID " + tdata["name"]:"?";
string tline = "&" + i + ": " + tlinename;
boolean sel = Storage::GetPartDisk()==tname &&
!custom_val;
buttonbox = add( buttonbox,
`Left(`RadioButton(`id(tname), tline, sel )));
i = i + 1;
}
});
}
buttonbox = add(buttonbox, `VSpacing(0.8) );
// Check box for expert partitioning mode rather than
// just selecting one of the hard disks and use
// a standard partitioning scheme
buttonbox =
add(buttonbox, `Left(`RadioButton(`id("CUSTOM"), `opt(`notify),
// label text
_("&Custom Partitioning (for experts)"),
custom_val )));
// This dialog selects the target disk for the installation.
// Below this label, all targets are listed that can be used as
// installation target
// heading text
contents = `Frame( _("Hard Disk"),
`RadioButtonGroup(`id(`options),
`VBox( `VSpacing(0.4),
`HSquash(buttonbox),
`VSpacing(0.4)
)
)
);
}
else
{
y2milestone("NO targetMap");
// normally the target is located on hard disks. Here no hard disks
// can be found. YaST2 cannot install. Update CD might have newer drivers.
contents = `Label (_("No disks found. Try using the update CD, if available, for installation."));
}
// There are several hard disks found. Linux is completely installed on
// one hard disk - this selection is done here
// "Preparing Hard Disk - Step 1" is the description of the dialog what to
// do while the following locale is the help description
// help part 1 of 3
string helptext = _("<p>
All hard disks automatically detected on your system
are shown here. Select the hard disk on which to install &product;.
</p>
");
// help part 2 of 3
helptext = helptext + _("<p>
You may select later which part of the disk is used for &product;.
</p>
");
// help part 3 of 3
helptext = helptext + _("
<p>
The <b>Custom Partitioning</b> option for experts allows full
control over partitioning the hard disks and assigning
partitions to mount points when installing &product;.
</p>
");
// first step of hd prepare, select a single disk or "expert" partitioning
Wizard::SetContents( _("Preparing Hard Disk: Step 1"),
contents, helptext, (boolean)WFM::Args(0),
(boolean)WFM::Args(1));
if ( Stage::initial () )
Wizard::SetTitleIcon( "yast-partitioning" );
if( UI::WidgetExists( `id(`disklist)) && !custom_val )
{
UI::ChangeWidget( `id(`disklist), `CurrentItem, Storage::GetPartDisk());
}
any ret = nil;
// Event handling
any option = nil;
symbol sym = `none;
repeat
{
ret = Wizard::UserInput();
y2milestone( "ret %1", ret );
if( is(ret, string) && (string)ret == "CUSTOM" )
{
//UI::ChangeWidget( `id(`disklist), `CurrentItem, "" );
custom_val = !custom_val;
}
sym = `none;
if( is( ret, symbol))
{
sym = (symbol)ret;
}
if( sym == `disklist )
{
y2milestone( "set CUSTOM false" );
custom_val = false;
UI::ChangeWidget( `id("CUSTOM"), `Value, false );
}
if( sym == `abort && Popup::ReallyAbort(true) )
return `abort;
if( sym == `next )
{
option = UI::QueryWidget(`id(`options), `CurrentButton);
y2milestone( "option %1", option );
if( option == nil )
{
string disk = "";
if( UI::WidgetExists( `id(`disklist)) && !custom_val )
{
disk = (string)UI::QueryWidget(`id(`disklist), `CurrentItem);
if( disk == nil ) disk="";
}
if( search( disk, "/dev/" ) == 0 )
option = disk;
else
{
// there is a selection from which one option must be
// chosen - at the moment no option is chosen
Popup::Message(_("Select one of the options to continue."));
sym = `again;
}
}
if( option!=nil && substring((string)option,0,5) == "/dev/" )
{
if( targetMap[(string)option,"readonly"]:false )
{
Popup::Error( Partitions::RdonlyText( (string)option, true ));
sym = `again;
}
else if( Arch::ia64() && targetMap[(string)option,"label"]:"gpt"!="gpt" )
{
Popup::Error( ia64_gpt_text() );
sym = `again;
}
else
{
Storage::SetPartMode( "USE_DISK" );
y2milestone( "PartMode Disk old %1 name %2",
Storage::GetPartDisk(), option );
Storage::DisposeTargetBackup("disk");
Storage::CreateTargetBackup("disk");
Storage::ResetOndiskTarget();
Storage::SetPartDisk( (string)option );
Storage::SetCustomDisplay( false );
Storage::SetDoResize( "NO" );
}
} // if (option)
else if( option!=nil )
{
y2milestone( "PartMode %1 %2", Storage::GetPartMode(),
Storage::GetPartDisk() );
Storage::CreateTargetBackup("disk");
if( Storage::GetPartMode() != "USE_DISK" )
{
Storage::ResetOndiskTarget();
}
// map tg = Storage::GetTargetMap();
// when creating your own setup you probably do not want to have
// these windows mount point (/windows/C, /windows/D) as default
// tg = Storage::AddMountPointsForWin(tg);
// Storage::SetTargetMap( tg );
Storage::SetCustomDisplay( true );
}
} // if (ret == next)
} until ( sym == `next || sym == `back || sym == `cancel );
if( sym != `next )
{
Storage::SetPartMode( "SUGGESTION" );
Storage::SetPartProposalActive( true );
}
Storage::SaveExitKey( sym );
return sym;
}