diff --git a/bootstrap/buildCoriolis.py b/bootstrap/buildCoriolis.py index c72696da..7143cf21 100755 --- a/bootstrap/buildCoriolis.py +++ b/bootstrap/buildCoriolis.py @@ -4,12 +4,73 @@ import sys import re import os import os.path -import time +import datetime import socket import subprocess import optparse +class ErrorMessage ( Exception ): + + def __init__ ( self, code, *arguments ): + self._code = code + self._errors = [ 'Malformed call to ErrorMessage()' + , '%s' % str(arguments) ] + + text = None + if len(arguments) == 1: + if isinstance(arguments[0],Exception): text = str(arguments[0]).split('\n') + else: + self._errors = arguments[0] + elif len(arguments) > 1: + text = list(arguments) + + if text: + self._errors = [] + while len(text[0]) == 0: del text[0] + + lstrip = 0 + if text[0].startswith('[ERROR]'): lstrip = 8 + + for line in text: + if line[0:lstrip ] == ' '*lstrip or \ + line[0:lstrip-1] == '[ERROR]': + self._errors += [ line[lstrip:] ] + else: + self._errors += [ line.lstrip() ] + return + + def __str__ ( self ): + if not isinstance(self._errors,list): + return "[ERROR] %s" % self._errors + + formatted = "\n" + for i in range(len(self._errors)): + if i == 0: formatted += "[ERROR] %s" % self._errors[i] + else: formatted += " %s" % self._errors[i] + if i+1 < len(self._errors): formatted += "\n" + return formatted + + def addMessage ( self, message ): + if not isinstance(self._errors,list): + self._errors = [ self._errors ] + if isinstance(message,list): + for line in message: + self._errors += [ line ] + else: + self._errors += [ message ] + return + + def terminate ( self ): + print self + sys.exit(self._code) + + def _getCode ( self ): return self._code + + code = property(_getCode) + + + class Project: def __init__ ( self, name, tools, repository ): @@ -53,8 +114,14 @@ class ProjectBuilder: self._projects = [] self._standalones = [] self._svnTag = "x" - self._svnMethod = "svn+ssh://coriolis.soc.lip6.fr" - self._rootDir = os.path.join ( os.environ["HOME"], "coriolis-2.x" ) + self._svnMethod = None + self._projectDir = 'coriolis-2.x' + self._rootDir = os.path.join ( os.environ["HOME"], self._projectDir ) + self._packageName = None + self._packageVersion = None + self._packageExcludes = [] + self._packageProject = [] + self._quiet = False self._buildMode = "Release" self._rmBuild = False @@ -81,7 +148,10 @@ class ProjectBuilder: if attribute == "svnTag": self._svnTag = value elif attribute == "svnMethod": self._svnMethod = value + elif attribute == "projectDir": self._projectDir = value elif attribute == "rootDir": self._rootDir = os.path.expanduser(value) + elif attribute == "packageName": self._packageName = value + elif attribute == "packageVersion": self._packageVersion = value elif attribute == "quiet": self._quiet = value elif attribute == "buildMode": self._buildMode = value elif attribute == "rmBuild": self._rmBuild = value @@ -100,11 +170,14 @@ class ProjectBuilder: def _updateSecondary ( self ): + self._rootDir = os.path.join ( os.environ["HOME"], self._projectDir ) self._rpmbuildDir = os.path.join ( self._rootDir , "rpmbuild" ) self._debbuildDir = os.path.join ( self._rootDir , "debbuild" ) self._tmppathDir = os.path.join ( self._rpmbuildDir, "tmp" ) self._tarballDir = os.path.join ( self._rootDir , "tarball" ) - self._archiveDir = os.path.join ( self._tarballDir , "coriolis2-1.0.%s" % self._svnTag ) + self._archiveDir = os.path.join ( self._tarballDir , "%s-%s.%s" % (self._packageName + ,self._packageVersion + ,self._svnTag) ) self._sourceDir = os.path.join ( self._rootDir , "src" ) self._osDir = os.path.join ( self._rootDir , self._osType @@ -115,26 +188,29 @@ class ProjectBuilder: if self._enableShared == "ON": self._libMode = "Shared" else: self._libMode = "Static" - self._specFileIn = os.path.join ( self._sourceDir, "bootstrap", "coriolis2.spec.in" ) - self._specFile = os.path.join ( self._sourceDir, "bootstrap", "coriolis2.spec" ) + self._specFileIn = os.path.join ( self._sourceDir, "bootstrap", "%s.spec.in"%self._packageName ) + self._specFile = os.path.join ( self._sourceDir, "bootstrap", "%s.spec" %self._packageName ) self._debianDir = os.path.join ( self._sourceDir, "bootstrap", "debian" ) self._debChangelogIn = os.path.join ( self._debianDir, "changelog.in" ) self._debChangelog = os.path.join ( self._debianDir, "changelog" ) - self._sourceTarBz2 = "coriolis2-1.0.%s.tar.bz2" % self._svnTag - self._binaryTarBz2 = "coriolis2-binary-1.0.%s-1.el5_soc.tar.bz2" % self._svnTag - self._distribPatch = os.path.join ( self._sourceDir, "bootstrap", "coriolis2-for-distribution.patch" ) + self._sourceTarBz2 = "%s-%s.%s.tar.bz2" % (self._packageName,self._packageVersion,self._svnTag) + self._binaryTarBz2 = "%s-binary-%s.%s-1.slsoc6.tar.bz2" % (self._packageName,self._packageVersion,self._svnTag) + self._distribPatch = os.path.join ( self._sourceDir, "bootstrap", "%s-for-distribution.patch"%self._packageName ) return def _guessOs ( self ): - self._libSuffix = None - self._osSlsoc6x_64 = re.compile (".*Linux.*el6.*x86_64.*") - self._osSlsoc6x = re.compile (".*Linux.*el6.*") - self._osSLSoC5x_64 = re.compile (".*Linux.*el5.*x86_64.*") - self._osSLSoC5x = re.compile (".*Linux.*(el5|2.6.23.13.*SoC).*") - self._osLinux_64 = re.compile (".*Linux.*x86_64.*") - self._osLinux = re.compile (".*Linux.*") - self._osDarwin = re.compile (".*Darwin.*") + self._libSuffix = None + self._osSlsoc6x_64 = re.compile (".*Linux.*el6.*x86_64.*") + self._osSlsoc6x = re.compile (".*Linux.*el6.*") + self._osSLSoC5x_64 = re.compile (".*Linux.*el5.*x86_64.*") + self._osSLSoC5x = re.compile (".*Linux.*(el5|2.6.23.13.*SoC).*") + self._osLinux_64 = re.compile (".*Linux.*x86_64.*") + self._osLinux = re.compile (".*Linux.*") + self._osFreeBSD8x_amd64 = re.compile (".*FreeBSD 8.*amd64.*") + self._osFreeBSD8x_64 = re.compile (".*FreeBSD 8.*x86_64.*") + self._osFreeBSD8x = re.compile (".*FreeBSD 8.*") + self._osDarwin = re.compile (".*Darwin.*") uname = subprocess.Popen ( ["uname", "-srm"], stdout=subprocess.PIPE ) lines = uname.stdout.readlines() @@ -152,6 +228,13 @@ class ProjectBuilder: self._libSuffix = "64" elif self._osLinux .match(lines[0]): self._osType = "Linux.i386" elif self._osDarwin .match(lines[0]): self._osType = "Darwin" + elif self._osFreeBSD8x_amd64.match(lines[0]): + self._osType = "FreeBSD.8x.amd64" + self._libSuffix = "64" + elif self._osFreeBSD8x_64.match(lines[0]): + self._osType = "FreeBSD.8x.x86_64" + self._libSuffix = "64" + elif self._osFreeBSD8x .match(lines[0]): self._osType = "FreeBSD.8x.i386" else: uname = subprocess.Popen ( ["uname", "-sr"], stdout=subprocess.PIPE ) self._osType = uname.stdout.readlines()[0][:-1] @@ -220,8 +303,11 @@ class ProjectBuilder: (pid,status) = os.waitpid ( child.pid, 0 ) status >>= 8 if status != 0: - print "[ERROR] %s (status:%d)." % (error,status) - sys.exit ( status ) + ErrorMessage( status, "%s (status:%d)."%(error,status) ).terminate() + return + + + def _enableTool ( self, tool ): return @@ -232,7 +318,7 @@ class ProjectBuilder: #cmakeModules = os.path.join ( self._installDir, "share", "cmake", "Modules" ) if not os.path.isdir(toolSourceDir): - print "[ERROR] Missing tool source directory: \"%s\" (skipped)." % toolSourceDir + print ErrorMessage( 0, "Missing tool source directory: \"%s\" (skipped)."%toolSourceDir ) return if self._rmBuild: @@ -273,7 +359,8 @@ class ProjectBuilder: command = [ "make" ] #command += [ "DESTDIR=%s" % self._installDir ] if self._enableDoc == "ON": - if tool == "crlcore" or tool == "stratus1": + #if tool == "crlcore" or tool == "stratus1": + if tool == "stratus1": command += [ "dvi", "safepdf", "html" ] command += self._makeArguments print "Make command:", command @@ -286,7 +373,7 @@ class ProjectBuilder: toolSourceDir = os.path.join ( self._sourceDir , tool ) if not os.path.isdir(toolSourceDir): if not self._quiet: - print "[ERROR] Missing tool source directory: \"%s\" (skipped)." % toolSourceDir + print ErrorMessage( 0, "Missing tool source directory: \"%s\" (skipped)."%toolSourceDir ) return os.chdir ( toolSourceDir ) @@ -301,7 +388,7 @@ class ProjectBuilder: toolSourceDir = os.path.join ( self._sourceDir , tool ) if not os.path.isdir(toolSourceDir): if not self._quiet: - print "[ERROR] Missing tool source directory: \"%s\" (skipped)." % toolSourceDir + print ErrorMessage( 0, "Missing tool source directory: \"%s\" (skipped)."%toolSourceDir) return os.chdir ( toolSourceDir ) @@ -315,11 +402,11 @@ class ProjectBuilder: def _svnCheckout ( self, tool ): project = self.getToolProject ( tool ) if not project: - print "[ERROR] Tool \"%s\" is not part of any project." % tool - print " Cannot guess the SVN repository." + print ErrorMessage( 0, "Tool \"%s\" is not part of any project."%tool + ,"Cannot guess the SVN repository." ) return if not project.getRepository (): - print "[ERROR] Project \"%s\" isn't associated to a repository." % project.getName() + print ErrorMessage( 0, "Project \"%s\" isn't associated to a repository."%project.getName() ) return toolSvnTrunkDir = os.path.join ( self._svnMethod+project.getRepository(), tool, "trunk" ) @@ -335,11 +422,11 @@ class ProjectBuilder: def _svnExport ( self, tool ): project = self.getToolProject ( tool ) if not project: - print "[ERROR] Tool \"%s\" is not part of any project." % tool - print " Cannot guess the SVN repository." + print ErrorMessage( 0, "Tool \"%s\" is not part of any project."%tool + , "Cannot guess the SVN repository.") return if not project.getRepository (): - print "[ERROR] Project \"%s\" isn't associated to a repository." % project.getName() + print ErrorMessage( 0, "Project \"%s\" isn't associated to a repository."%project.getName() ) return toolSvnTrunkDir = os.path.join ( self._svnMethod+project.getRepository(), tool, "trunk" ) @@ -380,7 +467,7 @@ class ProjectBuilder: def register ( self, project ): for registered in self._projects: if registered.getName() == project.getName(): - print "[ERROR] Project \"%s\" is already registered (ignored)." + print ErrorMessage( 0, "Project \"%s\" is already registered (ignored)." ) return self._projects += [ project ] return @@ -422,8 +509,7 @@ class ProjectBuilder: for projectName in projects: project = self.getProject ( projectName ) if not project: - print "[ERROR] No project of name \"%s\"." % projectName - sys.exit ( 1 ) + ErrorMessage( 1, "No project of name \"%s\"."%projectName ).terminate() project.activateAll() if not tools and not projects: @@ -441,6 +527,18 @@ class ProjectBuilder: return + def enable ( self, tools, projects ): + self._commandTemplate ( tools, projects, "_enableTool" ) + return + + + def enabledTools ( self ): + tools = [] + for project in self._projects: + tools += project.getActives() + return tools + + def build ( self, tools, projects ): self._commandTemplate ( tools, projects, "_build" ) return @@ -466,7 +564,7 @@ class ProjectBuilder: return - def tarball ( self, tools, projects ): + def svnTarball ( self, tools, projects ): if self._svnTag == "x": self._guessSvnTag ( self.getProject(projects[0]) ) @@ -482,12 +580,8 @@ class ProjectBuilder: os.makedirs ( self._tarballDir ) self.svnExport ( tools, projects ) - removeds = [ os.path.join("vlsisapd","src","openChams") - , os.path.join("vlsisapd","src","dtr") - ] - # Remove unpublisheds (yet) tools/files. - for item in removeds: + for item in self._packageExcludes: command = [ "/bin/rm", "-r", os.path.join(self._archiveDir,item) ] self._execute ( command, "rm of %s failed" % item) @@ -510,7 +604,8 @@ class ProjectBuilder: os.chdir ( self._tarballDir ) command = [ "/bin/tar" - , "--exclude", "\\.svn" + , "--exclude-backups" + , "--exclude-vcs" , "-jcvf", self._sourceTarBz2, os.path.basename(self._archiveDir) ] self._execute ( command, "tar command failed" ) @@ -521,8 +616,33 @@ class ProjectBuilder: return - def doRpm ( self, tools, projects ): - self.tarball ( tools, projects ) + def userTarball ( self, tools, projects ): + self.enable( tools, projects ) + + userSourceTarBz2 = os.path.join ( self._tarballDir + , datetime.date.today().strftime('%s-%s-%%Y%%m%%d.tar.bz2'% + (self._packageName + ,self._packageVersion)) ) + + excludes = [] + for exclude in self._packageExcludes: + excludes += [ '--exclude='+exclude ] + + os.chdir ( self._sourceDir ) + command = [ "/bin/tar" + , "--exclude-backups" + , "--exclude-vcs" + , "--transform=s,^,%s/src/,"%self._projectDir ] \ + + excludes \ + + [ "-jcvf", userSourceTarBz2 ] \ + + self.enabledTools() + self._execute ( command, "tar command failed" ) + + return + + + def doRpm ( self ): + self.svnTarball ( [], self._packageProjects ) for rpmDir in [ "SOURCES", "SPECS", "BUILD", "tmp" , "SRPMS", "RPMS/i386", "RPMS/i686", "RPMS/x86_64" ]: @@ -554,8 +674,8 @@ class ProjectBuilder: return - def doDeb ( self, tools, projects ): - self.tarball ( tools, projects ) + def doDeb ( self ): + self.svnTarball ( [], self._packageProjects ) if not os.path.isdir(self._debbuildDir): os.makedirs ( self._debbuildDir ) @@ -583,110 +703,163 @@ class ProjectBuilder: return + def loadConfiguration ( self, confFile ): + moduleGlobals = globals() + + print 'Reading configuration from:' + print ' <%s>' % options.conf + + if not os.path.isfile(confFile): + ErrorMessage( 1, 'Missing configuration file:', '<%s>'%confFile ).terminate() + + try: + execfile( confFile, moduleGlobals ) + except Exception, e: + ErrorMessage( 1, 'An exception occured while loading the configuration file:' + , '<%s>\n' % (confFile) + , 'You should check for simple python errors in this file.' + , 'Error was:' + , '%s\n' % e ).terminate() + + if moduleGlobals.has_key('projects'): + entryNb = 0 + for entry in moduleGlobals['projects']: + entryNb += 1 + if not entry.has_key('name'): + raise ErrorMessage( 1, 'Missing project name in project entry #%d.' % entryNb ) + if not entry.has_key('tools'): + raise ErrorMessage( 1, 'Missing tools list in project entry #%d (<%s>).' \ + % (entryNb,entry['name']) ) + if not isinstance(entry['tools'],list): + raise ErrorMessage( 1, 'Tools item of project entry #%d (<%s>) is not a list.' \ + % (entryNb,entry['name']) ) + if not entry.has_key('repository'): + raise ErrorMessage( 1, 'Missing project repository in project entry #%d.' \ + % entryNb ) + + self.register( Project(entry['name'],entry['tools'],entry['repository']) ) + else: + ErrorMessage( 1, 'Configuration file is missing the \'project\' symbol.' + , '<%s>'%confFile ).terminate() + + if moduleGlobals.has_key('projectdir'): + self.projectDir = moduleGlobals['projectdir'] + + if moduleGlobals.has_key('svnconfig'): + svnconfig = moduleGlobals['svnconfig'] + if svnconfig.has_key('method'): self._svnMethod = svnconfig['method'] + + if moduleGlobals.has_key('package'): + package = moduleGlobals['package'] + if package.has_key('name' ): self.packageName = package['name'] + if package.has_key('version' ): self.packageVersion = package['version'] + if package.has_key('excludes'): + if not isinstance(package['excludes'],list): + raise ErrorMessage( 1, 'Excludes of package configuration is not a list.') + self._packageExcludes = package['excludes'] + if package.has_key('projects'): + if not isinstance(package['projects'],list): + raise ErrorMessage( 1, 'Projects to package is not a list.') + self._packageProjects = package['projects'] + return + + + def showConfiguration ( self ): + print 'BuildCoriolis Configuration:' + if self._svnMethod: + print ' SVN Method: <%s>' % self._svnMethod + else: + print ' SVN Method not defined, will not be able to checkout/commit.' + + for project in self._projects: + print ' project:%-15s repository:<%s>' % ( ('<%s>'%project.getName()), project.getRepository() ) + toolOrder = 1 + for tool in project.getTools(): + print '%s%02d:<%s>' % (' '*26,toolOrder,tool) + toolOrder += 1 + print + return + + if __name__ == "__main__": - bootstrap = Project ( name = "bootstrap" - , tools =[ "bootstrap" ] - , repository="/users/outil/coriolis/svn" - ) + try: + scriptPath = os.path.abspath( os.path.dirname(sys.argv[0]) ) + print 'buildCoriolis.py is run from:' + print ' <%s>' % scriptPath - vlsisapd = Project ( name = "vlsisapd" - , tools =[ "vlsisapd" ] - , repository="/users/outil/coriolis/svn" - ) + parser = optparse.OptionParser () + # Build relateds. + parser.add_option ( "-c", "--conf", type="string", dest="conf", default=os.path.join(scriptPath,'build.conf') + , help="Fichier de configuration." ) + parser.add_option ( "--show-conf" , action="store_true" , dest="showConf" , help="Display the Project/Tools configuration, then exit." ) + parser.add_option ( "-q", "--quiet" , action="store_true" , dest="quiet" , help="Do not print all the informative messages." ) + parser.add_option ( "-r", "--release" , action="store_true" , dest="release" , help="Build a aka optimized version." ) + parser.add_option ( "-d", "--debug" , action="store_true" , dest="debug" , help="Build a aka (-g) version." ) + parser.add_option ( "-s", "--static" , action="store_true" , dest="static" , help="Try to link statically, as much as possible." ) + parser.add_option ( "--doc" , action="store_true" , dest="doc" , help="Enable the documentation building (uses with -j1)." ) + parser.add_option ( "-v", "--verbose" , action="store_true" , dest="verboseMakefile" , help="Tells CMake to print all compilation commands." ) + parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" , help="The root directory (default: <~/coriolis-2.x/>)." ) + parser.add_option ( "--no-build" , action="store_true" , dest="noBuild" , help="Do *not* build anything (by default: build)." ) + parser.add_option ( "--no-cache" , action="store_true" , dest="noCache" , help="Remove previous CMake cache before building." ) + parser.add_option ( "--rm-build" , action="store_true" , dest="rmBuild" , help="Remove previous build directoty before building." ) + parser.add_option ( "--make" , action="store" , type="string", dest="makeArguments", help="Arguments to pass to make (ex: \"-j4 install\")." ) + parser.add_option ( "--project" , action="append" , type="string", dest="projects" , help="The name of a project to build (may appears any number of time)." ) + parser.add_option ( "-t", "--tool" , action="append" , type="string", dest="tools" , help="The name of a tool to build (may appears any number of time)." ) + # SVN repository relateds. + parser.add_option ( "--svn-tag" , action="store" , type="string", dest="svnTag" , help="Explicitly select a SVN tag (for SVN related commands)." ) + parser.add_option ( "--svn-method" , action="store" , type="string", dest="svnMethod" , help="Allows to sets the svn checkout method (svn+ssh://coriolis.soc.lip6.fr)." ) + parser.add_option ( "--svn-status" , action="store_true" , dest="svnStatus" , help="Check status against the SVN repository." ) + parser.add_option ( "--svn-update" , action="store_true" , dest="svnUpdate" , help="Update to the latest SVN version *or* the one given by svn-tag." ) + parser.add_option ( "--svn-checkout" , action="store_true" , dest="svnCheckout", help="Checkout the latest SVN version *or* the one given by svn-tag." ) + # Miscellaneous. + parser.add_option ( "--user-tarball" , action="store_true" , dest="userTarball", help="Regenerate a tarball from checked out sources (in /tarball/." ) + parser.add_option ( "--tarball" , action="store_true" , dest="tarball" , help="Regenerate a tarball (in /tarball/." ) + parser.add_option ( "--rpm" , action="store_true" , dest="doRpm" , help="Regenerate RPM packages." ) + parser.add_option ( "--deb" , action="store_true" , dest="doDeb" , help="Regenerate Debian/Ubuntu packages." ) + # Katabatic/Kite specific options. + parser.add_option ( "-D", "--check-db" , action="store_true" , dest="checkDb" , help="Enable Katabatic/Kite data-base checking (*very* slow)." ) + parser.add_option ( "-u", "--check-deter", action="store_true" , dest="checkDeterminism", help="Enable Katabatic/Kite determinism checking (*very* slow)." ) + ( options, args ) = parser.parse_args () + + builder = ProjectBuilder () + builder.loadConfiguration ( options.conf ) - coriolis = Project ( name = "coriolis" - , tools =[ "hurricane" - , "crlcore" - , "nimbus" - , "metis" - , "mauka" - , "knik" - , "katabatic" - , "kite" - , "equinox" - , "solstice" - , "unicorn" - , "ispd" - , "cumulus" - , "stratus1" - ] - , repository="/users/outil/coriolis/svn" - ) - chams = Project ( name = "chams" - , tools =[ "hurricaneAMS" - , "amsCore" - , "opSim" - , "scribe" - , "graph" - , "pharos" - , "isis" - , "schematic" - , "autoDTR" - ] - , repository="/users/outil/chams/svn" - ) - - parser = optparse.OptionParser () - # Build relateds. - parser.add_option ( "-q", "--quiet" , action="store_true" , dest="quiet" , help="Do not print all the informative messages." ) - parser.add_option ( "-r", "--release" , action="store_true" , dest="release" , help="Build a aka optimized version." ) - parser.add_option ( "-d", "--debug" , action="store_true" , dest="debug" , help="Build a aka (-g) version." ) - parser.add_option ( "-s", "--static" , action="store_true" , dest="static" , help="Try to link statically, as much as possible." ) - parser.add_option ( "--doc" , action="store_true" , dest="doc" , help="Enable the documentation building (uses with -j1)." ) - parser.add_option ( "-v", "--verbose" , action="store_true" , dest="verboseMakefile" , help="Tells CMake to print all compilation commands." ) - parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" , help="The root directory (default: <~/coriolis-2.x/>)." ) - parser.add_option ( "--no-build" , action="store_true" , dest="noBuild" , help="Do *not* build anything (by default: build)." ) - parser.add_option ( "--no-cache" , action="store_true" , dest="noCache" , help="Remove previous CMake cache before building." ) - parser.add_option ( "--rm-build" , action="store_true" , dest="rmBuild" , help="Remove previous build directoty before building." ) - parser.add_option ( "--make" , action="store" , type="string", dest="makeArguments", help="Arguments to pass to make (ex: \"-j4 install\")." ) - parser.add_option ( "--project" , action="append" , type="string", dest="projects" , help="The name of a project to build (may appears any number of time)." ) - parser.add_option ( "-t", "--tool" , action="append" , type="string", dest="tools" , help="The name of a tool to build (may appears any number of time)." ) - # SVN repository relateds. - parser.add_option ( "--svn-tag" , action="store" , type="string", dest="svnTag" , help="Explicitly select a SVN tag (for SVN related commands)." ) - parser.add_option ( "--svn-method" , action="store" , type="string", dest="svnMethod" , help="Allows to sets the svn checkout method (svn+ssh://coriolis.soc.lip6.fr)." ) - parser.add_option ( "--svn-status" , action="store_true" , dest="svnStatus" , help="Check status against the SVN repository." ) - parser.add_option ( "--svn-update" , action="store_true" , dest="svnUpdate" , help="Update to the latest SVN version *or* the one given by svn-tag." ) - parser.add_option ( "--svn-checkout" , action="store_true" , dest="svnCheckout", help="Checkout the latest SVN version *or* the one given by svn-tag." ) - # Miscellaneous. - parser.add_option ( "--tarball" , action="store_true" , dest="tarball" , help="Regenerate a tarball (in /tarball/." ) - parser.add_option ( "--rpm" , action="store_true" , dest="doRpm" , help="Regenerate RPM packages." ) - parser.add_option ( "--deb" , action="store_true" , dest="doDeb" , help="Regenerate Debian/Ubuntu packages." ) - # Katabatic/Kite specific options. - parser.add_option ( "-D", "--check-db" , action="store_true" , dest="checkDb" , help="Enable Katabatic/Kite data-base checking (*very* slow)." ) - parser.add_option ( "-u", "--check-deter", action="store_true" , dest="checkDeterminism", help="Enable Katabatic/Kite determinism checking (*very* slow)." ) - ( options, args ) = parser.parse_args () - - builder = ProjectBuilder () - builder.register ( bootstrap ) - builder.register ( vlsisapd ) - builder.register ( coriolis ) - builder.register ( chams ) - - if options.quiet: builder.quiet = True - if options.release: builder.buildMode = "Release" - if options.debug: builder.buildMode = "Debug" - if options.static: builder.enableShared = "OFF" - if options.doc: builder.enableDoc = "ON" - if options.checkDb: builder.checkDatabase = "ON" - if options.checkDeterminism: builder.enableDeterminism = "ON" - if options.verboseMakefile: builder.verboseMakefile = "ON" - if options.rootDir: builder.rootDir = options.rootDir - if options.noBuild: builder.doBuild = False - if options.noCache: builder.noCache = True - if options.rmBuild: builder.rmBuild = True - if options.makeArguments: builder.makeArguments = options.makeArguments - if options.svnMethod: builder.svnMethod = options.svnMethod - if options.svnTag: builder.svnTag = options.svnTag - - packagedProjects = [ "bootstrap", "vlsisapd", "coriolis" ] - - if options.svnStatus: builder.svnStatus ( tools=options.tools, projects=options.projects ) - elif options.svnUpdate: builder.svnUpdate ( tools=options.tools, projects=options.projects ) - elif options.svnCheckout: builder.svnCheckout ( tools=options.tools, projects=options.projects ) - elif options.tarball: builder.tarball ( tools=options.tools, projects=options.projects ) - elif options.doRpm: builder.doRpm ( tools=[] , projects=packagedProjects ) - elif options.doDeb: builder.doDeb ( tools=[] , projects=packagedProjects ) - else: builder.build ( tools=options.tools, projects=options.projects ) + if options.showConf: + builder.showConfiguration () + sys.exit(0) + + if options.quiet: builder.quiet = True + if options.release: builder.buildMode = "Release" + if options.debug: builder.buildMode = "Debug" + if options.static: builder.enableShared = "OFF" + if options.doc: builder.enableDoc = "ON" + if options.checkDb: builder.checkDatabase = "ON" + if options.checkDeterminism: builder.enableDeterminism = "ON" + if options.verboseMakefile: builder.verboseMakefile = "ON" + if options.rootDir: builder.rootDir = options.rootDir + if options.noBuild: builder.doBuild = False + if options.noCache: builder.noCache = True + if options.rmBuild: builder.rmBuild = True + if options.makeArguments: builder.makeArguments = options.makeArguments + if options.svnMethod: builder.svnMethod = options.svnMethod + if options.svnTag: builder.svnTag = options.svnTag + + packagedProjects = [ "bootstrap", "vlsisapd", "coriolis" ] + + if options.svnStatus: builder.svnStatus ( tools=options.tools, projects=options.projects ) + elif options.svnUpdate: builder.svnUpdate ( tools=options.tools, projects=options.projects ) + elif options.svnCheckout: builder.svnCheckout ( tools=options.tools, projects=options.projects ) + elif options.userTarball: builder.userTarball ( tools=options.tools, projects=options.projects ) + elif options.tarball: builder.svnTarball ( tools=options.tools, projects=options.projects ) + elif options.doRpm: builder.doRpm () + elif options.doDeb: builder.doDeb () + else: builder.build ( tools=options.tools, projects=options.projects ) + except ErrorMessage, e: + print e + sys.exit(e.code) + #except Exception, e: + # print e + # sys.exit(1) sys.exit ( 0 ) diff --git a/bootstrap/coriolis2.sh b/bootstrap/coriolis2.sh index 05ae5edb..5554dc08 100644 --- a/bootstrap/coriolis2.sh +++ b/bootstrap/coriolis2.sh @@ -16,7 +16,7 @@ echo $coriolisEnvPy if [ -e ${coriolisEnvPy} ]; then - eval "`${coriolisEnvPy} --v2 --release --shared --python`" + eval "`${coriolisEnvPy} --release --shared`" else echo "[ERROR] Missing ${coriolisEnvPy} script." fi diff --git a/bootstrap/coriolisEnv.py b/bootstrap/coriolisEnv.py index 47be7172..c01b3a7a 100755 --- a/bootstrap/coriolisEnv.py +++ b/bootstrap/coriolisEnv.py @@ -32,15 +32,18 @@ def stripPath ( pathName ): def guessOs (): - osSlsoc6x_64 = re.compile (".*Linux.*el6.*x86_64.*") - osSlsoc6x = re.compile (".*Linux.*(el|slsoc)6.*") - osSLSoC5x_64 = re.compile (".*Linux.*el5.*x86_64.*") - osSLSoC5x = re.compile (".*Linux.*(el5|2.6.23.13.*SoC).*") - osLinux_64 = re.compile (".*Linux.*x86_64.*") - osLinux = re.compile (".*Linux.*") - osDarwin = re.compile (".*Darwin.*") - osUbuntu1004 = re.compile (".*Linux.*ubuntu.*") - osUbuntu1004_64 = re.compile (".*Linux.*ubuntu.*x86_64.*") + osSlsoc6x_64 = re.compile (".*Linux.*el6.*x86_64.*") + osSlsoc6x = re.compile (".*Linux.*(el|slsoc)6.*") + osSLSoC5x_64 = re.compile (".*Linux.*el5.*x86_64.*") + osSLSoC5x = re.compile (".*Linux.*(el5|2.6.23.13.*SoC).*") + osLinux_64 = re.compile (".*Linux.*x86_64.*") + osLinux = re.compile (".*Linux.*") + osDarwin = re.compile (".*Darwin.*") + osUbuntu1004 = re.compile (".*Linux.*ubuntu.*") + osUbuntu1004_64 = re.compile (".*Linux.*ubuntu.*x86_64.*") + osFreeBSD8x_amd64 = re.compile (".*FreeBSD 8.*amd64.*") + osFreeBSD8x_64 = re.compile (".*FreeBSD 8.*x86_64.*") + osFreeBSD8x = re.compile (".*FreeBSD 8.*") uname = subprocess.Popen ( ["uname", "-srm"], stdout=subprocess.PIPE ) lines = uname.stdout.readlines() @@ -48,7 +51,7 @@ def guessOs (): libDir="lib" if osSlsoc6x_64.match(lines[0]): osType = "Linux.slsoc6x_64" - libDir = "64" + libDir = "lib64" elif osSlsoc6x.match(lines[0]): osType = "Linux.slsoc6x" elif osSLSoC5x_64.match(lines[0]): osType = "Linux.SLSoC5x_64" @@ -65,6 +68,14 @@ def guessOs (): libDir = "lib64" elif osLinux.match(lines[0]): osType = "Linux.i386" + elif osFreeBSD8x_64.match(lines[0]): + osType = "FreeBSD.8x.x86_64" + libDir = "lib64" + elif osFreeBSD8x_amd64.match(lines[0]): + osType = "FreeBSD.8x.amd64" + libDir = "lib64" + elif osFreeBSD8x.match(lines[0]): + osType = "FreeBSD.8x.i386" elif osDarwin.match(lines[0]): osType = "Darwin" else: @@ -84,25 +95,20 @@ if __name__ == "__main__": (osType,libDir) = guessOs() buildType = "Release" linkType = "Shared" - coriolisVersion = None rootDir = None parser = optparse.OptionParser () # Build relateds. - parser.add_option ( "--csh" , action="store_true" , dest="csh" ) - parser.add_option ( "--v1" , action="store_true" , dest="v1" ) - parser.add_option ( "--v2" , action="store_true" , dest="v2" ) - parser.add_option ( "--release", action="store_true" , dest="release" ) - parser.add_option ( "--debug" , action="store_true" , dest="debug" ) - parser.add_option ( "--devel" , action="store_true" , dest="devel" ) - parser.add_option ( "--static" , action="store_true" , dest="static" ) - parser.add_option ( "--shared" , action="store_true" , dest="shared" ) - parser.add_option ( "--python" , action="store_true" , dest="python" ) - parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" ) + parser.add_option ( "--csh" , action="store_true" , dest="csh" ) + parser.add_option ( "--release" , action="store_true" , dest="release" ) + parser.add_option ( "--debug" , action="store_true" , dest="debug" ) + parser.add_option ( "--devel" , action="store_true" , dest="devel" ) + parser.add_option ( "--static" , action="store_true" , dest="static" ) + parser.add_option ( "--shared" , action="store_true" , dest="shared" ) + parser.add_option ( "--no-python", action="store_true" , dest="nopython" ) + parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" ) ( options, args ) = parser.parse_args () - if options.v1: coriolisVersion = 1 - if options.v2: coriolisVersion = 2 if options.release: buildType = "Release" if options.debug: buildType = "Debug" if options.devel: buildType = "Debug" @@ -114,102 +120,75 @@ if __name__ == "__main__": strippedLibraryPath = stripPath ( "LD_LIBRARY_PATH" ) strippedPythonPath = stripPath ( "PYTHONPATH" ) - if coriolisVersion == 1: + shellScriptSh = \ + """echo "%(MESSAGE)s";\n""" \ + """echo "Switching to Coriolis 2.x (%(buildDir)s)";\n""" \ + """PATH="%(PATH)s";\n""" \ + """LD_LIBRARY_PATH="%(LD_LIBRARY_PATH)s";\n""" \ + """BOOTSTRAP_TOP="%(BOOTSTRAP_TOP)s";\n""" \ + """CORIOLIS_TOP="%(CORIOLIS_TOP)s";\n""" \ + """STRATUS_MAPPING_NAME="%(SYSCONF_DIR)s/stratus2sxlib.xml";\n""" \ + """export PATH LD_LIBRARY_PATH BOOTSTRAP_TOP CORIOLIS_TOP STRATUS_MAPPING_NAME;\n""" \ + """hash -r;\n""" + shellScriptCsh = \ + """echo "%(MESSAGE)s";\n""" \ + """echo "Switching to Coriolis 2.x (%(buildDir)s)";\n""" \ + """setenv PATH "%(PATH)s";\n""" \ + """setenv LD_LIBRARY_PATH "%(LD_LIBRARY_PATH)s";\n""" \ + """setenv BOOTSTRAP_TOP "%(BOOTSTRAP_TOP)s";\n""" \ + """setenv CORIOLIS_TOP "%(CORIOLIS_TOP)s";\n""" \ + """setenv STRATUS_MAPPING_NAME "%(SYSCONF_DIR)s/stratus2sxlib.xml";\n""" \ + """rehash\n;""" + + buildDir = buildType + "." + linkType + scriptDir = os.path.dirname ( os.path.abspath(__file__) ) + #print "echo \"Script Location: %s\";" % scriptDir, + if scriptDir.startswith("/etc/coriolis2"): + coriolisTop = "/usr" + sysconfDir = scriptDir + shellMessage = "Using system-wide Coriolis 2 (/usr)" + elif scriptDir.startswith("/users/outil/coriolis/coriolis-2.x/") \ + or scriptDir.startswith("/soc/coriolis2/"): + coriolisTop = "/soc/coriolis2" + sysconfDir = coriolisTop + "/etc/coriolis2" + shellMessage = "Using SoC network-wide Coriolis 2 (/soc/coriolis2)" + else: if not rootDir: - rootDir = os.getenv("HOME") + "/coriolis-1.x" + rootDir = os.getenv("HOME") + "/coriolis-2.x" + coriolisTop = "%s/%s/%s/install" % ( rootDir, osType, buildDir ) + sysconfDir = coriolisTop + "/etc/coriolis2" + shellMessage = "Using user-selected Coriolis 2 (%s)" % rootDir - hurricaneTop = "%s/coriolis/%s/install" % ( rootDir, osType ) - buildDir = None - shellScript = \ -""" -echo "Switching to Coriolis 1.x"; -PATH=%(PATH)s; -LD_LIBRARY_PATH=%(LD_LIBRARY_PATH)s; -PYTHONPATH=%(PYTHONPATH)s; -HURRICANE_TOP=%(HURRICANE_TOP)s; -CORIOLIS_TOP=%(HURRICANE_TOP)s; -export PATH LD_LIBRARY_PATH PYTHONPATH HURRICANE_TOP CORIOLIS_TOP; -hash -r; -if [ -f "%(HURRICANE_TOP)s/share/etc/coriolis.sh" ]; then - . "%(HURRICANE_TOP)s/share/etc/coriolis.sh" -fi - """ + absLibDir = "%s/%s" % ( coriolisTop, libDir ) + strippedPath = "%s/bin:%s" % ( coriolisTop, strippedPath ) + strippedLibraryPath = "%s:%s" % ( absLibDir , strippedLibraryPath ) - elif coriolisVersion == 2: - - buildDir = buildType + "." + linkType - scriptDir = os.path.dirname ( os.path.abspath(__file__) ) - #print "echo \"Script Location: %s\";" % scriptDir, - if scriptDir.startswith("/etc/coriolis2"): - coriolisTop = "/usr" - sysconfDir = scriptDir - shellMessage = "Using system-wide Coriolis 2 (/usr)" - elif scriptDir.startswith("/users/outil/coriolis/coriolis-2.x/") \ - or scriptDir.startswith("/soc/coriolis2/"): - coriolisTop = "/soc/coriolis2" - sysconfDir = coriolisTop + "/etc/coriolis2" - shellMessage = "Using SoC network-wide Coriolis 2 (/soc/coriolis2)" + if not options.nopython: + pyVersion = sys.version_info + version = "%d.%d" % (pyVersion[0],pyVersion[1]) + if osType.startswith("Linux.SL") or osType.startswith("Linux.sl"): + sitePackagesDir = "%s/python%s/site-packages" % (absLibDir,version) else: - if not rootDir: - rootDir = os.getenv("HOME") + "/coriolis-2.x" - coriolisTop = "%s/%s/%s/install" % ( rootDir, osType, buildDir ) - sysconfDir = coriolisTop + "/etc/coriolis2" - shellMessage = "Using user-selected Coriolis 2 (%s)" % rootDir + sitePackagesDir = "%s/python%s/dist-packages" % (absLibDir,version) - absLibDir = "%s/%s" % ( coriolisTop, libDir ) - strippedPath = "%s/bin:%s" % ( coriolisTop, strippedPath ) - strippedLibraryPath = "%s:%s" % ( absLibDir , strippedLibraryPath ) + strippedPythonPath = "%s:" % (sitePackagesDir) + strippedPythonPath + strippedPythonPath = "%s/cumulus:" % (sitePackagesDir) + strippedPythonPath + strippedPythonPath = "%s/stratus:" % (sitePackagesDir) + strippedPythonPath - if options.python: - pyVersion = sys.version_info - version = "%d.%d" % (pyVersion[0],pyVersion[1]) - if osType.startswith("Linux.SL") or osType.startswith("Linux.sl"): - sitePackagesDir = "%s/python%s/site-packages" % (absLibDir,version) - else: - sitePackagesDir = "%s/python%s/dist-packages" % (absLibDir,version) + shellScriptSh += """PYTHONPATH="%(PYTHONPATH)s";\n""" \ + """export PYTHONPATH""" + shellScriptCsh += """setenv PYTHONPATH "%(PYTHONPATH)s";""" - strippedPythonPath = "%s:" % (sitePackagesDir) + strippedPythonPath - strippedPythonPath = "%s/cumulus:" % (sitePackagesDir) + strippedPythonPath - strippedPythonPath = "%s/stratus:" % (sitePackagesDir) + strippedPythonPath + if options.csh: shellScript = shellScriptCsh + else: shellScript = shellScriptSh - shellScriptSh = \ -""" -echo "%(MESSAGE)s"; -echo "Switching to Coriolis 2.x (%(buildDir)s)"; -PATH="%(PATH)s"; -LD_LIBRARY_PATH="%(LD_LIBRARY_PATH)s"; -PYTHONPATH="%(PYTHONPATH)s"; -BOOTSTRAP_TOP="%(BOOTSTRAP_TOP)s"; -CORIOLIS_TOP="%(CORIOLIS_TOP)s"; -STRATUS_MAPPING_NAME="%(SYSCONF_DIR)s/stratus2sxlib.xml"; -export PATH LD_LIBRARY_PATH PYTHONPATH BOOTSTRAP_TOP CORIOLIS_TOP STRATUS_MAPPING_NAME; -hash -r -""" - - shellScriptCsh = \ -""" -echo "%(MESSAGE)s"; -echo "Switching to Coriolis 2.x (%(buildDir)s)"; -setenv PATH "%(PATH)s"; -setenv LD_LIBRARY_PATH "%(LD_LIBRARY_PATH)s"; -setenv PYTHONPATH "%(PYTHONPATH)s"; -setenv BOOTSTRAP_TOP "%(BOOTSTRAP_TOP)s"; -setenv CORIOLIS_TOP "%(CORIOLIS_TOP)s"; -setenv STRATUS_MAPPING_NAME "%(SYSCONF_DIR)s/stratus2sxlib.xml"; -rehash -""" - - if coriolisVersion: - if options.csh: shellScript = shellScriptCsh - else: shellScript = shellScriptSh - - print shellScript % { "PATH" : strippedPath - , "LD_LIBRARY_PATH" : strippedLibraryPath - , "PYTHONPATH" : strippedPythonPath - , "BOOTSTRAP_TOP" : coriolisTop - , "CORIOLIS_TOP" : coriolisTop - , "SYSCONF_DIR" : sysconfDir - , "MESSAGE" : shellMessage - , "buildDir" : buildDir - } + print shellScript % { "PATH" : strippedPath + , "LD_LIBRARY_PATH" : strippedLibraryPath + , "PYTHONPATH" : strippedPythonPath + , "BOOTSTRAP_TOP" : coriolisTop + , "CORIOLIS_TOP" : coriolisTop + , "SYSCONF_DIR" : sysconfDir + , "MESSAGE" : shellMessage + , "buildDir" : buildDir + }