From 493b894862db7d7993610e355d889b8125fdda5b Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 26 Dec 2006 14:41:54 +0000 Subject: [PATCH] Implement features: - install and build SALOME module sources - install all products from sources --- config_files/SAMPLES.sh | 5 ++ runInstall | 98 +++++++++++++++++++++++++++++------- src/SALOME_InstallWizard.cxx | 15 +++--- src/SALOME_InstallWizard.hxx | 5 +- src/main.cxx | 6 ++- 5 files changed, 102 insertions(+), 27 deletions(-) diff --git a/config_files/SAMPLES.sh b/config_files/SAMPLES.sh index bba4558..cf362c7 100755 --- a/config_files/SAMPLES.sh +++ b/config_files/SAMPLES.sh @@ -59,6 +59,11 @@ check_jb tar xfz ${SOURCE_DIR}/SAMPLESsourcesV${VERSION}.tar.gz -C ${INSTALL_ROO print_env } +install_source_and_build() +{ +install_source +} + install_binary() { return 1 diff --git a/runInstall b/runInstall index f2b6c48..a902de3 100755 --- a/runInstall +++ b/runInstall @@ -18,7 +18,7 @@ warnings.filterwarnings("ignore", "", DeprecationWarning) # --- imports --- # import xmllib -import sys, os, string, re +import sys, os, re import types import random @@ -31,6 +31,12 @@ __TAG__SOURCES__ = "install sources" __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" #------------------------------------------------------------------# # # @@ -414,7 +420,8 @@ class Product : theInstalldiskspace = None, theTemporarydiskspace = None, theScript = None, - thePickUpEnvironment = None): + thePickUpEnvironment = None, + theContext = None): self.name = strip(theName) self.version = strip(theVersion) self.install = strip(theInstall) @@ -424,7 +431,36 @@ class Product : 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 #=================================================================== @@ -432,12 +468,13 @@ class ConfigParser(xmllib.XMLParser): """ 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) @@ -453,7 +490,10 @@ class ConfigParser(xmllib.XMLParser): 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 @@ -633,6 +673,15 @@ def parse_parameters(): 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", @@ -657,7 +706,7 @@ def parse_parameters(): 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 @@ -704,7 +753,7 @@ def create_dir(directory, access = 0777): directory creation; exits with error if access is denied. """ - dirs = string.split(directory, "/") + dirs = directory.split("/") existing = ""; dir = "" root = "" @@ -771,7 +820,7 @@ def check_dir(dir): # 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. @@ -781,13 +830,23 @@ def check_disk_space(products, scripts_dir, target_dir, tmp_dir): 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: @@ -861,7 +920,7 @@ def get_tmp_dir(dir): 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) @@ -936,6 +995,8 @@ if __name__ == "__main__": 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)) @@ -946,7 +1007,7 @@ if __name__ == "__main__": filehandle = open(xml_file) data = filehandle.read() filehandle.close() - parser = ConfigParser() + parser = ConfigParser(is_force_src) parser.feed(data) parser.close() @@ -954,7 +1015,8 @@ if __name__ == "__main__": 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: @@ -1015,7 +1077,7 @@ if __name__ == "__main__": # 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) @@ -1031,7 +1093,7 @@ if __name__ == "__main__": 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], diff --git a/src/SALOME_InstallWizard.cxx b/src/SALOME_InstallWizard.cxx index b568206..a9532c2 100644 --- a/src/SALOME_InstallWizard.cxx +++ b/src/SALOME_InstallWizard.cxx @@ -462,7 +462,8 @@ public: // ================================================================ 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 ), @@ -517,7 +518,7 @@ SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName, // create introduction page setupIntroPage(); // create products page - setupProductsPage(); + setupProductsPage(aForceSrc); // create prestart page setupCheckPage(); // create progress page @@ -673,7 +674,7 @@ void SALOME_InstallWizard::setupIntroPage() * Creates products page */ // ================================================================ -void SALOME_InstallWizard::setupProductsPage() +void SALOME_InstallWizard::setupProductsPage(const bool forceSrc) { // // create page @@ -776,6 +777,7 @@ void SALOME_InstallWizard::setupProductsPage() // // ... 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 ); @@ -858,6 +860,7 @@ void SALOME_InstallWizard::setupProductsPage() connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) ); // start on default - non-advanced - mode moreBox->hide(); + onBuildAll(); } // ================================================================ /*! @@ -2562,6 +2565,7 @@ void SALOME_InstallWizard::resetToDefaultState() // ================================================================ void SALOME_InstallWizard::onBuildAll() { + const QObject* snd = sender(); if ( allFromSrcBtn->isChecked() ) { productsView->blockSignals( true ); buildSrcBtn->setChecked( false ); @@ -2572,7 +2576,7 @@ void SALOME_InstallWizard::onBuildAll() 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" @@ -2580,9 +2584,8 @@ void SALOME_InstallWizard::onBuildAll() QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); - firstTimeClicked = false; } - + firstTimeClicked = false; } else { resetToDefaultState(); diff --git a/src/SALOME_InstallWizard.hxx b/src/SALOME_InstallWizard.hxx index 6621a69..5044556 100644 --- a/src/SALOME_InstallWizard.hxx +++ b/src/SALOME_InstallWizard.hxx @@ -146,7 +146,8 @@ class SALOME_InstallWizard: public InstallWizard // constructor SALOME_InstallWizard(const QString& aXmlFileName, const QString& aTargetDir = QString::null, - const QString& aTmpDir = QString::null); + const QString& aTmpDir = QString::null, + const bool aForceSrc = false); // destructor virtual ~SALOME_InstallWizard( ); @@ -203,7 +204,7 @@ class SALOME_InstallWizard: public InstallWizard // creates introduction page void setupIntroPage(); // creates products page - void setupProductsPage(); + void setupProductsPage(const bool forceSrc = false); // creates directories page void setupDirPage(); // creates prestart page diff --git a/src/main.cxx b/src/main.cxx index d759c9f..02453fe 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -55,6 +55,7 @@ int main( int argc, char **argv ) bool has_xml = false; bool has_target = false; bool has_tmp = false; + bool force_src = false; for( int i = 1; i < argc; i++ ) { QString a = QString( argv[i] ); if ( a == "--version" || a == "-v" ) { @@ -98,6 +99,9 @@ int main( int argc, char **argv ) xmlFileName = QString::null; } } + else if ( a == "--all-from-sources" || a == "-a" ) { + force_src = true; + } } if ( has_xml && xmlFileName.isEmpty() ) { printf("Please specify the configuration XML file!\n"); @@ -121,7 +125,7 @@ int main( int argc, char **argv ) int result = -1; QFile xmlfile(xmlFileName); if ( xmlfile.exists() ) { - SALOME_InstallWizard wizard(xmlFileName, targetDirPath, tmpDirPath); + SALOME_InstallWizard wizard(xmlFileName, targetDirPath, tmpDirPath, force_src); a.setMainWidget( &wizard ); wizard.show(); result = a.exec(); -- 2.39.2