[PC-BSD Commits] r20109 - users/ken/EasyPBI2
svn at pcbsd.org
svn at pcbsd.org
Thu Nov 1 20:45:31 PDT 2012
Author: kenmoore
Date: 2012-11-02 03:45:30 +0000 (Fri, 02 Nov 2012)
New Revision: 20109
Modified:
users/ken/EasyPBI2/mainGUI.cpp
users/ken/EasyPBI2/mainGUI.h
users/ken/EasyPBI2/mainGUI.ui
Log:
Get the PBI builder working again for EasyPBI2. Not up to previous functionality yet, but need to get the application preferences done before turning on the other functionality.
Modified: users/ken/EasyPBI2/mainGUI.cpp
===================================================================
--- users/ken/EasyPBI2/mainGUI.cpp 2012-11-01 20:10:04 UTC (rev 20108)
+++ users/ken/EasyPBI2/mainGUI.cpp 2012-11-02 03:45:30 UTC (rev 20109)
@@ -125,6 +125,7 @@
PBISETTINGS_FILE= PROG_DIR + "/.savedPBISettings.conf";
DEFAULTICON_FILE= PROG_DIR + "/defaulticon.png";
PORTS_DIR = "";
+ isSixtyFourBitOS=TRUE; //need to detect this later
//Check for EasyPBI directory structure and create it if it is not there
if( !QDir(PROG_DIR).exists() ){
@@ -309,7 +310,7 @@
if(i == currentIndex){ loadScript = TRUE; }
ui->list_scripts_file->setItemIcon(i,Backend::icon("file"));
}else{
- ui->list_scripts_file->setItemIcon(i,Backend::icon("new"));
+ ui->list_scripts_file->setItemIcon(i,Backend::icon("close"));
}
}
//Update the GUI appropriately
@@ -355,9 +356,16 @@
if( doall || doeditor || (item == "freenas")){
//nothing to make visible/invisible here
}
+ //------PBI BUILDER--------
if( doall || (item == "pbibuild")){
-
+ if(PBI_BUILDING_NOW.isEmpty()){
+ //only change things if there is nothing building at the moment
+ ui->line_build_outputdir->setText(PBIOUT_DIR);
+ if(ui->text_build_log->toPlainText().isEmpty()){ ui->push_build_save->setEnabled(FALSE); }
+ else{ ui->push_build_save->setEnabled(TRUE); }
+ }
}
+ //------OVERALL SETTINGS------
if( doall || doeditor ){
//Enable/disable the buttons that require the FreeBSD ports tree
if( CheckForPorts() ){
@@ -369,6 +377,9 @@
ui->push_addportbefore->setEnabled(FALSE);
ui->push_addportafter->setEnabled(FALSE);
}
+ //Check for a 64-bit system to enable the 32-bit build option
+ if(isSixtyFourBitOS){ ui->check_build_32->setVisible(TRUE); }
+ else{ ui->check_build_32->setVisible(FALSE); }
}
}
/*----------------------------------
@@ -1212,3 +1223,151 @@
FREENAS PLUGINS EDITOR OPTIONS
-------------------------------------------------
*/
+
+
+/*------------------------------------------------
+ PBI BUILDER OPTIONS
+ -------------------------------------------------
+*/
+void MainGUI::on_push_build_start_clicked(){
+ //Check GUI to make sure settings are set before running
+ bool gostatus = TRUE;
+ QString outdir = ui->line_build_outputdir->text();
+ if (outdir.isEmpty() ){gostatus=FALSE;}
+ //QString sigfile = "";ui->linePBIDigSigFile->text(); //this one can be empty
+ QString modDir = currentModule->path();
+ if(modDir.isEmpty()){gostatus=FALSE;}
+ if(!gostatus){
+ QMessageBox::warning(this,tr("Error"),tr("Invalid PBI Settings"));
+ return;
+ }
+
+ //Generate the PBI build command
+ QString cmd;
+ // -- PBI from ports
+ if(radio_module_port->isChecked()){
+ //Check that the ports tree is available
+ if( !CheckForPorts() ){
+ qDebug() << "Cannot build a PBI from ports without the FreeBSD ports tree available";
+ return;
+ }
+ //Setup the pbi_makeport command from GUI settings
+ cmd = PBIBUILD_CMD;
+ if(ui->check_build_32->isChecked()){ cmd += " --32"; }
+ cmd += " -c " + modDir;
+ if(PORTS_DIR != "/usr/ports"){ cmd += " -d " + PORTS_DIR; }
+ 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;
+
+ // -- PBI from local directory
+ }else if(radio_module_local->isChecked() ){
+ qDebug() << "Local PBI building is not supported yet";
+ return;
+ }
+
+ //Receive User verification before beginning build process due to:
+ // -- long time required, internet connection required, root permissions required
+ QMessageBox verify(this);
+ verify.setText(tr("Are you sure you wish to start the PBI build?"));
+ verify.setInformativeText(tr("This requires an active internet connection and root permissions. The time required to build a PBI varies depending upon system specifications and ports to be compiled."));
+ verify.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ verify.setDefaultButton(QMessageBox::Yes);
+ int ret = verify.exec();
+ if(ret != QMessageBox::Yes){return;}
+
+ //Add the necessary glue to the command to run the pbi build
+ cmd.prepend(SU_CMD+" \"");
+ cmd.append("\"");
+ qDebug() << "Actual command used:" << cmd;
+
+ //Setup the displays
+ ui->push_build_stop->setEnabled(TRUE);
+ ui->push_build_save->setEnabled(FALSE);
+ ui->check_build_32->setEnabled(FALSE);
+ ui->push_build_start->setEnabled(FALSE); //disable the button so they do not start more than 1 build at a time
+ ui->text_build_log->clear(); //clear the display in case this is not the first run
+ ui->line_build_module->setText(currentModule->path());
+ //Setup Process connections
+ p = new QProcess(this);
+ p->setProcessChannelMode(QProcess::MergedChannels);
+ p->setProcessEnvironment( QProcessEnvironment::systemEnvironment() );
+ connect(p,SIGNAL(readyReadStandardOutput()),this,SLOT(slotUpdatePBIBuild()) );
+ connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotPBIbuildFinished(int,QProcess::ExitStatus)) );
+ connect(p,SIGNAL(error(QProcess::ProcessError)),this,SLOT(slotBuildError(QProcess::ProcessError)) );
+
+ //Setup the flag for the finishing checks
+ PBI_BUILDING_NOW=outdir+":::"+currentModule->readValue("progname");
+ //Start the Process
+ qDebug() << "Starting the PBI build process...";
+ p->start(cmd);
+}
+
+void MainGUI::on_push_build_stop_clicked(){
+ slotKillPBIBuild();
+}
+
+void MainGUI::on_push_build_save_clicked(){
+ //Have user select a filename/location to save the log
+ QString filename = QFileDialog::getSaveFileName(this,tr("Save Log"),PROG_DIR+"/build.log",tr("Log Files")+" (*.log *.txt)");
+ if(filename.isEmpty()){return;} //User cancelled the process
+ //Open the file (as new)
+ QFile *file = new QFile(filename);
+ file->open(QIODevice::WriteOnly);
+ //Save the log into the file
+ file->write(ui->text_build_log->toPlainText().toUtf8());
+ file->close();
+}
+
+void MainGUI::slotUpdatePBIBuild(){
+ QString tmp = p->readAllStandardOutput();
+ if( tmp.startsWith("\n") ){tmp.remove(0,0);} //remove newline at the beginning (too much whitespace in log)
+ if( tmp.endsWith("\n") ){tmp.chop(1);} //remove newline at the end (already accounted for by appending)
+ if(!tmp.isEmpty()){ ui->text_build_log->append( tmp ); }
+ //qDebug() << "Update output: " << tmp;
+}
+
+void MainGUI::slotPBIbuildFinished(int exitCode,QProcess::ExitStatus exitStatus){
+ //Check to see if the PBI process finished successfully
+ qDebug() << "PBI build process Finished" << exitStatus << exitCode;
+ //Check that the new PBI exists
+ QDir outdir( PBI_BUILDING_NOW.section(":::",0,0) );
+ QString pbiname= PBI_BUILDING_NOW.section(":::",1,1).toLower().remove(" ");
+ QFileInfoList fL = outdir.entryInfoList( QStringList() << pbiname+"*.pbi" ,QDir::Files | QDir::NoSymLinks);
+ bool success = FALSE;
+ for(int i=0; i<fL.length(); i++){
+ qint64 msdiff = QDateTime::currentMSecsSinceEpoch() - fL[i].created().toMSecsSinceEpoch();
+ if(msdiff < 30000){ success = true; break; } //if less than a 30sec since creation of file - success
+ }
+
+ if(exitCode == 0 && success){
+ QMessageBox::information(this,tr("PBI Build Success"),tr("The PBI finished building successfully"));
+ }else if(exitCode == 0 && PBI_BUILD_TERMINATED){
+ //The user killed the process - No Message
+ }else{
+ QMessageBox::warning(this,tr("PBI Build Failure"),tr("The PBI failed to build.")+"\n"+tr("Please check the build log to find the cause of the failure and adjust the module accordingly"));
+ }
+ ui->push_build_start->setEnabled(TRUE);
+ ui->push_build_save->setEnabled(TRUE);
+ ui->push_build_stop->setEnabled(FALSE);
+ ui->check_build_32->setEnabled(TRUE);
+ p->close();
+ PBI_BUILDING_NOW.clear();
+ PBI_BUILD_TERMINATED=FALSE;
+}
+
+void MainGUI::slotKillPBIBuild(){
+ if( p->state()==QProcess::Running ){
+ //qDebug() << "Process PID:" << p->pid();
+ PBI_BUILD_TERMINATED=TRUE;
+ p->terminate();
+ ui->text_build_log->append("---PBI Build Terminated---");
+ }
+}
+
+void MainGUI::slotBuildError(QProcess::ProcessError error){
+ qDebug() << "QProcess PBI Build error#" << error;
+}
Modified: users/ken/EasyPBI2/mainGUI.h
===================================================================
--- users/ken/EasyPBI2/mainGUI.h 2012-11-01 20:10:04 UTC (rev 20108)
+++ users/ken/EasyPBI2/mainGUI.h 2012-11-02 03:45:30 UTC (rev 20109)
@@ -76,6 +76,14 @@
void on_push_el_remove_clicked();
void slotELSetFile(QAction*);
void slotELSetType(QAction*);
+ //PBI Build functions
+ void on_push_build_start_clicked();
+ void on_push_build_stop_clicked();
+ void on_push_build_save_clicked();
+ void slotUpdatePBIBuild();
+ void slotPBIbuildFinished(int,QProcess::ExitStatus);
+ void slotKillPBIBuild();
+ void slotBuildError(QProcess::ProcessError);
private:
@@ -87,7 +95,7 @@
QString PROG_DIR, PORTS_DIR, PBIOUT_DIR, MODOUT_DIR, CACHE_DIR, PROGVERSION, PBISETTINGS_FILE, DEFAULTICON_FILE;
QString SU_CMD, PBIBUILD_CMD, PBICREATE_CMD, PBI_BUILDING_NOW;
- bool PBI_BUILD_TERMINATED;
+ bool PBI_BUILD_TERMINATED, isSixtyFourBitOS;
QProcess *p;
void SetupDefaults();
Modified: users/ken/EasyPBI2/mainGUI.ui
===================================================================
(Binary files differ)
More information about the Commits
mailing list