Changeset e5cbe5c


Ignore:
Timestamp:
12/16/13 09:24:16 (9 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
4f9718b, 117b060
Parents:
835d3d3e
Message:

Get the EasyPBI preferences dialog ports-free and fix a bug with creating a non-existant parent directory

Location:
src-qt4/EasyPBI-devel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/EasyPBI-devel/Makefile

    rc8de217 re5cbe5c  
    11############################################################################# 
    22# Makefile for building: EasyPBI 
    3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Dec 13 21:15:29 2013 
     3# Generated by qmake (2.01a) (Qt 4.8.5) on: Mon Dec 16 10:44:43 2013 
    44# Project:  EasyPBI.pro 
    55# Template: app 
     
    225225                PBIModule.h \ 
    226226                ModuleUtils.h \ 
     227                pkgSelect.h \ 
    227228                mainGUI.h 
    228229        /usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) mainGUI.h -o moc_mainGUI.cpp 
     
    230231moc_newModuleDialog.cpp: ui_newModuleDialog.h \ 
    231232                backend.h \ 
     233                pkgSelect.h \ 
    232234                newModuleDialog.h 
    233235        /usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) newModuleDialog.h -o moc_newModuleDialog.cpp 
     
    304306                config.h \ 
    305307                PBIModule.h \ 
    306                 ModuleUtils.h 
     308                ModuleUtils.h \ 
     309                pkgSelect.h 
    307310        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp 
    308311 
     
    313316                PBIModule.h \ 
    314317                ModuleUtils.h \ 
     318                pkgSelect.h \ 
    315319                ui_mainGUI.h \ 
    316320                newModuleDialog.h \ 
     
    330334newModuleDialog.o: newModuleDialog.cpp newModuleDialog.h \ 
    331335                ui_newModuleDialog.h \ 
    332                 backend.h 
     336                backend.h \ 
     337                pkgSelect.h 
    333338        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o newModuleDialog.o newModuleDialog.cpp 
    334339 
  • src-qt4/EasyPBI-devel/PBIModule.cpp

    rcbead0d1 re5cbe5c  
    600600   
    601601  //Check that the parent directory exists, and create it if necessary 
    602   QDir dir(fileName); 
    603     dir.cdUp(); 
     602  QString pDir = fileName; 
     603  pDir.chop( fileName.section("/",-1).length() ); 
     604  QDir dir(pDir); 
    604605    if(!dir.exists()){  
     606      qDebug() << "Create parent Directory:" << dir.absolutePath(); 
    605607      if( !dir.mkpath(dir.absolutePath()) ){ 
    606608        qDebug() << fileName+": Could not create containing directory"; 
  • src-qt4/EasyPBI-devel/preferencesDialog.cpp

    r4071b4d re5cbe5c  
    2626        settings->scanForExternalUtilities();    
    2727        settings->loadSettingsFile(); 
    28         //initialize the QProcess 
    29         /*process = new QProcess(this); 
    30         process->setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); 
    31         connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(updateStatusBar()) ); 
    32         connect(process,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(processFinished(int,QProcess::ExitStatus)) ); 
    33         *///Put the current settings into the GUI 
     28         
     29        //Put the current settings into the GUI 
    3430        resetGUI(); 
    3531} 
     
    5652        ui->line_pbicreate->setText(settings->value("pbi_create")); 
    5753        ui->line_makeport->setText(settings->value("pbi_makeport")); 
    58         /*//ports tab 
    59         ui->list_portsDirectories->clear(); 
    60         QStringList pDirs; pDirs<< tr("Current User (~/EasyPBI/ports)") << tr("All Users (/usr/ports)") << tr("Other"); 
    61         ui->list_portsDirectories->addItems(pDirs); 
    62         QString portsdir = settings->value("portsdir"); 
    63         if(portsdir.endsWith("/")){ portsdir.chop(1); } 
    64         if(portsdir == (QDir::homePath()+"/EasyPBI/ports") ){ 
    65           ui->list_portsDirectories->setCurrentIndex(0); //User dir 
    66         }else if(portsdir == "/usr/ports"){ 
    67           ui->list_portsDirectories->setCurrentIndex(1); //system dir    
    68         }else{ 
    69           ui->list_portsDirectories->setCurrentIndex(2); //other 
    70           ui->line_otherPortsDir->setText(portsdir); 
    71         } 
    72         ui->progressBar->setMaximum(0); ui->progressBar->setMinimum(0); //default to a "loading" indicator 
    73         */updateGUI(); 
     54        updateGUI(); 
    7455} 
    7556 
     
    8162        if( ui->check_usepkgcache->isChecked() ){ ui->groupBox_pkgcache->setVisible(TRUE); } 
    8263        else{ ui->groupBox_pkgcache->setVisible(FALSE); } 
    83         /*//ports tab 
    84         int pIndex = ui->list_portsDirectories->currentIndex(); 
    85         if(pIndex == 2){ 
    86           ui->line_otherPortsDir->setVisible(TRUE); ui->tool_otherPortsDir->setVisible(TRUE); 
    87         }else{ 
    88           ui->line_otherPortsDir->setVisible(FALSE); ui->tool_otherPortsDir->setVisible(FALSE);  
    89         } 
    90         QString pDir; 
    91         switch (pIndex){ 
    92         case 0:  
    93                 pDir = QDir::homePath()+"/EasyPBI/ports"; break; 
    94         case 1: 
    95                 pDir = "/usr/ports"; break; 
    96         default: 
    97                 pDir = ui->line_otherPortsDir->text(); 
    98         }        
    99         QString pUpdate; 
    100         if(!pDir.isEmpty()){ pUpdate = getLastPortsUpdate(pDir); } //check for existance and last update 
    101         if( !pUpdate.isEmpty() ){ 
    102           ui->push_fetchPorts->setVisible(FALSE); 
    103           ui->push_updatePorts->setVisible(TRUE); 
    104           ui->label_portsUpdated->setText( pUpdate ); 
    105         }else{ 
    106           ui->push_fetchPorts->setVisible(TRUE); 
    107           ui->push_updatePorts->setVisible(FALSE); 
    108           ui->label_portsUpdated->setText( tr("Nonexistent") ); 
    109         } 
    110         if(process->state() == QProcess::NotRunning){ 
    111           ui->list_portsDirectories->setEnabled(TRUE); 
    112           ui->line_otherPortsDir->setEnabled(TRUE); ui->tool_otherPortsDir->setEnabled(TRUE); 
    113           ui->label_status->setVisible(FALSE); ui->progressBar->setVisible(FALSE); 
    114           ui->push_fetchPorts->setEnabled(TRUE); ui->push_updatePorts->setEnabled(TRUE); 
    115           ui->buttonBox->setEnabled(TRUE); 
    116         }else{ 
    117           ui->list_portsDirectories->setEnabled(FALSE); 
    118           ui->line_otherPortsDir->setEnabled(FALSE); ui->tool_otherPortsDir->setEnabled(FALSE); 
    119           ui->label_status->setVisible(TRUE); ui->progressBar->setVisible(TRUE); 
    120           ui->push_fetchPorts->setEnabled(FALSE); ui->push_updatePorts->setEnabled(FALSE); 
    121           ui->buttonBox->setEnabled(FALSE); 
    122         } 
    123         */ 
    12464} 
    12565 
     
    13878    badpkgs.removeDuplicates(); 
    13979    settings->setList("skippkgs", badpkgs); 
    140     /*QString portsDir; 
    141     int pIndex = ui->list_portsDirectories->currentIndex(); 
    142     if( pIndex == 0 ){portsDir = QDir::homePath()+"/EasyPBI/ports"; } 
    143     else if( pIndex == 1){ portsDir = "/usr/ports"; } 
    144     else{ portsDir = ui->line_otherPortsDir->text(); }     
    145     settings->setValue("portsdir", portsDir ); */ 
    14680    settings->setValue("moduledir", ui->line_moduledir->text() ); 
    14781    settings->setValue("icondir", ui->line_icondir->text() ); 
     
    290224  ui->line_makeport->setText(settings->value("pbi_makeport")); 
    291225} 
    292  
    293 // ======  Ports Tab ====== 
    294 /* 
    295 void PreferencesDialog::on_list_portsDirectories_currentIndexChanged(int index){ 
    296   index = 0; //Remove compiler warning about unused variable 
    297   updateGUI();   
    298 } 
    299  
    300 void PreferencesDialog::on_line_otherPortsDir_textChanged(QString text){ 
    301   text.clear(); //Remove compiler warning about unused variable 
    302   updateGUI();   
    303 } 
    304 void PreferencesDialog::on_tool_otherPortsDir_clicked(){ 
    305   //Get the desired directory 
    306   QString seldir = QFileDialog::getExistingDirectory(this, tr("Select FreeBSD Ports Directory"), QDir::homePath() ); 
    307   if(seldir.isEmpty()){ return; } //action cancelled 
    308   //Save the selection to the GUI 
    309   ui->line_otherPortsDir->setText(seldir); 
    310   updateGUI(); 
    311 } 
    312  
    313 void PreferencesDialog::on_push_fetchPorts_clicked(){ 
    314   int pIndex = ui->list_portsDirectories->currentIndex(); 
    315   QString pDir; 
    316     if( pIndex == 0 ){pDir = QDir::homePath()+"/EasyPBI/ports"; } 
    317     else if( pIndex == 1){ pDir = "/usr/ports"; } 
    318     else{ pDir = ui->line_otherPortsDir->text(); } 
    319   fetchPorts(pDir,TRUE); //is a new ports directory 
    320   updateGUI(); 
    321 } 
    322  
    323 void PreferencesDialog::on_push_updatePorts_clicked(){ 
    324   int pIndex = ui->list_portsDirectories->currentIndex(); 
    325   QString pDir; 
    326     if( pIndex == 0 ){pDir = QDir::homePath()+"/EasyPBI/ports"; } 
    327     else if( pIndex == 1){ pDir = "/usr/ports"; } 
    328     else{ pDir = ui->line_otherPortsDir->text(); } 
    329   fetchPorts(pDir,FALSE); //is an existing ports directory 
    330   updateGUI(); 
    331 } 
    332      
    333 void PreferencesDialog::updateStatusBar(){ 
    334   QString tmp = process->readAllStandardOutput(); 
    335   if(tmp.endsWith("\n")){ tmp.chop(1); } 
    336   tmp = tmp.section("\n",-1); 
    337   tmp = tmp.remove("\n").simplified(); 
    338   //qDebug() << "Status Update:" << tmp; 
    339   ui->label_status->clear(); 
    340   ui->label_status->setText(tmp); 
    341 } 
    342  
    343 void PreferencesDialog::processFinished(int exitCode,QProcess::ExitStatus status){ 
    344   qDebug() << " - Ports update finished:" << exitCode << status; 
    345   //Inform the user of the result 
    346   if(exitCode == 0){ 
    347     //Finished successfully 
    348     QMessageBox::information(this, tr("Success"), tr("The FreeBSD ports tree has been successfully updated") ); 
    349   }else{ 
    350     //Finished with error 
    351     QString msg = process->readAllStandardError(); 
    352     if(msg.isEmpty()){ msg = process->readAllStandardOutput(); } 
    353     QMessageBox::information(this, tr("Failure"), QString(tr("The FreeBSD ports tree has failed to update.")+"\n"+tr("Last Message: %1") ).arg(msg) ); 
    354   } 
    355   updateGUI(); //Update the interface times and such 
    356 } 
    357  
    358 QString PreferencesDialog::getLastPortsUpdate(QString ports){ 
    359   QDir dir(ports); 
    360   QFileInfoList list = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs, QDir::Time); //sort by most recently changed 
    361   QString out; 
    362   if(list.length() > 2){ //good ports tree 
    363     out = list[0].lastModified().toString(); 
    364   } 
    365   return out; 
    366 } 
    367  
    368 void PreferencesDialog::fetchPorts(QString portsDir, bool isNew){ 
    369   bool needRoot = TRUE; 
    370   QString localPSDB = QDir::homePath()+"/EasyPBI/.portSnapDB"; 
    371   if( portsDir.startsWith( QDir::homePath() )){ needRoot = FALSE; } 
    372    
    373   // == Generate the System Command == 
    374   QString cmd; 
    375   bool usePortsnap = FALSE; 
    376   //Graphical SU utility as needed 
    377   if(needRoot){  
    378     ui->label_status->setText(tr("Requesting Root Access")); //Put placeholder info 
    379     cmd = ui->line_suutility->text() + " \""; //use the switch-user utility 
    380   } 
    381   //Figure out whether to use portsnap or not 
    382   if( !isNew && QFile::exists(portsDir+"/.svn") ){ 
    383     //Use Subversion 
    384     cmd.append("svn update "+portsDir); 
    385   }else{ 
    386     //Use Portsnap 
    387     cmd.append("portsnap fetch "); 
    388     if(isNew){ cmd.append("extract "); } 
    389     else{ cmd.append("update "); } 
    390     cmd.append("-p "+portsDir); 
    391     if(!needRoot){ cmd.append(" -d "+localPSDB); } 
    392     usePortsnap=TRUE; 
    393      
    394   } 
    395   if(needRoot){ cmd.append("\""); } //close the quotes 
    396    
    397   //If using portsnap, make sure the intermediate file is there in the EasyPBI directory 
    398   if( usePortsnap ){ 
    399     QString pspath = QDir::homePath()+"/EasyPBI/.portsnapNI.sh"; // Non-Interactive (NI) version of portsnap 
    400     if( !QFile::exists(pspath) ){ 
    401       //Create the Non-Interactive version of portsnap if it does not exist yet 
    402       QString pscmd ="echo \"#!/bin/sh \n#Non-Interactive portsnap workaround for EasyPBI \ncat /usr/sbin/portsnap | sed 's|! -t 0|-z '1'|g' | /bin/sh -s \\$@\" > "+pspath+"; chmod 755 "+pspath; 
    403       //qDebug() << "system call:" << pscmd; 
    404       system(pscmd.toUtf8()); 
    405     } 
    406     if(!needRoot && !QFile::exists(localPSDB)){ 
    407       //Create the local portsnap database directory 
    408       QString tmpcmd = "mkdir "+localPSDB; 
    409       system(tmpcmd.toUtf8()); 
    410     } 
    411     cmd.replace("portsnap",pspath); 
    412   } 
    413   //Now run the command 
    414   process->start(cmd); 
    415   qDebug() << "Ports fetch started: CMD:" << cmd;        
    416 }*/ 
    417  
  • src-qt4/EasyPBI-devel/preferencesDialog.h

    r3038c71 re5cbe5c  
    4848    void on_push_makeport_clicked(); 
    4949    void on_push_resetutils_clicked(); 
    50     //Ports Tab 
    51     void on_list_portsDirectories_currentIndexChanged(int); 
    52     void on_line_otherPortsDir_textChanged(QString); 
    53     void on_tool_otherPortsDir_clicked(); 
    54     void on_push_fetchPorts_clicked(); 
    55     void on_push_updatePorts_clicked(); 
    56     void updateStatusBar(); 
    57     void processFinished(int,QProcess::ExitStatus); 
    58      
     50 
    5951 
    6052private: 
    6153    Ui::PreferencesDialog *ui; 
    6254    Config *settings; 
    63     QProcess *process; 
    64      
    65     QString getLastPortsUpdate(QString); 
    66     void fetchPorts(QString, bool); 
    6755 
    6856}; 
Note: See TracChangeset for help on using the changeset viewer.