Changeset 3855bbf


Ignore:
Timestamp:
12/15/14 10:28:58 (6 days ago)
Author:
Ken Moore <ken@…>
Branches:
master
Children:
a66fe45
Parents:
6384846
Message:

Add some new abilities to syscache regarding available updates:
1) Keep the hasupdates/updatelog options for overarching/raw usage
2) Make the needsreboot flag check at that time instead of using a cached value (simple flag check)
3) Add an "isupdating" option which also performs an instant check for the updating system flag
4) Parse the raw updatelog during a sync into different categories: "major", "security", and "pcbsd". These distinct types of updates are available through new flags: has[major/security/pcbsd]updates (true/false), and [major/security/pcbsd]updatelog for the info about those types of updates.

Location:
src-sh/syscache
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-sh/syscache/client/main.cpp

    rf2c507b r3855bbf  
    187187Usage:\n\ 
    188188  syscache startsync    -> Manually start a system information sync (usually unnecessary) \n\ 
    189   syscache hasupdates   -> [true/false] See whether FreeBSD system updates are available \n\ 
    190189  syscache needsreboot  -> [true/false] See whether the system needs to reboot to finish updates \n\ 
    191   syscache updatelog    -> Raw text output from the check for system updates\n\ 
     190  syscache isupdating   -> [true/false] See whether the system is currently performing updates \n\ 
     191  syscache hasupdates   -> [true/false] See whether any system updates are available \n\ 
     192  syscache updatelog    -> Raw text output from the check for system updates \n\ 
     193  syscache hasmajorupdates      -> [true/false] See whether major FreeBSD system updates are available \n\ 
     194  syscache majorupdatelog       -> Details about the major update(s)\n\ 
     195  syscache hassecurityupdates   -> [true/false] See whether FreeBSD security updates are available \n\ 
     196  syscache securityupdatelog    -> Details about any security update(s)\n\ 
     197  syscache haspcbsdupdates      -> [true/false] See whether any special PC-BSD hotfixes are available \n\ 
     198  syscache pcbsdupdatelog       -> Details about any PC-BSD hotfixes\n\ 
    192199\n\ 
    193200  syscache \"<DB request 1>\" \"<DB request 2>\" [etc] \n\ 
  • src-sh/syscache/daemon/DB.cpp

    r3b3ff1e r3855bbf  
    3131#define LISTDELIMITER QString("::::") 
    3232#define LOCALSYSTEM QString("**LOCALSYSTEM**") 
     33#define REBOOT_FLAG QString("/tmp/.rebootRequired") 
     34#define UPDATE_FLAG_CHECK QString("pgrep -F /tmp/.updateInProgress") //returns 0 if active 
    3335 
    3436DB::DB(QObject *parent) : QObject(parent){ 
     
    9092    if(request[0]=="startsync"){ kickoffSync(); return "Starting Sync..."; } 
    9193    else if(request[0]=="hasupdates"){ hashkey = "System/hasUpdates"; } 
    92     else if(request[0]=="needsreboot"){ hashkey = "System/needsReboot"; } 
     94    else if(request[0]=="needsreboot"){ return (QFile::exists(REBOOT_FLAG) ? "true": "false"); } 
     95    else if(request[0]=="isupdating"){ return ( (QProcess::execute(UPDATE_FLAG_CHECK)==0) ? "true": "false"); } 
    9396    else if(request[0]=="updatelog"){ hashkey = "System/updateLog"; } 
     97    else if(request[0]=="hasmajorupdates"){ hashkey = "System/hasMajorUpdates"; } 
     98    else if(request[0]=="majorupdatelog"){ hashkey = "System/majorUpdateDetails"; } 
     99    else if(request[0]=="hassecurityupdates"){ hashkey = "System/hasSecurityUpdates"; } 
     100    else if(request[0]=="securityupdatelog"){ hashkey = "System/securityUpdateDetails"; } 
     101    else if(request[0]=="haspcbsdupdates"){ hashkey = "System/hasPCBSDUpdates"; } 
     102    else if(request[0]=="pcbsdupdatelog"){ hashkey = "System/pcbsdUpdateDetails"; } 
    94103  }else if(request.length()==2){ 
    95104    if(request[0]=="jail"){ 
     
    10051014    //Save the raw output for later 
    10061015    HASH->insert("System/updateLog", info.join("<br>")); 
     1016    //Determine the number/types of updates listed 
     1017    QStringList ups; 
     1018    QString cup; 
     1019    for(int i=0; i<info.length(); i++){ 
     1020      if(cup.isEmpty() && info[i].contains("NAME: ") ){ 
     1021         //Starting a new update  
     1022         cup = info[i];      
     1023      }else if(!cup.isEmpty()){ 
     1024        //in the middle up an update - add the text 
     1025        cup.append("\n"+info[i]); 
     1026        if(info[i].contains("To install: ") || info[i].startsWith("Install: \"") ){ //last line of text for this update 
     1027          ups << cup; //save the complete entry to the array 
     1028          cup.clear(); //Clear it for the next one 
     1029        } 
     1030      } 
     1031    } 
     1032    //Now go through all the types of update and set flags appropriately 
     1033    // - Major system updates (10.0 -> 10.1 for example) 
     1034    QStringList tmp = ups.filter("TYPE: SYSUPDATE"); 
     1035    HASH->insert("System/hasMajorUpdates", !tmp.isEmpty() ? "true": "false" ); 
     1036    HASH->insert("System/majorUpdateDetails", tmp.join("\n----------\n").replace("\n","<br>") ); 
     1037    // - (Ignore package updates  - already taken care of with pkg details itself) 
     1038    tmp = ups.filter("pc-updatemanager pkgupdate"); 
     1039    for(int i=0; i<tmp.length(); i++){ 
     1040      ups.removeAll(tmp[i]); //Remove these updates from the total list 
     1041    } 
     1042    // - Freebsd/security updates 
     1043    tmp = ups.filter("TYPE: System Update"); 
     1044    HASH->insert("System/hasSecurityUpdates", !tmp.isEmpty() ? "true": "false" ); 
     1045    HASH->insert("System/securityUpdateDetails", tmp.join("\n----------\n").replace("\n","<br>") ); 
     1046    // - PC-BSD patches 
     1047    tmp = ups.filter("TYPE: PATCH"); 
     1048    HASH->insert("System/hasPCBSDUpdates", !tmp.isEmpty() ? "true": "false" ); 
     1049    HASH->insert("System/pcbsdUpdateDetails", tmp.join("\n----------\n").replace("\n","<br>") ); 
     1050 
    10071051    //Now save whether updates are available 
    1008     bool hasupdates = (info.filter("Install: \"").length() > 0); 
     1052    bool hasupdates = ups.length() > 0; 
    10091053    HASH->insert("System/hasUpdates", hasupdates ? "true": "false" ); 
     1054 
     1055    //Now save the last time this was updated 
    10101056    HASH->insert("System/lastSyncTimeStamp", QString::number(QDateTime::currentMSecsSinceEpoch()) ); 
    10111057  } 
    1012   //Always update the needs reboot flag (no time at all) 
    1013   HASH->insert("System/needsReboot", QFile::exists("/tmp/.rebootRequired") ? "true": "false"); 
    10141058} 
    10151059 
Note: See TracChangeset for help on using the changeset viewer.