[PC-BSD Commits] r21103 - pcbsd/current/src-qt4/pc-updategui
svn at pcbsd.org
svn at pcbsd.org
Tue Jan 22 09:35:24 PST 2013
Author: kris
Date: 2013-01-22 17:35:24 +0000 (Tue, 22 Jan 2013)
New Revision: 21103
Modified:
pcbsd/current/src-qt4/pc-updategui/mainWin.cpp
pcbsd/current/src-qt4/pc-updategui/mainWin.h
pcbsd/current/src-qt4/pc-updategui/mainWin.ui
Log:
Add new tab widget to update manager GUI. Split between system updates
and package updates. Run the new pc-updatemanager commands to update
packages from PKGNG.
Modified: pcbsd/current/src-qt4/pc-updategui/mainWin.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-updategui/mainWin.cpp 2013-01-22 17:26:54 UTC (rev 21102)
+++ pcbsd/current/src-qt4/pc-updategui/mainWin.cpp 2013-01-22 17:35:24 UTC (rev 21103)
@@ -32,6 +32,9 @@
//username = QString::fromLocal8Bit(getenv("LOGNAME"));
connect(buttonRescan, SIGNAL(clicked()), this, SLOT(slotRescanUpdates()));
connect(pushInstallUpdates, SIGNAL(clicked()), this, SLOT(slotInstallClicked()));
+ connect(pushUpdatePkgs, SIGNAL(clicked()), this, SLOT(slotUpdatePkgsClicked()));
+ connect(pushClose, SIGNAL(clicked()), this, SLOT(slotCloseClicked()));
+ connect(buttonRescanPkgs, SIGNAL(clicked()), this, SLOT(slotRescanPkgsClicked()));
connect(checkAll, SIGNAL(clicked()), this, SLOT(slotSelectAllClicked()));
connect(listViewUpdates, SIGNAL(itemClicked(QListWidgetItem *)),this,SLOT(slotListClicked()));
connect(listViewUpdates, SIGNAL(itemActivated(QListWidgetItem *)),this,SLOT(slotListClicked()));
@@ -39,7 +42,8 @@
connect(listViewUpdates, SIGNAL(itemPressed(QListWidgetItem *)),this,SLOT(slotListClicked()));
progressUpdate->setHidden(true);
- QTimer::singleShot(200, this, SLOT(slotRescanUpdates() ) );
+ QTimer::singleShot(100, this, SLOT(slotRescanUpdates() ) );
+ QTimer::singleShot(200, this, SLOT(slotRescanPkgsClicked() ) );
}
//Check whether an update was selected to enable the button
@@ -92,7 +96,7 @@
{
// Set our UI elements
progressUpdate->setHidden(false);
- groupUpdates->setEnabled(false);
+ tabUpdates->setEnabled(false);
curUpdate = -1;
curUpdateIndex = 0;
@@ -162,8 +166,6 @@
tag = listUpdates.at(z).at(4);
if ( listUpdates.at(z).at(1) == "PATCH" )
tag = listUpdates.at(z).at(3);
- if ( listUpdates.at(z).at(1) == "PACKAGE" )
- tag = "pkg-updates";
// Setup the upgrade process
@@ -181,18 +183,6 @@
if ( wDir.isEmpty() ) {
if ( listUpdates.at(z).at(1) == "FBSDUPDATE" ) {
uProc->start("freebsd-update", QStringList() << "install");
- } else if ( listUpdates.at(z).at(1) == "PACKAGE" ) {
- // Doing meta-pkg updates
- if ( wDir.isEmpty() )
- PkgSet="pcbsd";
- else
- PkgSet="warden";
-
- Version = Utils::getLineFromCommandOutput("pbreg get /PC-BSD/Version");
- Arch = Utils::getLineFromCommandOutput("uname -m");
- mUrl = Utils::getMasterMirror() + "/" + Version + "/" + Arch + "/netinstall/metapackages/" + PkgSet + "/packages/";
-
- uProc->start("pc-metapkgmanager", QStringList() << "update" << "all" << mUrl );
} else {
uProc->start("pc-updatemanager", QStringList() << "install" << tag );
}
@@ -200,19 +190,8 @@
// Doing a warden update in a chroot environment
if ( listUpdates.at(z).at(1) == "FBSDUPDATE" ) {
uProc->start("chroot", QStringList() << wDir << "freebsd-update" << "install");
- } else if ( listUpdates.at(z).at(1) == "PACKAGE" ) {
- // Doing meta-pkg updates
- PkgSet="warden";
-
- Version = Utils::getLineFromCommandOutput("pbreg get /PC-BSD/Version");
- Arch = Utils::getLineFromCommandOutput("uname -m");
- mUrl = Utils::getMasterMirror() + "/" + Version + "/" + Arch + "/netinstall/metapackages/" + PkgSet + "/packages/";
-
- qDebug() << "pc-metapkgmanager" << "--chroot" << wDir << "update all" << mUrl;
- uProc->start("pc-metapkgmanager", QStringList() << "--chroot" << wDir << "update" << "all" << mUrl);
- }
+ }
}
-
qDebug() << "Update started";
return;
}
@@ -234,62 +213,6 @@
while (uProc->canReadLine()) {
line = uProc->readLine().simplified();
- if ( dPackages ) {
- if ( line.indexOf("FETCH: ") == 0 ) {
- progressUpdate->setValue(progressUpdate->value() + 1);
- tmp = line;
- tmp = tmp.remove(0, tmp.lastIndexOf("/") + 1);
- textLabel->setText(tr("Downloading: %1")
- .arg(tmp));
- }
-
- if ( line.indexOf("DONEDOWNLOAD") == 0 ) {
- textLabel->setText(tr("Preparing to update system..."));
- progressUpdate->setRange(0, 0);
- continue;
- }
-
- if ( line.indexOf("PKGUPCOUNT:") == 0 ) {
- uPackages=true;
- dPackages=false;
- line.section(" ", 1,1).toInt(&ok);
- progressUpdate->setValue(0);
- progressUpdate->setRange(0, line.section(" ", 1,1).toInt(&ok));
- qDebug() << line;
- continue;
- }
- continue;
- }
-
- if ( uPackages ) {
- if ( line.indexOf("PKGUPDATE: ") == 0 ) {
- progressUpdate->setValue(progressUpdate->value() + 1);
- tmp = line;
- tmp = tmp.remove(0, tmp.indexOf(":") + 1);
- textLabel->setText(tr("Upgrading %1")
- .arg(tmp));
- }
- }
-
- if ( line.indexOf("PKGDLCOUNT:") == 0 ) {
- dPackages=true;
- line.section(" ", 1,1).toInt(&ok);
- progressUpdate->setValue(0);
- progressUpdate->setRange(0, (line.section(" ", 1,1).toInt(&ok) * 2 ));
- qDebug() << line;
- continue;
- }
-
-
- if ( line.indexOf("PKGFILECOUNT:") == 0 ) {
- dPackages=true;
- line.section(" ", 1,1).toInt(&ok);
- progressUpdate->setValue(0);
- progressUpdate->setRange(0, (line.section(" ", 1,1).toInt(&ok) * 2 ));
- qDebug() << line;
- continue;
- }
-
if ( line.indexOf("FETCH:") == 0 ) {
tmp = line;
tmp = tmp.remove(0, tmp.lastIndexOf("/") + 1);
@@ -377,11 +300,12 @@
checkAll->setEnabled(false);
}
pushInstallUpdates->setEnabled(false); //disable the button until an update is selected
+ groupUpdates->setEnabled(true);
}
void mainWin::slotDisplayUpdates()
{
- groupUpdates->setEnabled(true);
+ tabUpdates->setEnabled(true);
listViewUpdates->clear();
// Check if the system has an upgrade available
@@ -390,15 +314,21 @@
return;
}
- // Are we fully updated?
+
+ // Any system updates?
if ( listUpdates.isEmpty() ) {
- textLabel->setText(tr("Your system is fully updated!"));
+ if ( ! pushUpdatePkgs->isEnabled() ) {
+ textLabel->setText(tr("Your system is fully updated!"));
+ } else {
+ textLabel->setText(tr("Package updates available!"));
+ }
groupUpdates->setTitle("");
return;
}
- textLabel->setText("");
+ textLabel->setText(tr("System updates available!"));
groupUpdates->setTitle(tr("Available Updates"));
+ tabUpdates->setTabText(0, tr("System Updates (%1)").arg(listUpdates.count()));
// Start parsing the updates and list whats available
for (int z=0; z < listUpdates.count(); ++z) {
@@ -448,15 +378,18 @@
}
}
+void mainWin::slotRescanPkgsClicked()
+{
+ // Check for pkg updates
+ checkMPKGUpdates();
+}
+
void mainWin::slotReadUpdateData()
{
// If on the base system, check for PC-BSD updates
if ( wDir.isEmpty() )
checkPCUpdates();
- // Check for meta-pkg updates
- checkMPKGUpdates();
-
// Check for FreeBSD Updates now
checkFBSDUpdates();
@@ -552,48 +485,54 @@
void mainWin::checkMPKGUpdates() {
- QString line, tmp, name, pkgname, pkgover, pkgnver, pkgkb, pkgfile;
+ QString line, tmp, name, pkgname, pkgover, pkgnver;
QStringList up, listPkgs;
+ bool haveUpdates = false;
+ int totPkgs=0;
+ buttonRescanPkgs->setEnabled(false);
+ pushUpdatePkgs->setEnabled(false);
+ listViewUpdatesPkgs->clear();
+ groupUpdatesPkgs->setTitle(tr("Checking for updates"));
QProcess p;
if ( wDir.isEmpty() )
- p.start(QString("pc-metapkgmanager"), QStringList() << "checkup");
+ p.start(QString("pc-updatemanager"), QStringList() << "pkgcheck");
else
- p.start(QString("pc-metapkgmanager"), QStringList() << "--chroot" << wDir << "checkup");
+ p.start(QString("chroot"), QStringList() << wDir << "pc-updatemanager" << "pkgcheck");
while(p.state() == QProcess::Starting || p.state() == QProcess::Running)
QCoreApplication::processEvents();
while (p.canReadLine()) {
line = p.readLine().simplified();
qDebug() << line;
- if ( line.indexOf("PKGUPDATE: ") == 0) {
- tmp = line.replace("PKGUPDATE: ", "");
- pkgname = tmp.section(" ", 0, 0);
- pkgover = tmp.section(" ", 1, 1);
- pkgnver = tmp.section(" ", 3, 3);
+ if ( line.indexOf("Upgrading") != 0) {
continue;
}
- if ( line.indexOf("PKGUPDATEKB: ") == 0) {
- pkgkb = line.replace("PKGUPDATEKB: ", "");
- continue;
- }
- if ( line.indexOf("PKGUPDATEFILE: ") == 0) {
- pkgfile = line.replace("PKGUPDATEFILE: ", "");
- listPkgs << pkgname << pkgover << pkgnver << pkgkb << pkgfile ;
- continue;
- }
+ tmp = line;
+ pkgname = tmp.section(" ", 1, 1);
+ pkgname.replace(":", "");
+ pkgover = tmp.section(" ", 2, 2);
+ pkgnver = tmp.section(" ", 4, 4);
+ QTreeWidgetItem *myItem = new QTreeWidgetItem(QStringList() << pkgname << pkgover << pkgnver);
+ listViewUpdatesPkgs->addTopLevelItem(myItem);
+ haveUpdates = true;
+ totPkgs++;
+ }
- if ( line.indexOf("To update all run") == 0) {
- up.clear();
- up << name << "PACKAGE";
- up.append(listPkgs);
- listUpdates.append(up);
- name="", pkgkb="", pkgfile="", pkgname="", pkgover="", pkgnver="";
- continue;
- }
+ buttonRescanPkgs->setEnabled(true);
+ pushUpdatePkgs->setEnabled(haveUpdates);
+ if ( totPkgs > 0 ) {
+ tabUpdates->setTabText(1, tr("Package Updates (%1)").arg(totPkgs));
+ groupUpdatesPkgs->setTitle(tr("Available updates"));
+ } else {
+ tabUpdates->setTabText(1, tr("Package Updates"));
+ groupUpdatesPkgs->setTitle(tr("No available updates"));
}
+
+ slotDisplayUpdates();
}
+
void mainWin::checkFBSDUpdates() {
QString line;
QStringList up, listPkgs;
@@ -644,3 +583,79 @@
this->activateWindow();
this->raise();
}
+
+void mainWin::slotCloseClicked() {
+ close();
+}
+
+void mainWin::slotUpdatePkgsClicked() {
+ // Set our UI elements
+ progressUpdate->setHidden(false);
+ tabUpdates->setEnabled(false);
+
+ dPackages = false;
+ uPackages = false;
+ curUpdate = 0;
+
+ // Setup the upgrade process
+ uProc = new QProcess();
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ env.insert("PCFETCHGUI", "YES");
+ uProc->setProcessEnvironment(env);
+ uProc->setProcessChannelMode(QProcess::MergedChannels);
+
+ // Connect the slots
+ connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadPkgUpdateOutput()) );
+ connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotUpdatePkgDone()) );
+
+ if ( wDir.isEmpty() )
+ uProc->start("pc-updatemanager", QStringList() << "pkgupdate");
+ else
+ uProc->start("chroot", QStringList() << wDir << "pc-updatemanager" << "pkgupdate");
+
+ progressUpdate->setRange(0, listViewUpdatesPkgs->topLevelItemCount() );
+ progressUpdate->setValue(0);
+}
+
+void mainWin::slotReadPkgUpdateOutput() {
+ QString line, tmp;
+ while (uProc->canReadLine()) {
+ line = uProc->readLine().simplified();
+ tmp = line;
+ tmp.truncate(50);
+ if ( line.indexOf("Checking integrity") == 0 ) {
+ textLabel->setText(line);
+ uPackages = true;
+ dPackages = false;
+ curUpdate = 0;
+ progressUpdate->setValue(0);
+ continue;
+ }
+ if ( line.indexOf("to be downloaded") != -1 ) {
+ textLabel->setText(tr("Downloading packages..."));
+ dPackages = true;
+ curUpdate = 0;
+ progressUpdate->setValue(0);
+ continue;
+ }
+ if ( dPackages ) {
+ curUpdate++;
+ progressUpdate->setValue(curUpdate);
+ continue;
+ }
+ if ( uPackages ) {
+ if ( line.indexOf("Upgrading") == 0 ) {
+ textLabel->setText(line);
+ curUpdate++;
+ progressUpdate->setValue(curUpdate);
+ }
+ continue;
+ }
+
+ } // end of while
+}
+
+void mainWin::slotUpdatePkgDone() {
+ progressUpdate->setHidden(true);
+ checkMPKGUpdates();
+}
Modified: pcbsd/current/src-qt4/pc-updategui/mainWin.h
===================================================================
--- pcbsd/current/src-qt4/pc-updategui/mainWin.h 2013-01-22 17:26:54 UTC (rev 21102)
+++ pcbsd/current/src-qt4/pc-updategui/mainWin.h 2013-01-22 17:35:24 UTC (rev 21103)
@@ -45,7 +45,14 @@
void slotReadUpdateOutput();
void slotUpdateFinished();
void slotListClicked();
+ void slotCloseClicked();
+ // Package updates
+ void slotRescanPkgsClicked();
+ void slotUpdatePkgsClicked();
+ void slotReadPkgUpdateOutput();
+ void slotUpdatePkgDone();
+
private:
void doUpdates();
bool sanityCheck();
Modified: pcbsd/current/src-qt4/pc-updategui/mainWin.ui
===================================================================
--- pcbsd/current/src-qt4/pc-updategui/mainWin.ui 2013-01-22 17:26:54 UTC (rev 21102)
+++ pcbsd/current/src-qt4/pc-updategui/mainWin.ui 2013-01-22 17:35:24 UTC (rev 21103)
@@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
- <width>567</width>
- <height>316</height>
+ <width>554</width>
+ <height>338</height>
</rect>
</property>
<property name="windowTitle">
<string>Update Manager</string>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
+ <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="textLabel">
<property name="sizePolicy">
@@ -33,83 +33,6 @@
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QGroupBox" name="groupUpdates">
- <property name="title">
- <string>Available Updates</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QCheckBox" name="checkAll">
- <property name="text">
- <string>Select / Deselect All</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonRescan">
- <property name="text">
- <string>Rescan for Updates</string>
- </property>
- <property name="icon">
- <iconset resource="pc-updategui.qrc">
- <normaloff>:/view-refresh.png</normaloff>:/view-refresh.png</iconset>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <widget class="QListWidget" name="listViewUpdates"/>
- </item>
- <item row="2" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="pushInstallUpdates">
- <property name="text">
- <string>Install selected updates</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="spacer2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>223</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
<item row="1" column="0">
<widget class="QProgressBar" name="progressUpdate">
<property name="value">
@@ -117,6 +40,226 @@
</property>
</widget>
</item>
+ <item row="2" column="0">
+ <widget class="QTabWidget" name="tabUpdates">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="systab">
+ <attribute name="title">
+ <string>System Updates</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupUpdates">
+ <property name="title">
+ <string>Available Updates</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="checkAll">
+ <property name="text">
+ <string>Select / Deselect All</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonRescan">
+ <property name="text">
+ <string>Re&scan for Updates</string>
+ </property>
+ <property name="icon">
+ <iconset resource="pc-updategui.qrc">
+ <normaloff>:/view-refresh.png</normaloff>:/view-refresh.png</iconset>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QListWidget" name="listViewUpdates"/>
+ </item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="pushInstallUpdates">
+ <property name="text">
+ <string>&Install selected updates</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>223</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="pkgtab">
+ <attribute name="title">
+ <string>Package Updates</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_5">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupUpdatesPkgs">
+ <property name="title">
+ <string>Available Updates</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonRescanPkgs">
+ <property name="text">
+ <string>Re&scan packages</string>
+ </property>
+ <property name="icon">
+ <iconset resource="pc-updategui.qrc">
+ <normaloff>:/view-refresh.png</normaloff>:/view-refresh.png</iconset>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QPushButton" name="pushUpdatePkgs">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&Update packages</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer2_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>223</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QTreeWidget" name="listViewUpdatesPkgs">
+ <property name="indentation">
+ <number>0</number>
+ </property>
+ <attribute name="headerCascadingSectionResizes">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="headerDefaultSectionSize">
+ <number>160</number>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Package</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Old Version</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Version</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushClose">
+ <property name="text">
+ <string>&Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<resources>
More information about the Commits
mailing list