From: vsr Date: Thu, 16 Oct 2008 07:03:47 +0000 (+0000) Subject: Improve SALOME installation Wizard: uniform the platform definition way for batch... X-Git-Tag: before_merging_with_4X~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=62db96fe6b1975b41336fe8ff1adac6265666c51;p=tools%2Finstall.git Improve SALOME installation Wizard: uniform the platform definition way for batch and GUI modes for all supported platforms plus fix bug of platform definition for 64bit platforms --- diff --git a/src/SALOME_InstallWizard.cxx b/src/SALOME_InstallWizard.cxx index e610151..f626067 100644 --- a/src/SALOME_InstallWizard.cxx +++ b/src/SALOME_InstallWizard.cxx @@ -50,6 +50,7 @@ #else #include #include +#include #endif #ifdef WNT @@ -343,7 +344,7 @@ static bool hasSpace( const QString& dir ) * Creates HTML-wrapped title text */ // ================================================================ -QString makeTitle( const QString& text, const QString& separator = " ", bool fl = true ) +static QString makeTitle( const QString& text, const QString& separator = " ", bool fl = true ) { QStringList words = QStringList::split( separator, text ); if ( fl ) { @@ -491,26 +492,26 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, srcPath = QDir::currentDirPath() + "/Products/SOURCES"; oneProdDirName = "PRODUCTS"; - singleBinPlts << "Debian4.0" - << "Debian3.1" - << "Mandrake10.1" - << "Mandriva2006.0" - << "Mandriva2007.0" - << "Mandriva2008.0" - << "Mandriva2006.0_64" - << "Mandriva2008.0_64" - << "RedHat8.0" - << "RedHat9" - << "RedHatEnterprise4" - << "Scientific4.2" - << "Scientific4.3"; - commonPlatform = "Debian3.1"; + singleBinPlts << "Red Hat 8.0" + << "Red Hat 9" + << "Debian 3.1" + << "Debian 4.0 64bit" + << "Mandrake 10.1" + << "Mandriva 2006.0" + << "Mandriva 2006.0 64bit" + << "Mandriva 2007.0" + << "Mandriva 2008.0" + << "Mandriva 2008.0 64bit" + << "Red Hat Enterprise WS 4" + << "Scientific SL 4.2" + << "Scientific SL 4.3"; + commonPlatform = "Debian 3.1"; // // get XML filename and current platform // // ... get current platform - curPlatform = currentPlatform(); + curPlatform = currentPlatform().join(" "); // cout << "curOS = " << curPlatform << endl; // curPlatform = ""; // ... check XML and platform definition @@ -647,10 +648,10 @@ QString SALOME_InstallWizard::getBasePlatform() * Tries to determine the current user's operating system */ // ================================================================ -QString SALOME_InstallWizard::currentPlatform() +QStringList SALOME_InstallWizard::currentPlatform() { // file parsing - QString curOS = ""; + QString platName, platVersion, platArch; QString osFileName = "/etc/issue"; if ( QFile::exists( osFileName ) ) { QFile file( osFileName ); @@ -658,35 +659,50 @@ QString SALOME_InstallWizard::currentPlatform() QTextStream stream( &file ); QString str = stream.readLine(); file.close(); - // line parsing - QString pltName = "", platVersion = "", platBit = ""; - QRegExp rx( "(.*)[L|l]inux.*release\\s+([\\d.]*)" ); -// str = "Debian GNU/Linux 3.1 \n \l"; -// str = "Red Hat Enterprise Linux WS release 4 (Nahant)"; -// str = "Mandriva Linux release 2006.0 (Official) for x86_64"; - int pos = rx.search( str ); - if ( pos == -1 ) {// Debian case - rx = QRegExp( "(.*)GNU/Linux\\s+([\\d.]*)" ); - pos = rx.search( str ); + // parse line + QRegExp regvar = QRegExp( "(.*)\\s+[^\\s]*[R|r]elease[^\\s]*\\s+([\\d.]*)" ); + int pos = regvar.search( str ); + if ( pos == -1 ) { + regvar = QRegExp( "(.*)\\s+[^\\s]*[L|l][I|i][N|n][U|u][X|x][^\\s]*(.*)\\s+([\\d.]*)\\s+" ); + pos = regvar.search( str ); } - if ( pos > -1 ) { - pltName = rx.cap( 1 ); - platVersion = rx.cap( 2 ); - rx = QRegExp( "x86_64" ); - pos = rx.search( str ); - if ( pos > -1 ) - platBit = "_64"; - curOS = pltName + platVersion + platBit; + if ( pos >= 0 ) { + QStringList name; + for ( int i = 1; i < regvar.numCaptures(); i++ ) + name.append( regvar.cap( i ) ); + + // retrieve platform name + platName = QStringList::split( " ", name.join( " " ) ).join( " " ); + platName = platName.replace( "Linux", "" ).replace( "linux", "" ).replace( "LINUX", "" ).stripWhiteSpace(); + platName = platName.replace( "Welcometo", "" ).stripWhiteSpace(); + platName = QStringList::split( " ", platName ).join( " " ); + // retrieve platform version number + platVersion = regvar.cap( regvar.numCaptures() ); + // retrieve platform + utsname uname_data; + uname( &uname_data ); + if ( QString( uname_data.machine ) == "x86_64" ) + platArch = "64bit"; } } } - // return curOS.remove( " " ); - QString str( " " ); - int index = 0; - while ( (index = curOS.find( str, index, true)) != -1 ) - curOS.remove( index, str.length() ); - return curOS; + QStringList vals; + if ( !platName.isEmpty() ) vals.append( platName ); + if ( !platVersion.isEmpty() ) vals.append( platVersion ); + if ( !platArch.isEmpty() ) vals.append( platArch ); + return vals; } +// ================================================================ +/*! + * SALOME_InstallWizard::getPlatformBinPath + * Get platform binaries path + */ +// ================================================================ +QString SALOME_InstallWizard::getPlatformBinPath( const QString& plt ) const +{ + return QDir::cleanDirPath( getBinPath() + "/" + QStringList::split( " ", plt ).join( "_" ) ); +} + // ================================================================ /*! * SALOME_InstallWizard::getXmlMap @@ -694,17 +710,18 @@ QString SALOME_InstallWizard::currentPlatform() * corresponding XML files. */ // ================================================================ -MapXmlFiles SALOME_InstallWizard::getXmlMap( const QString& xmlFileName ) +MapXmlFiles SALOME_InstallWizard::getXmlMap( const QString& aXmlFileName ) { MapXmlFiles xmlMap; QStringList xmlList; - if ( xmlFileName ) - xmlList.append( xmlFileName ); + if ( !aXmlFileName.isEmpty() ) + xmlList.append( aXmlFileName ); else { QDir dir( QDir::currentDirPath() ); xmlList = dir.entryList( "*.xml", QDir::Files | QDir::Readable ); } -// cout << xmlList.join(",") << endl; + if ( xmlList.remove( "config.xml" ) ) + xmlList.append( "config.xml" ); // XML files parsing QFile file; QDomDocument doc( "xml_doc" ); @@ -733,13 +750,10 @@ MapXmlFiles SALOME_InstallWizard::getXmlMap( const QString& xmlFileName ) platforms = elem.attribute( "platforms" ).stripWhiteSpace(); QStringList platList = QStringList::split( ",", platforms ); for ( uint j = 0; j < platList.count(); j++ ) { - if ( !platList[j].isEmpty() ) - if ( xmlMap.find( platList[j] ) == xmlMap.end() || - xmlMap[ platList[j] ] == "config.xml" ) - xmlMap[ platList[j] ] = xmlList[i]; + QString platform = platList[j].stripWhiteSpace(); + if ( !platform.isEmpty() && xmlMap.find( platform ) == xmlMap.end() ) + xmlMap[ platList[j] ] = xmlList[i]; } -// if ( !curPlatform.isEmpty() && xmlMap.find( curPlatform ) != xmlMap.end() ) -// return xmlMap; } } } @@ -754,13 +768,13 @@ MapXmlFiles SALOME_InstallWizard::getXmlMap( const QString& xmlFileName ) void SALOME_InstallWizard::getXmlAndPlatform() { MapXmlFiles xmlMap; - if ( xmlFileName.isNull() ) { + if ( xmlFileName.isEmpty() ) { xmlMap = getXmlMap(); if ( !curPlatform.isEmpty() ) { // try to get XML file for current platform if ( xmlMap.find( curPlatform ) != xmlMap.end() ) { xmlFileName = xmlMap[ getBasePlatform() ]; - QFileInfo fibp( QDir::cleanDirPath( getBinPath() + "/" + getBasePlatform() ) ); + QFileInfo fibp( getPlatformBinPath( getBasePlatform() ) ); if ( !fibp.isDir() ) { warnMsg = tr( "Binaries are absent for current platform" ); } @@ -774,7 +788,7 @@ void SALOME_InstallWizard::getXmlAndPlatform() else { // get all supported platforms platformsMap = xmlMap; - warnMsg = tr( "Install Wizard can't define your Linux platform" ); + warnMsg = tr( "Installation Wizard can't identify target Linux platform" ); } } else { @@ -788,6 +802,9 @@ void SALOME_InstallWizard::getXmlAndPlatform() platformsMap.insert( it.key(), it.data(), true ); warnMsg = tr( "The given configuration file doesn't support your Linux platform" ); } + else { + platformsMap = xmlMap; + } } else { // get all supported platforms @@ -795,7 +812,7 @@ void SALOME_InstallWizard::getXmlAndPlatform() MapXmlFiles::Iterator it; for ( it = xmlMap.begin(); it != xmlMap.end(); ++it ) platformsMap.insert( it.key(), it.data(), true ); - warnMsg = tr( "Install Wizard can't define your Linux platform" ); + warnMsg = tr( "Installation Wizard can't define your Linux platform" ); } } } @@ -1433,7 +1450,7 @@ bool SALOME_InstallWizard::acceptData( const QString& pageTitle ) xmlFileName = platformsMap[ refPlatform ]; aPlatform = getPlatform(); } - QFileInfo fibp( QDir::cleanDirPath( getBinPath() + "/" + aPlatform ) ); + QFileInfo fibp( getPlatformBinPath( aPlatform ) ); if ( !fibp.isDir() ) { warnLab->setText( tr( "Binaries are absent for current platform." ) ); this->setAppropriate( platformsPage, true ); @@ -2040,7 +2057,7 @@ void SALOME_InstallWizard::launchScript() progressView->setStatus( prodProc, Processing ); progressView->ensureVisible( prodProc ); - QCheckListItem* item; + QCheckListItem* item = 0; // fill in script parameters shellProcess->clearArguments(); // ... script name @@ -2053,11 +2070,10 @@ void SALOME_InstallWizard::launchScript() shellProcess->addArgument( extraProducts[ prodProc ] ); // ... get folder with binaries - QString binDir = QDir::cleanDirPath( getBinPath() ); QString OS = getPlatform(); if ( refPlatform.isEmpty() && singleBinPlts.contains(curPlatform) == 0 ) OS = commonPlatform; - binDir += "/" + OS; + QString binDir = getPlatformBinPath( OS ); // ... temp folder QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME; //if( !tempFolder->isEnabled() ) @@ -2462,7 +2478,7 @@ void SALOME_InstallWizard::pageChanged( const QString & mytitle) QString plat = it.key(); QRadioButton* rb = ( (QRadioButton*) platBtnGrp->child( plat ) ); if ( installType == Binaries ) { - QFileInfo fib( QDir::cleanDirPath( getBinPath() + "/" + plat ) ); + QFileInfo fib( getPlatformBinPath( plat ) ); rb->setEnabled( fib.exists() ); if ( platBtnGrp->id( platBtnGrp->selected() ) == -1 && plat == getBasePlatform() ) rb->animateClick(); diff --git a/src/SALOME_InstallWizard.hxx b/src/SALOME_InstallWizard.hxx index 763482a..6165010 100644 --- a/src/SALOME_InstallWizard.hxx +++ b/src/SALOME_InstallWizard.hxx @@ -171,12 +171,14 @@ class SALOME_InstallWizard: public InstallWizard // get base platform to install binaries package QString getBasePlatform(); // get current platform - QString currentPlatform(); + static QStringList currentPlatform(); // get binaries path - QString getBinPath() { return binPath; } + QString getBinPath() const { return binPath; } // get sources path - QString getSrcPath() { return srcPath; } + QString getSrcPath() const { return srcPath; } + // get platform binaries path + QString getPlatformBinPath( const QString& ) const; // get map of supported platforms and corresponding XML files MapXmlFiles getXmlMap( const QString& aXmlFileName = QString::null );