#else
#include <unistd.h>
#include <algo.h>
+#include <sys/utsname.h>
#endif
#ifdef WNT
* 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 ) {
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
* 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 );
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
* 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" );
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;
}
}
}
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" );
}
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 {
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
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" );
}
}
}
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 );
progressView->setStatus( prodProc, Processing );
progressView->ensureVisible( prodProc );
- QCheckListItem* item;
+ QCheckListItem* item = 0;
// fill in script parameters
shellProcess->clearArguments();
// ... script name
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() )
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();