mirror of https://github.com/apache/cloudstack.git
Cleanup: Found some waf remnants
This commit is contained in:
parent
ae4befb0b9
commit
085846af94
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import Options, Utils
|
||||
import os
|
||||
|
||||
def detect(conf):
|
||||
conf.check_message_1('Detecting JAVADIR')
|
||||
javadir = getattr(Options.options, 'JAVADIR', '')
|
||||
if javadir:
|
||||
conf.env.JAVADIR = javadir
|
||||
conf.check_message_2("%s (forced through --javadir)"%conf.env.JAVADIR,"GREEN")
|
||||
else:
|
||||
conf.env.JAVADIR = os.path.join(conf.env.DATADIR,'java')
|
||||
conf.check_message_2("%s (using default ${DATADIR}/java directory)"%conf.env.JAVADIR,"GREEN")
|
||||
|
||||
def set_options(opt):
|
||||
inst_dir = opt.get_option_group('--datadir') # get the group that contains bindir
|
||||
if not inst_dir: raise Utils.WafError, "DATADIR not set. Did you load the gnu_dirs tool options with opt.tool_options('gnu_dirs') before running opt.tool_options('javadir')?"
|
||||
inst_dir.add_option('--javadir', # add javadir to the group that contains bindir
|
||||
help = 'Java class and jar files [Default: ${DATADIR}/java]',
|
||||
default = '',
|
||||
dest = 'JAVADIR')
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import Utils
|
||||
from TaskGen import feature, before
|
||||
from Configure import ConfigurationError
|
||||
import Task
|
||||
import os
|
||||
|
||||
# fixme: this seems to hang waf with 100% CPU
|
||||
|
||||
def detect(conf):
|
||||
conf.find_program("mkisofs",var='MKISOFS')
|
||||
if not conf.env.MKISOFS: conf.find_program("genisoimage",mandatory=True,var='MKISOFS')
|
||||
|
||||
def iso_up(task):
|
||||
tgt = task.outputs[0].bldpath(task.env)
|
||||
if os.path.exists(tgt): os.unlink(tgt)
|
||||
inps = []
|
||||
for inp in task.inputs:
|
||||
if inp.id&3==Node.BUILD:
|
||||
src = inp.bldpath(task.env)
|
||||
srcname = src
|
||||
srcname = sep.join(srcname.split(sep)[1:]) # chop off default/
|
||||
else:
|
||||
src = inp.srcpath(task.env)
|
||||
srcname = src
|
||||
srcname = sep.join(srcname.split(sep)[1:]) # chop off ../
|
||||
if task.generator.rename: srcname = task.generator.rename(srcname)
|
||||
inps.append(srcname+'='+src)
|
||||
ret = Utils.exec_command(
|
||||
[
|
||||
task.generator.env.MKISOFS,
|
||||
"-quiet",
|
||||
"-r",
|
||||
"-graft-points",
|
||||
"-o",tgt,
|
||||
] + inps, shell=False)
|
||||
if ret != 0: return ret
|
||||
|
||||
def apply_iso(self):
|
||||
Utils.def_attrs(self,fun=iso_up)
|
||||
self.default_install_path=0
|
||||
lst=self.to_list(self.source)
|
||||
self.meths.remove('apply_core')
|
||||
self.dict=getattr(self,'dict',{})
|
||||
out = self.path.find_or_declare(self.target)
|
||||
ins = []
|
||||
for x in Utils.to_list(self.source):
|
||||
node = self.path.find_resource(x)
|
||||
if not node:raise Utils.WafError('cannot find input file %s for processing'%x)
|
||||
ins.append(node)
|
||||
if self.dict and not self.env['DICT_HASH']:
|
||||
self.env=self.env.copy()
|
||||
keys=list(self.dict.keys())
|
||||
keys.sort()
|
||||
lst=[self.dict[x]for x in keys]
|
||||
self.env['DICT_HASH']=str(Utils.h_list(lst))
|
||||
tsk=self.create_task('iso',ins,out)
|
||||
tsk.fun=self.fun
|
||||
tsk.dict=self.dict
|
||||
tsk.dep_vars=['DICT_HASH']
|
||||
tsk.install_path=self.install_path
|
||||
tsk.chmod=self.chmod
|
||||
if not tsk.env:
|
||||
tsk.debug()
|
||||
raise Utils.WafError('task without an environment')
|
||||
|
||||
Task.task_type_from_func('iso',func=iso_up)
|
||||
feature('iso')(apply_iso)
|
||||
before('apply_core')(apply_iso)
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import Utils
|
||||
import Options
|
||||
import tarfile
|
||||
from TaskGen import feature, before
|
||||
import Task
|
||||
import os, sys
|
||||
|
||||
# construct a tar file containing them
|
||||
# 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 os.path.exists(tgt): os.unlink(tgt)
|
||||
if tgt.lower().endswith(".bz2"): z = tarfile.open(tgt,"w:bz2")
|
||||
elif tgt.lower().endswith(".gz"): z = tarfile.open(tgt,"w:gz")
|
||||
elif tgt.lower().endswith(".tgz"): z = tarfile.open(tgt,"w:gz")
|
||||
else: z = tarfile.open(tgt,"w")
|
||||
fileset = {}
|
||||
for inp in task.inputs:
|
||||
src = inp.srcpath(task.env)
|
||||
if src.startswith(".."):
|
||||
srcname = Utils.relpath(src,os.path.join("..",".")) # file in source dir
|
||||
else:
|
||||
srcname = Utils.relpath(src,os.path.join(task.env.variant(),".")) # file in artifacts dir
|
||||
srcname = srcname.split(os.path.sep,len(task.generator.root.split(os.path.sep)))[-1]
|
||||
if task.generator.rename: srcname = task.generator.rename(srcname)
|
||||
fileset[srcname] = src
|
||||
for srcname,src in fileset.items():
|
||||
ti = tarfile.TarInfo(srcname)
|
||||
ti.mode = 0755
|
||||
ti.size = os.path.getsize(src)
|
||||
openmode = 'r'
|
||||
if Options.platform == 'win32': openmode = openmode + 'b'
|
||||
f = file(src,openmode)
|
||||
z.addfile(ti,fileobj=f)
|
||||
f.close()
|
||||
z.close()
|
||||
if task.chmod: os.chmod(tgt,task.chmod)
|
||||
return 0
|
||||
|
||||
def apply_tar(self):
|
||||
Utils.def_attrs(self,fun=tar_up)
|
||||
self.default_install_path=0
|
||||
lst=self.to_list(self.source)
|
||||
self.meths.remove('apply_core')
|
||||
self.dict=getattr(self,'dict',{})
|
||||
out = self.path.find_or_declare(self.target)
|
||||
ins = []
|
||||
for x in Utils.to_list(self.source):
|
||||
node = self.path.find_resource(x)
|
||||
if not node:raise Utils.WafError('cannot find input file %s for processing'%x)
|
||||
ins.append(node)
|
||||
tsk=self.create_task('tar',ins,out)
|
||||
tsk.fun=self.fun
|
||||
tsk.dict=self.dict
|
||||
tsk.install_path=self.install_path
|
||||
tsk.chmod=self.chmod
|
||||
if not tsk.env:
|
||||
tsk.debug()
|
||||
raise Utils.WafError('task without an environment')
|
||||
|
||||
Task.task_type_from_func('tar',func=tar_up)
|
||||
feature('tar')(apply_tar)
|
||||
before('apply_core')(apply_tar)
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import Options, Utils
|
||||
import os
|
||||
|
||||
def detect(conf):
|
||||
if not conf.env.DATADIR:
|
||||
conf.fatal("DATADIR not found in the environment. Did you run conf.check_tool('gnu_dirs') before running check_tool('tomcat')?")
|
||||
conf.check_message_1('Detecting Tomcat')
|
||||
conf.env.TOMCATHOME = ''
|
||||
tomcathome = getattr(Options.options, 'TOMCATHOME', '')
|
||||
if tomcathome:
|
||||
conf.env.TOMCATHOME = tomcathome
|
||||
method = "forced through --with-tomcat"
|
||||
else:
|
||||
if "TOMCAT_HOME" in conf.environ and conf.environ['TOMCAT_HOME'].strip():
|
||||
conf.env.TOMCATHOME = conf.environ["TOMCAT_HOME"]
|
||||
method = 'got through environment variable %TOMCAT_HOME%'
|
||||
elif "CATALINA_HOME" in conf.environ and conf.environ['CATALINA_HOME'].strip():
|
||||
conf.env.TOMCATHOME = conf.environ['CATALINA_HOME']
|
||||
method = 'got through environment variable %CATALINA_HOME%'
|
||||
elif os.path.isdir(os.path.join(conf.env.DATADIR,"tomcat6")):
|
||||
conf.env.TOMCATHOME = os.path.join(conf.env.DATADIR,"tomcat6")
|
||||
method = 'detected existence of Tomcat directory under $DATADIR'
|
||||
elif os.path.isdir("/usr/share/tomcat6"):
|
||||
conf.env.TOMCATHOME = "/usr/share/tomcat6"
|
||||
method = 'detected existence of standard Linux system directory'
|
||||
if not conf.env.TOMCATHOME:
|
||||
conf.fatal("Could not detect Tomcat")
|
||||
elif not os.path.isdir(conf.env.TOMCATHOME):
|
||||
conf.fatal("Tomcat cannot be found at %s"%conf.env.TOMCATHOME)
|
||||
else:
|
||||
conf.check_message_2("%s (%s)"%(conf.env.TOMCATHOME,method),"GREEN")
|
||||
|
||||
def set_options(opt):
|
||||
inst_dir = opt.get_option_group('--datadir') # get the group that contains bindir
|
||||
if not inst_dir: raise Utils.WafError, "DATADIR not set. Did you load the gnu_dirs tool options with opt.tool_options('gnu_dirs') before running opt.tool_options('tomcat')?"
|
||||
inst_dir.add_option('--with-tomcat', # add javadir to the group that contains bindir
|
||||
help = 'Path to installed Tomcat 6 environment [Default: ${DATADIR}/tomcat6 (unless %%CATALINA_HOME%% is set)]',
|
||||
default = '',
|
||||
dest = 'TOMCATHOME')
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import Utils, Build
|
||||
from TaskGen import feature, before
|
||||
from Configure import ConfigurationError
|
||||
import Options
|
||||
import Task
|
||||
import os
|
||||
|
||||
def detect(conf):
|
||||
if Options.platform == 'win32': raise Utils.WafError('the usermgmt tool only works on Linux')
|
||||
if Options.platform == 'darwin': raise Utils.WafError('the usermgmt tool only works on Linux')
|
||||
path_list = ["/usr/local/sbin","/usr/sbin","/sbin"] + os.environ.get('PATH','').split(os.pathsep)
|
||||
conf.find_program("useradd",var='USERADD',mandatory=True,path_list=path_list)
|
||||
conf.find_program("userdel",var='USERDEL',mandatory=True,path_list=path_list)
|
||||
|
||||
def set_options(opt):
|
||||
if Options.platform == 'win32': raise Utils.WafError('the usermgmt tool only works on Linux')
|
||||
if Options.platform == 'darwin': raise Utils.WafError('the usermgmt tool only works on Linux')
|
||||
og = opt.get_option_group('--force')
|
||||
og.add_option('--nochown',
|
||||
action = 'store_true',
|
||||
help = 'do not create or remove user accounts or change file ownership on installed files',
|
||||
default = False,
|
||||
dest = 'NOUSERMGMT')
|
||||
|
||||
def _subst_add_destdir(x,bld):
|
||||
a = "${DESTDIR}" + x
|
||||
a = a.replace("${DESTDIR}",Options.options.destdir)
|
||||
a = Utils.subst_vars(a,bld.env)
|
||||
if a.startswith("//"): a = a[1:]
|
||||
return a
|
||||
Build.BuildContext.subst_add_destdir = staticmethod(_subst_add_destdir)
|
||||
|
||||
def _setownership(ctx,path,owner,group,mode=None):
|
||||
if Options.platform == 'win32': return
|
||||
if Options.platform == 'darwin': return
|
||||
if not hasattr(os,"getuid"): return
|
||||
if os.getuid() != 0: return
|
||||
if Options.options.NOUSERMGMT: return
|
||||
|
||||
import pwd
|
||||
import grp
|
||||
import stat
|
||||
from os import chown as _chown, chmod as _chmod
|
||||
|
||||
def f(bld,path,owner,group,mode):
|
||||
|
||||
try: uid = pwd.getpwnam(owner).pw_uid
|
||||
except KeyError,e:
|
||||
raise Utils.WafError("Before using setownership() you have to create the user with bld.createuser(username...)")
|
||||
try: gid = grp.getgrnam(group).gr_gid
|
||||
except KeyError,e:
|
||||
raise Utils.WafError("Before using setownership() you have to create the user with bld.createuser(username...)")
|
||||
|
||||
path = bld.subst_add_destdir(path,bld)
|
||||
current_uid,current_gid = os.stat(path).st_uid,os.stat(path).st_gid
|
||||
if current_uid != uid:
|
||||
Utils.pprint("GREEN","* setting owner of %s to UID %s"%(path,uid))
|
||||
_chown(path,uid,current_gid)
|
||||
current_uid = uid
|
||||
if current_gid != gid:
|
||||
Utils.pprint("GREEN","* setting group of %s to GID %s"%(path,gid))
|
||||
_chown(path,current_uid,gid)
|
||||
current_gid = gid
|
||||
if mode is not None:
|
||||
current_mode = stat.S_IMODE(os.stat(path).st_mode)
|
||||
if current_mode != mode:
|
||||
Utils.pprint("GREEN","* adjusting permissions on %s to mode %o"%(path,mode))
|
||||
_chmod(path,mode)
|
||||
current_mode = mode
|
||||
|
||||
if ctx.is_install > 0:
|
||||
ctx.add_post_fun(lambda ctx: f(ctx,path,owner,group,mode))
|
||||
Build.BuildContext.setownership = _setownership
|
||||
|
||||
def _createuser(ctx,user,homedir,shell):
|
||||
if Options.platform == 'win32': return
|
||||
if Options.platform == 'darwin': return
|
||||
if not hasattr(os,"getuid"): return
|
||||
if os.getuid() != 0: return
|
||||
if Options.options.NOUSERMGMT: return
|
||||
|
||||
def f(ctx,user,homedir,shell):
|
||||
import pwd
|
||||
try:
|
||||
pwd.getpwnam(user).pw_uid
|
||||
user_exists = True
|
||||
except KeyError,e:
|
||||
user_exists = False
|
||||
if user_exists: return
|
||||
|
||||
Utils.pprint("GREEN","* creating user %s"%user)
|
||||
cmd = [
|
||||
ctx.env.USERADD,
|
||||
'-M',
|
||||
'-r',
|
||||
'-s',shell,
|
||||
'-d',homedir,
|
||||
user,
|
||||
]
|
||||
ret = Utils.exec_command(cmd)
|
||||
if ret: raise Utils.WafError("Failed to run command %s"%cmd)
|
||||
|
||||
def g(ctx,user,homedir,shell):
|
||||
import pwd
|
||||
try:
|
||||
pwd.getpwnam(user).pw_uid
|
||||
user_exists = True
|
||||
except KeyError,e:
|
||||
user_exists = False
|
||||
if not user_exists: return
|
||||
|
||||
Utils.pprint("GREEN","* removing user %s"%user)
|
||||
cmd = [
|
||||
ctx.env.USERDEL,
|
||||
user,
|
||||
]
|
||||
ret = Utils.exec_command(cmd)
|
||||
if ret: raise Utils.WafError("Failed to run command %s"%cmd)
|
||||
|
||||
if ctx.is_install > 0:
|
||||
ctx.add_pre_fun(lambda ctx: f(ctx,user,homedir,shell))
|
||||
elif ctx.is_install < 0:
|
||||
ctx.add_pre_fun(lambda ctx: g(ctx,user,homedir,shell))
|
||||
Build.BuildContext.createuser = _createuser
|
||||
Loading…
Reference in New Issue