Changeset e9a3917


Ignore:
Timestamp:
01/08/14 07:40:47 (8 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
a469e71
Parents:
8a4c7a0
Message:

Finish cleaning up the new system manager ports/source checkout functionality.
Also create a backend class that just contains a bunch of static functions for simple usage elsewhere (like generating ports update commands). This will make it easy to update the utility later if URL's or other system calls change (since we don't need to worry about all the GUI-specific stuff getting mixed in).

Location:
src-qt4/pc-sysmanager
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-sysmanager/cmdDialog.cpp

    r8a4c7a0 re9a3917  
    2727  if(cmdtype.toLower() == "ports"){ 
    2828    this->setWindowTitle(tr("Getting PC-BSD Ports Tree")); 
    29     //Check for if the port tree needs to be initialized first 
    30     qDebug() << "WARNING: Ports init check still needs to be implemented"; 
    31     bool init = true; 
    32     //Now create the commands necessary 
    33     if(init){ 
    34       ui->textEdit->setPlainText("Starting Ports Tree Initialization...."); 
    35       if(QFile::exists("/usr/ports")){ 
    36         cmds << "rm -rf /usr/ports/* /usr/ports/.g*"; info << "Removing the old ports tree"; dirs << ""; //Clean the old ports tree 
    37       }else{ 
    38         cmds << "mkdir /usr/ports"; info << "Creating the ports tree"; dirs << ""; //Create the ports tree 
    39       } 
    40       cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/ports"; //setup git 
    41       cmds << "git remote remove origin"; info << ""; dirs <<"/usr/ports"; 
    42       cmds << "git remote add origin https://www.github.com/pcbsd/freebsd-ports.git"; info << ""; dirs << "/usr/ports/.git"; //setup PC-BSD git repo 
    43     }else{ 
    44       ui->textEdit->setPlainText("Updating the Ports Tree...."); 
    45     } 
    46     //Now create the git update commands 
    47     cmds << "git fetch --depth=1"; info << "Fetch new GIT info (this may take a while)"; dirs << "/usr/ports/.git"; 
    48     cmds << "git checkout master"; info << "Checkout the tree"; dirs << "/usr/ports";  
    49  
     29    Backend::generatePortsUpdateCMDS(cmds, dirs, info); 
     30           
    5031  }else if(cmdtype.toLower() == "source"){ 
    5132    this->setWindowTitle(tr("Getting PC-BSD Sources")); 
    52     //Check for if the source tree needs to be initialized first 
    53     qDebug() << "WARNING: Source init check still needs to be implemented"; 
    54     bool init = true; 
    55     //Now create the commands necessary 
    56     if(init){ 
    57       ui->textEdit->setPlainText("Starting Source Tree Initialization...."); 
    58       if(QFile::exists("/usr/src")){ 
    59         cmds << "rm -rf /usr/src/* /usr/src/.g*"; info << "Removing the old source tree"; dirs << ""; //Clean the old source tree 
    60       }else{ 
    61         cmds << "mkdir /usr/src"; info << "Creating the source tree"; dirs << ""; //Create the source tree 
    62       } 
    63       cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/src"; //setup git 
    64       cmds << "git remote remove origin"; info << ""; dirs <<"/usr/src"; 
    65       cmds << "git remote add origin https://www.github.com/pcbsd/freebsd.git"; info << ""; dirs << "/usr/src/.git"; //setup PC-BSD git repo 
    66     }else{ 
    67       ui->textEdit->setPlainText("Updating the Source Tree...."); 
    68     } 
    69     //Now create the git update commands 
    70     cmds << "git fetch --depth=1"; info << "Fetch new GIT info (this may take a while)"; dirs << "/usr/src/.git"; 
    71     cmds << "git checkout "+branch; info << "Checkout the right version of the tree"; dirs << "/usr/src";  
     33    Backend::generateSourceUpdateCMDS(branch, cmds, dirs, info); 
     34           
    7235  }else{ 
    7336    ui->textEdit->setPlainText("Unknown CMD Type: "+cmdtype); 
  • src-qt4/pc-sysmanager/cmdDialog.h

    r8a4c7a0 re9a3917  
    88 
    99#include "longProc.h" 
     10#include "backend.h" 
    1011 
    1112namespace Ui{ 
  • src-qt4/pc-sysmanager/longProc.cpp

    r8f95077 re9a3917  
    4848  process->terminate(); 
    4949} 
    50 // ==================== 
    51 //   STATIC PUBLIC FUNCTIONS 
    52 // ==================== 
    53 bool LongProc::quickCMD(QString dir, QString cmd, QStringList args){ 
    54   //Run a quick command without looking for output other than success/failure 
    55   QProcess *proc = new QProcess; 
    56   if( !dir.isEmpty() && QFile::exists(dir) ){ proc->setWorkingDirectory(dir); } 
    57   if(args.isEmpty()){ proc->start(cmd); } 
    58   else{ proc->start(cmd, args); } 
    59   while(!proc->waitForFinished(300)){ QCoreApplication::processEvents(); } 
    60   return (proc->exitCode() == 0); 
    61 } 
    6250 
    6351// ============== 
  • src-qt4/pc-sysmanager/longProc.h

    r8f95077 re9a3917  
    77#include <QString> 
    88#include <QStringList> 
    9 #include <QCoreApplication> 
    109#include <QDebug> 
    1110#include <QTimer> 
     
    2423        //Information functions 
    2524        bool isRunning(){ return running; } //so you can double check whether it is still running 
    26          
    27         //Quick function to run a command and return success/failure 
    28         static bool quickCMD(QString dir, QString cmd, QStringList args = QStringList());  
    2925 
    3026private: 
  • src-qt4/pc-sysmanager/pc-sysmanager.pro

    ra4325b4 re9a3917  
    1111        updaterDialog.h \ 
    1212        cmdDialog.h \ 
    13         longProc.h 
     13        longProc.h \ 
     14        backend.h 
    1415 
    1516SOURCES += main.cpp \ 
     
    1718        updaterDialog.cpp \ 
    1819        cmdDialog.cpp \ 
    19         longProc.cpp 
     20        longProc.cpp \ 
     21        backend.cpp 
    2022         
    2123 
Note: See TracChangeset for help on using the changeset viewer.