From 2897c5eb38f6722bfdd2e09b8d0d41781925a360 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 24 Mar 2004 14:18:21 +0000 Subject: [PATCH] Improve pick-up environment mechanizm --- config_files/KERNEL_BIN_1.4.1.sh | 5 ++ config_files/KERNEL_SRC_1.4.1.sh | 5 ++ src/SALOME_InstallWizard.cxx | 117 +++++++++++++++++-------------- src/SALOME_InstallWizard.hxx | 9 ++- src/SALOME_XmlHandler.cxx | 10 ++- 5 files changed, 90 insertions(+), 56 deletions(-) diff --git a/config_files/KERNEL_BIN_1.4.1.sh b/config_files/KERNEL_BIN_1.4.1.sh index 7437d07..d30900b 100755 --- a/config_files/KERNEL_BIN_1.4.1.sh +++ b/config_files/KERNEL_BIN_1.4.1.sh @@ -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; diff --git a/config_files/KERNEL_SRC_1.4.1.sh b/config_files/KERNEL_SRC_1.4.1.sh index a78a1fa..32dd02a 100755 --- a/config_files/KERNEL_SRC_1.4.1.sh +++ b/config_files/KERNEL_SRC_1.4.1.sh @@ -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; diff --git a/src/SALOME_InstallWizard.cxx b/src/SALOME_InstallWizard.cxx index 7424e15..d4df725 100644 --- a/src/SALOME_InstallWizard.cxx +++ b/src/SALOME_InstallWizard.cxx @@ -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 + } } } // 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; diff --git a/src/SALOME_InstallWizard.hxx b/src/SALOME_InstallWizard.hxx index 6c43088..23a24a3 100644 --- a/src/SALOME_InstallWizard.hxx +++ b/src/SALOME_InstallWizard.hxx @@ -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; diff --git a/src/SALOME_XmlHandler.cxx b/src/SALOME_XmlHandler.cxx index 9ea21ed..a2d0d05 100644 --- a/src/SALOME_XmlHandler.cxx +++ b/src/SALOME_XmlHandler.cxx @@ -12,6 +12,10 @@ #include +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 ) -- 2.39.2