[PC-BSD Commits] r5181 - pcbsd/trunk/SysInstaller

svn at pcbsd.org svn at pcbsd.org
Tue Dec 1 13:47:34 PST 2009


Author: kris
Date: 2009-12-01 13:47:34 -0800 (Tue, 01 Dec 2009)
New Revision: 5181

Modified:
   pcbsd/trunk/SysInstaller/backend.cpp
   pcbsd/trunk/SysInstaller/backend.h
   pcbsd/trunk/SysInstaller/sys-componentwidget.cpp
   pcbsd/trunk/SysInstaller/sysinstaller.cpp
   pcbsd/trunk/SysInstaller/sysinstaller.h
   pcbsd/trunk/SysInstaller/sysinstaller.ui
Log:

Added support for listing and creating cfg files when doing an upgrade now as well, all various install paths
should be complete now, just need to finish up i18n support, and create the actuall install process



Modified: pcbsd/trunk/SysInstaller/backend.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/backend.cpp	2009-12-01 20:43:03 UTC (rev 5180)
+++ pcbsd/trunk/SysInstaller/backend.cpp	2009-12-01 21:47:34 UTC (rev 5181)
@@ -15,6 +15,25 @@
   }
 }
 
+QStringList Backend::upgradePartitions()
+{
+    QString line;
+    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;
+          }
+        }
+    }
+
+  return list;
+}
+
 QStringList Backend::listRsyncBackups(QString Host, QString User, QString Port)
 {
     QString line;

Modified: pcbsd/trunk/SysInstaller/backend.h
===================================================================
--- pcbsd/trunk/SysInstaller/backend.h	2009-12-01 20:43:03 UTC (rev 5180)
+++ pcbsd/trunk/SysInstaller/backend.h	2009-12-01 21:47:34 UTC (rev 5181)
@@ -39,6 +39,7 @@
 public:
     static void enableNic(QString Nic, QString IP, QString NetMask, QString DNS, QString Gate, bool fetchMirrors);
     static void setupSSHKeys(QString Host, QString User, QString Port);
+    static QStringList upgradePartitions();
     static QStringList listRsyncBackups(QString Host, QString User, QString Port);
     static QStringList languages();
     static QStringList keyLayouts();

Modified: pcbsd/trunk/SysInstaller/sys-componentwidget.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sys-componentwidget.cpp	2009-12-01 20:43:03 UTC (rev 5180)
+++ pcbsd/trunk/SysInstaller/sys-componentwidget.cpp	2009-12-01 21:47:34 UTC (rev 5181)
@@ -81,7 +81,7 @@
   componentList << "installComponents=" + tmpList;
 
   summaryList << "";
-  summaryList << tr("Selected Components:");
+  summaryList << "<b>" + tr("Selected Components:") + "</b>";
   summaryList << tmpList;
 
   return componentList;

Modified: pcbsd/trunk/SysInstaller/sysinstaller.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.cpp	2009-12-01 20:43:03 UTC (rev 5180)
+++ pcbsd/trunk/SysInstaller/sysinstaller.cpp	2009-12-01 21:47:34 UTC (rev 5181)
@@ -111,6 +111,9 @@
        }
     }
 
+    // Load any upgradeable partitions
+    listUpgrades->addItems(Scripts::Backend::upgradePartitions()); 
+
     // Connect buttons / slots
     connect(radioInstall,SIGNAL(toggled(bool)), this, SLOT(slotChangedInstallType()));
     connect(radioUpgrade,SIGNAL(toggled(bool)), this, SLOT(slotChangedInstallType()));
@@ -194,13 +197,41 @@
 {
    netURL = url;
    qDebug() << "Using remote URL: " << netURL;
-   proceed(true);
+
+   // Check if doing an upgrade, and let it move us forward if so
+   if (!checkForwardUpgrade())
+     proceed(true);
 }
 
+// Slot which is called when moving forward / next to see if we are doing an upgrade
+bool SysInstaller::checkForwardUpgrade()
+{
+   // Check if we are trying to upgrade a partition and make sure its valid
+   if ( stackWidget->currentIndex() == 2 && radioUpgrade->isChecked() ) {
+      if ( listUpgrades->currentItem() )
+      {
+        QString ss = labels.at(2)->styleSheet();
+        labels.at(2)->setStyleSheet("color: rgb(255, 255, 255);");
+        labels.at(6)->setStyleSheet(ss);
+        setCurrentIndex(6);
+        return true;
+      } else {
+        QMessageBox::warning(this, tr("Invalid Upgrade Partition"),
+                                tr("No upgrade partition has been selected!"),
+                                QMessageBox::Ok,
+                                QMessageBox::Ok);
+        return false;
+      }
+   }
+
+  return false;
+}
+
 void SysInstaller::slotNext()
 {
    QString tmp;
 
+
    // If we've been called on the NIC page, and using network install
    if ( stackWidget->currentIndex() == 2 && radioNetworkInstall->isChecked() ) {
       dsn = new dialogSelectNetServer();
@@ -220,6 +251,10 @@
       return;
    }
 
+   // See if we are doing an upgrade, and let it move us to correct page if so
+   if (checkForwardUpgrade())
+     return;
+
    // If the chosen disk is too small or partition is invalid, don't continue
    if ( stackWidget->currentIndex() == 3 && ! checkDiskRequirements())
       return;
@@ -251,7 +286,16 @@
 
 void SysInstaller::slotBack()
 {
-    proceed(false);
+   // Check if we are trying to go back when doing an upgrade, and skip other steps
+   if ( stackWidget->currentIndex() == 6 && radioUpgrade->isChecked() ) {
+      QString ss = labels.at(6)->styleSheet();
+      labels.at(6)->setStyleSheet("color: rgb(255, 255, 255);");
+      labels.at(2)->setStyleSheet(ss);
+      setCurrentIndex(2);
+      return;
+   }
+
+   proceed(false);
 }
 
 void SysInstaller::slotAbort()
@@ -338,7 +382,7 @@
 {
 
   QStringList tmpList;
-  QString tmp;
+  QString tmp, upDrive, upSlice;
 
   summaryList << "<b>" + tr("The system will be installed with the following options:") + "</b>";
 
@@ -362,15 +406,28 @@
 
   } else if ( radioUpgrade->isChecked() ) {
     // Doing an upgrade
+
+    // Figure out the drive / slice
+    upDrive=listUpgrades->currentItem()->text();
+    upDrive.truncate(upDrive.indexOf(":") - 2); // Remove slice, such as s1:
+    upDrive = upDrive.remove(0, upDrive.indexOf("dev/") + 4);
+
+    upSlice=listUpgrades->currentItem()->text();
+    upSlice.truncate(upSlice.indexOf(":"));
+    upSlice = upSlice.remove(0, upSlice.size() -2);
+
+    // Save the mode as an upgrade
     tmpList << "installMode=upgrade";
+
+    // Set if we are doing an upgrade of PC-BSD or FreeBSD
     if ( radioInstallPCBSD->isChecked() ) {
       tmpList << "installType=PCBSD";
       tmpList << "packageType=uzip";
-      summaryList << tr("Performing a system upgrade of PC-BSD");
+      summaryList << tr("Performing a system upgrade of PC-BSD on:") + " /dev/" + upDrive + upSlice;
     } else {
       tmpList << "installType=FreeBSD";
       tmpList << "packageType=tar";
-      summaryList << tr("Performing a system upgrade of FreeBSD");
+      summaryList << tr("Performing a system upgrade of FreeBSD on:") + " /dev/" + upDrive + upSlice;
     }
   } else {
     // Doing a fresh install
@@ -408,13 +465,16 @@
       tmpList << "netDefaultRouter=" + lineDefaultRouter->text();
     }
 
-    tmpList << "netSaveDev=" + comboSelectNic->currentText();
-    if ( comboSelectNic->currentText() != "AUTO-DHCP" )
-    {
-      tmpList << "netSaveIP=" + lineIP->text();
-      tmpList << "netSaveMask=" + lineNetmask->text();
-      tmpList << "netSaveNameServer=" + lineDNS->text();
-      tmpList << "netSaveDefaultRouter=" + lineDefaultRouter->text();
+    // Setup the system nics when doing a fresh install as well
+    if ( radioInstall->isChecked() ) {
+      tmpList << "netSaveDev=" + comboSelectNic->currentText();
+      if ( comboSelectNic->currentText() != "AUTO-DHCP" )
+      {
+        tmpList << "netSaveIP=" + lineIP->text();
+        tmpList << "netSaveMask=" + lineNetmask->text();
+        tmpList << "netSaveNameServer=" + lineDNS->text();
+        tmpList << "netSaveDefaultRouter=" + lineDefaultRouter->text();
+      }
     }
   } else {
     // Doing a regular DVD/USB install
@@ -428,16 +488,27 @@
     tmpList << "localizeLang=" + lang;
   }
 
-  // Save the timezone
-  tmp = comboBoxTimezone->currentText();
-  tmp.truncate(tmp.indexOf(":"));
-  tmpList << "";
-  tmpList << "# Timezone";
-  tmpList << "timeZone=" + tmp ;
-  if ( checkTimeSync->isChecked() )
-    tmpList << "enableNTP=yes";
-  else
-    tmpList << "enableNTP=no";
+  // If we are doing an upgrade, put disk info for selected drive
+  if ( radioUpgrade->isChecked() )
+  {
+    tmpList << "";
+    tmpList << "# Specify the target upgrade partition";
+    tmpList << "disk0=" + upDrive;
+    tmpList << "partition=" + upSlice;
+    tmpList << "bootManager=none";
+    tmpList << "commitDiskPart";
+  } else {
+    // Save the timezone
+    tmp = comboBoxTimezone->currentText();
+    tmp.truncate(tmp.indexOf(":"));
+    tmpList << "";
+    tmpList << "# Timezone";
+    tmpList << "timeZone=" + tmp ;
+    if ( checkTimeSync->isChecked() )
+      tmpList << "enableNTP=yes";
+    else
+      tmpList << "enableNTP=no";
+  }
 
   // Now figure out of we need to set custom keyboard layouts
   if ( ! checkKbDefault->isChecked() )
@@ -475,11 +546,17 @@
   QStringList cfgList;
   QStringList summaryList;
 
+  // Generate the config file now
   cfgList+=getGlobalCfgSettings(summaryList);
-  cfgList+=getDiskCfgSettings(summaryList);
+
+  if ( ! radioUpgrade->isChecked() )
+    cfgList+=getDiskCfgSettings(summaryList);
+
   cfgList+=getComponentCfgSettings(summaryList);
-  cfgList+=getUsersCfgSettings(summaryList);
 
+  if ( ! radioUpgrade->isChecked() )
+    cfgList+=getUsersCfgSettings(summaryList);
+
   textEditSummary->clear();
 
   // Now write out the cfgList to file

Modified: pcbsd/trunk/SysInstaller/sysinstaller.h
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.h	2009-12-01 20:43:03 UTC (rev 5180)
+++ pcbsd/trunk/SysInstaller/sysinstaller.h	2009-12-01 21:47:34 UTC (rev 5181)
@@ -123,6 +123,9 @@
     void connectUserSlots(); // Function to connect user slots
     void refreshUsers();
     bool checkUserAccountInfo();
+
+    bool checkForwardUpgrade();
+
     QRegExp passwordRegExp;
 
     void connectKeyboardSlots();
@@ -158,6 +161,7 @@
     QList<QStringList> listComponents; // QStringList for our available components
     QString netURL; // Saved network URL when doing remote install
     QStringList languages;
+    QStringList updatePartitions;
 
 };
 

Modified: pcbsd/trunk/SysInstaller/sysinstaller.ui
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.ui	2009-12-01 20:43:03 UTC (rev 5180)
+++ pcbsd/trunk/SysInstaller/sysinstaller.ui	2009-12-01 21:47:34 UTC (rev 5181)
@@ -300,7 +300,7 @@
              <item>
               <widget class="QStackedWidget" name="anteInstallStack">
                <property name="currentIndex">
-                <number>7</number>
+                <number>2</number>
                </property>
                <widget class="QWidget" name="aiStep0">
                 <layout class="QGridLayout" name="gridLayout_10">



More information about the Commits mailing list