[PC-BSD Commits] r16096 - pcbsd/current/src-qt4/pc-updategui

svn at pcbsd.org svn at pcbsd.org
Thu Mar 29 14:03:32 PDT 2012


Author: kris
Date: 2012-03-29 21:03:32 +0000 (Thu, 29 Mar 2012)
New Revision: 16096

Modified:
   pcbsd/current/src-qt4/pc-updategui/main.cpp
   pcbsd/current/src-qt4/pc-updategui/mainWin.cpp
   pcbsd/current/src-qt4/pc-updategui/mainWin.h
Log:

Make the pc-updategui "warden" aware, and also add in functionality for
using pc-metapkgmanager for meta-pkg updates



Modified: pcbsd/current/src-qt4/pc-updategui/main.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-updategui/main.cpp	2012-03-29 20:11:16 UTC (rev 16095)
+++ pcbsd/current/src-qt4/pc-updategui/main.cpp	2012-03-29 21:03:32 UTC (rev 16096)
@@ -35,7 +35,22 @@
  
    mainWin w;
 
-   w.ProgramInit();
+   QString chroot, ip;
+   if ( argc >= 2)
+   {
+       QString chkarg = argv[1];
+       // Running in a warden jail?
+       if ( chkarg == "-warden" )
+         if ( argc == 4 ) {
+	   chroot = argv[2];
+	   ip = argv[3];
+         } else {
+           qDebug() << "Usage: -warden <directory> <ip>";
+           exit(1);
+         }
+   }
+
+   w.ProgramInit(chroot, ip);
    w.show();
 
    QObject::connect( &a, SIGNAL( messageReceived(const QString &) ), &w, SLOT( slotSingleInstance() ) );

Modified: pcbsd/current/src-qt4/pc-updategui/mainWin.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-updategui/mainWin.cpp	2012-03-29 20:11:16 UTC (rev 16095)
+++ pcbsd/current/src-qt4/pc-updategui/mainWin.cpp	2012-03-29 21:03:32 UTC (rev 16096)
@@ -18,8 +18,14 @@
 #include "mainWin.h"
 #include "../config.h"
 
-void mainWin::ProgramInit()
+void mainWin::ProgramInit(QString ch, QString ip)
 {
+  // Set any warden directories
+  wDir = ch;
+  wIP = ip;
+  if ( ! wDir.isEmpty() )
+     setWindowTitle(tr("Updates for Jail:") + " " + wIP );
+
   //Grab the username
   //username = QString::fromLocal8Bit(getenv("LOGNAME"));
   connect(buttonRescan, SIGNAL(clicked()), this, SLOT(slotRescanUpdates()));
@@ -161,10 +167,20 @@
       connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotUpdateLoop()) );
 
       // If doing FreeBSD Update run freebsd-update cmd
-      if ( listUpdates.at(z).at(1) == "FBSDUPDATE" )
-        uProc->start("freebsd-update", QStringList() << "install"); 
-      else
-        uProc->start("pc-updatemanager", QStringList() << "install" << tag ); 
+      if ( wDir.isEmpty() ) {
+         if ( listUpdates.at(z).at(1) == "FBSDUPDATE" )
+           uProc->start("freebsd-update", QStringList() << "install"); 
+         else if ( listUpdates.at(z).at(1) == "PACKAGE" )
+           uProc->start("pc-metapkgmanager", QStringList() << "updatepkgs"); 
+         else
+           uProc->start("pc-updatemanager", QStringList() << "install" << tag ); 
+      } else {
+	 // 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" )
+           uProc->start("pc-metapkgmanager", QStringList() << "--chroot" << wDir << "updatepkgs"); 
+      }
 
       qDebug() << "Update started";
       return;
@@ -377,8 +393,21 @@
 
 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();
+
+}
+
+void mainWin::checkPCUpdates() {
+
   QString line, tmp, name, type, version, date, tag, url, size, sa, rr;
-  QString pkgname, pkgover, pkgnver, pkgkb, pkgfile;
   QStringList up, listPkgs;
 
   QProcess p;
@@ -459,40 +488,68 @@
       }
     }
 
-    // Found PACKAGE updates
-    if ( type == "PACKAGE" ) {
-      if ( line.indexOf("PKGUPDATE: ") == 0) {
-         tmp = line.replace("PKGUPDATE: ", "");
-	 pkgname = tmp.section(" ", 0, 0);
-	 pkgover = tmp.section(" ", 1, 1);
-	 pkgnver = tmp.section(" ", 3, 3);
-         continue;
-      }
-      if ( line.indexOf("PKGUPDATEKB: ") == 0) {
-         pkgkb = line.replace("PKGUPDATEKB: ", "");
-         continue;
-      }
-      if ( line.indexOf("PKGUPDATEFILE: ") == 0) {
-         pkgfile = line.replace("PKGUPDATEFILE: ", "");
-	 // TODO add this pkg update to our list
-	 listPkgs << pkgname << pkgover << pkgnver << pkgkb << pkgfile ;
-         continue;
-      }
+  }
 
-      if ( line.indexOf("To install these") == 0) {
-         up.clear();
-	 up << name << type;
-	 up.append(listPkgs);
-	 listUpdates.append(up);
-         type=""; name="", pkgkb="", pkgfile="";
-	 continue;
-      }
+
+}
+
+void mainWin::checkMPKGUpdates() {
+
+  QString line, tmp, name, pkgname, pkgover, pkgnver, pkgkb, pkgfile;
+  QStringList up, listPkgs;
+
+  QProcess p;
+  if ( wDir.isEmpty() )
+     p.start(QString("pc-metapkgmanager"), QStringList() << "checkup");
+  else
+     p.start(QString("pc-metapkgmanager"), QStringList() << "--chroot" << wDir << "checkup");
+  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);
+       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;
+    }
+
+    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;
+    }
   }
+}
 
+void mainWin::checkFBSDUpdates() {
+  QString line;
+  QStringList up, listPkgs;
+
   // Now check if there are freebsd-updates to install
   QProcess f;
-  f.start(QString("pc-fbsdupdatecheck"), QStringList());
+  if ( wDir.isEmpty() )
+     f.start(QString("pc-fbsdupdatecheck"), QStringList());
+  else {
+     QProcess::execute("cp /usr/local/bin/pc-fbsdupdatecheck " + wDir + "/tmp/.fbupdatechk");
+     QProcess::execute("chmod 755 " + wDir + "/tmp/.fbupdatechk");
+     f.start(QString("chroot"), QStringList() << wDir << "/tmp/.fbupdatechk" << "fetch" );
+  }
   while(f.state() == QProcess::Starting || f.state() == QProcess::Running)
      QCoreApplication::processEvents();
 
@@ -500,6 +557,7 @@
   
   while (f.canReadLine()) {
     line = f.readLine().simplified();
+    qDebug() << line;
     if ( line.indexOf("The following files will be updated ") == 0) {
        fUp = true;
        listPkgs.clear();
@@ -508,10 +566,11 @@
 
     if ( fUp )
        listPkgs << line;
-    
-    qDebug() << line ;
   }
 
+  if ( ! wDir.isEmpty() )
+     QProcess::execute("rm " + wDir + "/tmp/.fbupdatechk");
+
   // Are there freebsd updates to install?
   if ( fUp ) {
     up.clear();

Modified: pcbsd/current/src-qt4/pc-updategui/mainWin.h
===================================================================
--- pcbsd/current/src-qt4/pc-updategui/mainWin.h	2012-03-29 20:11:16 UTC (rev 16095)
+++ pcbsd/current/src-qt4/pc-updategui/mainWin.h	2012-03-29 21:03:32 UTC (rev 16096)
@@ -32,7 +32,7 @@
     QMap <QString, QString> codeMap;
 
 public slots:
-    void ProgramInit();
+    void ProgramInit(QString, QString);
     void slotSingleInstance();
 
 private slots:
@@ -49,6 +49,9 @@
 private:
     void doUpdates();
     bool sanityCheck();
+    void checkFBSDUpdates();
+    void checkMPKGUpdates();
+    void checkPCUpdates();
     int curUpdate;
     int curUpdateIndex;
     int totUpdate;
@@ -56,6 +59,7 @@
     bool uPackages;
     QProcess *uProc;
     QList<QStringList> listUpdates;
+    QString wDir, wIP;
 
 signals:
 



More information about the Commits mailing list