[PC-BSD Commits] r6486 - pcbsd/trunk/SysInstaller
svn at pcbsd.org
svn at pcbsd.org
Thu Apr 1 09:33:13 PDT 2010
Author: kris
Date: 2010-04-01 09:33:13 -0700 (Thu, 01 Apr 2010)
New Revision: 6486
Modified:
pcbsd/trunk/SysInstaller/backend.cpp
pcbsd/trunk/SysInstaller/backend.h
pcbsd/trunk/SysInstaller/sys-diskwidget.cpp
Log:
Updated SysInstaller, now the GUI works with options to create / delete slices during the disk setup phase
Modified: pcbsd/trunk/SysInstaller/backend.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/backend.cpp 2010-04-01 16:31:34 UTC (rev 6485)
+++ pcbsd/trunk/SysInstaller/backend.cpp 2010-04-01 16:33:13 UTC (rev 6486)
@@ -15,6 +15,35 @@
}
}
+int Backend::deleteMBRPart(QString Slice, QString &output)
+{
+ QStringList list;
+ QString line;
+
+ Process p(QStringList() << "delete-part" << Slice);
+ if(p.waitForFinished()) {
+ while (p.canReadLine()) {
+ line = line + p.readLine().simplified() + "\n";
+ }
+ }
+ output = line;
+ return p.exitCode();
+}
+
+int Backend::addMBRPart(QString Disk, int size, QString &output)
+{
+ QStringList list;
+ QString tmp;
+
+ Process p(QStringList() << "create-part" << Disk << tmp.setNum(size));
+ if(p.waitForFinished()) {
+ while (p.canReadLine()) {
+ output = output + p.readLine().simplified() + "\n";
+ }
+ }
+ return p.exitCode();
+}
+
void Backend::setupSSHKeys(QString Host, QString User, QString Port)
{
QString line;
@@ -34,16 +63,15 @@
QStringList list;
Process p(QStringList() << "update-part-list");
- if (p.waitForFinished()) {
- while (p.canReadLine()) {
- line = p.readLine().simplified();
- if ( line.indexOf("/dev") == 0 ) {
- list << line;
- qDebug() << "Found Upgradeable Partition: " << line;
- }
+ if(p.waitForFinished()) {
+ while (p.canReadLine()) {
+ line = p.readLine().simplified();
+ if ( line.indexOf("/dev") == 0 ) {
+ list << line;
+ qDebug() << "Found Upgradeable Partition: " << line;
}
+ }
}
-
return list;
}
Modified: pcbsd/trunk/SysInstaller/backend.h
===================================================================
--- pcbsd/trunk/SysInstaller/backend.h 2010-04-01 16:31:34 UTC (rev 6485)
+++ pcbsd/trunk/SysInstaller/backend.h 2010-04-01 16:33:13 UTC (rev 6486)
@@ -55,6 +55,8 @@
static QList<QStringList> hardDrives();
static QList<QStringList> availComponents();
static int systemMemory();
+ static int deleteMBRPart(QString Slice, QString &output);
+ static int addMBRPart(QString Disk, int size, QString &output);
//static QList<QStringList> slices();
};
Modified: pcbsd/trunk/SysInstaller/sys-diskwidget.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sys-diskwidget.cpp 2010-04-01 16:31:34 UTC (rev 6485)
+++ pcbsd/trunk/SysInstaller/sys-diskwidget.cpp 2010-04-01 16:33:13 UTC (rev 6486)
@@ -21,12 +21,75 @@
void SysInstaller::slotAddMBRPartition()
{
+ QString Output, Disk;
+ int maxFree = 0;
+ int curDiskItem = comboDiskList->currentIndex();
+ bool ok = false;
+ // Determine the disk we are working on
+ Disk = comboDiskList->currentText();
+ Disk.truncate(Disk.indexOf(" -"));
+
+ // Check for free space on this disk
+ for (int z=0; z < sysDisks.count(); ++z)
+ if ( sysDisks.at(z).at(0) == "SLICE" \
+ && sysDisks.at(z).at(1) == Disk \
+ && sysDisks.at(z).at(4) == "Unused Space" )
+ maxFree = sysDisks.at(z).at(3).toInt(&ok);
+
+ // If we have free space, and its greater than 49MB
+ if ( ok && ( maxFree > 49 ) ) {
+
+ // Confirm we want to delete this slice
+ int size = QInputDialog::getInt(this, tr("PC-BSD Install"),
+ tr("Enter the size for this new slice."), 50, 50, maxFree, 1, &ok);
+
+ if (ok) {
+ if ( Scripts::Backend::addMBRPart(Disk, size, Output) != 0)
+ QMessageBox::critical(this, tr("Add Failed"),
+ tr("The slice creation failed with the following message:") + "\n" \
+ + Output);
+ loadDiskInfo();
+ if ( comboDiskList->count() >= curDiskItem)
+ comboDiskList->setCurrentIndex(curDiskItem);
+ }
+ } else {
+ QMessageBox::critical(this, tr("Add Failed"), tr("Not enough free space to create a new slice!"));
+ }
+
}
void SysInstaller::slotDeleteMBRPartition()
{
+ QString Output;
+ int curDiskItem = comboDiskList->currentIndex();
+ if ( listDiskSlices->currentItem() ) {
+ QString slice = listDiskSlices->currentItem()->text();
+ slice.truncate(slice.indexOf(":"));
+ // Confirm we want to delete this slice
+ int ret = QMessageBox::warning(this, tr("PC-BSD Install"),
+ tr("Are you sure you want to delete:") + " " + slice,
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No);
+ switch (ret) {
+ case QMessageBox::Yes:
+ // Lets start the deletion
+ if ( Scripts::Backend::deleteMBRPart(slice, Output) != 0)
+ QMessageBox::critical(this, tr("Delete Failed"),
+ tr("The slice deletion failed with the following message:") + "\n" \
+ + Output);
+ loadDiskInfo();
+ if ( comboDiskList->count() >= curDiskItem)
+ comboDiskList->setCurrentIndex(curDiskItem);
+ break;
+ case QMessageBox::No:
+ break;
+ default:
+ break;
+ }
+ }
+
}
// Slot which switches between basic / advanced disk setup
@@ -202,6 +265,7 @@
{
// load drives
comboDiskList->clear();
+ sysFinalDiskLayout.clear();
sysDisks = Scripts::Backend::hardDrives();
for (int i=0; i < sysDisks.count(); ++i) {
// Make sure to only add the drives to the comboDiskList
More information about the Commits
mailing list