2010-03-16 11:18:09 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import time
|
|
|
|
import socket
|
|
|
|
import subprocess
|
|
|
|
import optparse
|
|
|
|
|
|
|
|
|
|
|
|
class Project:
|
|
|
|
|
|
|
|
def __init__ ( self, name, tools, repository ):
|
|
|
|
self._name = name
|
|
|
|
self._tools = tools
|
|
|
|
self._repository = repository
|
|
|
|
self._actives = []
|
|
|
|
return
|
|
|
|
|
|
|
|
def getName ( self ): return self._name
|
|
|
|
def getTools ( self ): return self._tools
|
|
|
|
def getRepository ( self ): return self._repository
|
|
|
|
def getActives ( self ): return self._actives
|
2010-03-23 04:36:38 -05:00
|
|
|
def hasTool ( self, tool ): return tool in self._tools
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
def desactivate ( self ):
|
|
|
|
self._active = []
|
|
|
|
return
|
|
|
|
|
|
|
|
def activateAll ( self ):
|
|
|
|
self._actives = self._tools
|
|
|
|
return
|
|
|
|
|
|
|
|
def activate ( self, tools ):
|
|
|
|
# Build the ordered list.
|
|
|
|
for tool in self._tools:
|
2010-04-04 05:19:38 -05:00
|
|
|
if (tool in tools) and not (tool in self._actives):
|
2010-03-16 11:18:09 -05:00
|
|
|
self._actives += [ tool ]
|
|
|
|
# Find the tools not part of the project.
|
|
|
|
rejecteds = []
|
|
|
|
for tool in tools:
|
2010-04-04 05:19:38 -05:00
|
|
|
if not (tool in self._tools) and (not tool in rejecteds):
|
2010-03-16 11:18:09 -05:00
|
|
|
rejecteds += [ tool ]
|
|
|
|
return rejecteds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProjectBuilder:
|
|
|
|
|
|
|
|
def __init__ ( self ):
|
|
|
|
self._projects = []
|
|
|
|
self._standalones = []
|
|
|
|
self._svnTag = "x"
|
2010-04-27 09:19:10 -05:00
|
|
|
self._svnMethod = "svn+ssh://coriolis.soc.lip6.fr"
|
2010-03-16 11:18:09 -05:00
|
|
|
self._rootDir = os.path.join ( os.environ["HOME"], "coriolis-2.x" )
|
2010-03-19 05:05:30 -05:00
|
|
|
self._quiet = False
|
2010-03-16 11:18:09 -05:00
|
|
|
self._buildMode = "Release"
|
2010-04-28 10:54:30 -05:00
|
|
|
self._rmBuild = False
|
2010-03-16 11:18:09 -05:00
|
|
|
self._doBuild = True
|
|
|
|
self._noCache = False
|
|
|
|
self._enableShared = "ON"
|
|
|
|
self._enableDoc = "OFF"
|
|
|
|
self._checkDatabase = "OFF"
|
|
|
|
self._checkDeterminism = "OFF"
|
|
|
|
self._verboseMakefile = "OFF"
|
|
|
|
self._libMode = "Shared"
|
|
|
|
self._makeArguments = []
|
2010-03-18 10:38:10 -05:00
|
|
|
self._environment = os.environ
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
self._guessOs ()
|
|
|
|
self._updateSecondary ()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def __setattr__ ( self, attribute, value ):
|
|
|
|
if attribute[0] == "_":
|
|
|
|
self.__dict__[attribute] = value
|
|
|
|
return
|
|
|
|
|
|
|
|
if attribute == "svnTag": self._svnTag = value
|
2010-04-20 07:05:52 -05:00
|
|
|
elif attribute == "svnMethod": self._svnMethod = value
|
2010-03-22 09:13:40 -05:00
|
|
|
elif attribute == "rootDir": self._rootDir = os.path.expanduser(value)
|
2010-03-19 05:05:30 -05:00
|
|
|
elif attribute == "quiet": self._quiet = value
|
2010-03-16 11:18:09 -05:00
|
|
|
elif attribute == "buildMode": self._buildMode = value
|
2010-04-28 10:54:30 -05:00
|
|
|
elif attribute == "rmBuild": self._rmBuild = value
|
2010-03-16 11:18:09 -05:00
|
|
|
elif attribute == "doBuild": self._doBuild = value
|
|
|
|
elif attribute == "noCache": self._noCache = value
|
|
|
|
elif attribute == "enableShared": self._enableShared = value
|
|
|
|
elif attribute == "enableDoc": self._enableDoc = value
|
|
|
|
elif attribute == "enableShared": self._enableShared = value
|
|
|
|
elif attribute == "checkDatabase": self._checkDatabase = value
|
|
|
|
elif attribute == "checkDeterminism": self._checkDeterminism = value
|
|
|
|
elif attribute == "verboseMakefile": self._verboseMakefile = value
|
|
|
|
elif attribute == "makeArguments": self._makeArguments = value.split ()
|
|
|
|
elif attribute == "libMode": self._libMode = value
|
|
|
|
self._updateSecondary ()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def _updateSecondary ( self ):
|
2011-02-02 06:02:39 -06:00
|
|
|
self._rpmbuildDir = os.path.join ( self._rootDir , "rpmbuild" )
|
|
|
|
self._debbuildDir = os.path.join ( self._rootDir , "debbuild" )
|
2010-06-08 07:15:31 -05:00
|
|
|
self._tmppathDir = os.path.join ( self._rpmbuildDir, "tmp" )
|
2011-02-02 06:02:39 -06:00
|
|
|
self._tarballDir = os.path.join ( self._rootDir , "tarball" )
|
|
|
|
self._archiveDir = os.path.join ( self._tarballDir , "coriolis2-1.0.%s" % self._svnTag )
|
|
|
|
self._sourceDir = os.path.join ( self._rootDir , "src" )
|
2010-06-08 07:15:31 -05:00
|
|
|
self._osDir = os.path.join ( self._rootDir
|
2010-03-16 11:18:09 -05:00
|
|
|
, self._osType
|
|
|
|
, "%s.%s" % (self._buildMode,self._libMode) )
|
2010-06-08 07:15:31 -05:00
|
|
|
self._buildDir = os.path.join ( self._osDir, "build" )
|
|
|
|
self._installDir = os.path.join ( self._osDir, "install" )
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
if self._enableShared == "ON": self._libMode = "Shared"
|
|
|
|
else: self._libMode = "Static"
|
2010-05-17 09:45:55 -05:00
|
|
|
|
2010-07-14 14:50:21 -05:00
|
|
|
self._specFileIn = os.path.join ( self._sourceDir, "bootstrap", "coriolis2.spec.in" )
|
|
|
|
self._specFile = os.path.join ( self._sourceDir, "bootstrap", "coriolis2.spec" )
|
2011-02-02 04:40:25 -06:00
|
|
|
self._debianDir = os.path.join ( self._sourceDir, "bootstrap", "debian" )
|
2010-05-17 10:37:30 -05:00
|
|
|
self._sourceTarBz2 = "coriolis2-1.0.%s.tar.bz2" % self._svnTag
|
|
|
|
self._binaryTarBz2 = "coriolis2-binary-1.0.%s-1.el5_soc.tar.bz2" % self._svnTag
|
2010-07-14 14:50:21 -05:00
|
|
|
self._distribPatch = os.path.join ( self._sourceDir, "bootstrap", "coriolis2-for-distribution.patch" )
|
2010-03-16 11:18:09 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def _guessOs ( self ):
|
2010-05-17 16:19:02 -05:00
|
|
|
self._libSuffix = None
|
2010-03-16 11:18:09 -05:00
|
|
|
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.*")
|
|
|
|
|
|
|
|
uname = subprocess.Popen ( ["uname", "-srm"], stdout=subprocess.PIPE )
|
|
|
|
lines = uname.stdout.readlines()
|
|
|
|
|
2010-05-17 16:19:02 -05:00
|
|
|
if self._osSLSoC5x_64.match(lines[0]):
|
|
|
|
self._osType = "Linux.SLSoC5x_64"
|
|
|
|
self._libSuffix = "64"
|
2010-03-16 11:18:09 -05:00
|
|
|
elif self._osSLSoC5x .match(lines[0]): self._osType = "Linux.SLSoC5x"
|
2010-05-17 16:19:02 -05:00
|
|
|
elif self._osLinux_64 .match(lines[0]):
|
|
|
|
self._osType = "Linux.x86_64"
|
|
|
|
self._libSuffix = "64"
|
2010-03-16 11:18:09 -05:00
|
|
|
elif self._osLinux .match(lines[0]): self._osType = "Linux.i386"
|
|
|
|
elif self._osDarwin .match(lines[0]): self._osType = "Darwin"
|
|
|
|
else:
|
|
|
|
uname = subprocess.Popen ( ["uname", "-sr"], stdout=subprocess.PIPE )
|
|
|
|
self._osType = uname.stdout.readlines()[0][:-1]
|
|
|
|
|
|
|
|
print "[WARNING] Unrecognized OS: \"%s\"." % lines[0][:-1]
|
|
|
|
print " (using: \"%s\")" % self._osType
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-05-16 11:41:25 -05:00
|
|
|
def _guessSvnTag ( self, project ):
|
|
|
|
revisionPattern = re.compile ( r"^Revision:\s*(?P<revision>\d+)" )
|
|
|
|
projectSvnDir = os.path.join ( self._svnMethod+project.getRepository() )
|
|
|
|
|
|
|
|
command = [ "svn", "info", projectSvnDir ]
|
|
|
|
svnInfo = subprocess.Popen ( command, stdout=subprocess.PIPE )
|
|
|
|
|
|
|
|
for line in svnInfo.stdout.readlines():
|
|
|
|
m = revisionPattern.match ( line )
|
|
|
|
if m:
|
|
|
|
self._svnTag = m.group("revision")
|
|
|
|
print "Latest revision of project %s is %s." % (project.getName(),self._svnTag)
|
2010-05-17 09:45:55 -05:00
|
|
|
self._updateSecondary ()
|
2010-05-16 11:41:25 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
print "[WARNING] Cannot guess revision for project \"%s\"." % project.getName()
|
|
|
|
print " (using: \"x\")"
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-05-17 09:45:55 -05:00
|
|
|
def _doSpec ( self ):
|
|
|
|
fdSpecFileIn = open ( self._specFileIn, "r" )
|
|
|
|
fdSpecFile = open ( self._specFile , "w" )
|
|
|
|
|
|
|
|
for line in fdSpecFileIn.readlines():
|
|
|
|
stable = False
|
|
|
|
substituted0 = line
|
|
|
|
|
|
|
|
while not stable:
|
|
|
|
substituted1 = re.sub ( r"@svntag@" , self._svnTag , substituted0 )
|
|
|
|
substituted1 = re.sub ( r"@coriolisTop@", "/opt/coriolis2", substituted1 )
|
|
|
|
if substituted0 == substituted1: stable = True
|
|
|
|
else: substituted0 = substituted1
|
|
|
|
|
|
|
|
fdSpecFile.write ( substituted0 )
|
|
|
|
|
|
|
|
fdSpecFileIn.close ()
|
|
|
|
fdSpecFile.close ()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-03-18 10:38:10 -05:00
|
|
|
def _execute ( self, command, error ):
|
2010-04-20 06:11:08 -05:00
|
|
|
sys.stdout.flush ()
|
|
|
|
sys.stderr.flush ()
|
2010-03-18 10:38:10 -05:00
|
|
|
child = subprocess.Popen ( command, env=self._environment, stdout=None )
|
2010-03-16 11:18:09 -05:00
|
|
|
(pid,status) = os.waitpid ( child.pid, 0 )
|
2010-03-26 13:09:30 -05:00
|
|
|
status >>= 8
|
2010-03-16 11:18:09 -05:00
|
|
|
if status != 0:
|
2010-03-26 13:09:30 -05:00
|
|
|
print "[ERROR] %s (status:%d)." % (error,status)
|
2010-03-16 11:18:09 -05:00
|
|
|
sys.exit ( status )
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def _build ( self, tool ):
|
|
|
|
toolSourceDir = os.path.join ( self._sourceDir, tool )
|
|
|
|
toolBuildDir = os.path.join ( self._buildDir , tool )
|
|
|
|
# Supplied directly in the CMakeLists.txt.
|
2010-05-22 08:39:38 -05:00
|
|
|
#cmakeModules = os.path.join ( self._installDir, "share", "cmake", "Modules" )
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
if not os.path.isdir(toolSourceDir):
|
|
|
|
print "[ERROR] Missing tool source directory: \"%s\" (skipped)." % toolSourceDir
|
|
|
|
return
|
2010-04-28 10:54:30 -05:00
|
|
|
|
|
|
|
if self._rmBuild:
|
|
|
|
print "Removing tool build directory: \"%s\"." % toolBuildDir
|
2010-05-19 09:47:48 -05:00
|
|
|
command = [ "/bin/rm", "-rf", toolBuildDir ]
|
2010-04-28 10:54:30 -05:00
|
|
|
self._execute ( command, "Removing tool build directory" )
|
|
|
|
|
2010-03-16 11:18:09 -05:00
|
|
|
if not os.path.isdir(toolBuildDir):
|
|
|
|
print "Creating tool build directory: \"%s\"." % toolBuildDir
|
|
|
|
os.makedirs ( toolBuildDir )
|
|
|
|
os.chdir ( toolBuildDir )
|
|
|
|
|
|
|
|
command = ["cmake", "-D", "CMAKE_BUILD_TYPE:STRING=%s" % self._buildMode
|
|
|
|
, "-D", "BUILD_SHARED_LIBS:STRING=%s" % self._enableShared
|
|
|
|
#, "-D", "CMAKE_MODULE_PATH:STRING=%s" % cmakeModules
|
|
|
|
, toolSourceDir ]
|
2010-03-18 10:38:10 -05:00
|
|
|
self._execute ( command, "First CMake failed" )
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
os.chdir ( toolBuildDir )
|
|
|
|
if self._noCache:
|
2010-03-22 09:13:40 -05:00
|
|
|
cmakeCache = os.path.join(toolBuildDir,"CMakeCache.txt")
|
2010-03-22 11:38:25 -05:00
|
|
|
if os.path.isfile ( cmakeCache ): os.unlink ( cmakeCache )
|
2010-03-16 11:18:09 -05:00
|
|
|
|
2010-03-22 09:13:40 -05:00
|
|
|
command = ["cmake", "-D", "CMAKE_BUILD_TYPE:STRING=%s" % self._buildMode
|
|
|
|
, "-D", "BUILD_SHARED_LIBS:STRING=%s" % self._enableShared
|
2010-03-16 11:18:09 -05:00
|
|
|
, "-D", "BUILD_DOC:STRING=%s" % self._enableDoc
|
|
|
|
, "-D", "CHECK_DATABASE:STRING=%s" % self._checkDatabase
|
|
|
|
, "-D", "CHECK_DETERMINISM:STRING=%s" % self._checkDeterminism
|
|
|
|
, "-D", "CMAKE_VERBOSE_MAKEFILE:STRING=%s" % self._verboseMakefile
|
2010-05-16 11:41:25 -05:00
|
|
|
, "-D", "CMAKE_INSTALL_PREFIX:STRING=%s" % self._installDir
|
2010-05-17 16:19:02 -05:00
|
|
|
]
|
|
|
|
if self._libSuffix:
|
|
|
|
command += [ "-D", "LIB_SUFFIX:STRING=%s" % self._libSuffix ]
|
|
|
|
command += [ toolSourceDir ]
|
2010-03-18 10:38:10 -05:00
|
|
|
self._execute ( command, "Second CMake failed" )
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
if self._doBuild:
|
2010-05-25 11:00:53 -05:00
|
|
|
command = [ "make" ]
|
|
|
|
#command += [ "DESTDIR=%s" % self._installDir ]
|
2011-01-09 13:21:01 -06:00
|
|
|
if self._enableDoc == "ON":
|
|
|
|
if tool == "crlcore" or tool == "stratus1":
|
|
|
|
command += [ "dvi", "safepdf", "html" ]
|
2010-05-17 03:20:02 -05:00
|
|
|
command += self._makeArguments
|
2010-05-25 11:00:53 -05:00
|
|
|
print "Make command:", command
|
|
|
|
sys.stdout.flush ()
|
2010-03-18 10:38:10 -05:00
|
|
|
self._execute ( command, "Build failed" )
|
2010-03-16 11:18:09 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def _svnStatus ( self, tool ):
|
|
|
|
toolSourceDir = os.path.join ( self._sourceDir , tool )
|
2010-03-19 05:01:54 -05:00
|
|
|
if not os.path.isdir(toolSourceDir):
|
2010-03-19 05:05:30 -05:00
|
|
|
if not self._quiet:
|
|
|
|
print "[ERROR] Missing tool source directory: \"%s\" (skipped)." % toolSourceDir
|
2010-03-19 05:07:12 -05:00
|
|
|
return
|
2010-03-16 11:18:09 -05:00
|
|
|
os.chdir ( toolSourceDir )
|
|
|
|
|
|
|
|
print "Checking SVN status of tool: ", tool
|
|
|
|
command = [ "svn", "status", "-u", "-q" ]
|
2010-03-18 10:38:10 -05:00
|
|
|
self._execute ( command, "svn status -u -q" )
|
2010-03-16 11:18:09 -05:00
|
|
|
print
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def _svnUpdate ( self, tool ):
|
|
|
|
toolSourceDir = os.path.join ( self._sourceDir , tool )
|
2010-03-19 05:01:54 -05:00
|
|
|
if not os.path.isdir(toolSourceDir):
|
2010-03-19 05:05:30 -05:00
|
|
|
if not self._quiet:
|
|
|
|
print "[ERROR] Missing tool source directory: \"%s\" (skipped)." % toolSourceDir
|
2010-03-19 05:01:54 -05:00
|
|
|
return
|
2010-03-16 11:18:09 -05:00
|
|
|
os.chdir ( toolSourceDir )
|
|
|
|
|
|
|
|
print "Doing a SVN update of tool: ", tool
|
|
|
|
command = [ "svn", "update" ]
|
2010-03-18 10:38:10 -05:00
|
|
|
self._execute ( command, "svn update" )
|
2010-03-16 11:18:09 -05:00
|
|
|
print
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
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."
|
|
|
|
return
|
|
|
|
if not project.getRepository ():
|
|
|
|
print "[ERROR] Project \"%s\" isn't associated to a repository." % project.getName()
|
|
|
|
return
|
|
|
|
|
2010-04-20 07:05:52 -05:00
|
|
|
toolSvnTrunkDir = os.path.join ( self._svnMethod+project.getRepository(), tool, "trunk" )
|
2010-03-16 11:18:09 -05:00
|
|
|
os.chdir ( self._sourceDir )
|
|
|
|
|
|
|
|
print "Doing a SVN checkout of tool: ", tool
|
|
|
|
command = [ "svn", "co", toolSvnTrunkDir, tool ]
|
2010-03-18 10:38:10 -05:00
|
|
|
self._execute ( command, "svn checkout %s" % tool )
|
2010-03-16 11:18:09 -05:00
|
|
|
print
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-05-16 11:41:25 -05:00
|
|
|
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."
|
|
|
|
return
|
|
|
|
if not project.getRepository ():
|
|
|
|
print "[ERROR] Project \"%s\" isn't associated to a repository." % project.getName()
|
|
|
|
return
|
|
|
|
|
|
|
|
toolSvnTrunkDir = os.path.join ( self._svnMethod+project.getRepository(), tool, "trunk" )
|
|
|
|
|
|
|
|
if not os.path.isdir ( self._archiveDir ):
|
|
|
|
os.mkdir ( self._archiveDir )
|
|
|
|
os.chdir ( self._archiveDir )
|
|
|
|
|
|
|
|
toolExportDir = os.path.join ( self._archiveDir, tool )
|
|
|
|
if os.path.isdir ( toolExportDir ):
|
|
|
|
print "Removing tool export (tarball) directory: \"%s\"." % toolExportDir
|
|
|
|
command = [ "/bin/rm", "-r", toolExportDir ]
|
|
|
|
self._execute ( command, "Removing tool export (tarball) directory" )
|
|
|
|
|
|
|
|
print "Doing a SVN export of tool: ", tool
|
|
|
|
command = [ "svn", "export", toolSvnTrunkDir, toolExportDir ]
|
|
|
|
if self._svnTag != "x":
|
|
|
|
command += [ "--revision", self._svnTag ]
|
|
|
|
self._execute ( command, "svn export %s" % toolExportDir )
|
|
|
|
print
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-03-16 11:18:09 -05:00
|
|
|
def getProject ( self, name ):
|
|
|
|
for project in self._projects:
|
|
|
|
if project.getName() == name:
|
|
|
|
return project
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def getToolProject ( self, name ):
|
|
|
|
for project in self._projects:
|
|
|
|
if project.hasTool(name):
|
|
|
|
return project
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def register ( self, project ):
|
|
|
|
for registered in self._projects:
|
|
|
|
if registered.getName() == project.getName():
|
|
|
|
print "[ERROR] Project \"%s\" is already registered (ignored)."
|
|
|
|
return
|
|
|
|
self._projects += [ project ]
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-07-01 07:05:15 -05:00
|
|
|
def _setEnvironment ( self, systemVariable, userVariable ):
|
|
|
|
if not self._environment.has_key(systemVariable):
|
|
|
|
self._environment[ systemVariable ] = self._installDir
|
|
|
|
#if not self._environment.has_key(userVariable):
|
|
|
|
# self._environment[ userVariable ] = self._installDir
|
|
|
|
if not self._quiet:
|
|
|
|
print "Setting %s = \"%s\"." % (systemVariable ,self._environment[systemVariable])
|
|
|
|
if self._environment.has_key(userVariable):
|
|
|
|
print "Transmitting %s = \"%s\"." % (userVariable,self._environment[userVariable])
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-04-03 09:06:08 -05:00
|
|
|
def _commandTemplate ( self, tools, projects, command ):
|
2010-03-18 10:38:10 -05:00
|
|
|
# Set or guess the various projects TOP environment variables.
|
|
|
|
for project in self._projects:
|
|
|
|
topVariable = "%s_TOP" % project.getName().upper()
|
|
|
|
topUserVariable = "%s_USER_TOP" % project.getName().upper()
|
2010-07-01 07:05:15 -05:00
|
|
|
self._setEnvironment ( topVariable, topUserVariable )
|
2010-03-18 10:38:10 -05:00
|
|
|
|
2010-04-04 05:19:38 -05:00
|
|
|
if tools:
|
|
|
|
# Checks if the requested tools are in the various projects.
|
|
|
|
self._standalones = tools
|
|
|
|
for project in self._projects:
|
|
|
|
self._standalones = project.activate ( self._standalones )
|
|
|
|
for tool in self._standalones:
|
|
|
|
print "[WARNING] Tool \"%s\" is not part of any project." % tool
|
|
|
|
|
2010-04-03 09:06:08 -05:00
|
|
|
if projects:
|
|
|
|
for projectName in projects:
|
|
|
|
project = self.getProject ( projectName )
|
|
|
|
if not project:
|
|
|
|
print "[ERROR] No project of name \"%s\"." % projectName
|
|
|
|
sys.exit ( 1 )
|
|
|
|
project.activateAll()
|
2010-04-04 05:19:38 -05:00
|
|
|
|
|
|
|
if not tools and not projects:
|
2010-03-16 11:18:09 -05:00
|
|
|
for project in self._projects:
|
2010-04-04 05:19:38 -05:00
|
|
|
project.activateAll ()
|
|
|
|
|
|
|
|
for project in self._projects:
|
|
|
|
for tool in project.getActives():
|
2010-03-19 09:47:32 -05:00
|
|
|
print "\nProcessing tool: \"%s\"." % tool
|
2010-03-16 11:18:09 -05:00
|
|
|
getattr(self,command) ( tool )
|
2010-04-04 05:19:38 -05:00
|
|
|
|
|
|
|
for tool in self._standalones:
|
|
|
|
print "\nProcessing tool: \"%s\"." % tool
|
|
|
|
getattr(self,command) ( tool )
|
2010-03-16 11:18:09 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-04-03 09:06:08 -05:00
|
|
|
def build ( self, tools, projects ):
|
|
|
|
self._commandTemplate ( tools, projects, "_build" )
|
2010-03-16 11:18:09 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-04-03 09:06:08 -05:00
|
|
|
def svnStatus ( self, tools, projects ):
|
|
|
|
self._commandTemplate ( tools, projects, "_svnStatus" )
|
2010-03-16 11:18:09 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-04-03 09:06:08 -05:00
|
|
|
def svnUpdate ( self, tools, projects ):
|
|
|
|
self._commandTemplate ( tools, projects, "_svnUpdate" )
|
2010-03-16 11:18:09 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-04-03 09:06:08 -05:00
|
|
|
def svnCheckout ( self, tools, projects ):
|
|
|
|
self._commandTemplate ( tools, projects, "_svnCheckout" )
|
2010-03-16 11:18:09 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-05-16 11:41:25 -05:00
|
|
|
def svnExport ( self, tools, projects ):
|
|
|
|
self._commandTemplate ( tools, projects, "_svnExport" )
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def tarball ( self, tools, projects ):
|
|
|
|
if self._svnTag == "x":
|
|
|
|
self._guessSvnTag ( self.getProject(projects[0]) )
|
2010-05-17 09:45:55 -05:00
|
|
|
|
|
|
|
self._doSpec ()
|
2010-05-16 11:41:25 -05:00
|
|
|
|
|
|
|
if os.path.isdir(self._tarballDir):
|
|
|
|
print "Removing previous tarball directory: \"%s\"." % self._tarballDir
|
2011-02-02 06:02:39 -06:00
|
|
|
command = [ "/bin/rm", "-rf", self._tarballDir ]
|
2010-05-16 11:41:25 -05:00
|
|
|
self._execute ( command, "Removing top export (tarball) directory" )
|
2010-05-17 09:45:55 -05:00
|
|
|
|
2010-05-16 11:41:25 -05:00
|
|
|
print "Creating tarball directory: \"%s\"." % self._tarballDir
|
|
|
|
os.makedirs ( self._tarballDir )
|
|
|
|
self.svnExport ( tools, projects )
|
2010-05-25 11:00:53 -05:00
|
|
|
|
2011-01-09 13:21:01 -06:00
|
|
|
removeds = [ os.path.join("vlsisapd","src","openChams")
|
|
|
|
, os.path.join("vlsisapd","src","dtr")
|
2010-05-27 06:54:24 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
# Remove unpublisheds (yet) tools/files.
|
|
|
|
for item in removeds:
|
|
|
|
command = [ "/bin/rm", "-r", os.path.join(self._archiveDir,item) ]
|
|
|
|
self._execute ( command, "rm of %s failed" % item)
|
2011-01-09 13:21:01 -06:00
|
|
|
|
|
|
|
# Adds files neededs only for packaging purpose.
|
|
|
|
command = [ "/bin/cp", "-r", os.path.join(self._sourceDir ,"bootstrap","Makefile.package")
|
|
|
|
, os.path.join(self._archiveDir,"Makefile") ]
|
|
|
|
self._execute ( command, "copy of %s failed" % "boostrap/Makefile.package")
|
2011-02-02 04:40:25 -06:00
|
|
|
|
|
|
|
command = [ "/bin/cp", self._specFile, self._archiveDir ]
|
|
|
|
self._execute ( command, "Copying RPM spec file" )
|
|
|
|
|
|
|
|
command = [ "/bin/cp", "-r", self._debianDir, self._archiveDir ]
|
|
|
|
self._execute ( command, "Copying Debian/Ubuntu package control files" )
|
2010-05-17 09:45:55 -05:00
|
|
|
|
2010-05-27 06:54:24 -05:00
|
|
|
os.chdir ( self._archiveDir )
|
2011-01-09 13:21:01 -06:00
|
|
|
#command = [ "/usr/bin/patch", "--remove-empty-files"
|
|
|
|
# , "--no-backup-if-mismatch"
|
|
|
|
# , "-p0", "-i", self._distribPatch ]
|
|
|
|
#self._execute ( command, "patch for distribution command failed" )
|
2010-05-27 06:54:24 -05:00
|
|
|
|
2010-05-16 11:41:25 -05:00
|
|
|
os.chdir ( self._tarballDir )
|
2011-02-02 06:02:39 -06:00
|
|
|
command = [ "/bin/tar"
|
|
|
|
, "--exclude", "\\.svn"
|
|
|
|
, "-jcvf", self._sourceTarBz2, os.path.basename(self._archiveDir) ]
|
2010-05-16 11:41:25 -05:00
|
|
|
self._execute ( command, "tar command failed" )
|
2010-05-17 09:45:55 -05:00
|
|
|
|
2010-05-16 11:41:25 -05:00
|
|
|
print "Cleanup SVN export tarball archive directory: \"%s\"." % self._archiveDir
|
2011-02-02 06:02:39 -06:00
|
|
|
command = [ "/bin/rm", "-rf", self._archiveDir ]
|
2010-05-16 11:41:25 -05:00
|
|
|
self._execute ( command, "Removing archive export (tarball) directory" )
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-05-17 09:45:55 -05:00
|
|
|
def doRpm ( self, tools, projects ):
|
|
|
|
self.tarball ( tools, projects )
|
|
|
|
|
2010-06-08 07:15:31 -05:00
|
|
|
for rpmDir in [ "SOURCES", "SPECS", "BUILD", "tmp"
|
|
|
|
, "SRPMS", "RPMS/i386", "RPMS/i686", "RPMS/x86_64" ]:
|
|
|
|
rpmFullDir = os.path.join ( self._rpmbuildDir, rpmDir )
|
|
|
|
if not os.path.isdir(rpmFullDir):
|
|
|
|
os.makedirs ( rpmFullDir )
|
2010-05-17 09:45:55 -05:00
|
|
|
|
2011-02-02 04:40:25 -06:00
|
|
|
#rpmSpecFile = os.path.join ( self._rpmbuildDir, "SPECS" , "coriolis2.spec" )
|
2010-06-08 07:15:31 -05:00
|
|
|
rpmSourceFile = os.path.join ( self._rpmbuildDir, "SOURCES", self._sourceTarBz2 )
|
|
|
|
sourceFile = os.path.join ( self._tarballDir, self._sourceTarBz2 )
|
2010-05-17 09:45:55 -05:00
|
|
|
|
2011-02-02 04:40:25 -06:00
|
|
|
#if os.path.isfile ( rpmSpecFile ):
|
|
|
|
# os.unlink ( rpmSpecFile )
|
|
|
|
#os.symlink ( self._specFile, rpmSpecFile )
|
2010-05-22 08:21:24 -05:00
|
|
|
|
2010-05-17 09:45:55 -05:00
|
|
|
if not os.path.islink ( rpmSourceFile ):
|
|
|
|
os.symlink ( sourceFile, rpmSourceFile )
|
|
|
|
|
2010-06-08 07:15:31 -05:00
|
|
|
os.chdir ( self._rpmbuildDir )
|
|
|
|
|
|
|
|
command = [ "/usr/bin/rpmbuild"
|
|
|
|
, "--define", "_topdir %s" % self._rpmbuildDir
|
|
|
|
, "--define", "_tmppath %s" % self._tmppathDir
|
|
|
|
, "--define", "_enable_debug_packages 0"
|
2011-02-02 04:40:25 -06:00
|
|
|
, "-ta", "--with", "binarytar", rpmSourceFile ]
|
2010-05-17 09:45:55 -05:00
|
|
|
|
|
|
|
self._execute ( command, "Rebuild rpm packages" )
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2011-02-02 04:40:25 -06:00
|
|
|
def doDeb ( self, tools, projects ):
|
|
|
|
self.tarball ( tools, projects )
|
|
|
|
|
|
|
|
if not os.path.isdir(self._debbuildDir):
|
|
|
|
os.makedirs ( self._debbuildDir )
|
|
|
|
|
|
|
|
os.chdir ( self._debbuildDir )
|
|
|
|
sourceFile = os.path.join ( self._tarballDir, self._sourceTarBz2 )
|
|
|
|
|
|
|
|
command = [ "/bin/tar", "jxf", sourceFile ]
|
|
|
|
self._execute ( command, "Unpacking pristine sources" )
|
|
|
|
|
|
|
|
#command = [ "/bin/cp", "-r", self._debianDir, "." ]
|
|
|
|
#self._execute ( command, "Copying Debian/Ubuntu package control files" )
|
|
|
|
|
|
|
|
packageDir = os.path.join ( self._debbuildDir, "coriolis2-1.0.%s" % self._svnTag )
|
|
|
|
os.chdir ( packageDir )
|
|
|
|
|
|
|
|
self._environment["CFLAGS" ] = "-O2"
|
|
|
|
self._environment["CXXFLAGS"] = "-O2"
|
|
|
|
command = [ "/usr/bin/debuild", "-us", "-uc" ]
|
|
|
|
self._execute ( command, "Rebuild Debian packages" )
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2010-03-16 11:18:09 -05:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2010-07-14 14:50:21 -05:00
|
|
|
bootstrap = Project ( name = "bootstrap"
|
|
|
|
, tools =[ "bootstrap" ]
|
|
|
|
, repository="/users/outil/coriolis/svn"
|
|
|
|
)
|
|
|
|
|
|
|
|
vlsisapd = Project ( name = "vlsisapd"
|
|
|
|
, tools =[ "vlsisapd" ]
|
|
|
|
, repository="/users/outil/coriolis/svn"
|
|
|
|
)
|
|
|
|
|
|
|
|
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"
|
|
|
|
, "pharos"
|
|
|
|
, "schematic"
|
2010-12-06 03:42:58 -06:00
|
|
|
, "autoDTR"
|
2010-07-14 14:50:21 -05:00
|
|
|
]
|
|
|
|
, repository="/users/outil/chams/svn"
|
|
|
|
)
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
parser = optparse.OptionParser ()
|
|
|
|
# Build relateds.
|
2010-04-28 10:54:30 -05:00
|
|
|
parser.add_option ( "-q", "--quiet" , action="store_true" , dest="quiet" )
|
|
|
|
parser.add_option ( "-r", "--release" , action="store_true" , dest="release" )
|
|
|
|
parser.add_option ( "-d", "--debug" , action="store_true" , dest="debug" )
|
|
|
|
parser.add_option ( "-s", "--static" , action="store_true" , dest="static" )
|
|
|
|
parser.add_option ( "--doc" , action="store_true" , dest="doc" )
|
|
|
|
parser.add_option ( "-D", "--check-db" , action="store_true" , dest="checkDb" )
|
|
|
|
parser.add_option ( "-u", "--check-deter", action="store_true" , dest="checkDeterminism" )
|
|
|
|
parser.add_option ( "-v", "--verbose" , action="store_true" , dest="verboseMakefile" )
|
|
|
|
parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" )
|
|
|
|
parser.add_option ( "--no-build" , action="store_true" , dest="noBuild" )
|
|
|
|
parser.add_option ( "--no-cache" , action="store_true" , dest="noCache" )
|
|
|
|
parser.add_option ( "--rm-build" , action="store_true" , dest="rmBuild" )
|
|
|
|
parser.add_option ( "--svn-tag" , action="store" , type="string", dest="svnTag" )
|
|
|
|
parser.add_option ( "--svn-method" , action="store" , type="string", dest="svnMethod")
|
|
|
|
parser.add_option ( "--make" , action="store" , type="string", dest="makeArguments")
|
|
|
|
parser.add_option ( "--project" , action="append" , type="string", dest="projects" )
|
|
|
|
parser.add_option ( "-t", "--tool" , action="append" , type="string", dest="tools" )
|
2010-03-16 11:18:09 -05:00
|
|
|
# SVN repository relateds.
|
|
|
|
parser.add_option ( "--svn-status" , action="store_true", dest="svnStatus" )
|
|
|
|
parser.add_option ( "--svn-update" , action="store_true", dest="svnUpdate" )
|
|
|
|
parser.add_option ( "--svn-checkout" , action="store_true", dest="svnCheckout" )
|
2010-05-16 11:41:25 -05:00
|
|
|
# Miscellaneous.
|
|
|
|
parser.add_option ( "--tarball" , action="store_true", dest="tarball" )
|
2010-05-17 09:45:55 -05:00
|
|
|
parser.add_option ( "--do-rpm" , action="store_true", dest="doRpm" )
|
2011-02-02 04:40:25 -06:00
|
|
|
parser.add_option ( "--do-deb" , action="store_true", dest="doDeb" )
|
2010-03-16 11:18:09 -05:00
|
|
|
( options, args ) = parser.parse_args ()
|
|
|
|
|
|
|
|
builder = ProjectBuilder ()
|
2010-07-14 14:50:21 -05:00
|
|
|
builder.register ( bootstrap )
|
2010-05-18 10:12:27 -05:00
|
|
|
builder.register ( vlsisapd )
|
2010-03-16 11:18:09 -05:00
|
|
|
builder.register ( coriolis )
|
2010-03-18 10:38:10 -05:00
|
|
|
builder.register ( chams )
|
2010-03-16 11:18:09 -05:00
|
|
|
|
2010-03-19 05:05:30 -05:00
|
|
|
if options.quiet: builder.quiet = True
|
2010-03-16 11:18:09 -05:00
|
|
|
if options.release: builder.buildMode = "Release"
|
|
|
|
if options.debug: builder.buildMode = "Debug"
|
|
|
|
if options.static: builder.enableShared = "OFF"
|
|
|
|
if options.doc: builder.enableDoc = "ON"
|
2010-12-13 08:00:40 -06:00
|
|
|
if options.checkDb: builder.checkDatabase = "ON"
|
2010-03-16 11:18:09 -05:00
|
|
|
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
|
2010-04-28 10:54:30 -05:00
|
|
|
if options.rmBuild: builder.rmBuild = True
|
2010-03-16 11:18:09 -05:00
|
|
|
if options.makeArguments: builder.makeArguments = options.makeArguments
|
2010-04-20 07:05:52 -05:00
|
|
|
if options.svnMethod: builder.svnMethod = options.svnMethod
|
2010-03-16 11:18:09 -05:00
|
|
|
if options.svnTag: builder.svnTag = options.svnTag
|
|
|
|
|
2010-04-03 09:06:08 -05:00
|
|
|
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 )
|
2010-05-16 11:41:25 -05:00
|
|
|
elif options.tarball: builder.tarball ( tools=options.tools, projects=options.projects )
|
2010-05-17 09:45:55 -05:00
|
|
|
elif options.doRpm: builder.doRpm ( tools=options.tools, projects=options.projects )
|
2011-02-02 04:40:25 -06:00
|
|
|
elif options.doDeb: builder.doDeb ( tools=options.tools, projects=options.projects )
|
2010-04-03 09:06:08 -05:00
|
|
|
else: builder.build ( tools=options.tools, projects=options.projects )
|
2010-03-16 11:18:09 -05:00
|
|
|
|
|
|
|
sys.exit ( 0 )
|