Changeset ffa2c7a


Ignore:
Timestamp:
12/06/13 06:06:00 (11 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
15ea961
Parents:
f112183
Message:

Get the script support added in to the new EasyPBI module backend.

Location:
src-qt4/EasyPBI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/EasyPBI/PBIModule.cpp

    r618dff3 rffa2c7a  
    55    // 10.x PBI format: 12/5/13 
    66  version = "10.x" 
     7  //pbi.conf values 
    78  CTextValues << "PBI_PROGNAME" << "PBI_PROGWEB" << "PBI_PROGAUTHOR" << "PBI_PROGICON" \ 
    89                << "PBI_LICENCE" << "PBI_TAGS" << "PBI_PROGTYPE" << "PBI_ICONURL" << "PBI_CATEGORY" \ 
     
    1011  CBoolValues << "PBI_REQUIRESROOT" << "PBI_AB_NOTMPFS" << "PBI_AB_NOPKGBUILD"; 
    1112  CIntValues << "PBI_BUILDKEY" << "PBI_PROGREVISION" << "PBI_AB_PRIORITY"; 
     13  //Valid Scripts 
     14  scriptValues << "pre-pbicreate.sh" << "pre-install.sh" << "post-install.sh" << "pre-remove.sh"; 
     15         
    1216  HASH.clear(); //Make sure the hash is currently empty 
    1317} 
     
    182186//     SCRIPTS 
    183187// ========== 
    184          
     188QStringList PBIModule::readScript(QString var){ 
     189  QStringList out; 
     190  if( scriptValues.contains(var) || QFile:exists(basePath+"/scripts/"+var) ){ 
     191    out = readFile(basePath+"/scripts/"+var); 
     192  }        
     193  return out; 
     194} 
     195 
     196bool PBIModule::writeScript(QString var,QStringList val){ 
     197  bool ok = false; 
     198  if( scriptValues.contains(var) || QFile:exists(basePath+"/scripts/"+var) ){ 
     199    ok = createFile(basePath+"/scripts/"+var, val); 
     200  } 
     201  return ok; 
     202} 
     203 
     204QStringList PBIModule::validScripts(){ 
     205  return scriptValues; 
     206} 
     207 
     208QStringList PBIModule::existingScripts(){ 
     209  QStringList out; 
     210  QDir dir(basePath+"/scripts"); 
     211  if(dir.exists()){ 
     212    out = dir.entryList(QStringList() << "*.sh", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); 
     213  } 
     214  return out; 
     215} 
     216 
    185217// ============= 
    186218//      RESOURCES 
     
    201233//fileName = full path to file (I.E. /home/pcbsd/junk/junk.txt) 
    202234//contents = list of lines to be written (one line per entry in the list - no newline needed at the end of an entry) 
     235         
     236  //Check if this is actually a file removal 
     237  if(contents.isEmpty() && QFile::exists(fileName)){ 
     238    bool good = QFile::remove(fileName); 
     239    if(!good){ 
     240      qDebug() << fileName+": Could not be deleted"; 
     241    } 
     242    return good; 
     243  } 
     244   
    203245  //Check that the parent directory exists, and create it if necessary 
    204246  QDir dir(fileName); 
     
    240282  //Return success 
    241283  QString extra = QDir::homePath(); //remove this from the filename display 
    242   qDebug() << "Created:" << fileName.replace(extra,"~"); 
     284  qDebug() << "Saved:" << fileName.replace(extra,"~"); 
    243285  return true;; 
    244286} 
     
    248290  //Check that the file exists first 
    249291  if(!QFile::exists(filePath)){  
    250     qDebug() << "Error: file to read does not exist:" << filePath; 
     292    qDebug() << "Warning: file to read does not exist:" << filePath; 
    251293    return contents;  
    252294  } 
  • src-qt4/EasyPBI/PBIModule.h

    r618dff3 rffa2c7a  
    5454private: 
    5555        QHash<QString, QVariant> HASH; 
    56         QStringList CTextValues, CBoolValues, CIntValues; 
     56        QStringList CTextValues, CBoolValues, CIntValues, scriptValues; 
    5757        QString basePath, version; 
    5858 
Note: See TracChangeset for help on using the changeset viewer.