コード例 #1
0
ファイル: pbiNgBackend.cpp プロジェクト: prodigeni/pcbsd
void PBIBackend::installApp(QStringList appID, QString injail){
  qDebug() << "Install App requested for:" << appID;
  bool jailok = RUNNINGJAILS.contains(injail) && JAILPKGS.contains(injail);
  for(int i=0; i<appID.length(); i++){
    NGApp app;
    if(APPHASH.contains(appID[i])){ app = APPHASH[appID[i]]; }
    else if(PKGHASH.contains(appID[i])){ app = PKGHASH[appID[i]]; }
    else{
      qDebug() << appID[i] << "is not a valid application";
      continue; //go to the next item is this one is invalid
    } 
    bool jailpkgok = false;
    if(jailok){ jailpkgok = !JAILPKGS[injail].contains(app.origin); }
    if( !app.isInstalled || jailpkgok ){
      queueProcess(appID[i], true, injail);
      emit PBIStatusChange(appID[i]);
    }else{
      qDebug() << appID[i] << "is already installed!";
    }
  } // end of loop over items
  //Now check/start the remove process
  QTimer::singleShot(0,this,SLOT(checkProcesses()) );
  //Now emit the signal that items have changed or been added
  emit LocalPBIChanges();
}
コード例 #2
0
ファイル: pbiNgBackend.cpp プロジェクト: prodigeni/pcbsd
void PBIBackend::removePBI(QStringList appID, QString injail){
  qDebug() << "PBI Removals requested for:" << appID;
  bool jailok = RUNNINGJAILS.contains(injail) && JAILPKGS.contains(injail);
  QStringList cancelList;
  for(int i=0; i<appID.length(); i++){
    NGApp app;
    if(APPHASH.contains(appID[i])){ app = APPHASH[appID[i]]; }
    else if(PKGHASH.contains(appID[i])){ app = PKGHASH[appID[i]]; }
    else{ continue; }
    bool jailpkgok = false;
    if(jailok){ jailpkgok = !JAILPKGS[injail].contains(app.origin); }
      if( (!app.isInstalled && !jailok) || jailpkgok ){
	//Not a fully-installed PBI - cancel it instead (probably pending)
	qDebug() << jailok << jailpkgok << appID[i];
	cancelList << appID[i];
      }else if( BASELIST.contains(appID[i]) ){
	qDebug() << "PC-BSD base dependency:" << appID[i] << " - cannot remove";	      
      }else{
	queueProcess(appID[i], false, injail);
        emit PBIStatusChange(appID[i]);
      }
  }
  //If there are PBIs to cancel, do that too
  if(!cancelList.isEmpty()){ cancelActions(cancelList); }
  //Now check/start the remove process
  QTimer::singleShot(0,this,SLOT(checkProcesses()) );
}
コード例 #3
0
ファイル: pbiNgBackend.cpp プロジェクト: KhuramAli/pcbsd
 // ===============================
 // ======   PRIVATE SLOTS   ======
 // ===============================
 // Internal Process Management
 void PBIBackend::checkProcesses(){
   //Check whether to startup the next pending process
   if( !PKGRUN.isEmpty() || PENDING.isEmpty() ){ return; } //currently running or nothing to do

   //Parse the next PENDING command
   PKGRUN = PENDING[0].section("::::",0,0);
   PKGCMD = PENDING[0].section("::::",1,1);
   PKGJAIL = PENDING[0].section("::::",2,2);
   PENDING.removeAt(0); //remove this from the pending list
   if( PKGCMD.startsWith("pbi_add") || PKGCMD.startsWith("pc-pkg install") ){ PROCTYPE = 0; } //install
   else if( PKGCMD.startsWith("pbi_delete") || PKGCMD.startsWith("pc-pkg remove") ){ PROCTYPE = 1; } //remove
   else{ PROCTYPE = -1; } //other type of command (no special checks later)
   
   PROCCANCELLED = false;
   PKGRUNSTAT.clear();
   PROCLOG.clear();
   bool injail = !PKGJAIL.isEmpty();
   QHash<QString, NGApp> hash;
   if(JAILPKGS.contains(PKGJAIL) && PKGJAIL!="--newjail"){ hash = JAILPKGS[PKGJAIL]; }
   else if(APPHASH.contains(PKGRUN)){ hash = APPHASH; }
   else if(PKGHASH.contains(PKGRUN)){ hash = PKGHASH; }
   //Check that this is a valid entry/command
   bool skip = false; //need to skip this PENDING entry for some reason
   if( hash.isEmpty() ){ skip = true; qDebug() << PKGRUN+":" << "pkg not on repo";} //invalid pkg on the repo
   else if( PROCTYPE==0 && hash.value(PKGRUN).isInstalled && PKGJAIL!="--newjail"){ skip = true; qDebug() << PKGRUN+":"  << "already installed"; } //already installed
   else if( PROCTYPE==1 && !hash.value(PKGRUN).isInstalled ){ skip = true; qDebug() << PKGRUN+":"  << "already uninstalled"; } //not installed
   if(skip){
    qDebug() << "Requested Process Invalid:" << PKGRUN << PKGCMD;
    emit PBIStatusChange(PKGRUN);
    PKGRUN.clear();
    PKGCMD.clear();
    QTimer::singleShot(1,this,SLOT(checkProcesses()) ); //restart this function to check the next command
    return;
   }
   //Now run any pre-remove commands (if not an in-jail removal, or raw pkg mode)
   if(PROCTYPE==1 && !injail && PKGCMD.startsWith("pc-pkg ") ){
     Extras::getCmdOutput("pbi_icon del-desktop del-menu del-mime "+PKGRUN); //don't care about result
   }else if( PROCTYPE==0 && injail && RUNNINGJAILS.contains(PKGJAIL) && PKGJAIL!="--newjail"){
     //For installations, make sure the jail pkg config is synced with the current system pkg config
     qDebug() << "Syncing pkg config in jail:" << PKGJAIL;
     emit devMessage( "** Syncing pkg config in jail: " +PKGJAIL+" **" );
     Extras::getCmdOutput("pc-updatemanager -j "+RUNNINGJAILS[PKGJAIL]+" syncconf");
   }
   qDebug() << "Starting Process:" << PKGRUN << PKGCMD;
   //Set the new status
   if(PROCTYPE==0){ PKGRUNSTAT=tr("Starting Installation"); }
   else if(PROCTYPE==1){ PKGRUNSTAT=tr("Starting Removal"); }
   else{ PKGRUNSTAT.clear(); }
   emit PBIStatusChange(PKGRUN);
   
   //Now start the command
   emit devMessage( "** Starting Process: \""+PKGCMD+"\" **" );
   pkgProc->start(PKGCMD);

}
コード例 #4
0
ファイル: pbiNgBackend.cpp プロジェクト: KhuramAli/pcbsd
void PBIBackend::installAppIntoJail(QString appID){
  NGApp app;
    if(APPHASH.contains(appID)){ app = APPHASH[appID]; }
    else if(PKGHASH.contains(appID)){ app = PKGHASH[appID]; }
    else{ qDebug() << "Invalid application ID:" << appID; return; }
  if(app.pbiorigin.isEmpty()){
    qDebug() << "Installing into a new jail only works with PBI's!!";
    return;
  }
  PENDING << appID+"::::"+"pbi_add -J "+appID+"::::--newjail";
  //Now check/start the process
  QTimer::singleShot(0,this,SLOT(checkProcesses()) );
}
コード例 #5
0
ファイル: pbiNgBackend.cpp プロジェクト: KhuramAli/pcbsd
void PBIBackend::procFinished(int ret, QProcess::ExitStatus stat){
  emit devMessage("** Process Finished **");
  if(stat != QProcess::NormalExit){
    //Process Crashed
    emit Error(tr("Process Crashed"), QString(tr("The process for %1 has quit unexpectedly. Please restart this operation at a later time.")).arg(PKGRUN), PROCLOG);
  }else if( ret != 0 ){
    //Failure
    QString title, msg;
      if(PROCTYPE==0){ 
	title = tr("Installation Failure"); 
	msg = QString(tr("The following application installation experienced an error: %1")+"\n\n"+tr("Please try again later.")).arg(APPHASH[PKGRUN].name);
      }else if(PROCTYPE==1){ 
	title = tr("Removal Failure"); 
	msg = QString(tr("The following application removal experienced an error: %1")+"\n\n"+tr("Please try again later.")).arg(APPHASH[PKGRUN].name);
      }
      if(!msg.isEmpty()){ emit Error(title, msg, PROCLOG); }
  }else{
    //Success - perform any cleanup operations
    if(PROCTYPE==0 && PKGCMD.contains("pbi_") && !PROCCANCELLED && PKGJAIL.isEmpty()){ //if new installation on main system
      Extras::getCmdOutput("pbi_icon add-menu add-mime "+PKGRUN); //don't care about result
      if(autoDE && APPHASH[PKGRUN].hasDE){ runCmdAsUser("pbi_icon add-desktop "+PKGRUN); }
    }else if(PROCTYPE==0 && PKGCMD.contains("pc-pkg ") && !PROCCANCELLED && PKGJAIL.isEmpty()){
      Extras::getCmdOutput("pc-extractoverlay ports"); //make sure to extract the ports overlay after a pkg operation
    }
	  
  }
  //Now clean up the process variables and update the app status
  if(PKGJAIL.isEmpty()){
    //update the local system info
    slotSyncToDatabase(true);
  }else if(PKGJAIL=="--newjail"){
    //Find the new jail
    checkForJails();
    emit JailListChanged();
  }else{
    //Just update the pkg list for this particular jail
    checkForJails(PKGJAIL);
  }
  QString origin = PKGRUN; //temporary
  PKGCMD.clear();
  PKGRUN.clear();
  PKGJAIL.clear();
  //Emit the proper signals
  emit PBIStatusChange(origin);
  emit LocalPBIChanges(); //so that it knows to look for a different install list
  //Now check for the next command to run
  QTimer::singleShot(1, this, SLOT(checkProcesses()) );
}
コード例 #6
0
ファイル: pbiNgBackend.cpp プロジェクト: prodigeni/pcbsd
void PBIBackend::unlockApp(QStringList appID, QString injail){
  QHash<QString, NGApp> hash;
  if(JAILPKGS.contains(injail)){ hash = JAILPKGS[injail]; }
  for(int i=0; i<appID.length(); i++){
    NGApp app;
    if(hash.contains(appID[i])){ app = hash[appID[i]]; }
    else if(APPHASH.contains(appID[i])){ app = APPHASH[appID[i]]; }
    else if(PKGHASH.contains(appID[i])){ app = PKGHASH[appID[i]]; }
    else{ continue; }
    if(app.isInstalled && app.isLocked){
      //Run lock/unlock commands ASAP since they take no time at all, but have to be in the pkg queue
      QString cmd;
      if(injail.isEmpty() || !RUNNINGJAILS.contains(injail) ){ cmd = "pc-pkg unlock -y "+appID[i]; injail.clear();}
      else{ cmd = "pc-pkg -j "+RUNNINGJAILS[injail]+" unlock -y "+appID[i]; }
      PENDING.prepend(appID[i]+"::::"+cmd+"::::"+injail);
    }
  }
  QTimer::singleShot(0,this,SLOT(checkProcesses()) );	
}