Changeset a4325b4


Ignore:
Timestamp:
01/07/14 10:34:30 (18 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, enter/10, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
5db8f02
Parents:
5662a7c
Message:

Move the gitprogress class over to LongProc? and change it to just take a list of commands/info to iterate through and check for success. Because of this, move all the ports/source command generation to cmdDialog for the moment. This makes it much easier to run/check command outputs for multiple-command setups.

Location:
src-qt4/pc-sysmanager
Files:
3 deleted
5 edited

Legend:

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

    r8d1c3e0 ra4325b4  
    55  ui->setupUi(this); //load the designer UI file 
    66  //Setup the backend process class 
    7   PROC = new gitProc; 
     7  PROC = new LongProc; 
    88    connect(PROC, SIGNAL(ProcMessage(QString)), this, SLOT(NewMessage(QString)) ); 
    9     connect(PROC, SIGNAL(procFinished(bool)), this, SLOT(Finished(bool)) ); 
     9    connect(PROC, SIGNAL(ProcFinished()), this, SLOT(Finished()) ); 
    1010  //Setup internal flags 
    11   initPorts = false; initSource = false; //make sure these are both initially disabled 
    1211  connect(ui->push_close, SIGNAL(clicked()), this, SLOT(CloseUI()) );    
    1312} 
     
    2322  } 
    2423  ui->push_close->setEnabled(false); //make sure they cannot close this while it is running 
     24  ui->textEdit->clear(); //make sure this is cleared 
     25  QStringList cmds, dirs, info; //For generating the necessary input to the backend 
    2526  if(cmdtype.toLower() == "ports"){ 
    2627    //Check for if the port tree needs to be initialized first 
    2728    qDebug() << "WARNING: Ports init check still needs to be implemented"; 
    2829    bool init = true; 
     30    //Now create the commands necessary 
    2931    if(init){ 
    30       initPorts = true; //set the internal flag 
    3132      ui->textEdit->setPlainText("Starting Ports Tree Initialization...."); 
    32       bool ok = PROC->startInitPorts(); 
    33       if(!ok){  
    34         ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/ports"); 
    35         ui->push_close->setEnabled(true); //they can now close the window 
     33      if(QFile::exists("/usr/ports")){ 
     34        cmds << "rm -rf /usr/ports/*"; info << "Removing the old ports tree"; dirs << ""; //Clean the old ports tree 
     35      }else{ 
     36        cmds << "mkdir /usr/ports"; info << "Creating the ports tree"; dirs << ""; //Create the source tree 
    3637      } 
     38      cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/ports"; //setup git 
     39      cmds << "git remote add origin https://www.github.com/pcbsd/freebsd-ports.git"; info << ""; dirs << "/usr/ports/.git"; //setup PC-BSD git repo 
    3740    }else{ 
    38       ui->textEdit->setPlainText("Fetching the Ports Tree...."); 
    39       bool ok = PROC->startPorts(); 
    40       if(!ok){  
    41         ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports"); 
    42         ui->push_close->setEnabled(true); //they can now close the window 
    43       } 
     41      ui->textEdit->setPlainText("Updating the Ports Tree...."); 
    4442    } 
     43    //Now create the git update commands 
     44    cmds << "git fetch --depth=1"; info << "Fetch new GIT info"; dirs << "/usr/ports/.git"; 
     45    cmds << "git checkout -t origin/master"; info << "Checkout the tree"; dirs << "/usr/ports/.git";  
     46 
    4547  }else if(cmdtype.toLower() == "source"){ 
    4648    //Check for if the source tree needs to be initialized first 
    4749    qDebug() << "WARNING: Source init check still needs to be implemented"; 
    4850    bool init = true; 
     51    //Now create the commands necessary 
    4952    if(init){ 
    50       initSource = true; //set the internal flag 
    5153      ui->textEdit->setPlainText("Starting Source Tree Initialization...."); 
    52       bool ok = PROC->startInitSource(); 
    53       if(!ok){  
    54         ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/src"); 
    55         ui->push_close->setEnabled(true); //they can now close the window 
     54      if(QFile::exists("/usr/src")){ 
     55        cmds << "rm -rf /usr/src/*"; info << "Removing the old source tree"; dirs << ""; //Clean the old source tree 
     56      }else{ 
     57        cmds << "mkdir /usr/src"; info << "Creating the source tree"; dirs << ""; //Create the source tree 
    5658      } 
     59      cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/src"; //setup git 
     60      cmds << "git remote add origin https://www.github.com/pcbsd/freebsd.git"; info << ""; dirs << "/usr/src/.git"; //setup PC-BSD git repo 
    5761    }else{ 
    58       ui->textEdit->setPlainText("Fetching the Source Tree...."); 
    59       bool ok = PROC->startSource(); 
    60       if(!ok){  
    61         ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src"); 
    62         ui->push_close->setEnabled(true); //they can now close the window 
    63       } 
     62      ui->textEdit->setPlainText("Updating the Source Tree...."); 
    6463    } 
     64    //Now create the git update commands 
     65    cmds << "git fetch --depth=1"; info << "Fetch new GIT info"; dirs << "/usr/src/.git"; 
     66    cmds << "git checkout -t origin/master"; info << "Checkout the tree"; dirs << "/usr/src/.git";  
    6567  }else{ 
    6668    ui->textEdit->setPlainText("Unknown CMD Type: "+cmdtype); 
    6769    ui->push_close->setEnabled(true); 
     70    return; 
    6871  } 
     72  PROC->startCMDs(cmds, dirs, info); 
    6973} 
    7074 
     
    7478} 
    7579 
    76 void CMDDialog::Finished(bool ok){ 
    77   if(!ok){ 
    78     ui->textEdit->appendPlainText("\n=============\nProcess Completed Unsuccessfully"); 
     80void CMDDialog::Finished(){ 
    7981    ui->push_close->setEnabled(true); //enabled the close button 
    80   }else if(initPorts){ 
    81     initPorts = false; //make sure it doesn't fall into this catch again 
    82     //ports tree initialized successfully - start the fetch process 
    83     ui->textEdit->appendPlainText("\n=============\nFetching the Ports Tree...."); 
    84     bool ok = PROC->startPorts(); 
    85     if(!ok){  
    86       ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports"); 
    87       ui->push_close->setEnabled(true); //they can now close the window 
    88     } 
    89   }else if(initSource){ 
    90     initSource = false; //make sure it doesn't fall into this catch again 
    91     //Source tree initialized successfully - start the fetch process 
    92     ui->textEdit->appendPlainText("\n=============\nFetching the Source Tree...."); 
    93     bool ok = PROC->startPorts(); 
    94     if(!ok){  
    95       ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src"); 
    96       ui->push_close->setEnabled(true); //they can now close the window 
    97     } 
    98   }else{ 
    99     ui->textEdit->appendPlainText("\n=============\nFinished Successfully"); 
    100   } 
    10182} 
    10283 
  • src-qt4/pc-sysmanager/cmdDialog.h

    r6d7b1e6 ra4325b4  
    66#include <QWidget> 
    77 
    8 #include "gitprogress.h" 
     8#include "longProc.h" 
    99 
    1010namespace Ui{ 
     
    2222private: 
    2323        Ui::CMDDialog *ui; 
    24         gitProc *PROC; 
    25         bool initPorts, initSource; //to keep track if only the first step was running 
     24        LongProc *PROC; 
    2625 
    2726private slots: 
    2827        void NewMessage(QString); 
    29         void Finished(bool); 
     28        void Finished(); 
    3029        void CloseUI(); 
    3130}; 
  • src-qt4/pc-sysmanager/pbsystemtab.cpp

    r7cd7e8f ra4325b4  
    2626{ 
    2727    //Grab the username 
    28     username = QString::fromLocal8Bit(getenv("SUDO_USER")); 
    29     qDebug() << "Username:" << username; 
     28    username = QString::fromLocal8Bit(getenv("SUDO_USER")); //since the app is always run as root with sudo 
     29    if(username.isEmpty()){ username = QString::fromLocal8Bit(getenv("LOGNAME")); } //in case SUDO_USER is not set 
     30    //qDebug() << "Username:" << username; 
    3031    // Set the Uname on the General Tab 
    3132    CheckUname(); 
     
    148149        args << SheetFileName; 
    149150        args << username; 
    150         qDebug() << "CMD: " << prog+" "+args.join(" "); 
     151        //qDebug() << "CMD: " << prog+" "+args.join(" "); 
    151152        connect( SheetGenScript, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finishedSheet()) ); 
    152153                 
  • src-qt4/pc-sysmanager/pbsystemtab.ui

    rba438ce ra4325b4  
    660660  <include location="local">qfile.h</include> 
    661661  <include location="local">qsettings.h</include> 
    662   <include location="local">gitprogress.h</include> 
    663662  <include location="global">qregexp.h</include> 
    664663  <include location="global">pcbsd-utils.h</include> 
  • src-qt4/pc-sysmanager/pc-sysmanager.pro

    ra2d9be06 ra4325b4  
    99 
    1010HEADERS += pbsystemtab.h \ 
    11         gitprogress.h \ 
    1211        updaterDialog.h \ 
    13         cmdDialog.h 
     12        cmdDialog.h \ 
     13        longProc.h 
    1414 
    1515SOURCES += main.cpp \ 
    1616        pbsystemtab.cpp \ 
    17         gitprogress.cpp \ 
    1817        updaterDialog.cpp \ 
    19         cmdDialog.cpp 
     18        cmdDialog.cpp \ 
     19        longProc.cpp 
     20         
    2021 
    2122FORMS   = pbsystemtab.ui \ 
    22         gitprogress.ui \ 
    2323        updaterDialog.ui \ 
    2424        cmdDialog.ui 
Note: See TracChangeset for help on using the changeset viewer.