Salome HOME
Improve pick-up environment mechanizm
authorvsr <vsr@opencascade.com>
Wed, 24 Mar 2004 14:18:21 +0000 (14:18 +0000)
committervsr <vsr@opencascade.com>
Wed, 24 Mar 2004 14:18:21 +0000 (14:18 +0000)
config_files/KERNEL_BIN_1.4.1.sh
config_files/KERNEL_SRC_1.4.1.sh
src/SALOME_InstallWizard.cxx
src/SALOME_InstallWizard.hxx
src/SALOME_XmlHandler.cxx

index 7437d07927d15a037cfd89980a6b0ef8909e376f..d30900b26e24998b3b56a0318f6fc9813d35366e 100755 (executable)
@@ -58,6 +58,11 @@ check_jb tar xfz ${SOURCE_DIR}/KERNELbinariesV1.4.1.tar.gz -C ${INSTALL_ROOT}
 print_env
 }
 
+pickup_env()
+{
+make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE} ${PRODUCT_DIR}
+}
+
 export PROCEDURE=$1;
 export INSTALL_WORK=$2;
 export SOURCE_DIR=$3;
index a78a1fad976d4569399907aef76e73968bb38451..32dd02a54860a57ce3c2841aa95ef49fc94b4dc3 100755 (executable)
@@ -58,6 +58,11 @@ install_binary()
 return 1
 }
 
+pickup_env()
+{
+make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE} ${PRODUCT_DIR}
+}
+
 export PROCEDURE=$1;
 export INSTALL_WORK=$2;
 export SOURCE_DIR=$3;
index 7424e15a20f5b328d81839a603872a645c99397a..d4df72540626a3ad140ee3c7a0ba5866cf18111f 100644 (file)
@@ -46,7 +46,8 @@
 #define max( x, y ) ( x ) > ( y ) ? ( x ) : ( y )
 #endif
 
-#define TEMPDIRNAME ( "/INSTALLWORK" + QString::number( getpid() ) )
+QString tmpDirName() { return QString(  "/INSTALLWORK" ) + QString::number( getpid() ); }
+#define TEMPDIRNAME tmpDirName()
 
 // ================================================================
 /*!
@@ -854,7 +855,8 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
        return false; 
       }
       else {
-       tempFolder->setText( "/tmp" );
+       tempDir = "/tmp";
+       tempFolder->setText( tempDir );
       }
     }
     QFileInfo fit( QDir::cleanDirPath( tempDir ) );
@@ -1114,8 +1116,8 @@ void SALOME_InstallWizard::launchScript()
 
     // ... temp folder
     QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
-    if( !tempFolder->isEnabled() )
-      tmpFolder = "/tmp";
+    //if( !tempFolder->isEnabled() )
+    //tmpFolder = "/tmp";
 
     // ... binaries ?
     if ( productsView->isBinaries( item ) ) {
@@ -1170,29 +1172,37 @@ void SALOME_InstallWizard::launchScript()
 #ifdef DEBUG
   cout << "All products have been installed successfully" << endl;
 #endif
-  // all products installed successfully
-  QFileInfo fi_sh ( targetFolder->text() + "/env_products.sh");
-  QFileInfo fi_csh( targetFolder->text() + "/env_products.csh");
-  QCheckListItem* itemBin = findItem( "KERNEL-Bin" );
-  QCheckListItem* itemSrc = findItem( "KERNEL-Src" );
-  if ( itemBin /*&& !productsView->isNone( itemBin )*/ ) {
-    if ( fi_sh.exists() ) {
-      QString script = "cp " + fi_sh.filePath() + " " + targetFolder->text() + "/KERNEL_" + itemBin->text(1) + "/salome.sh";
-      if ( system( script.latin1() ) ) {}
-    }
-    if ( fi_csh.exists() ) {
-      QString script = "cp " + fi_csh.filePath() + " " + targetFolder->text() + "/KERNEL_" + itemBin->text(1) + "/salome.csh";
-      if ( system( script.latin1() ) ) {}
-    }
-  }
-  if ( itemSrc /*&& !productsView->isNone( itemSrc )*/ ) {
-    if ( fi_sh.exists() ) {
-      QString script = "cp " + fi_sh.filePath() + " " + targetFolder->text() + "/KERNEL_SRC_" + itemSrc->text(1) + "/salome.sh";
-      if ( system( script.latin1() ) ) {}
-    }
-    if ( fi_csh.exists() ) {
-      QString script = "cp " + fi_csh.filePath() + " " + targetFolder->text() + "/KERNEL_SRC_" + itemSrc->text(1) + "/salome.csh";
-      if ( system( script.latin1() ) ) {}
+  // all products are installed successfully
+  QString workDir = QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() );
+  MapProducts::Iterator mapIter;
+#ifdef DEBUG
+  cout << "starting pick-up environment" << endl;
+#endif
+  for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
+    QCheckListItem* item = mapIter.key();
+    Dependancies dep = mapIter.data();
+    QString depproducts = QUOTE( DefineDependeces(productsMap) ); 
+    if ( dep.pickUpEnvironment() ) {
+#ifdef DEBUG
+      cout << "... for " << dep.getName() << endl;
+#endif
+      QString script;
+      script += "cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
+      script += item->text(2) + " ";
+      script += "pickup_env ";
+      script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
+      script += QUOTE( QFileInfo( QDir::cleanDirPath( QDir::currentDirPath() + "/Products" ) ).absFilePath() ) + " ";
+      script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
+      script += depproducts + " ";
+      script += item->text(0);
+#ifdef DEBUG
+      cout << "... --> " << script.latin1() << endl;
+#endif
+      if ( system( script.latin1() ) ) { 
+#ifdef DEBUG
+       cout << "ERROR" << endl; 
+#endif
+      }
     }
   }
   // <Next> button
@@ -1247,35 +1257,37 @@ void SALOME_InstallWizard::onMoreBtn()
 // ================================================================
 void SALOME_InstallWizard::onLaunchSalome()
 {
-  QCheckListItem* item = 0;
-  if ( ( item = findItem( "KERNEL-Bin" ) ) ) {
+  QString msg = tr( "You don't have SALOME binaries installed in the %1 directory!" ).arg( targetFolder->text() );
+
+  QCheckListItem* item = findItem( "KERNEL-Bin" );
+  if ( item ) {
     QFileInfo fi( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" );
-    if ( fi.exists() ) {
-      QString script;
-      script += "cd " + targetFolder->text() + "/KERNEL_" + item->text(1) + "; ";
-      script += "source salome.csh; ";
-      script += "cd bin/salome; ";
-      //script += "cd bin; ";
-      //script += "runSalome > /dev/null";
-      script += "runSalome > /dev/null";
-      script = "(csh -c '" + script + "')";
+    QFileInfo fienv( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" );
+    if ( fienv.exists() ) {
+      if ( fi.exists() ) {
+       QString script;
+       script += "cd " + targetFolder->text() + "/KERNEL_" + item->text(1) + "; ";
+       script += "source salome.csh; ";
+       script += "cd bin/salome; ";
+       script += "runSalome > /dev/null";
+       script = "(csh -c '" + script + "')";
 #ifdef DEBUG
-      cout << script.latin1() << endl;
+       cout << script.latin1() << endl;
 #endif
-      if ( system( script.latin1() ) ){
-       QMessageBox::warning( this, 
-                             tr( "Error" ), 
-                             tr( "Can't launch SALOME" ), 
-                             QMessageBox::Ok, 
-                             QMessageBox::NoButton,
-                             QMessageBox::NoButton );
+       if ( !system( script.latin1() ) )
+         return;
+       else
+         msg = tr( "Can't launch SALOME." );
       }
-      return;
+      else
+       msg = tr( "Can't launch SALOME." ) + "\n" + tr( "runSalome file can not be found." );
     }
+    else
+      msg = tr( "Can't launch SALOME." ) + "\n" + tr( "Can't find environment file." );
   }
   QMessageBox::warning( this, 
                        tr( "Error" ), 
-                       tr( "You don't have SALOME binaries installed in the %1 directory!" ).arg( targetFolder->text() ), 
+                       msg,
                        QMessageBox::Ok, 
                        QMessageBox::NoButton,
                        QMessageBox::NoButton );
@@ -1365,7 +1377,7 @@ void SALOME_InstallWizard::clean()
 {
   // VSR: first remove temporary files
   QString script = "cd ./config_files/; remove_tmp.sh '";
-  script += tempFolder->text().stripWhiteSpace();
+  script += tempFolder->text().stripWhiteSpace() + TEMPDIRNAME;
   script += "' ";
   script += QUOTE(DefineDependeces(productsMap));
   script += " > /dev/null";
@@ -1436,9 +1448,10 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle)
     }
   }
   else if ( aPage == readmePage ) {
-    QCheckListItem* item = 0;
-    runSalomeBtn->setEnabled( ( item = findItem( "KERNEL-Bin" ) ) && 
-                             QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" ).exists() );
+    QCheckListItem* item = findItem( "KERNEL-Bin" );
+    runSalomeBtn->setEnabled( item &&
+                             QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" ).exists() &&
+                             QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" ).exists() );
     finishButton()->setEnabled( true );
   }
   previousPage = aPage;
index 6c43088d7711e2b77aa19d9571b22fe467f08ec2..23a24a3158ae55027bd95133221246111a899a6f 100644 (file)
@@ -36,14 +36,16 @@ class Dependancies
                 const long         Sourcessize, 
                 const long         tempsize, 
                 const QString&     def = QString::null,
-                const QString&     descr = QString::null )
+                const QString&     descr = QString::null,
+                bool               pickup = false )
     : smbName( name ), 
       dependsOn( depend ), 
       sizeSourcesTotal( Sourcessize ), 
       sizeBinaryTotal( Binsize ), 
       sizeTemp( tempsize ),
       defaultMode( def ),
-      description( descr ) {}
+      description( descr ),
+      pickupEnv( pickup ) {}
 
   // gets symbolic name
   QString     getName() const         { return smbName;   }
@@ -57,6 +59,8 @@ class Dependancies
   QString     getDescription() const  { return description; }
   // gets default mode
   QString     getDefault() const      { return defaultMode; }
+  // returns true if this product needs to pick-up environment
+  bool        pickUpEnvironment()     { return pickupEnv; }
 
  private:
   QString     smbName;          // symbolic name
@@ -66,6 +70,7 @@ class Dependancies
   long        sizeTemp;         // disk space for temporary files required
   QString     defaultMode;      // default installation mode
   QString     description;      // product's description
+  bool        pickupEnv;        // "Pick-up environment" flag
 };
 
 class QLineEdit;
index 9ea21ed587a86b8bf25a2035426881bb8aa79325..a2d0d05fb594af53212e00ae84a30aca98146092 100644 (file)
 
 #include <qlineedit.h>
 
+bool isBoolAttributeSet( const QString& attr ) {
+  return ( attr == "true" || attr == "yes" || attr == "ok" || ( !attr.stripWhiteSpace().isEmpty() && attr.toInt() != 0 ) );
+}
+
 // ================================================================
 /*!
  *  StructureParser::StructureParser
@@ -101,7 +105,7 @@ bool StructureParser::startElement( const QString&        /*namespaceURI*/,
     }
   } 
   else if (( qName == "product" ) && ( attributes.length() > 0 ) && myTree && myWizard ) {
-    if (attributes.value( "disable" ) == "true" )
+    if ( isBoolAttributeSet( attributes.value( "disable" ) ) )
       return true;
     
     QString install = attributes.value( "install" );
@@ -115,6 +119,7 @@ bool StructureParser::startElement( const QString&        /*namespaceURI*/,
     QString descr = QString::null;
     if ( attributes.value( "description" ) != "" )
       descr = attributes.value( "description" ).stripWhiteSpace();
+    bool pickUp = isBoolAttributeSet( attributes.value( "pickupenv" ) );
     myWizard->setDependancies( element, 
                               Dependancies( attributes.value( "name" ), 
                                             deps,
@@ -122,7 +127,8 @@ bool StructureParser::startElement( const QString&        /*namespaceURI*/,
                                             ( diskspace.count() > 1 ? diskspace[1].toInt() : ( diskspace.count() > 0 ? diskspace[0].toInt() : 0 ) ), 
                                             attributes.value( "temporarydiskspace" ).toInt(),
                                             install,
-                                            descr ) );
+                                            descr,
+                                            pickUp ) );
   }
   else if (( qName == "path" ) && ( attributes.length() > 0 ) && myWizard ) {
     if ( myTargetDir )