Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Update the installer disk wizard
- Add a GPT / MBR radio button selection
- Add a UEFI / BIOS radio button selection
  • Loading branch information
Kris Moore committed Feb 10, 2015
1 parent b286199 commit 1e77bb0
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 99 deletions.
16 changes: 9 additions & 7 deletions src-qt5/pc-installgui/installer.cpp
Expand Up @@ -19,6 +19,7 @@ Installer::Installer(QWidget *parent) : QMainWindow(parent)
translator = new QTranslator();
haveWarnedSpace=false;
force4K = false;
forceBIOS="";

connect(abortButton, SIGNAL(clicked()), this, SLOT(slotAbort()));
connect(backButton, SIGNAL(clicked()), this, SLOT(slotBack()));
Expand Down Expand Up @@ -275,7 +276,7 @@ bool Installer::autoGenPartitionLayout(QString target, bool isDisk)

// Save 100MiB for EFI FAT16 filesystem
if ( efiMode )
totalSize = totalSize - 100;
totalSize = totalSize - 110;

// Setup some swap space
if ( totalSize > 30000 ) {
Expand Down Expand Up @@ -494,7 +495,7 @@ void Installer::slotDiskCustomizeClicked()
wDisk->setWindowModality(Qt::ApplicationModal);
if ( radioRestore->isChecked() )
wDisk->setRestoreMode();
connect(wDisk, SIGNAL(saved(QList<QStringList>, QString, bool, QString, bool)), this, SLOT(slotSaveDiskChanges(QList<QStringList>, QString, bool, QString, bool)));
connect(wDisk, SIGNAL(saved(QList<QStringList>, QString, bool, QString, bool, QString)), this, SLOT(slotSaveDiskChanges(QList<QStringList>, QString, bool, QString, bool, QString)));
wDisk->show();
wDisk->raise();
}
Expand Down Expand Up @@ -524,12 +525,13 @@ void Installer::slotSaveMetaChanges(QStringList sPkgs)
textDeskSummary->setText(tr("The following meta-pkgs will be installed:") + "<br>" + selectedPkgs.join("<br>"));
}

void Installer::slotSaveDiskChanges(QList<QStringList> newSysDisks, QString BL, bool GPT, QString zName, bool zForce )
void Installer::slotSaveDiskChanges(QList<QStringList> newSysDisks, QString BL, bool GPT, QString zName, bool zForce, QString biosMode )
{

bootLoader=BL;
zpoolName = zName;
force4K = zForce;
forceBIOS=biosMode;

// Save the new disk layout
loadGPT = GPT;
Expand Down Expand Up @@ -1323,6 +1325,10 @@ void Installer::startInstall()
else
PCSYSINSTALL = "/usr/local/sbin/pc-sysinstall";

// If the user wants to set UEFI/BIOS mode manually
if ( ! forceBIOS.isEmpty() )
system("kenv grub.platform='" + forceBIOS.toLatin1() + "'");

QString program = PCSYSINSTALL;
QStringList arguments;
arguments << "-c" << cfgFile;
Expand Down Expand Up @@ -1637,10 +1643,6 @@ QStringList Installer::getDeskPkgCfg()
}
}

// Load EFI packages
if ( efiMode )
pkgList << "sysutils/grub2-efi";

cfgList << "installPackages=" + pkgList.join(" ");
return cfgList;
}
Expand Down
5 changes: 4 additions & 1 deletion src-qt5/pc-installgui/installer.h
Expand Up @@ -48,7 +48,7 @@ private slots:

// Disk slots
void slotDiskCustomizeClicked();
void slotSaveDiskChanges(QList<QStringList>, QString, bool, QString, bool);
void slotSaveDiskChanges(QList<QStringList>, QString, bool, QString, bool, QString);

// Slots for the installation
void slotInstallProcFinished( int exitCode, QProcess::ExitStatus status);
Expand Down Expand Up @@ -197,6 +197,9 @@ private slots:
// Force 4K mode?
bool force4K;

// String to override install mode efi/pc
QString forceBIOS;

// Running in EFI mode?
bool efiMode;

Expand Down
90 changes: 52 additions & 38 deletions src-qt5/pc-installgui/wizardDisk.cpp
Expand Up @@ -23,7 +23,8 @@ void wizardDisk::programInit()
populateDiskInfo();

//connect(pushClose, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(checkGPT, SIGNAL(clicked()), this, SLOT(slotGPTClicked()));
connect(radioUEFI, SIGNAL(clicked()), this, SLOT(slotUEFIClicked()));
connect(radioBIOS, SIGNAL(clicked()), this, SLOT(slotUEFIClicked()));
connect(pushSwapSize, SIGNAL(clicked()), this, SLOT(slotSwapSize()));
connect(pushRemoveMount, SIGNAL(clicked()), this, SLOT(slotRemoveFS()));
connect(pushAddMount, SIGNAL(clicked()), this, SLOT(slotAddFS()));
Expand Down Expand Up @@ -57,10 +58,14 @@ void wizardDisk::programInit()
connect(lineEncPass2,SIGNAL(textChanged(const QString &)),this,SLOT(slotCheckComplete()));

// Check if we are running in EFI mode
if ( system("kenv grub.platform | grep -q 'efi'") == 0 )
if ( system("kenv grub.platform | grep -q 'efi'") == 0 ) {
radioUEFI->setChecked(true);
efiMode=true;
else
} else {
radioBIOS->setChecked(true);
efiMode=false;
}
slotUEFIClicked();
}

void wizardDisk::populateDiskInfo()
Expand Down Expand Up @@ -117,21 +122,19 @@ void wizardDisk::accept()
bool useGPT = false;
bool force4K = false;
QString zpoolName;
QString biosMode;

if ( radioUEFI->isChecked() )
biosMode="efi";
else
biosMode="pc";

if (comboPartition->currentIndex() == 0 )
useGPT = checkGPT->isChecked();
useGPT = radioGPT->isChecked();

// Get the boot-loader
bootLoader = comboBootLoader->currentText();
if ( radioBasic->isChecked() )
bootLoader="GRUB";

if ( comboPartition->currentIndex() != 0 && bootLoader == "NONE" ) {
QMessageBox::warning(this, tr("No boot-loader!"),
tr("You have chosen not to install a boot-loader. You will need to manually setup your own loader."),
QMessageBox::Ok,
QMessageBox::Ok);
}

bootLoader="GRUB";

// When doing advanced ZFS setups, make sure to use GPT
if ( radioAdvanced->isChecked() && groupZFSOpts->isChecked() )
useGPT = true;
Expand All @@ -144,9 +147,9 @@ void wizardDisk::accept()
zpoolName = lineZpoolName->text();

if ( radioExpert->isChecked() )
emit saved(sysFinalDiskLayout, QString("NONE"), false, zpoolName, force4K);
emit saved(sysFinalDiskLayout, QString("NONE"), false, zpoolName, force4K, QString(""));
else
emit saved(sysFinalDiskLayout, bootLoader, useGPT, zpoolName, force4K);
emit saved(sysFinalDiskLayout, bootLoader, useGPT, zpoolName, force4K, biosMode);
close();
}

Expand All @@ -157,16 +160,23 @@ int wizardDisk::nextId() const
if (radioExpert->isChecked())
return Page_Expert;
if (radioBasic->isChecked()) {
checkGPT->setVisible(false);
comboBootLoader->setVisible(false);
textBootLoader->setVisible(false);
radioGPT->setChecked(true);
groupScheme->setVisible(false);
groupBIOS->setVisible(false);
checkForce4K->setVisible(false);
groupZFSPool->setVisible(false);
// Check if we are running in EFI mode
if ( system("kenv grub.platform | grep -q 'efi'") == 0 ) {
radioUEFI->setChecked(true);
radioMBR->setEnabled(false);
} else {
radioBIOS->setChecked(true);
radioMBR->setEnabled(true);
}
}
if (radioAdvanced->isChecked()) {
checkGPT->setVisible(true);
comboBootLoader->setVisible(true);
textBootLoader->setVisible(true);
groupScheme->setVisible(true);
groupBIOS->setVisible(true);
checkForce4K->setVisible(true);
groupZFSPool->setVisible(true);
}
Expand All @@ -179,13 +189,13 @@ int wizardDisk::nextId() const
if (comboPartition->currentIndex() != 0 ) {
groupZFSOpts->setEnabled(false);
// If we are installing to a GPT partition, disable swap
if ( comboPartition->currentIndex() != 0 && checkGPT->isChecked() )
if ( comboPartition->currentIndex() != 0 && radioGPT->isChecked() )
pushSwapSize->setVisible(false);
else
pushSwapSize->setVisible(true);
return Page_Mounts;
} else {
if ( checkGPT->isChecked() )
if ( radioGPT->isChecked() )
groupEncrypt->setEnabled(true);
else
groupEncrypt->setEnabled(false);
Expand All @@ -201,7 +211,7 @@ int wizardDisk::nextId() const
break;
case Page_Enc:
// If we are installing to a GPT partition, disable swap
if ( comboPartition->currentIndex() != 0 && checkGPT->isChecked() )
if ( comboPartition->currentIndex() != 0 && radioGPT->isChecked() )
pushSwapSize->setVisible(false);
else
pushSwapSize->setVisible(true);
Expand Down Expand Up @@ -273,15 +283,19 @@ bool wizardDisk::validatePage()
case Page_BasicDisk:

if ( ! radioAdvanced->isChecked() ) {
checkGPT->setChecked(true);
checkGPT->setVisible(false);
radioGPT->setChecked(true);
groupScheme->setVisible(false);
groupBIOS->setVisible(false);
checkForce4K->setVisible(false);
checkForce4K->setChecked(false);
} else {
if ( comboPartition->currentIndex() == 0)
checkGPT->setVisible(true);
else
checkGPT->setVisible(false);
if ( comboPartition->currentIndex() == 0) {
groupScheme->setVisible(true);
groupBIOS->setVisible(true);
} else {
groupScheme->setVisible(false);
groupBIOS->setVisible(false);
}
checkForce4K->setVisible(true);
}

Expand Down Expand Up @@ -567,7 +581,7 @@ void wizardDisk::generateDiskLayout()
fileSystem.clear();

// If installing to a specific GPT slice, we can't create a 2nd swap partition
if ( targetType == "ALL" || ! checkGPT->isChecked() ) {
if ( targetType != "ALL" || radioGPT->isChecked() ) {
// Now add swap space
fileSystem << targetDisk << targetSlice << "SWAP.eli" << "SWAP.eli" << tmp.setNum(swapsize) << "" << "";
sysFinalDiskLayout << fileSystem;
Expand Down Expand Up @@ -630,7 +644,6 @@ int wizardDisk::getDiskSliceSize()
if ( efiMode )
safeBuf = 110;


// Check the full disk
if ( comboPartition->currentIndex() == 0) {
for (int i=0; i < sysDisks.count(); ++i) {
Expand Down Expand Up @@ -1094,7 +1107,7 @@ void wizardDisk::generateCustomDiskLayout()
sysFinalDiskLayout << fileSystem;

// If installing to a specific GPT slice, we can't create a 2nd swap partition
if ( targetType == "ALL" || ! checkGPT->isChecked() ) {
if ( targetType != "ALL" || radioGPT->isChecked() ) {
// Now add swap space
fileSystem.clear();
fileSystem << targetDisk << targetSlice << "SWAP.eli" << "SWAP.eli" << tmp.setNum(swapsize) << "" << "";
Expand Down Expand Up @@ -1286,8 +1299,9 @@ void wizardDisk::setRestoreMode()
restoreMode=true;
}

void wizardDisk::slotGPTClicked()
void wizardDisk::slotUEFIClicked()
{
// We can do 4K block forcing on GPT / MBR now
checkForce4K->setEnabled(true);
radioMBR->setEnabled(! radioUEFI->isChecked());
if ( radioUEFI->isChecked() )
radioGPT->setChecked(true);
}
4 changes: 2 additions & 2 deletions src-qt5/pc-installgui/wizardDisk.h
Expand Up @@ -39,7 +39,7 @@ private slots:
void slotTreeMountsRightClick();
void slotTerminal();
void slotSwapSize();
void slotGPTClicked();
void slotUEFIClicked();

// QMenu slots
void slotZCMON();
Expand Down Expand Up @@ -96,7 +96,7 @@ private slots:
enum { Page_Intro, Page_BasicDisk, Page_ZFS, Page_ZFS2, Page_Enc, Page_Mounts, Page_Expert, Page_Confirmation };

signals:
void saved(QList<QStringList>, QString, bool, QString, bool);
void saved(QList<QStringList>, QString, bool, QString, bool, QString);

} ;
#endif // WIZDISK_H

0 comments on commit 1e77bb0

Please sign in to comment.