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

svn at pcbsd.org svn at pcbsd.org
Mon Jul 2 11:50:56 PDT 2012


Author: kenmoore
Date: 2012-07-02 18:50:56 +0000 (Mon, 02 Jul 2012)
New Revision: 17575

Modified:
   pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp
   pcbsd/current/src-qt4/EasyPBI/mainwindow.h
   pcbsd/current/src-qt4/EasyPBI/mainwindow.ui
   pcbsd/current/src-qt4/EasyPBI/modBuild.cpp
   pcbsd/current/src-qt4/EasyPBI/modBuild.h
Log:
Add the ability for EasyPBI to use the pacakge caching ability for building PBI's now. Also fix reading a ports Makefile if it is split between a "Makefile" and a "Makefile.inc"



Modified: pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp
===================================================================
--- pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp	2012-07-02 18:40:43 UTC (rev 17574)
+++ pcbsd/current/src-qt4/EasyPBI/mainwindow.cpp	2012-07-02 18:50:56 UTC (rev 17575)
@@ -56,6 +56,7 @@
   PROG_DIR = QDir::homePath() + "/EasyPBI";
   PBIOUT_DIR= PROG_DIR + "/PBI";
   MODOUT_DIR= PROG_DIR + "/Modules";  
+  CACHE_DIR= PROG_DIR + "/.cache";
   PBISETTINGS_FILE= PROG_DIR + "/.savedPBISettings.conf";
   DEFAULTICON_FILE= PROG_DIR + "/defaulticon.png";
   PORTS_DIR = "";
@@ -90,6 +91,15 @@
       return;
     }
   }  
+  if( !QDir(CACHE_DIR).exists() ){
+    QDir dir;
+    dir.root();
+    if( !dir.mkdir(CACHE_DIR) ){ //Create the program directory
+      //Could not create the Program directory
+      QMessageBox::warning(this, tr("Error: Permissions"), tr("Invalid permissions to create EasyPBI directory in home folder"));
+      return;
+    }
+  }  
   //Check for the ports Directory and Set the internal variable 'PORTS_DIR'
   Check_For_Ports(true);
 
@@ -387,6 +397,8 @@
   out << ui->linePBIDigSigFile->text() + "\n";
   if(ui->checkTMPFS->isChecked()){out << 1;}
   else{out << 0;}
+  if(ui->checkUseCache->isChecked()){out << 1;}
+  else{out << 0;}
   
   file->close();
   //Inform the user that the save is complete
@@ -408,6 +420,10 @@
   int chked = line.toInt();
   if(chked==1){ui->checkTMPFS->setChecked(TRUE);}
   else{ui->checkTMPFS->setChecked(FALSE);}
+  line = in.readLine(); //CACHE checked
+  chked = line.toInt();
+  if(chked==1){ui->checkUseCache->setChecked(TRUE);}
+  else{ui->checkUseCache->setChecked(FALSE);}
 
   file->close();
 }
@@ -444,6 +460,7 @@
   cmd += " -o " + outdir;
   cmd += " --delbuild";
   if( ui->checkTMPFS->isChecked() ){ cmd += " --tmpfs"; }
+  if( ui->checkUseCache->isChecked() ){ cmd += " --pkgdir " + CACHE_DIR; }
   if(!sigfile.isEmpty()){ cmd += " --sign " + sigfile; }
   qDebug() << "Build PBI command created:"<<cmd;
 

Modified: pcbsd/current/src-qt4/EasyPBI/mainwindow.h
===================================================================
--- pcbsd/current/src-qt4/EasyPBI/mainwindow.h	2012-07-02 18:40:43 UTC (rev 17574)
+++ pcbsd/current/src-qt4/EasyPBI/mainwindow.h	2012-07-02 18:50:56 UTC (rev 17575)
@@ -97,7 +97,7 @@
     void SetupDefaults();
     void loadPBISettings();
     QStringList getPortBinaries(QString);
-    QString PROG_DIR, PORTS_DIR, PORT_SELECTED, PBIOUT_DIR, MODOUT_DIR, PROGVERSION, PBISETTINGS_FILE, DEFAULTICON_FILE;
+    QString PROG_DIR, PORTS_DIR, PORT_SELECTED, PBIOUT_DIR, MODOUT_DIR, CACHE_DIR, PROGVERSION, PBISETTINGS_FILE, DEFAULTICON_FILE;
     QProcess *p;
     //PBI_Struct *pbi_data;
 };

Modified: pcbsd/current/src-qt4/EasyPBI/mainwindow.ui
===================================================================
--- pcbsd/current/src-qt4/EasyPBI/mainwindow.ui	2012-07-02 18:40:43 UTC (rev 17574)
+++ pcbsd/current/src-qt4/EasyPBI/mainwindow.ui	2012-07-02 18:50:56 UTC (rev 17575)
@@ -28,7 +28,7 @@
        <enum>QTabWidget::Rounded</enum>
       </property>
       <property name="currentIndex">
-       <number>0</number>
+       <number>1</number>
       </property>
       <widget class="QWidget" name="tabModules">
        <attribute name="icon">
@@ -403,6 +403,19 @@
             </property>
            </widget>
           </item>
+          <item row="5" column="2">
+           <widget class="QCheckBox" name="checkUseCache">
+            <property name="toolTip">
+             <string>Speed up PBI builds by re-using packages built previously</string>
+            </property>
+            <property name="text">
+             <string>Use Package Caching</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
          </layout>
         </item>
         <item>

Modified: pcbsd/current/src-qt4/EasyPBI/modBuild.cpp
===================================================================
--- pcbsd/current/src-qt4/EasyPBI/modBuild.cpp	2012-07-02 18:40:43 UTC (rev 17574)
+++ pcbsd/current/src-qt4/EasyPBI/modBuild.cpp	2012-07-02 18:50:56 UTC (rev 17575)
@@ -671,30 +671,13 @@
   return outL;
 }
 
-bool ModBuild::isGoodPort(QString portDir, bool forceRead){
-  //Remove extra "/" at end of the dir path if needed
-  if(portDir.endsWith("/")){portDir.chop(1);}
-  //Check if it is a valid port directory
-  if( !QFile::exists(portDir+"/Makefile") || (!QFile::exists(portDir+"/distinfo") && !QFile::exists(portDir+"/pkg-descr")) ){
-    qDebug() << "Invalid Port Directory";
-    return FALSE;
-  }
-  
-  //Check if we need to re-read the Port info
-  if( forceRead || (portDir != savePortDir) ){
-    //Clear the data structure and initialize it
-    portStruct.clear();
-    portStruct << "" << "" << "" << "" << "" << "";
-    
-    qDebug() << "Reading port information for:" << portDir;
-    //Read the Port files and save the info to the data structure
-    QStringList actualopts, bins, listopts; //initialize lists
-    bool variableBinFound = FALSE;
-    
-    //Load the Makefile
-    QFile mkfile(portDir+"/Makefile");
+int ModBuild::readMakeFile(QString makefile){
+  bool variableBinFound=FALSE;
+  QStringList bins, actualopts, listopts;
+
+    QFile mkfile(makefile);
     if(!mkfile.open(QIODevice::ReadOnly) ){
-      return FALSE;
+      return -1;
     }
     QTextStream mkin(&mkfile);
     while( !mkin.atEnd() ){
@@ -761,7 +744,47 @@
     }
     //qDebug() << "lo:" << listopts << "\nao:" << actualopts;
     mkfile.close();
+
+    if(!portStruct[3].isEmpty()){portStruct[3].append("###");}
+    if(!portStruct[4].isEmpty()){portStruct[4].append("###");}
+    portStruct[3].append(actualopts.join("###"));
+    portStruct[4].append(bins.join("###"));
+
+    if(variableBinFound){return 1;}
+    else{return 0;}
+}
+
+bool ModBuild::isGoodPort(QString portDir, bool forceRead){
+  //Remove extra "/" at end of the dir path if needed
+  if(portDir.endsWith("/")){portDir.chop(1);}
+  //Check if it is a valid port directory
+  if( !QFile::exists(portDir+"/Makefile") || !(QFile::exists(portDir+"/distinfo") || QFile::exists(portDir+"/pkg-descr")) ){
+    qDebug() << "Invalid Port Directory";
+    return FALSE;
+  }
+  
+  //Check if we need to re-read the Port info
+  if( forceRead || (portDir != savePortDir) ){
+    //Clear the data structure and initialize it
+    portStruct.clear();
+    portStruct << "" << "" << "" << "" << "" << "";
     
+    qDebug() << "Reading port information for:" << portDir;
+    //Read the Port files and save the info to the data structure
+    QStringList actualopts, bins, listopts; //initialize lists
+    bool variableBinFound = FALSE;
+    
+    //Load the Makefile(s)
+    int rst = readMakeFile(portDir+"/Makefile");
+    if(rst==-1){return FALSE;}
+    else if(rst==1){variableBinFound=TRUE;}
+    if(QFile::exists(portDir+"/Makefile.inc")){
+      rst = readMakeFile(portDir+"/Makefile.inc");
+      if(rst==-1){return FALSE;}
+      else if(rst==1){variableBinFound=TRUE;}
+    }
+
+    
     //Load pkg-descr file
     if(QFile::exists(portDir+"/pkg-descr")){
       QFile desfile(portDir+"/pkg-descr");
@@ -799,11 +822,14 @@
         }
       }
       pfile.close();
+      if(!portStruct[4].isEmpty()){ portStruct[4].append("###"); }
+      portStruct[4].append( bins.join("###") );
     }
+
     //Replace any common variables that might be in the bin list if any were found
     if( variableBinFound ){
       qDebug() << " - Attempting to fix binary names";
-      QStringList tmpbins = bins;
+      QStringList tmpbins = portStruct[4].split("###");
       //Try to replace common variables (add more later)
       tmpbins.replaceInStrings("%%PORTNAME%%",portStruct[0]);
       tmpbins.replaceInStrings("$PORTNAME",portStruct[0]);
@@ -816,17 +842,24 @@
 	  bins << tmpbins[i];
 	}
       }
+      //Save the binaries back into the struct
+      portStruct[4] = bins.join("###");
     }
+
+
+
     //Assign the program a menu category based on the port category
     portStruct[5] = assignPortMenuCategory(portDir);
     qDebug() << " - Assigned menu category:"<<portStruct[5];
+
+    //Remove any duplicate entries
+    QStringList tmp = portStruct[3].split("###");
+    tmp.removeDuplicates();
+    portStruct[3] = tmp.join("###");
+    tmp = portStruct[4].split("###");
+    tmp.removeDuplicates();
+    portStruct[4] = tmp.join("###");
     
-    //Save the binaries and options as a string
-    actualopts.removeDuplicates();
-    bins.removeDuplicates();
-    portStruct[3] = actualopts.join("###");
-    portStruct[4] = bins.join("###");
-    
     //For debugging display all info
     qDebug() << " - Make Options:" << portStruct[3].split("###");
     qDebug() << " - Binaries:" << portStruct[4].split("###");

Modified: pcbsd/current/src-qt4/EasyPBI/modBuild.h
===================================================================
--- pcbsd/current/src-qt4/EasyPBI/modBuild.h	2012-07-02 18:40:43 UTC (rev 17574)
+++ pcbsd/current/src-qt4/EasyPBI/modBuild.h	2012-07-02 18:50:56 UTC (rev 17575)
@@ -12,6 +12,7 @@
   static bool goodStructs();
   static bool isGoodPort(QString, bool);
   static QString assignPortMenuCategory(QString);
+  static int readMakeFile(QString);
 
 public:
   static void makeStructs(QString,QString,QString,QString,QString,QString,QString,QString,QString,bool,QString,bool);



More information about the Commits mailing list