[PC-BSD Commits] r19329 - pcbsd/current/src-qt4/EasyPBI

svn at pcbsd.org svn at pcbsd.org
Tue Sep 18 09:31:25 PDT 2012


Author: kenmoore
Date: 2012-09-18 16:31:24 +0000 (Tue, 18 Sep 2012)
New Revision: 19329

Modified:
   pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp
   pcbsd/current/src-qt4/EasyPBI/mainwindow.h
Log:
Setup EasyPBI to auto-detect the available "switch user" utility (pc-su, qsu, gksu, kdesu) and use that when building a PBI. Also find and use the full path to the pbi_makeport command and clean up the build process environment a bit. This should fix problems running EasyPBI as a PBI install into non-PCBSD systems.
While here, also tag EasyPBI as version 1.3.1



Modified: pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp
===================================================================
--- pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp	2012-09-18 15:48:22 UTC (rev 19328)
+++ pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp	2012-09-18 16:31:24 UTC (rev 19329)
@@ -26,6 +26,11 @@
       connect(ui->pushSavePbiConf,SIGNAL(clicked()),this,SLOT(editSavePbiConf()) );
       connect(ui->pushRefreshResources,SIGNAL(clicked()),this,SLOT(editRefreshResources()) );
       SetupDefaults();
+      //Deactivate the PBI Build tab if the proper external utilities not found
+      if(SU_CMD.isEmpty() || PBIBUILD_CMD.isEmpty()){
+        ui->tabWidget->setTabEnabled(1,FALSE);
+        QMessageBox::warning(this,tr("Incomplete Installation"),tr("EasyPBI could not find the external utilities necessary to build PBI's.")+"\n"+tr("Please enure that the pbi manager tools and a graphical switch user utility (qsu, gksu, kdesu) are installed properly to enable this feature of EasyPBI."));
+      }
 }
 
 MainWindow::~MainWindow()
@@ -52,7 +57,7 @@
       exit(0);
     }
 
-  PROGVERSION = "1.3";
+  PROGVERSION = "1.3.1";
   PROG_DIR = QDir::homePath() + "/EasyPBI";
   PBIOUT_DIR= PROG_DIR + "/PBI";
   MODOUT_DIR= PROG_DIR + "/Modules";  
@@ -61,7 +66,7 @@
   DEFAULTICON_FILE= PROG_DIR + "/defaulticon.png";
   PORTS_DIR = "";
   PORT_SELECTED = "";
-
+  
   //Check for EasyPBI directory structure and create it if it is not there
   if( !QDir(PROG_DIR).exists() ){
     qDebug() << "Creating the EasyPBI directory in current user's home folder:" << PROG_DIR;
@@ -120,6 +125,8 @@
     ui->linePBIOutDir->setText(PBIOUT_DIR);
   }
   
+  //Scan for the external utilities needed to build PBI's
+  findExternalCommands();
 }
 
 void MainWindow::Reset_Form()
@@ -468,7 +475,7 @@
   }
   
   //Setup the pbi_makeport command from GUI settings
-  QString cmd = "pbi_makeport";
+  QString cmd = PBIBUILD_CMD;
   cmd += " -c " + modDir;
   if(PORTS_DIR != "/usr/ports"){ cmd += " -d " + PORTS_DIR; }
   cmd += " -o " + outdir;
@@ -489,7 +496,7 @@
   if(ret != QMessageBox::Yes){return;}
 
   //Add the necessary glue to the command to run the pbi build
-  cmd.prepend("gksu -a \"unset LD_LIBRARY_PATH; ");
+  cmd.prepend(SU_CMD+" \"");
   cmd.append("\"");
   qDebug() << "Actual command used:" << cmd;
   
@@ -502,6 +509,7 @@
   //Setup Process connections
   p = new QProcess(this);
   p->setProcessChannelMode(QProcess::MergedChannels);
+  p->setProcessEnvironment( QProcessEnvironment::systemEnvironment() );
   connect(p,SIGNAL(readyReadStandardOutput()),this,SLOT(updatePBIBuild()) );
   connect(ui->pushKillBuild,SIGNAL(clicked()),this,SLOT(killPBIBuild()) );
   connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(PBIbuildFinished(int,QProcess::ExitStatus)) );
@@ -1099,3 +1107,60 @@
   else{ ui->lineLinkBin->setVisible(FALSE); }
 }
 
+//*********************************************************
+//  Scanning utilities to find the appropriate file paths to external programs
+//*********************************************************
+
+void MainWindow::findExternalCommands(){
+  SU_CMD.clear();
+  PBIBUILD_CMD.clear();
+  bool sufound = FALSE;
+  bool pbifound = FALSE;
+  //Setup the commands to look for (lists in order of preference)
+  QStringList suCMD;
+  suCMD << "pc-su" << "qsu" << "gksu" << "kdesu"; //graphical "switch user" utility
+  QString pbiCMD = "pbi_makeport";  //command to create a PBI
+  
+  //Get the current application path
+  QString cpath = QCoreApplication::applicationDirPath();
+  if(cpath.endsWith("/.sbin")){ cpath.chop(6); } //Fix for PBI installation of EasyPBI
+  qDebug() << "Application Path:" << cpath;
+  //Set the search paths
+  QStringList paths;
+  paths <<"/usr/local/bin/"<<"/usr/local/sbin/"<<"/usr/bin/"<<"/usr/sbin/"<<cpath+"/bin/"<<cpath+"/sbin/";
+
+  //Perform the Search
+  for(int i=0; i<paths.length(); i++){
+    //PBI build commands
+    if(!pbifound){
+      if(QFile::exists(paths[i]+pbiCMD)){
+        pbifound = TRUE;
+        PBIBUILD_CMD = paths[i]+pbiCMD;
+      }
+    }
+    //SU utility
+    if(!sufound){
+      for(int j=0; j<suCMD.length(); j++){
+        if(QFile::exists(paths[i]+suCMD[j])){
+      	  sufound = TRUE;
+      	  SU_CMD = paths[i]+suCMD[j];
+      	  break;
+      	}
+      }    	    
+    }
+  }
+  //Report the results
+  if(!SU_CMD.isEmpty()){
+    qDebug() << "Graphical switch user utility found at:"<<SU_CMD;  
+  }else{
+    qDebug() << "No graphical switch user utility found!";
+    qDebug() << " - Utilities searched for:" << suCMD;
+    qDebug() << " - Paths searched:" << paths;
+  }
+  if(!PBIBUILD_CMD.isEmpty()){
+    qDebug() << "pbi_makeport found at:"<<PBIBUILD_CMD;  
+  }else{
+    qDebug() << "pbi_makeport utility could not be found!";
+    qDebug() << " - Paths searched:" << paths;
+  }
+}

Modified: pcbsd/current/src-qt4/EasyPBI/mainwindow.h
===================================================================
--- pcbsd/current/src-qt4/EasyPBI/mainwindow.h	2012-09-18 15:48:22 UTC (rev 19328)
+++ pcbsd/current/src-qt4/EasyPBI/mainwindow.h	2012-09-18 16:31:24 UTC (rev 19329)
@@ -96,10 +96,11 @@
     Ui::MainWindow *ui;
     void SetupDefaults();
     void loadPBISettings();
+    void findExternalCommands();
     QStringList getPortBinaries(QString);
     QString PROG_DIR, PORTS_DIR, PORT_SELECTED, PBIOUT_DIR, MODOUT_DIR, CACHE_DIR, PROGVERSION, PBISETTINGS_FILE, DEFAULTICON_FILE;
+    QString SU_CMD, PBIBUILD_CMD;
     QProcess *p;
-    //PBI_Struct *pbi_data;
 };
 
 #endif // MAINWINDOW_H



More information about the Commits mailing list