Salome HOME
Set default path to save an installation log equal to a target directory path instead...
[tools/install.git] / src / SALOME_InstallWizard.cxx
index ac09dffa59ebebc0f808a710c37412e5b371cb5a..403011e029bb825f76441bf6ba3c52dd7f6e9ae9 100644 (file)
@@ -511,10 +511,10 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName,
   addLogo( pixmap( pxLogo ) );
 
   // set defaults
-  setVersion( "3.2.6" );
+  setVersion( "3.2.7" );
   setCaption( tr( "SALOME %1" ).arg( myVersion ) );
   setCopyright( tr( "Copyright (C) 2007 CEA" ) );
-  setLicense( tr( "All right reserved" ) );
+  setLicense( tr( "All rights reserved." ) );
 
   ___MESSAGE___( "Configuration file : " << xmlFileName.latin1() );
   ___MESSAGE___( "Target directory   : " << myTargetPath.latin1() );
@@ -533,6 +533,10 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName,
   // create instance of class for starting shell install script
   shellProcess = new QProcess( this, "shellProcess" );
 
+  // create instance of class for starting shell script to check Fortran libraries
+  checkFLibProc = new QProcess( this, "checkFLibProc" );
+  connect(checkFLibProc, SIGNAL( processExited() ), this, SLOT( checkFLibResult() ) );
+
   // create introduction page
   setupIntroPage();
   // create page to select installation type
@@ -903,10 +907,11 @@ void SALOME_InstallWizard::setupTypePage()
   QLabel* srcCompileLab3 = new QLabel( " " + 
                                       tr( "it is a long time operation and it can take more than 24 hours depending\n on the computer." ), 
                                       buttonGrp );
-  removeSrcBtn = new QMyCheckBox( tr( "Remove sources and temporary files after compilation" ), typePage );
+  removeSrcBtn = new QCheckBox( tr( "Remove sources and temporary files after compilation" ), typePage );
   setAboutInfo( removeSrcBtn, tr( "Check this option if you want to remove sources of the products\nwith all the temporary files after build finishing" ) );
-  removeSrcBtn->setState( QButton::Off );
+  removeSrcBtn->setChecked( false );
   removeSrcBtn->setEnabled( false );
+  rmSrcPrevState = removeSrcBtn->isChecked();
 
   srcCompileLayout->addMultiCellWidget( srcCompileBtn,  0, 0, 0, 2 );
   srcCompileLayout->addMultiCell      ( spacer6,        1, 2, 0, 0 );
@@ -926,7 +931,6 @@ void SALOME_InstallWizard::setupTypePage()
   pageLayout->addWidget( buttonGrp, 0, 0 );
   // connecting signals
   connect( buttonGrp, SIGNAL( clicked(int) ), this, SLOT ( onButtonGroup(int) ) );
-  connect( removeSrcBtn,  SIGNAL( toggled( bool ) ), this, SLOT( onRemoveSrcBtn() ) );
   // adding page
   addPage( typePage, tr( "Installation type" ) );
 }
@@ -1319,11 +1323,6 @@ void SALOME_InstallWizard::showChoiceInfo()
   item = (QCheckListItem*)( prereqsView->firstChild() );
   while( item ) {
     if ( productsMap.contains( item ) ) {
-      if ( productsMap[ item ].hasType( "salome sources" ) || 
-          productsMap[ item ].hasType( "salome binaries" ) ) {
-       item = (QCheckListItem*)( item->nextSibling() );
-       continue; // skip SALOME sources and binaries
-      }
       if ( item->isOn() ) {
        text += "<li><b>" + item->text() + " " + productsMap[ item ].getVersion() + "</b><br>";
        nbProd++;
@@ -1489,7 +1488,7 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
     // ########## check if any products are selected to be installed
     long totSize, tempSize;
     bool anySelected = checkSize( &totSize, &tempSize );
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On ) {
+    if ( installType == Compile && removeSrcBtn->isOn() ) {
       totSize += tempSize;
     }
     if ( !anySelected ) {
@@ -1517,7 +1516,7 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
                              QMessageBox::NoButton );
       return false;
     }
-    // AKL: 13/08/07 - skip tmp disk space checking (all files are unpucked into installation directory) ==>
+    // AKL: 13/08/07 - skip tmp disk space checking (all files are unpacked into installation directory) ==>
     /*
     // run script that check available disk space for temporary files
     // returns 1 in case of error
@@ -1537,7 +1536,7 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
       return false;
       }
     */
-    // AKL: 13/08/07 - skip tmp disk space checking (all files are unpucked into installation directory) <==
+    // AKL: 13/08/07 - skip tmp disk space checking (all files are unpacked into installation directory) <==
 
     // ########## check installation scripts
     QCheckListItem* item;
@@ -1622,17 +1621,14 @@ bool SALOME_InstallWizard::checkSize( long* totSize, long* tempSize )
     Dependancies dep = mapIter.data();
     if ( !item->isOn() )
       continue;
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On )
-      tots += dep.getSize( Binaries );
-    else
-      tots += dep.getSize( installType );
+    tots += ( QStringList::split( " ", item->text(1) )[0] ).toLong();
     maxSrcTmp = max( maxSrcTmp, dep.getSize( Compile ) - dep.getSize( Binaries ) );
     temps += dep.getTempSize( installType );
     nbSelected++;
   }
 
   if ( totSize )
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On )
+    if ( installType == Compile && removeSrcBtn->isOn() )
       temps += maxSrcTmp;
     *totSize = tots;
   if ( tempSize )
@@ -1651,6 +1647,71 @@ void SALOME_InstallWizard::updateAvailableSpace()
     availableSize->setText( diskSpaceProc->readLineStdout() + " KB");
 }
 // ================================================================
+/*!
+ *  SALOME_InstallWizard::checkFLibResult
+ *  Slot to take result of Fortran libraries checking
+ */
+// ================================================================
+void SALOME_InstallWizard::checkFLibResult()
+{
+  if ( checkFLibProc->normalExit() && checkFLibProc->exitStatus() == 1 ) {
+    QStringList notFoundLibsList;
+    QString record = "";
+    while ( checkFLibProc->canReadLineStdout() ) {
+      record = checkFLibProc->readLineStdout();
+      if ( !record.isEmpty() && !notFoundLibsList.contains( record ) )
+       notFoundLibsList.append( record );
+    }
+    QMessageBox::warning( this,
+                         tr( "Warning" ),
+                         tr( "The following libraries are absent on current system:\n"
+                         "%1").arg( notFoundLibsList.join( "\n" ) ),
+                         QMessageBox::Ok,
+                         QMessageBox::NoButton,
+                         QMessageBox::NoButton );
+  }
+  // Update GUI and check installation errors
+  completeInstallation();
+}
+// ================================================================
+/*!
+ *  SALOME_InstallWizard::updateSizeColumn
+ *  Sets required size for each product according to 
+ *  installation type and 'Remove SRC & TMP' checkbox state
+ */
+// ================================================================
+void SALOME_InstallWizard::updateSizeColumn()
+{
+  long prodSize = 0;
+  bool removeSrc = removeSrcBtn->isChecked();
+  MapProducts::Iterator mapIter;
+  for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
+    QCheckListItem* item = mapIter.key();
+    Dependancies dep = mapIter.data();
+    // get required size for current product
+    long binSize = dep.getSize( Binaries );
+    long srcSize = dep.getSize( Sources );
+    long bldSize = dep.getSize( Compile );
+    InstallationType instType = getInstType();
+    if ( instType == Binaries ) {
+      if ( dep.getType() == "component" )
+       prodSize = binSize + srcSize;
+      else
+       prodSize = ( binSize != 0 ? binSize : srcSize );
+    }
+    else if ( instType == Sources )
+      prodSize = srcSize;
+    else
+      if ( removeSrc )
+       prodSize = ( binSize != 0 ? binSize : srcSize );
+      else {
+       prodSize = ( bldSize != 0 ? bldSize : srcSize );
+      }
+    // fill in 'Size' field
+    item->setText( 1, QString::number( prodSize )+" KB" );
+  }
+}
+// ================================================================
 /*!
  *  SALOME_InstallWizard::checkProductPage
  *  Checks products page validity (directories and products selection) and
@@ -1761,7 +1822,6 @@ void SALOME_InstallWizard::unsetPrerequisites( QCheckListItem* item )
        if ( itProd1.data().getType() == "prerequisite" ) {
          MapProducts::Iterator itProd2;
          for ( itProd2 = productsMap.begin(); itProd2 != productsMap.end(); ++itProd2 ) {
-           //      if ( itProd2.data().getType() == "component" ) {
            if ( itProd2.key()->isOn() ) {
              QStringList prereqsList = productsMap[ itProd2.key() ].getDependancies();
              for ( int k = 0; k < (int)prereqsList.count(); k++ ) {
@@ -1870,7 +1930,7 @@ void SALOME_InstallWizard::launchScript()
     // ... sources directory
     shellProcess->addArgument( QDir::cleanDirPath( getSrcPath() ) );
     // ... remove sources and tmp files or not?
-    if ( installType == Compile && removeSrcBtn->state() == QButton::On )
+    if ( installType == Compile && removeSrcBtn->isOn() )
       shellProcess->addArgument( "TRUE" );
     else 
       shellProcess->addArgument( "FALSE" );
@@ -1912,6 +1972,34 @@ void SALOME_InstallWizard::launchScript()
       }
     }
   }
+  
+  if ( installType == Binaries ) {
+    // Check Fortran libraries
+    // ... update status label
+    statusLab->setText( tr( "Check Fortran libraries..." ) );
+    // ... search "not found" libraries
+    checkFLibProc->setWorkingDirectory( QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() ) );
+    checkFLibProc->addArgument( "checkFortran.sh" );
+    checkFLibProc->addArgument( "find_libraries" );
+    checkFLibProc->addArgument( QDir::cleanDirPath( QFileInfo( targetFolder->text().stripWhiteSpace() ).absFilePath() ) );
+    // ... run script
+    if ( !checkFLibProc->start() ) {
+      ___MESSAGE___( "Error: process could not start!" );
+    }
+  }
+  else
+    // Update GUI and check installation errors
+    completeInstallation();
+  
+}
+// ================================================================
+/*!
+ *  SALOME_InstallWizard::completeInstallation
+ *  Update GUI and check installation errors
+ */
+// ================================================================
+void SALOME_InstallWizard::completeInstallation()
+{
   // update status label
   statusLab->setText( tr( "Installation completed" ) );
   // <Next> button
@@ -1944,6 +2032,7 @@ void SALOME_InstallWizard::launchScript()
       saveLog();
   }
   hasErrors = false;
+
 }
 // ================================================================
 /*!
@@ -1962,7 +2051,8 @@ void SALOME_InstallWizard::onInstallGuiBtn()
       }
       else {
        QString itemName = itProd.data().getName();
-       if ( itemName != "KERNEL" && itemName != "MED" && itemName != "SAMPLES" ) {
+       if ( itemName != "KERNEL" && itemName != "MED" && 
+            itemName != "SAMPLES" && itemName != "DOCUMENTATION" ) {
          itProd.key()->setOn( false );
          itProd.key()->setEnabled( false );
        }
@@ -2171,7 +2261,7 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
     if ( buttonGrp->id( buttonGrp->selected() ) == -1 )
       binBtn->animateClick(); // set default installation type
   }
-  if ( aPage == platformsPage ) {
+  else if ( aPage == platformsPage ) {
     // installation platforms page
     MapXmlFiles::Iterator it;
     if ( previousPage == typePage ) {
@@ -2208,6 +2298,8 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
       if ( tempFolder->text().isEmpty() )
        parser->setTempDir( tempFolder );
       parser->readXmlFile( xmlFileName );
+      // update required size for each product
+      updateSizeColumn();
       // take into account command line parameters
       if ( !myTargetPath.isEmpty() )
        targetFolder->setText( myTargetPath );
@@ -2219,6 +2311,11 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
       if ( modulesView->childCount() > 0 && !modulesView->selectedItem() )
        modulesView->setSelected( modulesView->firstChild(), true );
       stateChanged = false;
+    } 
+    else if ( rmSrcPrevState != removeSrcBtn->isChecked() ) {
+      // only update required size for each product
+      updateSizeColumn();
+      rmSrcPrevState = removeSrcBtn->isChecked();
     }
   }
   else if ( aPage == productsPage ) {
@@ -2291,7 +2388,7 @@ void SALOME_InstallWizard::onButtonGroup( int rbIndex )
   else if ( aPage == platformsPage ) {
     refPlatform = platBtnGrp->find( rbIndex )->name();
     xmlFileName = platformsMap[ refPlatform ];
-    cout << xmlFileName << endl;
+//     cout << xmlFileName << endl;
     setNextEnabled( platformsPage, true );
   }
   if ( prevType != installType || 
@@ -2364,7 +2461,6 @@ void SALOME_InstallWizard::directoryChanged( const QString& /*text*/ )
 // ================================================================
 void SALOME_InstallWizard::onStart()
 {
-  cout << "" << endl;
   if ( nextButton()->text() == tr( "&Stop" ) ) {
     statusLab->setText( tr( "Aborting installation..." ) );
     shellProcess->kill();
@@ -2372,6 +2468,7 @@ void SALOME_InstallWizard::onStart()
     statusLab->setText( tr( "Installation has been aborted by user" ) );
     return;
   }
+
   hasErrors = false;
   progressView->clear();
   installInfo->clear();
@@ -2379,6 +2476,7 @@ void SALOME_InstallWizard::onStart()
   passedParams->clear();
   passedParams->setEnabled( false );
   QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
+
   // update status label
   statusLab->setText( tr( "Preparing for installation..." ) );
   // clear lists of products
@@ -2408,6 +2506,42 @@ void SALOME_InstallWizard::onStart()
   }
   // if something at all is selected
   if ( (int)toInstall.count() > 1 ) {
+
+    if ( installType == Compile ) {
+      // update status label
+      statusLab->setText( tr( "Check Fortran compiler..." ) );
+      // check Fortran compiler.
+      QString script = "./config_files/checkFortran.sh find_compilers";
+      script += " " + QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() );
+      ___MESSAGE___( "script = " << script.latin1() );
+      if ( system( script ) ) {
+       QMessageBox::critical( this,
+                              tr( "Error" ),
+                              tr( "Fortran compiler was not found at current system!\n"
+                                  "Installation can not be continued!"),
+                              QMessageBox::Ok,
+                              QMessageBox::NoButton,
+                              QMessageBox::NoButton );
+       // installation aborted
+       abort();
+       statusLab->setText( tr( "Installation has been aborted" ) );
+       // enable <Next> button
+       setNextEnabled( true );
+       nextButton()->setText( tr( "&Start" ) );
+       setAboutInfo( nextButton(), tr( "Start installation process" ) );
+       // reconnect Next button - to use it as Start button
+       disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
+       disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
+       connect(    this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
+       // enable <Back> button
+       setBackEnabled( true );
+       return;
+      }
+    }  
+    
+    // update status label
+    statusLab->setText( tr( "Preparing for installation..." ) );
+
     clean(false); // VSR 07/02/05 - bug fix: first we should clear temporary directory
     // disable <Next> button
     //setNextEnabled( false );
@@ -2525,7 +2659,7 @@ void SALOME_InstallWizard::productInstalled()
   }
   else {
     ___MESSAGE___( "...abnormal exit" );
-    statusLab->setText( tr( "Script is not completed and installation has been aborted" ) );
+    statusLab->setText( tr( "Installation has been aborted" ) );
     // installation aborted
     abort();
     // clear script passed parameters lineedit
@@ -2596,6 +2730,7 @@ void SALOME_InstallWizard::onCancel()
 /*!
  *  SALOME_InstallWizard::onSelectionChanged
  *  Called when selection is changed in the products list view
+ *  to fill in the 'Information about product' text box
  */
 // ================================================================
 void SALOME_InstallWizard::onSelectionChanged()
@@ -2604,11 +2739,9 @@ void SALOME_InstallWizard::onSelectionChanged()
   QListViewItem* item = modulesView->selectedItem();
   if ( snd == prereqsView )
     item = prereqsView->selectedItem();
-  else if ( snd != modulesView )
-    return;
-  productInfo->clear();
   if ( !item )
     return;
+  productInfo->clear();
   QCheckListItem* anItem = (QCheckListItem*)item;
   if ( !productsMap.contains( anItem ) )
     return;
@@ -2620,14 +2753,13 @@ void SALOME_InstallWizard::onSelectionChanged()
   if ( !dep.getDescription().isEmpty() ) {
     text += "<i>" + dep.getDescription() + "</i><br><br>";
   }
-  long totSize = 0, tempSize = 0;
-  if ( installType == Compile && removeSrcBtn->state() == QButton::On )
-    totSize = dep.getSize( Binaries );
-  else
-    totSize = dep.getSize( installType );
-  tempSize = dep.getTempSize( installType );
-  text += tr( "Disk space required" ) + ": " + QString::number( totSize ) + " KB<br>";
-  text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " KB<br>";
+  /* AKL: 07/08/28 - hide required disk space for tmp files for each product ==>
+     long tempSize = 0;
+     tempSize = dep.getTempSize( installType );
+     text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " KB<br>";
+     AKL: 07/08/28 - hide required disk space for tmp files for each product <==
+  */
+  text += tr( "Disk space required" ) + ": " + item->text(1) + "<br>";
   text += "<br>";
   QString req = ( dep.getDependancies().count() > 0 ? dep.getDependancies().join(", ") : tr( "none" ) );
   text +=  tr( "Prerequisites" ) + ": " + req;
@@ -2780,6 +2912,7 @@ void SALOME_InstallWizard::saveLog()
   QDateTime dt = QDateTime::currentDateTime();
   QString fileName = dt.toString("ddMMyy-hhmm");
   fileName.prepend("install-"); fileName.append(".html");
+  fileName = QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ), fileName ).absFilePath();
   fileName = QFileDialog::getSaveFileName( fileName,
                                           QString( "HTML files (*.htm *.html)" ),
                                           this, 0,