change run_plugin to run_callbacks and remove the modification for kojikamid.py
This commit is contained in:
parent
222ed94e93
commit
efc4c9bcff
3 changed files with 42 additions and 54 deletions
|
|
@ -1415,13 +1415,13 @@ class BuildMavenTask(BaseBuildTask):
|
||||||
uploadpath = self.getUploadDir()
|
uploadpath = self.getUploadDir()
|
||||||
|
|
||||||
|
|
||||||
self.run_plugin('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
||||||
# Check out sources from the SCM
|
# Check out sources from the SCM
|
||||||
sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)
|
sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)
|
||||||
self.run_plugin("postSCMCheckout",
|
self.run_callbacks("postSCMCheckout",
|
||||||
scminfo=scm.get_info(),
|
scminfo=scm.get_info(),
|
||||||
scratch=opts.get('scratch'),
|
scratch=opts.get('scratch'),
|
||||||
srcdir=sourcedir)
|
srcdir=sourcedir)
|
||||||
|
|
||||||
# zip up pristine sources for auditing purposes
|
# zip up pristine sources for auditing purposes
|
||||||
self._zip_dir(sourcedir, os.path.join(outputdir, 'scm-sources.zip'))
|
self._zip_dir(sourcedir, os.path.join(outputdir, 'scm-sources.zip'))
|
||||||
|
|
@ -1431,14 +1431,14 @@ class BuildMavenTask(BaseBuildTask):
|
||||||
patchlog = self.workdir + '/patches.log'
|
patchlog = self.workdir + '/patches.log'
|
||||||
patch_scm = SCM(self.opts.get('patches'))
|
patch_scm = SCM(self.opts.get('patches'))
|
||||||
patch_scm.assert_allowed(self.options.allowed_scms)
|
patch_scm.assert_allowed(self.options.allowed_scms)
|
||||||
self.run_plugin('preSCMCheckout', scminfo=patch_scm.get_info(), build_tag=build_tag)
|
self.run_callbacks('preSCMCheckout', scminfo=patch_scm.get_info(), build_tag=build_tag)
|
||||||
# never try to check out a common/ dir when checking out patches
|
# never try to check out a common/ dir when checking out patches
|
||||||
patch_scm.use_common = False
|
patch_scm.use_common = False
|
||||||
patchcheckoutdir = patch_scm.checkout(patchdir, self.session, uploadpath, patchlog)
|
patchcheckoutdir = patch_scm.checkout(patchdir, self.session, uploadpath, patchlog)
|
||||||
self.run_plugin("postSCMCheckout",
|
self.run_callbacks("postSCMCheckout",
|
||||||
scminfo=patch_scm.get_info(),
|
scminfo=patch_scm.get_info(),
|
||||||
scratch=opts.get('scratch'),
|
scratch=opts.get('scratch'),
|
||||||
srcdir=patchcheckoutdir)
|
srcdir=patchcheckoutdir)
|
||||||
self._zip_dir(patchcheckoutdir, os.path.join(outputdir, 'patches.zip'))
|
self._zip_dir(patchcheckoutdir, os.path.join(outputdir, 'patches.zip'))
|
||||||
|
|
||||||
# Apply patches, if present
|
# Apply patches, if present
|
||||||
|
|
@ -1719,12 +1719,12 @@ class WrapperRPMTask(BaseBuildTask):
|
||||||
logfile = os.path.join(self.workdir, 'checkout.log')
|
logfile = os.path.join(self.workdir, 'checkout.log')
|
||||||
scmdir = buildroot.rootdir() + '/tmp/scmroot'
|
scmdir = buildroot.rootdir() + '/tmp/scmroot'
|
||||||
koji.ensuredir(scmdir)
|
koji.ensuredir(scmdir)
|
||||||
self.run_plugin('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
||||||
specdir = scm.checkout(scmdir, self.session, self.getUploadDir(), logfile)
|
specdir = scm.checkout(scmdir, self.session, self.getUploadDir(), logfile)
|
||||||
self.run_plugin("postSCMCheckout",
|
self.run_callbacks("postSCMCheckout",
|
||||||
scminfo=scm.get_info(),
|
scminfo=scm.get_info(),
|
||||||
scratch=opts.get('scratch'),
|
scratch=opts.get('scratch'),
|
||||||
srcdir=specdir)
|
srcdir=specdir)
|
||||||
|
|
||||||
spec_template = None
|
spec_template = None
|
||||||
for path, dir, files in os.walk(specdir):
|
for path, dir, files in os.walk(specdir):
|
||||||
|
|
@ -2658,12 +2658,12 @@ class ImageTask(BaseTaskHandler):
|
||||||
scm = SCM(self.opts['ksurl'])
|
scm = SCM(self.opts['ksurl'])
|
||||||
scm.assert_allowed(self.options.allowed_scms)
|
scm.assert_allowed(self.options.allowed_scms)
|
||||||
logfile = os.path.join(self.workdir, 'checkout.log')
|
logfile = os.path.join(self.workdir, 'checkout.log')
|
||||||
self.run_plugin('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
||||||
scmsrcdir = scm.checkout(scmdir, self.session, self.getUploadDir(), logfile)
|
scmsrcdir = scm.checkout(scmdir, self.session, self.getUploadDir(), logfile)
|
||||||
self.run_plugin("postSCMCheckout",
|
self.run_callbacks("postSCMCheckout",
|
||||||
scminfo=scm.get_info(),
|
scminfo=scm.get_info(),
|
||||||
scratch=self.opts.get('scratch'),
|
scratch=self.opts.get('scratch'),
|
||||||
srcdir=scmsrcdir)
|
srcdir=scmsrcdir)
|
||||||
kspath = os.path.join(scmsrcdir, ksfile)
|
kspath = os.path.join(scmsrcdir, ksfile)
|
||||||
else:
|
else:
|
||||||
kspath = self.localPath("work/%s" % ksfile)
|
kspath = self.localPath("work/%s" % ksfile)
|
||||||
|
|
@ -3276,13 +3276,13 @@ class OzImageTask(BaseTaskHandler):
|
||||||
scm = SCM(self.opts['ksurl'])
|
scm = SCM(self.opts['ksurl'])
|
||||||
scm.assert_allowed(self.options.allowed_scms)
|
scm.assert_allowed(self.options.allowed_scms)
|
||||||
logfile = os.path.join(self.workdir, 'checkout-%s.log' % self.arch)
|
logfile = os.path.join(self.workdir, 'checkout-%s.log' % self.arch)
|
||||||
self.run_plugin('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
||||||
scmsrcdir = scm.checkout(self.workdir, self.session,
|
scmsrcdir = scm.checkout(self.workdir, self.session,
|
||||||
self.getUploadDir(), logfile)
|
self.getUploadDir(), logfile)
|
||||||
self.run_plugin("postSCMCheckout",
|
self.run_callbacks("postSCMCheckout",
|
||||||
scminfo=scm.get_info(),
|
scminfo=scm.get_info(),
|
||||||
scratch=self.opts.get('scratch'),
|
scratch=self.opts.get('scratch'),
|
||||||
srcdir=scmsrcdir)
|
srcdir=scmsrcdir)
|
||||||
kspath = os.path.join(scmsrcdir, os.path.basename(ksfile))
|
kspath = os.path.join(scmsrcdir, os.path.basename(ksfile))
|
||||||
else:
|
else:
|
||||||
tops = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir'])
|
tops = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir'])
|
||||||
|
|
@ -4087,14 +4087,14 @@ class BuildIndirectionImageTask(OzImageTask):
|
||||||
if fileurl:
|
if fileurl:
|
||||||
scm = SCM(fileurl)
|
scm = SCM(fileurl)
|
||||||
scm.assert_allowed(self.options.allowed_scms)
|
scm.assert_allowed(self.options.allowed_scms)
|
||||||
self.run_plugin('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
||||||
logfile = os.path.join(self.workdir, 'checkout.log')
|
logfile = os.path.join(self.workdir, 'checkout.log')
|
||||||
scmsrcdir = scm.checkout(self.workdir, self.session,
|
scmsrcdir = scm.checkout(self.workdir, self.session,
|
||||||
self.getUploadDir(), logfile)
|
self.getUploadDir(), logfile)
|
||||||
self.run_plugin("postSCMCheckout",
|
self.run_callbacks("postSCMCheckout",
|
||||||
scminfo=scm.get_info(),
|
scminfo=scm.get_info(),
|
||||||
scratch=self.opts.get('scratch'),
|
scratch=self.opts.get('scratch'),
|
||||||
srcdir=scmsrcdir)
|
srcdir=scmsrcdir)
|
||||||
final_path = os.path.join(scmsrcdir, os.path.basename(filepath))
|
final_path = os.path.join(scmsrcdir, os.path.basename(filepath))
|
||||||
else:
|
else:
|
||||||
tops = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir'])
|
tops = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir'])
|
||||||
|
|
@ -4436,13 +4436,13 @@ class BuildSRPMFromSCMTask(BaseBuildTask):
|
||||||
logfile = self.workdir + '/checkout.log'
|
logfile = self.workdir + '/checkout.log'
|
||||||
uploadpath = self.getUploadDir()
|
uploadpath = self.getUploadDir()
|
||||||
|
|
||||||
self.run_plugin('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag)
|
||||||
# Check out spec file, etc. from SCM
|
# Check out spec file, etc. from SCM
|
||||||
sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)
|
sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)
|
||||||
self.run_plugin("postSCMCheckout",
|
self.run_callbacks("postSCMCheckout",
|
||||||
scminfo=scm.get_info(),
|
scminfo=scm.get_info(),
|
||||||
scratch=self.opts.get('scratch'),
|
scratch=self.opts.get('scratch'),
|
||||||
srcdir=sourcedir)
|
srcdir=sourcedir)
|
||||||
# chown the sourcedir and everything under it to the mockuser
|
# chown the sourcedir and everything under it to the mockuser
|
||||||
# so we can build the srpm as non-root
|
# so we can build the srpm as non-root
|
||||||
uid = pwd.getpwnam(self.options.mockuser)[2]
|
uid = pwd.getpwnam(self.options.mockuser)[2]
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ class BaseTaskHandler(object):
|
||||||
return repo_info
|
return repo_info
|
||||||
|
|
||||||
|
|
||||||
def run_plugin(self, plugin, *args, **kwargs):
|
def run_callbacks(self, plugin, *args, **kwargs):
|
||||||
if 'taskinfo' not in kwargs:
|
if 'taskinfo' not in kwargs:
|
||||||
try:
|
try:
|
||||||
taskinfo = self.taskinfo
|
taskinfo = self.taskinfo
|
||||||
|
|
|
||||||
|
|
@ -47,20 +47,19 @@ MANAGER_PORT = 7000
|
||||||
|
|
||||||
KOJIKAMID = True
|
KOJIKAMID = True
|
||||||
|
|
||||||
|
|
||||||
## INSERT kojikamid dup
|
## INSERT kojikamid dup
|
||||||
|
|
||||||
class fakemodule(object):
|
class fakemodule(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#make parts of the above insert accessible as koji.X
|
||||||
# make parts of the above insert accessible as koji.X
|
|
||||||
koji = fakemodule()
|
koji = fakemodule()
|
||||||
koji.GenericError = GenericError
|
koji.GenericError = GenericError
|
||||||
koji.BuildError = BuildError
|
koji.BuildError = BuildError
|
||||||
|
|
||||||
|
|
||||||
class WindowsBuild(object):
|
class WindowsBuild(object):
|
||||||
|
|
||||||
LEADING_CHAR = re.compile('^[^A-Za-z_]')
|
LEADING_CHAR = re.compile('^[^A-Za-z_]')
|
||||||
VAR_CHARS = re.compile('[^A-Za-z0-9_]')
|
VAR_CHARS = re.compile('[^A-Za-z0-9_]')
|
||||||
|
|
||||||
|
|
@ -137,7 +136,7 @@ class WindowsBuild(object):
|
||||||
self.logger.info('file %s exists', entry)
|
self.logger.info('file %s exists', entry)
|
||||||
if errors:
|
if errors:
|
||||||
raise BuildError('error validating build environment: %s' % \
|
raise BuildError('error validating build environment: %s' % \
|
||||||
', '.join(errors))
|
', '.join(errors))
|
||||||
|
|
||||||
def updateClam(self):
|
def updateClam(self):
|
||||||
"""update ClamAV virus definitions"""
|
"""update ClamAV virus definitions"""
|
||||||
|
|
@ -319,7 +318,7 @@ class WindowsBuild(object):
|
||||||
# rpms don't have a md5sum in the fileinfo, but check it for everything else
|
# rpms don't have a md5sum in the fileinfo, but check it for everything else
|
||||||
if ('md5sum' in fileinfo) and (digest != fileinfo['md5sum']):
|
if ('md5sum' in fileinfo) and (digest != fileinfo['md5sum']):
|
||||||
raise BuildError('md5 checksum validation failed for %s, %s (computed) != %s (provided)' % \
|
raise BuildError('md5 checksum validation failed for %s, %s (computed) != %s (provided)' % \
|
||||||
(destpath, digest, fileinfo['md5sum']))
|
(destpath, digest, fileinfo['md5sum']))
|
||||||
self.logger.info('Retrieved %s (%s bytes, md5: %s)', destpath, offset, digest)
|
self.logger.info('Retrieved %s (%s bytes, md5: %s)', destpath, offset, digest)
|
||||||
|
|
||||||
def fetchBuildReqs(self):
|
def fetchBuildReqs(self):
|
||||||
|
|
@ -469,7 +468,7 @@ class WindowsBuild(object):
|
||||||
self.virusCheck(self.workdir)
|
self.virusCheck(self.workdir)
|
||||||
if errors:
|
if errors:
|
||||||
raise BuildError('error validating build output: %s' % \
|
raise BuildError('error validating build output: %s' % \
|
||||||
', '.join(errors))
|
', '.join(errors))
|
||||||
|
|
||||||
def virusCheck(self, path):
|
def virusCheck(self, path):
|
||||||
"""ensure a path is virus free with ClamAV. path should be absolute"""
|
"""ensure a path is virus free with ClamAV. path should be absolute"""
|
||||||
|
|
@ -500,7 +499,6 @@ class WindowsBuild(object):
|
||||||
self.expireBuildroot()
|
self.expireBuildroot()
|
||||||
return self.gatherResults()
|
return self.gatherResults()
|
||||||
|
|
||||||
|
|
||||||
def run(cmd, chdir=None, fatal=False, log=True):
|
def run(cmd, chdir=None, fatal=False, log=True):
|
||||||
global logfd
|
global logfd
|
||||||
output = ''
|
output = ''
|
||||||
|
|
@ -530,7 +528,6 @@ def run(cmd, chdir=None, fatal=False, log=True):
|
||||||
raise BuildError(msg)
|
raise BuildError(msg)
|
||||||
return ret, output
|
return ret, output
|
||||||
|
|
||||||
|
|
||||||
def find_net_info():
|
def find_net_info():
|
||||||
"""
|
"""
|
||||||
Find the network gateway configured for this VM.
|
Find the network gateway configured for this VM.
|
||||||
|
|
@ -559,7 +556,6 @@ def find_net_info():
|
||||||
gateway = None
|
gateway = None
|
||||||
return macaddr, gateway
|
return macaddr, gateway
|
||||||
|
|
||||||
|
|
||||||
def upload_file(server, prefix, path):
|
def upload_file(server, prefix, path):
|
||||||
"""upload a single file to the vmd"""
|
"""upload a single file to the vmd"""
|
||||||
logger = logging.getLogger('koji.vm')
|
logger = logging.getLogger('koji.vm')
|
||||||
|
|
@ -580,7 +576,6 @@ def upload_file(server, prefix, path):
|
||||||
server.verifyChecksum(path, digest, 'md5')
|
server.verifyChecksum(path, digest, 'md5')
|
||||||
logger.info('Uploaded %s (%s bytes, md5: %s)', destpath, offset, digest)
|
logger.info('Uploaded %s (%s bytes, md5: %s)', destpath, offset, digest)
|
||||||
|
|
||||||
|
|
||||||
def get_mgmt_server():
|
def get_mgmt_server():
|
||||||
"""Get a ServerProxy object we can use to retrieve task info"""
|
"""Get a ServerProxy object we can use to retrieve task info"""
|
||||||
logger = logging.getLogger('koji.vm')
|
logger = logging.getLogger('koji.vm')
|
||||||
|
|
@ -599,7 +594,6 @@ def get_mgmt_server():
|
||||||
logger.debug('found task-specific port %s', task_port)
|
logger.debug('found task-specific port %s', task_port)
|
||||||
return xmlrpclib.ServerProxy('http://%s:%s/' % (gateway, task_port), allow_none=True)
|
return xmlrpclib.ServerProxy('http://%s:%s/' % (gateway, task_port), allow_none=True)
|
||||||
|
|
||||||
|
|
||||||
def get_options():
|
def get_options():
|
||||||
"""handle usage and parse options"""
|
"""handle usage and parse options"""
|
||||||
usage = """%prog [options]
|
usage = """%prog [options]
|
||||||
|
|
@ -609,12 +603,10 @@ def get_options():
|
||||||
parser = OptionParser(usage=usage)
|
parser = OptionParser(usage=usage)
|
||||||
parser.add_option('-d', '--debug', action='store_true', help='Log debug statements')
|
parser.add_option('-d', '--debug', action='store_true', help='Log debug statements')
|
||||||
parser.add_option('-i', '--install', action='store_true', help='Install this daemon as a service', default=False)
|
parser.add_option('-i', '--install', action='store_true', help='Install this daemon as a service', default=False)
|
||||||
parser.add_option('-u', '--uninstall', action='store_true',
|
parser.add_option('-u', '--uninstall', action='store_true', help='Uninstall this daemon if it was installed previously as a service', default=False)
|
||||||
help='Uninstall this daemon if it was installed previously as a service', default=False)
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(opts):
|
def setup_logging(opts):
|
||||||
global logfile, logfd
|
global logfile, logfd
|
||||||
logger = logging.getLogger('koji.vm')
|
logger = logging.getLogger('koji.vm')
|
||||||
|
|
@ -629,13 +621,11 @@ def setup_logging(opts):
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
return handler
|
return handler
|
||||||
|
|
||||||
|
|
||||||
def log_local(msg):
|
def log_local(msg):
|
||||||
tb = ''.join(traceback.format_exception(*sys.exc_info()))
|
tb = ''.join(traceback.format_exception(*sys.exc_info()))
|
||||||
sys.stderr.write('%s: %s\n' % (time.ctime(), msg))
|
sys.stderr.write('%s: %s\n' % (time.ctime(), msg))
|
||||||
sys.stderr.write(tb)
|
sys.stderr.write(tb)
|
||||||
|
|
||||||
|
|
||||||
def stream_logs(server, handler, builds):
|
def stream_logs(server, handler, builds):
|
||||||
"""Stream logs incrementally to the server.
|
"""Stream logs incrementally to the server.
|
||||||
The global logfile will always be streamed.
|
The global logfile will always be streamed.
|
||||||
|
|
@ -673,7 +663,6 @@ def stream_logs(server, handler, builds):
|
||||||
log_local('error uploading %s' % relpath)
|
log_local('error uploading %s' % relpath)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
def fail(server, handler):
|
def fail(server, handler):
|
||||||
"""do the right thing when a build fails"""
|
"""do the right thing when a build fails"""
|
||||||
global logfile, logfd
|
global logfile, logfd
|
||||||
|
|
@ -700,7 +689,6 @@ def fail(server, handler):
|
||||||
logfile = '/tmp/build.log'
|
logfile = '/tmp/build.log'
|
||||||
logfd = None
|
logfd = None
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
prog = os.path.basename(sys.argv[0])
|
prog = os.path.basename(sys.argv[0])
|
||||||
opts = get_options()
|
opts = get_options()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue