Changeset a4ac142


Ignore:
Timestamp:
08/06/13 10:59:03 (14 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
4f9718b, f615958
Parents:
feb0fb0 (diff), 7369d56 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:pcbsd/pcbsd

Files:
8 edited

Legend:

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

    r71f823e r7369d56  
    13741374      QDir cDir( settings->value("cachedir") ); 
    13751375      QStringList filters = settings->list("skippkgs"); 
    1376       QStringList badFiles = cDir.entryList(filters, QDir::Files | QDir:: NoDotAndDotDot); 
    1377       for(int i=0; i<badFiles.length(); i++){ cDir.remove(badFiles[i]); } 
     1376      if(!filters.isEmpty()){ 
     1377        QStringList badFiles = cDir.entryList(filters, QDir::Files | QDir:: NoDotAndDotDot); 
     1378        for(int i=0; i<badFiles.length(); i++){ cDir.remove(badFiles[i]); } 
     1379      } 
    13781380    } 
    13791381    if( settings->check("usesignature") && QFile::exists(settings->value("sigfile")) ){ cmd += " --sign " + settings->value("sigfile"); } 
     
    14181420  ui->push_build_start->setEnabled(FALSE); //disable the button so they do not start more than 1 build at a time 
    14191421  ui->text_build_log->clear(); //clear the display in case this is not the first run 
    1420   ui->line_build_module->setText(currentModule->path()); 
     1422  ui->line_build_module->setText( currentModule->path().replace(QDir::homePath(), "~") ); 
    14211423  ui->line_build_outputdir->setText(settings->value("pbidir")); 
    14221424  //Setup Process connections 
     
    14581460  if( tmp.startsWith("\n") ){tmp.remove(0,0);} //remove newline at the beginning (too much whitespace in log) 
    14591461  if( tmp.endsWith("\n") ){tmp.chop(1);} //remove newline at the end (already accounted for by appending) 
     1462  //clear the display  if it is starting a new port compilation (prevent the log getting too large) 
     1463  if(tmp.toLower().startsWith("compiling port: ")){ ui->text_build_log->clear(); } 
    14601464  if(!tmp.isEmpty()){ ui->text_build_log->append( tmp ); } 
    14611465  //qDebug() << "Update output: " << tmp; 
  • src-qt4/pc-mounttray/fsDialog.cpp

    r891636a r6edfd8a  
    3030      QString name = fsList[i].section("::",0,0); 
    3131      QString filesystem = fsList[i].section("::",1,1); 
    32       int totalK = fsList[i].section("::",2,2).toInt(); 
    33       int usedK = fsList[i].section("::",3,3).toInt(); 
     32      double totalK = fsList[i].section("::",2,2).toDouble(); 
     33      double usedK = fsList[i].section("::",3,3).toDouble(); 
    3434      int percent = fsList[i].section("::",4,4).toInt(); 
    3535      //Create item for the data 
    3636      QStringList text; //column text 
    37       text << name << filesystem.toUpper() << FSWatcher::intToDisplay(usedK)+"/"+FSWatcher::intToDisplay(totalK) << QString::number(percent)+"%"; 
     37      text << name << filesystem.toUpper() << FSWatcher::doubleToDisplay(usedK)+"/"+FSWatcher::doubleToDisplay(totalK) << QString::number(percent)+"%"; 
    3838      QTreeWidgetItem *tmp = new QTreeWidgetItem(text); 
    3939       
  • src-qt4/pc-mounttray/fsWatcher.cpp

    r781fd04 r6edfd8a  
    3535      QString avail = tmp[1].section(" ",0,0,QString::SectionSkipEmpty); 
    3636      QString used = tmp[1].section(" ",1,1,QString::SectionSkipEmpty); 
    37       int iUsed = displayToInt(used); 
    38       int iTotal = displayToInt(avail) + iUsed; 
     37      double iUsed = floor(displayToDouble(used)); 
     38      double iTotal = floor(displayToDouble(avail)) + iUsed; 
    3939      int percent = calculatePercentage(iUsed, iTotal); 
    4040      //qDebug() << "Percent calc: tot:"<<iTotal<<"used"<<iUsed<<"percent"<<percent; 
     
    6060        QString used = dfout[i].section("  ",3,3,QString::SectionSkipEmpty).simplified(); 
    6161        //Calculate the percent 
    62         int iUsed = displayToInt(used); 
    63         int iTotal = displayToInt(total); 
     62        double iUsed = displayToDouble(used); 
     63        double iTotal = displayToDouble(total); 
    6464        int percent = calculatePercentage(iUsed, iTotal); 
    6565        //qDebug() << "df Item:" << dfout[i]; 
     
    7676} 
    7777 
    78 int FSWatcher::displayToInt(QString entry){ 
     78int FSWatcher::displayToDouble(QString entry){ 
    7979  //split the number from the size label 
    8080  //qDebug() << "Display to Int conversion:" << entry; 
     
    8383  double num = entry.toDouble(); 
    8484  //qDebug() << "initial number:" << num << "units:" << units; 
    85   if(units=="K"){} //Kilobytes (no change) 
    86   else if(units=="M"){ num=num*1024; } //Megabytes to K 
    87   else if(units=="G"){ num=num*1048576; } //Gigabytes to K 
    88   else{ num=0; } //smaller than a KB 
     85  QStringList unitL; unitL << "K" << "M" << "G" << "T" << "P" << "E" << "Z" << "Y"; 
     86  bool ok = false; 
     87  for(int i=0; i< unitL.length(); i++){ 
     88    if(units == unitL[i]){ num = num*pow(1024.0,i); ok = true; break;} 
     89  } 
     90  if(!ok){num=0; } 
    8991  //qDebug() << "number:" << num; 
    9092  return num; 
    9193} 
    9294 
    93 QString FSWatcher::intToDisplay(int K){ 
     95QString FSWatcher::doubleToDisplay(double K){ 
    9496  QString num; 
    9597  //qDebug() << "Int to Display:" << K; 
    9698  double kdb = K; //using pure integers causes errors with large numbers 
    97   if( K > 1048576 ){ num = QString::number( int((kdb*100)/1048576)/100.0 ) +"G"; } 
    98   else if(K > 1024){ num = QString::number( int((kdb*100)/1024)/100.0 ) +"M"; } 
    99   else{ num = QString::number(K) +"K"; } 
     99  QStringList units; units << "K" << "M" << "G" << "T" << "P" << "E" << "Z" << "Y"; 
     100  int i=0; 
     101  while( (kdb > 1000) && (i < 8) ){ 
     102    kdb = kdb/1024; 
     103    i++; 
     104  } 
     105  if(i<8){ 
     106    num = QString::number( int((kdb*100))/100.0) + units[i]; 
     107  }else{ 
     108    num = "??"; 
     109  } 
    100110  //qDebug() << "Display:" << num; 
    101111  return num; 
     
    134144 
    135145//===== Calculate Percentages ===== 
    136 int FSWatcher::calculatePercentage(int used, int total){ 
     146int FSWatcher::calculatePercentage(double used, double total){ 
    137147  double U = used; 
    138148  double T = total; 
  • src-qt4/pc-mounttray/fsWatcher.h

    r781fd04 r6edfd8a  
    1212#include <QTime> 
    1313 
     14#include <math.h> 
    1415 
    1516class FSWatcher : public QObject 
     
    2526   
    2627  static QStringList getFSmountpoints(); 
    27   static QString intToDisplay(int); 
    28   static int displayToInt(QString);  
     28  static QString doubleToDisplay(double); 
     29  static int displayToDouble(QString);  
    2930   
    3031private: 
     
    3334   
    3435  static QStringList runCMD(QString); 
    35   static int calculatePercentage(int,int); 
     36  static int calculatePercentage(double,double); 
    3637   
    3738public slots: 
  • src-sh/lpreserver/backend/functions.sh

    r4e5cced rfeb0fb0  
    1414if [ ! -d "$DBDIR" ] ; then mkdir -p ${DBDIR} ; fi 
    1515CMDLOG="${DBDIR}/lp-lastcmdout" 
     16CMDLOG2="${DBDIR}/lp-lastcmdout2" 
    1617REPCONF="${DBDIR}/replication" 
    1718LOGDIR="/var/log" 
     
    180181  echo "$LDATA:$TIME:$HOST:$USER:$PORT:$RDATA" >> ${REPCONF} 
    181182 
     183  if [ "$TIME" != "sync" ] ; then 
     184    cronscript="${PROGDIR}/backend/runrep.sh" 
     185    cLine="0    $TIME       *       *       *" 
     186    echo -e "$cLine\troot    ${cronscript} ${LDATA}" >> /etc/crontab 
     187  fi 
    182188} 
    183189 
     
    186192  cat ${REPCONF} | grep -v "^${1}:" > ${REPCONF}.tmp 
    187193  mv ${REPCONF}.tmp ${REPCONF} 
    188 } 
    189  
     194 
     195  # Make sure we remove any old replication entries for this dataset 
     196  cronscript="${PROGDIR}/backend/runrep.sh" 
     197  cat /etc/crontab | grep -v " $cronscript $1" > /etc/crontab.new 
     198  mv /etc/crontab.new /etc/crontab 
     199} 
     200 
     201list_rep_task() { 
     202  if [ ! -e "$REPCONF" ] ; then return ; fi 
     203 
     204  echo "Scheduled replications:" 
     205  echo "---------------------------------" 
     206 
     207  while read line 
     208  do 
     209     LDATA=`echo $line | cut -d ':' -f 1` 
     210     TIME=`echo $line | cut -d ':' -f 2` 
     211     HOST=`echo $line | cut -d ':' -f 3` 
     212     USER=`echo $line | cut -d ':' -f 4` 
     213     PORT=`echo $line | cut -d ':' -f 5` 
     214     RDATA=`echo $line | cut -d ':' -f 6` 
     215 
     216     echo "$LDATA -> $USER@$HOST[$PORT]:$RDATA Time: $TIME" 
     217 
     218  done < ${REPCONF} 
     219} 
     220 
     221check_rep_task() { 
     222  export DIDREP=0 
     223  if [ ! -e "$REPCONF" ] ; then return 0; fi 
     224 
     225  repLine=`cat ${REPCONF} | grep "^${1}:"` 
     226  if [ -z "$repLine" ] ; then return 0; fi 
     227 
     228  # We have a replication task for this dataset, lets check if we need to do it now 
     229  LDATA="$1" 
     230  TIME=`echo $repLine | cut -d ':' -f 2` 
     231 
     232  # Export the replication variables we will be using 
     233  export REPHOST=`echo $repLine | cut -d ':' -f 3` 
     234  export REPUSER=`echo $repLine | cut -d ':' -f 4` 
     235  export REPPORT=`echo $repLine | cut -d ':' -f 5` 
     236  export REPRDATA=`echo $repLine | cut -d ':' -f 6` 
     237 
     238  # If we are checking for a sync task, and the rep isn't marked as sync we can return 
     239  if [ "$2" = "sync" -a "$TIME" != "sync" ] ; then return 0; fi 
     240 
     241  # Is this a sync-task we do at the time of a snapshot? 
     242  if [ "$2" = "sync" -a "$TIME" = "sync" ] ; then 
     243     export DIDREP=1 
     244     echo_log "`date`: Starting replication SYNC task on ${DATASET}\n" 
     245     queue_msg "`date`: Starting replication SYNC task on ${DATASET}\n" 
     246     start_rep_task "$LDATA" 
     247     return $? 
     248  else 
     249     # Ready to do a scheduled replication 
     250     export DIDREP=1 
     251     echo_log "`date`: Starting replication SCHEDULED task on ${DATASET}\n" 
     252     queue_msg "`date`: Starting replication SCHEDULED task on ${DATASET}\n" 
     253     start_rep_task "$LDATA" 
     254     return $? 
     255  fi 
     256} 
     257 
     258start_rep_task() { 
     259  LDATA="$1" 
     260 
     261  # Check for the last snapshot marked as replicated already 
     262  lastSEND=`zfs get -r backup:lpreserver ${LDATA} | grep LATEST | awk '{$1=$1}1' OFS=" " | tail -1 | cut -d '@' -f 2 | cut -d ' ' -f 1` 
     263 
     264  # Lets get the last snapshot for this dataset 
     265  lastSNAP=`zfs list -t snapshot -d 1 -H ${LDATA} | tail -1 | awk '{$1=$1}1' OFS=" " | cut -d '@' -f 2 | cut -d ' ' -f 1` 
     266  
     267  if [ "$lastSEND" = "$lastSNAP" ] ; then 
     268     queue_msg "`date`: Last snapshot $lastSNAP is already marked as replicated!" 
     269     return 1 
     270  fi 
     271 
     272  # Starting replication, first lets check if we can do an incremental send 
     273  if [ -n "$lastSEND" ] ; then 
     274     zFLAGS="-Rv -I $lastSEND $LDATA@$lastSNAP" 
     275  else 
     276     zFLAGS="-Rv $LDATA@$lastSNAP" 
     277  fi 
     278 
     279  zSEND="zfs send $zFLAGS" 
     280  zRCV="ssh -p ${REPPORT} ${REPUSER}@${REPHOST} zfs receive -dvuF ${REPRDATA}" 
     281 
     282  queue_msg "Using ZFS send command:\n$zSEND | $zRCV\n\n" 
     283 
     284  # Start up our process 
     285  $zSEND 2>${CMDLOG} | $zRCV >${CMDLOG2} 2>${CMDLOG2} 
     286  zStatus=$? 
     287  queue_msg "ZFS SEND LOG:\n--------------\n`cat ${CMDLOG}`\n\n" 
     288  queue_msg "ZFS RCV LOG:\n--------------\n`cat ${CMDLOG2}`\n\n" 
     289 
     290  if [ $zStatus -eq 0 ] ; then 
     291     # SUCCESS! 
     292     # Lets mark our new latest snapshot and unmark the last one 
     293     zfs set backup:lpreserver=' ' ${LDATA}@$lastSEND 
     294     zfs set backup:lpreserver=LATEST ${LDATA}@$lastSNAP 
     295     echo_log "`date`: Finished replication task on ${DATASET}\n" 
     296  else 
     297     # FAILED :-( 
     298     # Lets save the output for us to look at later 
     299     FLOG=${LOGDIR}/lpreserver_failed.log 
     300     echo "Failed with command:\n$zSEND | $zRCV\n" > ${FLOG} 
     301     echo "\nSending log:\n" >> ${FLOG} 
     302     cat ${CMDLOG} >> ${FLOG} 
     303     echo "\nRecv log:\n" >> ${FLOG} 
     304     cat ${CMDLOG2} >> ${FLOG} 
     305     echo_log "`date`: FAILED replication task on ${DATASET}: LOGFILE: $FLOG\n" 
     306  fi 
     307 
     308  return $zStatus 
     309} 
     310 
     311get_data_props() { 
     312 
     313  # Lets start by building a list of props to keep 
     314  pTag=`echo $DATASET | md5` 
     315 
     316  if [ "$RECURMODE" = "ON" ] ; then 
     317     zfs get -r all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     318  else 
     319     zfs get all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     320  fi 
     321  
     322  cat /tmp/.propList.$$ 
     323  rm /tmp/.propList.$$ 
     324 
     325} 
  • src-sh/lpreserver/backend/runrep.sh

    r9fa96a3 rfeb0fb0  
    1111 
    1212DATASET="${1}" 
     13TIME="${2}" 
    1314 
    1415if [ -z "${DATASET}" ]; then 
     
    1617fi 
    1718 
    18 # Lets start by building a list of props to keep 
    19 pTag=`echo $DATASET | md5` 
     19check_rep_task "$DATASET" "$TIME" 
     20status=$? 
    2021 
    21 if [ "$RECURMODE" = "ON" ] ; then 
    22    zfs get -r all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     22# No replication was needed / done 
     23if [ $DIDREP -eq 0 ] ; then exit 0 ; fi 
     24 
     25if [ $status -eq 0 ] ; then 
     26  title="Success" 
    2327else 
    24    zfs get all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
     28  title="FAILED" 
    2529fi 
    2630 
    27 cat /tmp/.propList.$$ 
    28 rm /tmp/.propList.$$ 
    29  
    30 if [ "$EMAILMODE" = "ALL" ] ; then 
    31    #email_msg "Automated Snapshot" "`echo_queue_msg`" 
    32 fi 
     31case $EMAILMODE in 
     32    ALL) email_msg "Automated Replication - $title" "`echo_queue_msg`" ;; 
     33    *) if [ $status -ne 0 ] ; then 
     34          email_msg "Automated Replication - $title" "`echo_queue_msg`" 
     35       fi 
     36       ;; 
     37esac 
  • src-sh/lpreserver/backend/runsnap.sh

    r0fe982e rfeb0fb0  
    6363   email_msg "Automated Snapshot" "`echo_queue_msg`" 
    6464fi 
     65 
     66# Check if we need to run a replication task for this dataset 
     67${PROGDIR}/backend/runrep.sh ${DATASET} sync 
  • src-sh/lpreserver/lpreserver

    r4e5cced rfeb0fb0  
    375375            case ${1} in 
    376376                add) add_rep_task "$2" "$3" "$4" "$5" "$6" "$7" ;; 
    377                 list) ;; 
     377                list) list_rep_task ;; 
    378378                remove) cat ${REPCONF} | grep -q "^${2}:"  
    379379                        if [ $? -eq 0 ] ; then 
Note: See TracChangeset for help on using the changeset viewer.