# --- imports --- #
import xmllib
-import sys, os, string, re
+import sys, os, re
import types
import random
__TAG__BINARIES__ = "install binaries"
__TAG__NATIVE__ = "use native"
__TAG__PREINSTALL__ = "not install"
+__TAG__BUILDSRC__ = "build sources"
+
+# --- product context definition --- #
+__CTX__SALOME__SRC__ = "salome sources"
+__CTX__SALOME__BIN__ = "salome binaries"
+__CTX__PREREQUISITE__ = "prerequisite"
#------------------------------------------------------------------#
# #
theInstalldiskspace = None,
theTemporarydiskspace = None,
theScript = None,
- thePickUpEnvironment = None):
+ thePickUpEnvironment = None,
+ theContext = None):
self.name = strip(theName)
self.version = strip(theVersion)
self.install = strip(theInstall)
self.temporarydiskspace = strip(theTemporarydiskspace)
self.script = strip(theScript)
self.pickupEnv = strip(thePickUpEnvironment)
+ self.context = strip(theContext)
+ self.whattodo = self.install
+
+ def hasContext(self, ctx):
+ try:
+ return ctx in [ strip(s) for s in self.context.split(",") ]
+ except:
+ pass
+ return False
+ def setMode(self, mode):
+ if mode not in [__TAG__SOURCES__, __TAG__BINARIES__, __TAG__NATIVE__, __TAG__PREINSTALL__]:
+ return
+ try:
+ supported = [ strip(s) for s in self.supported.split(",") ]
+ if mode in supported or mode == __TAG__PREINSTALL__:
+ self.install = mode
+ self.whattodo = self.install
+ salbin = self.hasContext(__CTX__SALOME__BIN__)
+ salsrc = self.hasContext(__CTX__SALOME__SRC__)
+ if mode == __TAG__SOURCES__:
+ if salbin and not salsrc:
+ self.install = __TAG__PREINSTALL__
+ self.whattodo = self.install
+ elif salsrc:
+ self.whattodo = __TAG__BUILDSRC__
+ except:
+ pass
+ return
+
#===================================================================
# class ConfigParser : XML files parser implementation
#===================================================================
"""
XML configuration files parser
"""
- def __init__(self):
+ def __init__(self, is_force_src=False):
xmllib.XMLParser.__init__(self)
self.products = []
self.currentdata = []
self.path = None
self.config = None
+ self.is_force_src = is_force_src
def handle_data(self, data):
self.currentdata.append(data)
attrs.get('installdiskspace', None),
attrs.get('temporarydiskspace', None),
attrs.get('script', None),
- attrs.get('pickupenv', None))
+ attrs.get('pickupenv', None),
+ attrs.get('context', None))
+ if self.is_force_src:
+ aProduct.setMode(__TAG__SOURCES__)
self.products.append(aProduct)
pass
dest="tmp_dir",
metavar="DIR",
help=help_str)
+ help_str = "Force all products to be installed from sources\n"
+ help_str += "including SALOME modules."
+ help_str += "If this option is used all the default installation modes are ignored."
+ opt_parser.add_option("-a",
+ "--all-from-sources",
+ action="store_true",
+ dest="force_sources",
+ default=False,
+ help=help_str)
help_str = "Prints version information and quits."
opt_parser.add_option("-v",
"--version",
os.system(cmd)
print ""
sys.exit(0)
- return [options.xmlfile, options.target_dir, options.tmp_dir, options.gui]
+ return [options.xmlfile, options.target_dir, options.tmp_dir, options.gui, options.force_sources]
#=================================================================
# strip : removes spaces at the beginning and at the end of the
directory creation; exits with error if access
is denied.
"""
- dirs = string.split(directory, "/")
+ dirs = directory.split("/")
existing = "";
dir = ""
root = ""
# check_disk_space : checks the disk space;
# quits if there is no enough disk space
#===============================================================
-def check_disk_space(products, scripts_dir, target_dir, tmp_dir):
+def check_disk_space(products, scripts_dir, target_dir, tmp_dir, is_force_src=False):
"""
Checks if there is enough disk space to install products.
Quits with error if there is no enough disk space.
for product in products:
if product.install in [__TAG__NATIVE__, __TAG__PREINSTALL__]:
continue
- spaces = string.split(product.installdiskspace, ',')
- prod_space = spaces[0]
- if (len(spaces) > 1 ) and (product.install == __TAG__SOURCES__):
- prod_space = spaces[1]
- install_space = install_space + string.atoi(prod_space)
+ prod_space = 0
+ try:
+ spaces = product.installdiskspace.split(',')
+ prod_space = int( spaces[0] )
+ if len( spaces ) > 1 and product.install == __TAG__SOURCES__ and not is_force_src:
+ prod_space = int( spaces[1] )
+ except:
+ pass
+ install_space = install_space + prod_space
if product.install == __TAG__SOURCES__:
- temporary_space = max(temporary_space, string.atoi(product.temporarydiskspace))
+ tmp_space = 0
+ try:
+ tmp_space = int( product.temporarydiskspace )
+ except:
+ pass
+ temporary_space = max( temporary_space, tmp_space )
+ pass
res = os.system("%s/%s %s %d"%(scripts_dir, "checkSize.sh", target_dir, install_space))
if res:
if __name__ == "__main__":
# parse command line
- [xml_file, target_dir, tmp_dir, is_gui] = parse_parameters()
+ [xml_file, target_dir, tmp_dir, is_gui, is_force_src] = parse_parameters()
if xml_file: xml_file = os.path.abspath(xml_file)
if target_dir: target_dir = os.path.abspath(target_dir)
if tmp_dir: tmp_dir = os.path.abspath(tmp_dir)
cmd += " --target %s"%target_dir
if tmp_dir is not None:
cmd += " --tmp %s"%tmp_dir
+ if is_force_src:
+ cmd += " --all-from-sources"
cmd += "&"
sys.exit(os.system(cmd))
filehandle = open(xml_file)
data = filehandle.read()
filehandle.close()
- parser = ConfigParser()
+ parser = ConfigParser(is_force_src)
parser.feed(data)
parser.close()
what_to_do = { __TAG__SOURCES__ : "install_source",
__TAG__BINARIES__ : "install_binary",
__TAG__NATIVE__ : "try_native",
- __TAG__PREINSTALL__ : "try_preinstalled"}
+ __TAG__PREINSTALL__ : "try_preinstalled",
+ __TAG__BUILDSRC__ : "install_source_and_build"}
# source directory map
bin_dir = ""
if parser.config.os:
# check available disk space -----------
message("Checking available disk space")
- check_disk_space(parser.products, scripts_dir, target_dir, tmp_dir)
+ check_disk_space(parser.products, scripts_dir, target_dir, tmp_dir, is_force_src)
# change current directory -----------
os.chdir(scripts_dir)
message("... processing %s ..."%product.name)
cmd = '%s/%s %s %s %s/%s %s "%s" %s'%(scripts_dir,
product.script,
- what_to_do[product.install],
+ what_to_do[product.whattodo],
tmp_dir,
source_dir,
subdir[product.install],
// ================================================================
SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName,
const QString& aTargetDir,
- const QString& aTmpDir)
+ const QString& aTmpDir,
+ const bool aForceSrc)
: InstallWizard( qApp->desktop(), "SALOME_InstallWizard", false, 0 ),
helpWindow( NULL ),
moreMode( false ),
// create introduction page
setupIntroPage();
// create products page
- setupProductsPage();
+ setupProductsPage(aForceSrc);
// create prestart page
setupCheckPage();
// create progress page
* Creates products page
*/
// ================================================================
-void SALOME_InstallWizard::setupProductsPage()
+void SALOME_InstallWizard::setupProductsPage(const bool forceSrc)
{
//
// create page
//
// ... <Install all products from sources> check box
allFromSrcBtn = new QMyCheckBox( tr( "Install all products from sources" ), lessBox );
+ allFromSrcBtn->setChecked( forceSrc );
setAboutInfo( allFromSrcBtn, tr( "Check this box if you want to build\nall the products from sources.\n\nWarning: this is long-time operation!" ) );
lessBoxLayout->addWidget( allFromSrcBtn, 0, 0 );
lessBoxLayout->setRowStretch( 1, 10 );
connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) );
// start on default - non-advanced - mode
moreBox->hide();
+ onBuildAll();
}
// ================================================================
/*!
// ================================================================
void SALOME_InstallWizard::onBuildAll()
{
+ const QObject* snd = sender();
if ( allFromSrcBtn->isChecked() ) {
productsView->blockSignals( true );
buildSrcBtn->setChecked( false );
productsView->blockSignals( false );
checkProductPage();
static bool firstTimeClicked = true;
- if ( firstTimeClicked ) {
+ if ( snd == allFromSrcBtn && firstTimeClicked ) {
QMessageBox::warning( this,
tr( "Warning" ),
tr( "The building of all products from sources can take a lot of time\n"
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
- firstTimeClicked = false;
}
-
+ firstTimeClicked = false;
}
else {
resetToDefaultState();