[PC-BSD Commits] r19826 - users/ken/EasyPBI2

svn at pcbsd.org svn at pcbsd.org
Fri Oct 19 17:03:18 PDT 2012


Author: kenmoore
Date: 2012-10-20 00:03:17 +0000 (Sat, 20 Oct 2012)
New Revision: 19826

Modified:
   users/ken/EasyPBI2/mainGUI.cpp
   users/ken/EasyPBI2/mainGUI.h
   users/ken/EasyPBI2/mainGUI.ui
   users/ken/EasyPBI2/modBuild.cpp
   users/ken/EasyPBI2/modBuild.h
Log:
Finish up the pbi.conf editor for EasyPBI2, as well as the port reading backend. All that is left for pbi.conf is to make sure that it adds the port options in the optionsNG format.



Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp	2012-10-19 22:09:38 UTC (rev 19825)
+++ users/ken/EasyPBI2/mainGUI.cpp	2012-10-20 00:03:17 UTC (rev 19826)
@@ -38,8 +38,8 @@
 	ui->push_change_progdir->setIcon(Backend::icon("load"));
 	ui->push_change_makeport->setIcon(Backend::icon("file"));
 	ui->push_addmakeopt->setIcon(Backend::icon("left"));
-	//menuList[0] = new QMenu();
 	ui->push_addmakeopt->setMenu(&menu_addOpt);
+	connect(&menu_addOpt,SIGNAL(triggered(QAction*)),this,SLOT(slotAddMakeOption(QAction*)) );
 	ui->push_config_save->setIcon(Backend::icon("save"));
 	// -- resources tab --
 	ui->push_resources_savewrapper->setIcon(Backend::icon("save"));
@@ -55,12 +55,10 @@
 	ui->list_scripts_file->addItems(QStringList() << "Installation Scripts" << "pre-portmake.sh" << "post-portmake.sh" << "pre-install.sh" << "post-install.sh" << "pre-remove.sh" );
 	// -- External links tab --
 	ui->push_el_files->setIcon(Backend::icon("left"));
-	//menuList[1] = new QMenu();
 	menu_binList.addAction("No Binaries Detected");
 	ui->push_el_files->setMenu(&menu_binList);
 	
 	ui->push_el_filetype->setIcon(Backend::icon("left"));
-	//menuList[2] = new QMenu();
 	menu_elOpts.addAction("binary");
 	menu_elOpts.addAction("linux");
 	menu_elOpts.addAction("keep");
@@ -175,6 +173,14 @@
   return ok;
 }
 
+bool MainGUI::isValidPort(QString pPath){
+  bool ok = FALSE;
+  if( QFile::exists(pPath) && QFile::exists(pPath+"/Makefile") && QFile::exists(pPath+"/distinfo") ){
+    ok = TRUE;
+  }
+  return ok;
+}
+
 void MainGUI::refreshGUI(QString item){
   //Enable/disable the interface appropriately
   
@@ -199,14 +205,14 @@
 	ui->line_progversion->setVisible(FALSE); ui->label_progversion->setVisible(FALSE);
 	ui->line_progdir->setVisible(FALSE); ui->push_change_progdir->setVisible(FALSE); ui->label_progdir->setVisible(FALSE);
 	ui->line_makeport->setVisible(TRUE); ui->push_change_makeport->setVisible(TRUE); ui->label_makeport->setVisible(TRUE);
-	ui->line_makeopts->setVisible(TRUE); ui->push_addmakeopt->setVisible(TRUE); ui->label_makeopts->setVisible(TRUE);
+	ui->edit_makeopts->setVisible(TRUE); ui->push_addmakeopt->setVisible(TRUE); ui->label_makeopts->setVisible(TRUE);
 	ui->list_portbefore->setVisible(TRUE); ui->push_addportbefore->setVisible(TRUE); ui->push_rmportbefore->setVisible(TRUE);ui->label_portbefore->setVisible(TRUE);
 	ui->list_portafter->setVisible(TRUE); ui->push_addportafter->setVisible(TRUE); ui->push_rmportafter->setVisible(TRUE); ui->label_portafter->setVisible(TRUE);
     }else{
 	ui->line_progversion->setVisible(TRUE); ui->label_progversion->setVisible(TRUE);
 	ui->line_progdir->setVisible(TRUE); ui->push_change_progdir->setVisible(TRUE); ui->label_progdir->setVisible(TRUE);
 	ui->line_makeport->setVisible(FALSE); ui->push_change_makeport->setVisible(FALSE); ui->label_makeport->setVisible(FALSE);
-	ui->line_makeopts->setVisible(FALSE); ui->push_addmakeopt->setVisible(FALSE); ui->label_makeopts->setVisible(FALSE);
+	ui->edit_makeopts->setVisible(FALSE); ui->push_addmakeopt->setVisible(FALSE); ui->label_makeopts->setVisible(FALSE);
 	ui->list_portbefore->setVisible(FALSE); ui->push_addportbefore->setVisible(FALSE); ui->push_rmportbefore->setVisible(FALSE);ui->label_portbefore->setVisible(FALSE);
 	ui->list_portafter->setVisible(FALSE); ui->push_addportafter->setVisible(FALSE); ui->push_rmportafter->setVisible(FALSE); ui->label_portafter->setVisible(FALSE);
     }
@@ -222,7 +228,7 @@
     ui->line_progauthor->setText(currentModule->readValue("progauthor"));
     ui->line_progdir->setText(currentModule->readValue("packagedir"));
     ui->line_makeport->setText(currentModule->readValue("makeport"));
-    ui->line_makeopts->setText(currentModule->readValue("makeoptions"));
+    ui->edit_makeopts->setPlainText(currentModule->readValue("makeoptions"));
     // -- combo boxes (lists)
     ui->list_portbefore->clear(); ui->list_portafter->clear(); ui->list_progicon->clear();
     ui->list_portbefore->addItems( currentModule->readValue("makeportbefore").split(" ") );
@@ -238,7 +244,11 @@
     }else{
       ui->list_progicon->addItem(currentModule->readValue("progicon"));
     }
-    
+    menu_addOpt.clear();
+    QStringList opts = currentModule->readValue("portoptions").split(" ");
+    for(int i=0; i<opts.length(); i++){
+      menu_addOpt.addAction(opts[i]);
+    }
   }
   if( doall || doeditor || (item == "resources")){
     //Get the all the current files in the resources category and add them to the list
@@ -333,7 +343,18 @@
   if( doall || (item == "pbibuild")){
 	  
   }
-  
+  if( doall || doeditor ){
+    //Enable/disable the buttons that require the FreeBSD ports tree
+    if( CheckForPorts() ){
+      ui->push_change_makeport->setEnabled(TRUE);
+      ui->push_addportbefore->setEnabled(TRUE);
+      ui->push_addportafter->setEnabled(TRUE);
+    }else{
+      ui->push_change_makeport->setEnabled(FALSE);
+      ui->push_addportbefore->setEnabled(FALSE);
+      ui->push_addportafter->setEnabled(FALSE);
+    }
+  }
 }
 
 void MainGUI::on_actionExit_triggered(){
@@ -353,7 +374,12 @@
     qDebug() << "Loaded module:"<<modSel;	  
     line_module->setText(modSel.replace(QDir::homePath(),"~")); 
     if(currentModule->isLocalPBI){ radio_module_local->toggle(); }
-    else{ radio_module_port->toggle(); }
+    else{ 
+      radio_module_port->toggle(); //Port PBI
+      if( CheckForPorts() ){ 
+        currentModule->readPortInformation(PORTS_DIR+"/"+currentModule->readValue("makeport"));
+      }
+    }
     refreshGUI("all");
   }
 }
@@ -381,16 +407,75 @@
   if( !CheckForPorts() ){
     //No ports tree available
     QMessageBox::warning(this,tr("EasyPBI: No FreeBSD Ports"), tr("The FreeBSD Ports tree could not be found on your system. You may fetch the ports tree through the EasyPBI menu or manually set the path to the port tree in the EasyPBI preferences if it is installed in a non-standard location."));
+    return;
   }
   //Prompt for a new port
   QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), PORTS_DIR);
   if(portSel.isEmpty()){return;} //action cancelled or closed	
   //Check if the port is valid
-  qDebug() << "Still need to add a check for port validity in on_push_change_makeport_clicked()";
+  if( !isValidPort(portSel) ){
+    QMessageBox::warning(this,tr("EasyPBI: Invalid Port"), tr("The directory selected is not a valid FreeBSD port. Please select a port directory which contains the appropriate Makefile and distinfo-."));
+    return;
+  }
   //Save the port info to the GUI
-  ui->line_makeport->setText(portSel.remove(PORTS_DIR));
+  ui->line_makeport->setText(portSel.remove(PORTS_DIR+"/"));
 }
 
+void MainGUI::slotAddMakeOption(QAction* act){
+  qDebug() << "Trying to add build option:" << act->text();
+  
+}
+
+void MainGUI::on_push_addportbefore_clicked(){
+  if( !CheckForPorts() ){
+    //No ports tree available
+    QMessageBox::warning(this,tr("EasyPBI: No FreeBSD Ports"), tr("The FreeBSD Ports tree could not be found on your system. You may fetch the ports tree through the EasyPBI menu or manually set the path to the port tree in the EasyPBI preferences if it is installed in a non-standard location."));
+  }
+  //Prompt for a new port
+  QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), PORTS_DIR);
+  if(portSel.isEmpty()){return;} //action cancelled or closed	
+  //Check if the port is valid
+  if( !isValidPort(portSel) ){
+    QMessageBox::warning(this,tr("EasyPBI: Invalid Port"), tr("The directory selected is not a valid FreeBSD port. Please select a port directory which contains the appropriate Makefile and distinfo files."));
+    return;
+  }
+  //Save the port info to the GUI
+  if(ui->list_portbefore->count() == 1 && ui->list_portbefore->currentText().isEmpty() ){ ui->list_portbefore->clear(); }
+  ui->list_portbefore->addItem(portSel.remove(PORTS_DIR+"/"));
+}
+
+void MainGUI::on_push_rmportbefore_clicked(){
+  int index = ui->list_portbefore->currentIndex();
+  if(index != -1){
+    ui->list_portbefore->removeItem(index);
+  }
+}
+
+void MainGUI::on_push_addportafter_clicked(){
+  if( !CheckForPorts() ){
+    //No ports tree available
+    QMessageBox::warning(this,tr("EasyPBI: No FreeBSD Ports"), tr("The FreeBSD Ports tree could not be found on your system. You may fetch the ports tree through the EasyPBI menu or manually set the path to the port tree in the EasyPBI preferences if it is installed in a non-standard location."));
+  }
+  //Prompt for a new port
+  QString portSel = QFileDialog::getExistingDirectory(this, tr("Select Port"), PORTS_DIR);
+  if(portSel.isEmpty()){return;} //action cancelled or closed	
+  //Check if the port is valid
+  if( !isValidPort(portSel) ){
+    QMessageBox::warning(this,tr("EasyPBI: Invalid Port"), tr("The directory selected is not a valid FreeBSD port. Please select a port directory which contains the appropriate Makefile and distinfo files."));
+    return;
+  }
+  //Save the port info to the GUI
+  if(ui->list_portafter->count() == 1 && ui->list_portafter->currentText().isEmpty() ){ ui->list_portafter->clear(); }
+  ui->list_portafter->addItem(portSel.remove(PORTS_DIR+"/"));
+}
+
+void MainGUI::on_push_rmportafter_clicked(){
+  int index = ui->list_portafter->currentIndex();
+  if(index != -1){
+    ui->list_portafter->removeItem(index);
+  }
+}
+
 void MainGUI::on_push_config_save_clicked(){
   //Save the current settings to the backend structures
     //global settings for all modules
@@ -403,7 +488,7 @@
     //Module-dependant settings
     if( radio_module_port->isChecked() ){ //FreeBSD port module
 	currentModule->writeValue("makeport",ui->line_makeport->text());
-	currentModule->writeValue("makeoptions",ui->line_makeopts->text());
+	currentModule->writeValue("makeoptions",ui->edit_makeopts->toPlainText());
 	QString tmp;
 	for(int i=0; i < ui->list_portbefore->count(); i++){
 	  tmp.append(" "+ui->list_portbefore->itemText(i) );

Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h	2012-10-19 22:09:38 UTC (rev 19825)
+++ users/ken/EasyPBI2/mainGUI.h	2012-10-20 00:03:17 UTC (rev 19826)
@@ -42,6 +42,11 @@
     void slotModTabChanged(int);
     //pbi.conf functions
     void on_push_change_makeport_clicked();
+    void slotAddMakeOption(QAction*);
+    void on_push_addportbefore_clicked();
+    void on_push_rmportbefore_clicked();
+    void on_push_addportafter_clicked();
+    void on_push_rmportafter_clicked();
     void on_push_config_save_clicked();
     //resources functions
     void slotResourceChanged();
@@ -61,6 +66,7 @@
 
     void SetupDefaults();
     bool CheckForPorts();
+    bool isValidPort(QString);
 
 };
 

Modified: users/ken/EasyPBI2/mainGUI.ui
===================================================================
(Binary files differ)

Modified: users/ken/EasyPBI2/modBuild.cpp
===================================================================
--- users/ken/EasyPBI2/modBuild.cpp	2012-10-19 22:09:38 UTC (rev 19825)
+++ users/ken/EasyPBI2/modBuild.cpp	2012-10-20 00:03:17 UTC (rev 19826)
@@ -3,7 +3,7 @@
 ModBuild::ModBuild(QWidget* parent) : QWidget(parent){
   // --Clear the internal variables--
   isPortPBI=FALSE; isLocalPBI=FALSE;
-  progStruct.clear(); mkStruct.clear(); serverStruct.clear();
+  progStruct.clear(); mkStruct.clear(); serverStruct.clear(); portStruct.clear();
   menuStruct.clear(); desktopStruct.clear(); mimeStruct.clear(); linksStruct.clear();
   // --Setup the structures with the proper sizes--
   progStruct <<""<<""<<""<<""<<""<<"";
@@ -18,6 +18,9 @@
     //desktopStruct=[ name, genericname, exec, icon, nodisplay, terminal, mimetype]
   mimeStruct << "" << "" << "";
     //mimeStruct=[ info, type, patterns] (patterns is a " "-delimited list)
+  portStruct << "" << "" << "" << "" << "" << "" << "FALSE";
+    //portStruct=[ name, author, website, options, binaries, menu-category, isGraphical ]
+    
 }
 
 ModBuild::~ModBuild(){
@@ -40,11 +43,10 @@
   //Clear out all the module structures
   currentBins.clear(); currentIcons.clear(); currentMimeTypes.clear();
   loadDesktop(""); loadMenu(""); loadMime("");
-  linksStruct.clear();  loadPBIconf();
+  linksStruct.clear();  loadPBIconf();  readPortInformation("");
   //Try to auto-populate the module structures if possible
   if(isPortPBI){
     mkStruct[0] = modBase; //pbi_makeport
-    qDebug() << "Reading port info has not been finished for EasyPBI 2";
   }
   if(isLocalPBI){
     progStruct[0] = modBase.section("/",-1); //pbi_progname
@@ -85,10 +87,6 @@
     if(tmp[i].endsWith(".png")){ currentIcons << tmp[i]; }
     if(tmp[i].startsWith("bin/")){ currentBins << tmp[i]; }
   }
-  //Get additional port binaries (if applicable)
-  if(isPortPBI){
-    qDebug() << "Reading port info has not been finished for EasyPBI 2";
-  }
   //Load the external-links file
   if(!dir.exists("external-links")){
     linksStruct.clear();
@@ -96,9 +94,121 @@
   }else{
     loadExternalLinks();
   }
+  //Reset the ports structure
+  readPortInformation("");
   return TRUE;
 }
 
+bool ModBuild::readPortInformation(QString portPath){
+    //Clear the data structure and initialize it
+    portStruct.clear();
+    portStruct << "" << "" << "" << "" << "" << "" << "FALSE";
+    //portStruct=[ programName, author, website, options, binaries, menu-category, isGraphical ]
+    if(portPath.isEmpty()){ return TRUE; } //catch to just reset the ports structure;
+    qDebug() << "Reading port information for:" << portPath;
+    //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)
+    QDir pDir(portPath);
+    QStringList mL = pDir.entryList(QStringList("Make*"),QDir::Files | QDir::NoDotAndDotDot | QDir::Readable);
+    for(int i=0; i<mL.length(); i++){
+      if( !mL[i].contains(".old") ){ //make sure to ignore any files labelled *.old
+        int ok = readMakeFile(portPath+"/"+mL[i]);
+        if(ok==-1){ return FALSE; }
+        else if(ok==1){ variableBinFound=TRUE;}
+      }
+    }
+    
+    //Load pkg-descr file
+    if(QFile::exists(portPath+"/pkg-descr")){
+      QFile desfile(portPath+"/pkg-descr");
+      if(!desfile.open(QIODevice::ReadOnly) ){
+        return FALSE;
+      }
+      QTextStream desin(&desfile);
+      while( !desin.atEnd() ){
+        QString line = desin.readLine().simplified();
+        // ---- Program Website -----
+        if( line.startsWith("WWW:") ){
+          portStruct[2] = line.replace("\t"," ").section(" ",1,1,QString::SectionSkipEmpty);
+	  qDebug() << " - Found website:" << portStruct[2];
+        // ---- Program Author -----
+        }else if(line.startsWith("Author:") ){
+	  portStruct[1] = line.replace("\t"," ").section(" ",1,4,QString::SectionSkipEmpty);
+	  qDebug() << " - Found author:" << portStruct[1];
+	}
+      }
+      desfile.close();
+    }
+    
+    //Load the pkg-plist file
+    if(QFile::exists(portPath+"/pkg-plist")){
+      QFile pfile(portPath+"/pkg-plist");
+      if(!pfile.open(QIODevice::ReadOnly) ){
+        return FALSE;
+      }
+      QTextStream pin(&pfile);
+      while( !pin.atEnd() ){
+        QString line = pin.readLine().simplified();
+        if( line.startsWith("bin/") || line.startsWith("sbin/") ){
+	  bins << line;
+	  if(line.contains("%%")){ variableBinFound=TRUE; }
+        }
+        if(line.endsWith(".png") || line.endsWith(".jpg") || line.endsWith(".svg")){
+          //Images contained in the port, tag it as a GUI app
+          if(portStruct[6]=="FALSE"){ qDebug() << " - Detected Graphical Application"; }
+          portStruct[6] = "TRUE";
+        }
+      }
+      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 = portStruct[4].split("###");
+      //Try to replace common variables (add more later)
+      tmpbins.replaceInStrings("%%PORTNAME%%",portStruct[0]);
+      tmpbins.replaceInStrings("$PORTNAME",portStruct[0]);
+      tmpbins.replaceInStrings("${PORTNAME}",portStruct[0]);
+      
+      //If there are any bins that still have a variable in them, remove it from the list
+      bins.clear();
+      for(int i=0; i<tmpbins.length(); i++){
+	if(!tmpbins[i].contains("%%") && !tmpbins[i].contains("$") ){
+	  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(portPath);
+    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(" ");
+    
+    //For debugging display all info
+    qDebug() << " - Make Options:" << portStruct[3].split(" ");
+    qDebug() << " - Binaries:" << portStruct[4].split(" ");
+    qDebug() << " - Finished Detecting port information";
+    savePortDir = portPath;
+  
+  return TRUE;
+}
+
 bool ModBuild::loadPBIconf(){
   //Clear the current structures
   progStruct.clear(); mkStruct.clear(); serverStruct.clear();
@@ -149,13 +259,12 @@
 	mkStruct[2] = val; 
       }
       else if(var=="PBI_MAKEOPTS"){ 
-	QStringList tmpL = val.split(" ");
+	QString tmp = val;
 	while( !val.simplified().endsWith("\"")){
 	  val = in.readLine().section(";",0,0,QString::SectionSkipEmpty).simplified();
-	  tmpL.append(val.split(" "));
+	  tmp.append("\n"+val); //keep the same format for each line
 	}
-	val = tmpL.join(" ").remove("\""); //put the list back together
-	mkStruct[3] = val; 
+	mkStruct[3] = tmp.remove("\""); //Make sure to remove the quotes
       }
       else if(var=="PBI_REQUIRESROOT"){ serverStruct[0] = val.remove("\""); }
       else if(var=="PBI_BUILDKEY"){ serverStruct[1] = val.remove("\""); }
@@ -773,7 +882,7 @@
 //menuStruct=[ name, genericname, exec, icon, nodisplay, terminal, categories, mimetype]
 //desktopStruct=[ name, genericname, exec, icon, nodisplay, terminal, mimetype]
 //mimeStruct=[ info, type, patterns] (patterns is a " "-delimited list)
-	
+//portStruct=[ name, author, website, options, binaries, menu-category, isGraphical ]	
   QString val;
   QString var = variable.toLower();
   if(var=="progname"){ val = progStruct[0] ;}
@@ -808,6 +917,13 @@
   else if(variable=="mimeinfo"){ val = mimeStruct[0]; }
   else if(variable=="mimetype"){ val = mimeStruct[1]; }
   else if(variable=="mimepatterns"){ val = mimeStruct[2]; }
+  else if(variable=="portname"){ val = portStruct[0]; }
+  else if(variable=="portauthor"){ val = portStruct[1]; }
+  else if(variable=="portwebsite"){ val = portStruct[2]; }
+  else if(variable=="portoptions"){ val = portStruct[3]; }
+  else if(variable=="portbinaries"){ val = portStruct[4]; }
+  else if(variable=="portmenucategory"){ val = portStruct[5]; }
+  else if(variable=="portisgraphical"){ val = portStruct[6]; }
   else{
     qDebug() << "Error: Invalid variable name to read";
   }
@@ -865,7 +981,7 @@
   //Compress the module directory
   QString localDir = getFilenameFromPath(modulePath);
   QString cmd = "cd "+modulePath+"/..; tar czf "+localDir+".tar.gz "+localDir;
-  //qDebug() << cmd;
+  qDebug() << "Compressing module:" << modulePath+".tar.gz";
   system( cmd.toUtf8() );
   return;
 }
@@ -875,37 +991,6 @@
   return fullPath.section("/",-1);
 }
 
-QStringList ModBuild::getPortInfo(QString portDir, QString value, bool forceRead){
-  QStringList outL;
-  //Check the given port location and fill the port info structures
-  if( !isGoodPort(portDir, forceRead) ){
-    //Bad port directory given
-    qDebug() << "Invalid port directory given";
-    return outL; //is empty list
-  }
-  
-  //Now return the desired port info (fill outL list)
-  if(value.toLower() == "portname"){
-    outL = portStruct[0].split("###",QString::SkipEmptyParts);
-  }else if(value.toLower() == "maintainer"){
-    outL = portStruct[1].split("###",QString::SkipEmptyParts);
-  }else if(value.toLower() == "website"){
-    outL = portStruct[2].split("###",QString::SkipEmptyParts);
-  }else if(value.toLower() == "options"){
-    outL = portStruct[3].split("###",QString::SkipEmptyParts);
-  }else if(value.toLower() == "binaries"){
-    outL = portStruct[4].split("###",QString::SkipEmptyParts);
-  }else if(value.toLower() == "menucategory"){
-    outL = portStruct[5].split("###",QString::SkipEmptyParts);
-  }else if(value.toLower() == "hasgui"){
-    outL = portStruct[6].split("###",QString::SkipEmptyParts);
-  }else{
-    qDebug() << "Invalid port info requested\n - Valid Options: portname, maintainer, website, options, binaries, menucategory";
-  }
-  
-  return outL;
-}
-
 int ModBuild::readMakeFile(QString makefile){
   bool variableBinFound=FALSE;
   QStringList bins, actualopts, listopts;
@@ -995,127 +1080,6 @@
     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 << "" << "" << "" << "" << "" << "" << "FALSE";
-    
-    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");
-      if(!desfile.open(QIODevice::ReadOnly) ){
-        return FALSE;
-      }
-      QTextStream desin(&desfile);
-      while( !desin.atEnd() ){
-        QString line = desin.readLine().simplified();
-        // ---- Program Website -----
-        if( line.startsWith("WWW:") ){
-          portStruct[2] = line.replace("\t"," ").section(" ",1,1,QString::SectionSkipEmpty);
-	  qDebug() << " - Found website:" << portStruct[2];
-        // ---- Program Author -----
-        }else if(line.startsWith("Author:") ){
-	  portStruct[1] = line.replace("\t"," ").section(" ",1,4,QString::SectionSkipEmpty);
-	  qDebug() << " - Found author:" << portStruct[1];
-	}
-      }
-      desfile.close();
-    }
-    
-    //Load the pkg-plist file
-    if(QFile::exists(portDir+"/pkg-plist")){
-      QFile pfile(portDir+"/pkg-plist");
-      if(!pfile.open(QIODevice::ReadOnly) ){
-        return FALSE;
-      }
-      QTextStream pin(&pfile);
-      while( !pin.atEnd() ){
-        QString line = pin.readLine().simplified();
-        if( line.startsWith("bin/") || line.startsWith("sbin/") ){
-	  bins << line;
-	  if(line.contains("%%")){ variableBinFound=TRUE; }
-        }
-        if(line.endsWith(".png") || line.endsWith(".jpg") || line.endsWith(".svg")){
-          //Images contained in the port, tag it as a GUI app
-          if(portStruct[6]=="FALSE"){ qDebug() << " - Detected Graphical Application"; }
-          portStruct[6] = "TRUE";
-        }
-      }
-      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 = portStruct[4].split("###");
-      //Try to replace common variables (add more later)
-      tmpbins.replaceInStrings("%%PORTNAME%%",portStruct[0]);
-      tmpbins.replaceInStrings("$PORTNAME",portStruct[0]);
-      tmpbins.replaceInStrings("${PORTNAME}",portStruct[0]);
-      
-      //If there are any bins that still have a variable in them, remove it from the list
-      bins.clear();
-      for(int i=0; i<tmpbins.length(); i++){
-	if(!tmpbins[i].contains("%%") && !tmpbins[i].contains("$") ){
-	  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("###");
-    
-    //For debugging display all info
-    qDebug() << " - Make Options:" << portStruct[3].split("###");
-    qDebug() << " - Binaries:" << portStruct[4].split("###");
-    qDebug() << " - Finished Detecting port information";
-    savePortDir = portDir;
-  } // end of reading the port information and saving it to the structure
-  
-  return TRUE;
-}
-
 QString ModBuild::assignPortMenuCategory(QString portDir){
   //Assign a menu category based upon the port category
   

Modified: users/ken/EasyPBI2/modBuild.h
===================================================================
--- users/ken/EasyPBI2/modBuild.h	2012-10-19 22:09:38 UTC (rev 19825)
+++ users/ken/EasyPBI2/modBuild.h	2012-10-20 00:03:17 UTC (rev 19826)
@@ -17,7 +17,6 @@
   QStringList progStruct, mkStruct, serverStruct, menuStruct, desktopStruct, mimeStruct, linksStruct, portStruct;
   QString modulePath, saveMenuFile, saveDesktopFile, saveMimeFile, savePortDir;
   //Internal functions
-  bool isGoodPort(QString, bool);
   QString assignPortMenuCategory(QString);
   int readMakeFile(QString);
   static bool emptyDirectory(QString);
@@ -35,6 +34,7 @@
     //Module startup functions
   bool createNewModule(QString, QString, QString);
   bool loadModule(QString);
+  bool readPortInformation(QString);
     //pbi.conf functions
   bool loadPBIconf();
   bool writePBIconf();
@@ -69,9 +69,6 @@
   // --Static functions--
   static bool createFile(QString,QStringList);
   static QStringList readFile(QString);
-
-
-  QStringList getPortInfo(QString, QString, bool forceRead = FALSE);
   
 
 };



More information about the Commits mailing list