cloudstack/wscript_build
2010-08-30 01:37:12 -07:00

649 lines
25 KiB
Python

#!/usr/bin/env python
"""builds the entire stack"""
#For every matching build change here, that produces new installable
#files, the cloud.spec file and the Debian control files must be
#revised and tested.
import shutil,os
import Utils,Node,Options,Logs,Scripting,Environment,Build,Configure
from os import unlink as _unlink, makedirs as _makedirs, getcwd as _getcwd, chdir as _chdir
from os.path import abspath as _abspath, basename as _basename, dirname as _dirname, exists as _exists, isdir as _isdir, split as _split, join as _join, sep, pathsep, pardir
from glob import glob as _glob
try: set([1,2,3])
except Exception: from Sets import set
import re
import zipfile,tarfile
try:
from os import chmod as _chmod,chown as _chown
import pwd,stat,grp
except ImportError:
_chmod,_chown,pwd,stat,grp = (None,None,None,None,None)
required_env = [
"APISERVERLOG",
"MSLOG",
"PIDDIR",
"CPPATH",
"AGENTSIMULATORCLASSPATH",
"SYSTEMJAVADIR",
"USAGELOG",
"PLUGINJAVADIR",
]
for e in required_env:
if e not in bld.env: raise Utils.WafError("configure required: new variable %s added"%e)
sourcedir = bld.srcnode.abspath()
builddir = bld.path.abspath(bld.env)
buildpremium = _exists(_join(sourcedir,"cloudstack-proprietary"))
filelist = bld.path.ant_glob
sccsinfo = _join(sourcedir,"sccs-info")
if _exists(sccsinfo): bld.install_files("${DOCDIR}","sccs-info")
tgen = bld(features='subst', name='configure-info', source="configure-info.in", target="configure-info")
def gen_configure_info():
lines = []
for key,val in sorted(bld.env.get_merged_dict().items()):
if "CLASSPATH" in key:
lines.append(" %s:"%key)
for v in val.split(pathsep):
lines.append(" %s"%v)
continue
lines.append(" %s: %s"%(key,val))
return "\n".join(lines)
tgen.dict = {"CONFIGUREVARS":gen_configure_info()}
bld.install_files("${DOCDIR}","configure-info")
# ==================== Java compilation ===========================
sfl = lambda filespec: filelist(filespec,src=True,bld=False,dir=False,flat=True)
# discover ant targets and properties
antxmlfiles = _glob(_join("build","*.xml")) + _glob(_join("build","*.properties"))
if buildpremium: antxmlfiles += _glob(_join("build","premium","*.xml")) + _glob(_join("cloudstack-proprietary","build","*.xml"))
targets,antprops = Utils.discover_ant_targets_and_properties(antxmlfiles)
javac_env = bld.env.copy()
# FIXME trigger recompilation / cache avoidance when debuglevel changes. ATM this does not happen.
if antprops.get('debuglevel',None): javac_env.append_value("JAVACFLAGS",["-g:%s"%antprops['debuglevel']])
Implementation_Version = bld.env.VERSION
buildnumber = Utils.getbuildnumber()
if buildnumber: Implementation_Version += "." + buildnumber
# compile .class files using waf
classpathentries = [ _join(builddir,x[2]) for x in targets ]
javawclasspath = pathsep.join( classpathentries + [ _abspath(x) for x in bld.env.CLASSPATH.split(pathsep) ] )
javac_tgens = [
bld( features='javac', name=name, srcdir=srcdir, outdir=classdir,
after=" ".join(deps), classpath=javawclasspath, env=javac_env )
for name,srcdir,classdir,jarpath,deps in targets ]
[ bld.process_after(tgen) for tgen in javac_tgens ]
# compile jar files using ant
# ant only needs to be reinvoked if the version with build number changes
# we here trim all the depended targets from the target list:
build_targets = [ x[0] for x in targets ]
nondep_build_targets = list ( set([ x[0] for x in targets ]) - set([ x for dependencies in [ y[4] for y in targets ] for x in dependencies ]) )
ant_sources = " ".join(antxmlfiles + [ sfl(x[1] + "/**/*.java") for x in targets ])
ant_jars = [ x[3] for x in targets ]
# because build-console-viewer does not use compile-java macro, we have to hardcode it here
ant_args = [
"-Dimpl.version=%s"%Implementation_Version,
"-Dtarget.dir=%s"%Utils.relpath(_join(builddir,"target")),
"-Ddist.dir=%s"%Utils.relpath(_join(builddir,"ant-dist")),
]
if not buildpremium: ant_args += ["-DOSS=true"]
# this is to trigger recompilation / cache avoidance if the relevant environment for ant changes
tgen = bld(features='subst', name='version-info', source="version-info.in", target="version-info")
tgen.dict = { "Implementation_Version":Implementation_Version,"JAVACFLAGS":javac_env.JAVACFLAGS,"ant_args":ant_args }
bld.install_files("${DOCDIR}","version-info")
build_targets += ["version-info"]
ant_sources += " version-info"
bld.path.ensure_dir_node_from_path("target/jar")
tgen = bld(rule=Utils.runant, name='runant', source=ant_sources, target=ant_jars, anttgts = nondep_build_targets, antargs=ant_args, after=build_targets)
bld.process_after(tgen)
# install jar files
[ bld.install_files('${JAVADIR}',jar) for jar in ant_jars if _basename(jar).startswith("cloud-") ]
# ======================= End Java compilation ======================
# =================== C / Python compilation =========================
if bld.env.DISTRO not in ['Windows','Mac']:
# build / install declarations of the daemonization utility - except for Windows
bld(
name='daemonize',
features='cc cprogram',
source='daemonize/daemonize.c',
target='daemonize/cloud-daemonize')
# build / install declarations of vnet
files = """vnetd/connection.c vnetd/select.c vnetd/timer.c vnetd/spinlock.c vnetd/skbuff.c
vnetd/vnetd.c vnet-module/skb_util.c vnet-module/sxpr_util.c vnet-module/timer_util.c
vnet-module/etherip.c vnet-module/vnet.c vnet-module/vnet_eval.c vnet-module/vnet_forward.c
vnet-module/vif.c vnet-module/tunnel.c vnet-module/sa.c vnet-module/varp.c
libxutil/allocate.c libxutil/enum.c libxutil/file_stream.c libxutil/hash_table.c
libxutil/iostream.c libxutil/lexis.c libxutil/socket_stream.c libxutil/string_stream.c
libxutil/sxpr.c libxutil/sxpr_parser.c libxutil/sys_net.c libxutil/sys_string.c libxutil/util.c"""
files = [ "vnet/src/%s"%s for s in Utils.to_list(files) ]
bld(
name='vnetd',
features='cc cprogram',
source= files,
includes="vnet/src/libxutil vnet/src/vnet-module vnet/src/vnetd",
lib='dl pthread'.split(),
target='vnet/%s-vnetd'%bld.env.PACKAGE,
install_path="${SBINDIR}"
)
obj = bld(features = 'py',name='pythonmodules')
obj.find_sources_in_dirs('python/lib', exts=['.py'])
# ===================== End C / Python compilation ==========================
# ================ Third-party / dependency installation ===============
bld.install_files('${JAVADIR}','deps/*.jar')
if buildpremium: bld.install_files('${PREMIUMJAVADIR}','cloudstack-proprietary/thirdparty/*.jar')
# =================== End 3rdparty/dep install ========================
# =================== Build install declaratoin of console proxy project ========
# -> binary unsubstitutable files
start_path = bld.path.find_dir("console-proxy")
bld.install_files("${CPLIBDIR}",
start_path.ant_glob("images/**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
# -> source files with tokens
patterns = 'console-proxy/css/** console-proxy/js/** console-proxy/ui/** console-proxy/scripts/**'
src_files = Utils.to_list(filelist(patterns,flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = [ Utils.relpath(x,"console-proxy") for x in src_files ]
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
bld.install_as("${CPLIBDIR}/%s"%inst, tgt)
# -> configuration
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${CPSYSCONFDIR}",filelist("console-proxy/conf.dom0/*"))
# ================== End console proxy ===================
# ================ Creation of patch.tgz's ============================
# done here because the patches require substituted files
patterns = "patches/**"
src_files = Utils.to_list(filelist(patterns,flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = src_files
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', name='patchsubst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
# this is a clever little thing
# given a list of nodes, build or source
# construct a tar file containing them
# rooted in the parameter root =, specified in the task generator
# and renaming the names of the files according to a rename(x) function passed to the task generator as well
# if a build node's result of rename() has the same name as a source node, the build node will take precedence
# for as long as the build node appears later than the source node (this is an implementation detail of waf we are relying on)
def tar_up(task):
tgt = task.outputs[0].bldpath(task.env)
if _exists(tgt): _unlink(tgt)
z = tarfile.open(tgt,"w:gz")
fileset = {}
for inp in task.inputs:
src = inp.srcpath(task.env)
if src.startswith(".."):
srcname = Utils.relpath(src,_join("..",".")) # file in source dir
else:
srcname = Utils.relpath(src,_join(task.env.variant(),".")) # file in artifacts dir
if task.generator.rename: srcname = task.generator.rename(srcname)
for dummy in task.generator.root.split("/"):
splittedname = srcname.split("/")
srcname = "/".join(splittedname[1:])
fileset[srcname] = src
for srcname,src in fileset.items():
ti = tarfile.TarInfo(srcname)
ti.mode = 0755
ti.size = os.path.getsize(src)
f = file(src)
z.addfile(ti,fileobj=f)
f.close()
z.close()
return 0
for virttech in [ _basename(x) for x in _glob(_join("patches","*")) ]:
if virttech == "shared":
continue
patchfiles = filelist('patches/%s/** patches/shared/**'%virttech,src=True,bld=True,dir=False,flat=True)
tgen = bld(
rule = tar_up,
source = patchfiles,
target = '%s-patch.tgz'%virttech,
name = '%s-patch_tgz'%virttech,
root = "patches/%s"%virttech,
rename = lambda x: re.sub(".subst$","",x),
after = 'patchsubst',
)
bld.process_after(tgen)
if virttech != "xenserver":
# xenserver uses the patch.tgz file later to make an ISO, so we do not need to install it
bld.install_as("${AGENTLIBDIR}/scripts/vm/hypervisor/%s/patch.tgz"%virttech, "%s-patch.tgz"%virttech)
tgen = bld(
rule = 'cp ${SRC} ${TGT}',
source = 'xenserver-patch.tgz',
target = 'patch.tgz',
after = 'xenserver-patch_tgz',
name = 'patch_tgz'
)
bld.process_after(tgen)
# ================== End creation of patch.tgz's ====================
# ================== systemvm patch creation ====================
deps = " ".join( Utils.to_list(
"""
deps/cloud-xmlrpc-client-3.1.3.jar
deps/cloud-xmlrpc-common-3.1.3.jar
deps/cloud-log4j.jar
deps/cloud-gson-1.3.jar
deps/cloud-apache-log4j-extras-1.0.jar
deps/cloud-libvirt-0.4.5.jar
deps/cloud-jna.jar
deps/cloud-cglib.jar
"""
) )
thirdparties = " ".join( Utils.to_list(
"""
cloudstack-proprietary/thirdparty/xmlrpc-client-3.1.3.jar
cloudstack-proprietary/thirdparty/xmlrpc-common-3.1.3.jar
cloudstack-proprietary/thirdparty/ws-commons-util-1.0.2.jar
cloudstack-proprietary/thirdparty/log4j-1.2.15.jar
cloudstack-proprietary/thirdparty/gson-1.3.jar
cloudstack-proprietary/thirdparty/apache-log4j-extras-1.0.jar
cloudstack-proprietary/thirdparty/commons-httpclient-3.1.jar
cloudstack-proprietary/thirdparty/commons-logging-1.1.1.jar
cloudstack-proprietary/thirdparty/commons-collections-3.2.1.jar
cloudstack-proprietary/thirdparty/commons-codec-1.4.jar
cloudstack-proprietary/thirdparty/commons-pool-1.4.jar
cloudstack-proprietary/thirdparty/libvirt-0.4.5.jar
cloudstack-proprietary/thirdparty/jna.jar
cloudstack-proprietary/thirdparty/cglib-nodep-2.2.jar
"""
) )
patterns = Utils.to_list(
"""
console-proxy/css/**
console-proxy/images/**
console-proxy/js/**
console-proxy/ui/**
console-proxy/conf/**
console-proxy/scripts/*.sh
console-proxy/vm-script/*.sh
scripts/storage/secondary/*sh
"""
)
premiumpatterns = patterns + ["cloudstack-proprietary/console-proxy-premium/certs/**"]
artifacts = "target/jar/VMOpsConsoleApplet.jar " + " ".join( "target/jar/cloud-%s.jar"%j for j in "console-proxy console-common agent utils api core".split() )
premiumartifacts = artifacts + " target/jar/cloud-console-proxy-premium.jar"
sources = " ".join( [ filelist(x,src=True,bld=False,dir=False,flat=True) for x in patterns ] )
premiumsources = " ".join( [ filelist(x,src=True,bld=False,dir=False,flat=True) for x in premiumpatterns ] )
systemfiles = [ (f,_join(".",_basename(f))) for f in bld.env.SYSTEMCLASSPATH.split(pathsep) ]
systems = " ".join( [ n[1] for n in systemfiles ] )
systemtargetdir = _join(builddir,".")
def copydeps(task):
Utils.check_dir(systemtargetdir)
for src,tgt in systemfiles: shutil.copy(src,systemtargetdir)
return 0
def zip_up(task):
tgt = task.outputs[0].bldpath(task.env)
if _exists(tgt): _unlink(tgt)
z = zipfile.ZipFile(tgt,"w")
for inp in task.inputs:
if inp.id&3==Node.BUILD:
src = inp.bldpath(task.env)
srcname = src
srcname = "/".join(srcname.split("/")[1:]) # chop off default/
if srcname.startswith("target/jar"): srcname = "/".join(srcname.split("/")[2:]) # chop off target/jar
else:
src = inp.srcpath(task.env)
srcname = src
srcname = "/".join(srcname.split("/")[1:]) # chop off ../
if srcname.startswith("cloudstack-proprietary"): srcname = "/".join(srcname.split("/")[1:]) # chop off cloudstack proprietary
srcname = "/".join(srcname.split("/")[1:]) # chop off project name
# post-process the paths
if True in [ srcname.startswith(strt) for strt in [ 'scripts/run','scripts/config_ssl','scripts/config_auth','scripts/ssvm-check' ] ]:
srcname = "/".join(srcname.split("/")[1:])
elif srcname.startswith('storage'):
srcname = "scripts/" + srcname
elif srcname.startswith('VMOpsConsoleApplet'):
srcname = "applet/" + srcname
elif srcname.startswith('certs'):
srcname = srcname
z.write(src,srcname)
z.close()
return 0
bld.path.ensure_dir_node_from_path("target/oss")
bld.path.ensure_dir_node_from_path("target/premium")
if bld.env.DISTRO not in ["Windows","Mac"]:
tgen = bld(
rule = copydeps,
source = 'wscript_configure',
target = systems,
name = 'getsystemjars',
)
tgen = bld(
rule = zip_up,
source = " ".join( [sources,artifacts,deps,systems] ),
target = 'target/oss/systemvm.zip',
name = 'systemvm_zip',
after = 'getsystemjars runant',
)
bld.process_after(tgen)
bld.install_files("${AGENTLIBDIR}/vms", "target/oss/systemvm.zip")
if buildpremium:
tgen = bld(
rule = zip_up,
source = " ".join( [premiumsources,premiumartifacts,thirdparties] ),
target = 'target/premium/systemvm.zip',
name = 'systemvm-premium_zip',
after = 'runant',
)
bld.process_after(tgen)
#no need to install the premium one, we have ISOs below
#bld.install_files("${AGENTLIBDIR}/vms", "systemvm-premium.zip")
# ================== End systemvm patch creation ====================
# ================== systemvm ISO creation ====================
if bld.env.DISTRO not in ["Windows","Mac"]: # mkisofs only on windows
def iso_up(task):
tgt = task.outputs[0].bldpath(task.env)
if _exists(tgt): _unlink(tgt)
inps = []
for inp in task.inputs:
if inp.id&3==Node.BUILD:
src = inp.bldpath(task.env)
srcname = src
srcname = "/".join(srcname.split("/")[1:]) # chop off default/
else:
src = inp.srcpath(task.env)
srcname = src
srcname = "/".join(srcname.split("/")[1:]) # chop off ../
# post-process the paths
inps.append(src)
return Utils.exec_command(
[
#"echo",
"mkisofs",
"-quiet",
"-r",
"-o",tgt,
] + inps)
tgen = bld(
rule = iso_up,
source = "patch.tgz target/oss/systemvm.zip",
target = 'target/oss/systemvm.iso',
name = 'systemvm_iso',
after = 'systemvm_zip patch_tgz',
)
bld.process_after(tgen)
bld.install_as("${AGENTLIBDIR}/vms/systemvm.iso", "target/oss/systemvm.iso")
if buildpremium:
tgen = bld(
rule = iso_up,
source = "patch.tgz target/premium/systemvm.zip",
target = 'target/premium/systemvm.iso',
name = 'systemvm-premium_iso',
after = 'systemvm-premium_zip patch_tgz',
)
bld.process_after(tgen)
bld.install_as("${AGENTLIBDIR}/vms/systemvm-premium.iso", "target/premium/systemvm.iso")
# ================== End systemvm ISO creation ====================
# =================== Empty directory / symlink creation on install target ====================
# 7. make log and cache dirs (this actually runs first)
if bld.env.DISTRO in 'Windows Mac': pass
else:
x = ("root",bld.env.MSUSER)
directories = [
("${MSLOGDIR}",0770,x),
("${AGENTLOGDIR}",0770,x),
("${USAGELOGDIR}",0770,x),
("${CPLOGDIR}",0770,x),
("${LOCALSTATEDIR}/cache/${MSPATH}",0770,x),
("${LOCALSTATEDIR}/cache/${MSPATH}/temp",0770,x),
("${LOCALSTATEDIR}/cache/${MSPATH}/work",0770,x),
("${SHAREDSTATEDIR}/${MSPATH}",0770,x),
("${MSMNTDIR}",0770,x),
("${MSCONF}/Catalina",0770,x),
("${MSCONF}/Catalina/localhost",0770,x),
("${MSCONF}/Catalina/localhost/client",0770,x),
("${PIDDIR}",0755,("root","root")),
("${LOCKDIR}",0755,("root","root")),
]
for a,mode,owner in directories:
s = bld.subst_add_destdir(a,bld)
if Options.is_install:
bld.install_dir(a)
bld.setownership(a,owner[0],owner[1],mode)
# 8. create environment symlinks
symlinks = [
('${MSENVIRON}/bin', '${TOMCATHOME}/bin'),
('${MSENVIRON}/lib', '${TOMCATHOME}/lib'),
('${MSENVIRON}/logs', "${MSLOGDIR}"),
('${MSENVIRON}/temp', '${LOCALSTATEDIR}/cache/${MSPATH}/temp'),
('${MSENVIRON}/work','${LOCALSTATEDIR}/cache/${MSPATH}/work'),
('${MSENVIRON}/conf', '${SYSCONFDIR}/${MSPATH}'),
("${AGENTLIBDIR}/css", '${CPLIBDIR}/css'),
("${AGENTLIBDIR}/images", '${CPLIBDIR}/images'),
("${AGENTLIBDIR}/js", '${CPLIBDIR}/js'),
("${AGENTLIBDIR}/ui", '${CPLIBDIR}/ui'),
]
for lnk,dst in symlinks: bld.symlink_as(lnk,Utils.subst_vars(dst,bld.env))
# ================== End empty directory / symlink creation on install target =====================
# =================== Subst / installation of agent scripts project ========
src_files = Utils.to_list(filelist("scripts/** cloudstack-proprietary/scripts/**",flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = src_files
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', name='scriptssubst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
if inst.startswith("cloudstack-proprietary"): inst = inst[len("cloudstack-proprietary")+1:]
bld.install_as("${AGENTLIBDIR}/%s"%inst, tgt, chmod=0755)
# ================== End agent scripts ===================
# ================== Subst / installation of scripts in bin directories ========================
bld.install_files_filtered("${LIBEXECDIR}","*/libexec/* cloudstack-proprietary/*/libexec/*",chmod=0755)
bld.install_files_filtered("${BINDIR}","*/bindir/* cloudstack-proprietary/*/bindir/*",chmod=0755)
bld.install_files_filtered("${SBINDIR}","*/sbindir/* cloudstack-proprietary/*/sbindir/*",chmod=0755)
# ================== End subst / installation of scripts in bin directories ========================
# ================== Installation of scripts / bindirs / configuration files ===========================
# build / install declarations of test project
if buildpremium:
proj = 'test'
start_path = bld.path.find_dir("cloudstack-proprietary/test/scripts")
bld.install_files('${LIBDIR}/${PACKAGE}/test',
start_path.ant_glob("**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
start_path = bld.path.find_dir("cloudstack-proprietary/test/metadata")
bld.install_files('${SHAREDSTATEDIR}/${PACKAGE}/test',
start_path.ant_glob("**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
if not Options.options.PRESERVECONFIG:
bld.install_files('${SYSCONFDIR}/%s/%s'%(bld.env.PACKAGE,proj),'cloudstack-proprietary/test/conf/*')
# build / install declarations of server project <- this is actually now in client project
start_path = bld.path.find_dir("client/WEB-INF")
bld.install_files('${MSENVIRON}/webapps/client/WEB-INF',
start_path.ant_glob("**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${SERVERSYSCONFDIR}","server/conf/*")
# build / install declarations of agent project
proj = 'agent'
start_path = bld.path.find_dir(proj)
bld.install_files("${AGENTLIBDIR}",
start_path.ant_glob("storagepatch/**",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${AGENTSYSCONFDIR}","%s/conf/*"%proj)
# build / install declarations of client UI project
# -> binary unsubstitutable files
start_path = bld.path.find_dir("ui")
bld.install_files("${MSENVIRON}/webapps/client",
start_path.ant_glob("*.ico **/*png **/*jpg **/*gif",src=True,bld=False,dir=False,flat=True),
cwd=start_path,relative_trick=True)
# -> source files with tokens
patterns = 'ui/*html ui/**/*html ui/**/*js ui/**/*css ui/**/*properties ui/**/*jsp'
src_files = Utils.to_list(filelist(patterns,flat=True))
subst_files = [ x+".subst" for x in src_files ]
inst_files = [ Utils.relpath(x,"ui") for x in src_files ]
for src,tgt,inst in zip(src_files,subst_files,inst_files):
tgen = bld(features='subst', source=src, target=tgt)
tgen.dict = bld.env.get_merged_dict()
bld.path.find_or_declare(tgt)
bld.install_as("${MSENVIRON}/webapps/client/%s"%inst, tgt)
# -> minification of UI files
def minifyjs(task):
tgt = task.outputs[0].bldpath(task.env)
inputfiles = []
outputfile = ['--js_output_file',tgt]
for inp in task.inputs:
src = inp.srcpath(task.env)
inputfiles.append(src)
newinputfiles = []
for inputfile in inputfiles:
if inputfile not in newinputfiles:
newinputfiles.append('--js')
newinputfiles.append(inputfile)
compilerjar = _join(sourcedir,'tools','gcc','compiler.jar')
return Utils.exec_command(["java",'-jar',compilerjar] + newinputfiles + outputfile,log=True)
javascripts = [
['ui/scripts/jquery-1.4.2.min.js','ui/scripts/date.js'],
Utils.to_list(filelist('ui/scripts/jquery*js')),
['ui/scripts/cloud.core.js','ui/scripts/cloud.core.callbacks.js'],
Utils.to_list(filelist('ui/scripts/cloud*js')),
]
sourcefiles = []
for lst in javascripts:
for x in lst:
if x not in sourcefiles: sourcefiles.append(x)
tgen = bld(
rule = minifyjs,
source = sourcefiles,
target = 'ui/scripts/cloud.min.js',
name = 'minifyjs',
)
bld.install_files("${MSENVIRON}/webapps/client/scripts", "ui/scripts/cloud.min.js")
# substitute and install generic tomcat config
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${MSCONF}","*/tomcatconf/* cloudstack-proprietary/*/tomcatconf/*")
bld.install_files("${MSCONF}",'client/tomcatconf/db.properties',chmod=0640)
bld.setownership("${MSCONF}/db.properties","root",bld.env.MSUSER)
# apply distro-specific config on top of the 'all' generic cloud-management config
globspec = _join("*","distro",bld.env.DISTRO.lower(),"*") # matches premium/distro/centos/SYSCONFDIR
distrospecificdirs=_glob(globspec) + _glob(_join("cloudstack-proprietary",globspec))
for dsdir in distrospecificdirs:
start_path = bld.srcnode.find_dir(dsdir)
subpath,varname = _split(dsdir)
dsdirwithvar = _join("${%s}"%varname)
files = filelist('%s/**'%dsdir,src=True,bld=False,dir=False,flat=True)
mode = 0644
if "SYSCONFDIR" in dsdir:
mode = 0755
if Options.options.PRESERVECONFIG: continue
bld.install_files_filtered(dsdirwithvar, files, cwd=start_path, relative_trick=True,chmod=mode)
# build / install declarations of usage
if buildpremium:
if not Options.options.PRESERVECONFIG:
#print filelist("usage/conf/* cloudstack-proprietary/usage/conf/*")
#assert False
bld.install_files_filtered("${USAGESYSCONFDIR}","usage/conf/* cloudstack-proprietary/usage/conf/*")
bld.symlink_as("${USAGESYSCONFDIR}/db.properties",Utils.subst_vars("${MSCONF}/db.properties",bld.env))
# install db data files
bld.install_files_filtered("${SETUPDATADIR}",filelist("*/db/* cloudstack-proprietary/*/db/*",excl=Node.exclude_regs + "\ncloud-gate\ncloud-bridge"))
# ================== End installation of scripts / bindirs / configuration files ===========================
# ====================== Feature-specific plugins ========================
for plugin in _glob(_join("plugins","*")) + _glob(_join("cloudstack-proprietary","plugins","*")):
if not _exists(_join(plugin,"build.xml")): continue
pluginname = _basename(plugin)
target = 'target/jar/cloud-%s.jar' % pluginname
sources = filelist( '%s/**/*.java' % plugin.replace(sep,"/") , src=True, bld=False, dir=False )
tgen = bld(rule=lambda x: runant("compile-%s"%pluginname), name='compile_%s'%pluginname, source=sources, target=target, after='runant')
bld.install_files('${PLUGINJAVADIR}',target)
# ====================== End feature-specific plugins ====================
# ====================== Vendor-specific plugins ========================
for vendor in _glob(_join("vendor","*")) + _glob(_join("cloudstack-proprietary","vendor","*")):
if not Options.options.PRESERVECONFIG:
bld.install_files_filtered("${MSCONF}/%s"%vendor,filelist("%s/tomcatconf/*"%vendor))
# ====================== End vendor-specific plugins ====================