1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-22 21:16:16 +01:00

- drop hardcoded source validator executions

This commit is contained in:
Adrian Schröter 2011-09-07 13:55:05 +02:00
parent f80ce9c663
commit 568612cedc
4 changed files with 19 additions and 73 deletions

3
NEWS
View File

@ -1,6 +1,9 @@
0.133
- add --meta option also to "list", "cat" and "less" commands
- project checkout is skipping packages linking to project local packages by default
- source validators are not called by default anymore:
* They can get used via source services now
* Allows different validations based on the code streams
#
# Features which requires OBS 2.3
#

View File

@ -3687,10 +3687,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='read log message from FILE, \'-\' denotes standard input.')
@cmdln.option('-f', '--force', default=False, action="store_true",
help='ignored')
@cmdln.option('--skip-validation', default=False, action="store_true",
help='Skip the source validation')
@cmdln.option('-v', '--verbose', default=False, action="store_true",
help='Run the source services and validation with verbose information')
help='Run the source services with verbose information')
@cmdln.option('--skip-local-service-run', default=False, action="store_true",
help='Skip service run of \'localonly\' or \'trylocal\' configured source services')
def do_commit(self, subcmd, opts, *args):
@ -3709,15 +3707,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
"""
args = parseargs(args)
validators = conf.config['source_validator_directory']
if opts.skip_validation:
validators = None
elif not os.path.exists(validators):
print >>sys.stderr, "WARNING: source_validator_directory configured but it "\
"does not exist:\n\t %s \n"\
"\t Install osc-source_validator to fix." % validators
validators = None
msg = ''
if opts.message:
msg = opts.message
@ -3737,7 +3726,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
prj = Project(arg)
if not msg:
msg = edit_message()
prj.commit(validators_dir=validators, msg=msg, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
prj.commit(msg=msg, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
except oscerr.ExtRuntimeError, e:
print >>sys.stderr, "ERROR: service run failed", e
return 1
@ -3769,13 +3758,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
prj = Project(prj_path)
if not msg:
msg = get_commit_msg(prj.absdir, pac_objs[prj_path])
prj.commit(packages, validators_dir=validators, msg=msg, files=files, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
prj.commit(packages, msg=msg, files=files, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
store_unlink_file(prj.absdir, '_commit_msg')
for pac in single_paths:
p = Package(pac)
if not msg:
msg = get_commit_msg(p.absdir, [p])
p.commit(msg, validators_dir=validators, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
p.commit(msg, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
store_unlink_file(p.absdir, '_commit_msg')
else:
for p in pacs:
@ -3785,7 +3774,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
p.todo.sort()
if not msg:
msg = get_commit_msg(p.absdir, [p])
p.commit(msg, validators_dir=validators, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
p.commit(msg, skip_local_service_run=opts.skip_local_service_run, verbose=opts.verbose)
store_unlink_file(p.absdir, '_commit_msg')
@cmdln.option('-r', '--revision', metavar='REV',

View File

@ -136,8 +136,6 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org',
'request_list_days': 0,
# check for unversioned/removed files before commit
'check_filelist': '1',
# External scripts to validate sources, esp before commit. This is a directory
'source_validator_directory': '/usr/lib/osc/source_validators',
# check for pending requests after executing an action (e.g. checkout, update, commit)
'check_for_request_on_action': '0',
# what to do with the source package if the submitrequest has been accepted
@ -300,9 +298,6 @@ apiurl = %(apiurl)s
#review requests interactively (default: off)
#request_show_review = 1
# Directory with executables to validate sources, esp before committing
#source_validator_directory = /usr/lib/osc/source_validators
[%(apiurl)s]
user = %(user)s
pass = %(pass)s

View File

@ -737,26 +737,7 @@ class Project:
finally:
self.write_packages()
# TO BE OBSOLETED WITH SOURCE SERVICE VALIDATORS
def validate_pacs(self, validators, verbose_validation=False, *pacs):
if len(pacs) == 0:
for pac in self.pacs_broken:
if self.get_state(pac) != 'D':
msg = 'validation failed: package \'%s\' is missing' % pac
raise oscerr.PackageMissing(self.name, pac, msg)
pacs = self.pacs_have
for pac in pacs:
if pac in self.pacs_broken and self.get_state(pac) != 'D':
msg = 'validation failed: package \'%s\' is missing' % pac
raise oscerr.PackageMissing(self.name, pac, msg)
if os_path_samefile(os.path.join(self.dir, pac), os.getcwd()):
p = Package('.')
else:
p = Package(os.path.join(self.dir, pac))
p.validate(validators, verbose_validation)
def commit(self, pacs = (), msg = '', files = {}, validators_dir = None, verbose = False, skip_local_service_run = False):
def commit(self, pacs = (), msg = '', files = {}, verbose = False, skip_local_service_run = False):
if len(pacs):
try:
for pac in pacs:
@ -765,7 +746,7 @@ class Project:
todo = files[pac]
state = self.get_state(pac)
if state == 'A':
self.commitNewPackage(pac, msg, todo, validators_dir=validators_dir, verbose=verbose, skip_local_service_run=skip_local_service_run)
self.commitNewPackage(pac, msg, todo, verbose=verbose, skip_local_service_run=skip_local_service_run)
elif state == 'D':
self.commitDelPackage(pac)
elif state == ' ':
@ -775,13 +756,13 @@ class Project:
else:
p = Package(os.path.join(self.dir, pac))
p.todo = todo
p.commit(msg, validators_dir=validators_dir, verbose=verbose, skip_local_service_run=skip_local_service_run)
p.commit(msg, verbose=verbose, skip_local_service_run=skip_local_service_run)
elif pac in self.pacs_unvers and not is_package_dir(os.path.join(self.dir, pac)):
print 'osc: \'%s\' is not under version control' % pac
elif pac in self.pacs_broken:
print 'osc: \'%s\' package not found' % pac
elif state == None:
self.commitExtPackage(pac, msg, todo, validators_dir=validators_dir, verbose=verbose)
self.commitExtPackage(pac, msg, todo, verbose=verbose)
finally:
self.write_packages()
else:
@ -795,15 +776,15 @@ class Project:
state = self.get_state(pac)
if state == ' ':
# do a simple commit
Package(os.path.join(self.dir, pac)).commit(msg, validators_dir=validators_dir, verbose=verbose, skip_local_service_run=skip_local_service_run)
Package(os.path.join(self.dir, pac)).commit(msg, verbose=verbose, skip_local_service_run=skip_local_service_run)
elif state == 'D':
self.commitDelPackage(pac)
elif state == 'A':
self.commitNewPackage(pac, msg, validators_dir=validators_dir, verbose=verbose, skip_local_service_run=skip_local_service_run)
self.commitNewPackage(pac, msg, verbose=verbose, skip_local_service_run=skip_local_service_run)
finally:
self.write_packages()
def commitNewPackage(self, pac, msg = '', files = [], validators_dir = None, verbose = False, skip_local_service_run = False):
def commitNewPackage(self, pac, msg = '', files = [], verbose = False, skip_local_service_run = False):
"""creates and commits a new package if it does not exist on the server"""
if pac in self.pacs_available:
print 'package \'%s\' already exists' % pac
@ -824,7 +805,7 @@ class Project:
p = Package(os.path.join(self.dir, pac))
p.todo = files
print statfrmt('Sending', os.path.normpath(p.dir))
p.commit(msg=msg, validators_dir=validators_dir, verbose=verbose, skip_local_service_run=skip_local_service_run)
p.commit(msg=msg, verbose=verbose, skip_local_service_run=skip_local_service_run)
self.set_state(pac, ' ')
os.chdir(olddir)
@ -850,7 +831,7 @@ class Project:
delete_package(self.apiurl, self.name, pac)
self.del_package_node(pac)
def commitExtPackage(self, pac, msg, files = [], validators_dir=None, verbose=False):
def commitExtPackage(self, pac, msg, files = [], verbose=False):
"""commits a package from an external project"""
if os_path_samefile(os.path.join(self.dir, pac), os.getcwd()):
pac_path = '.'
@ -869,7 +850,7 @@ class Project:
template_args=({'name': pac, 'user': user}), apiurl=apiurl)
p = Package(pac_path)
p.todo = files
p.commit(msg=msg, validators_dir=validators_dir, verbose=verbose)
p.commit(msg=msg, verbose=verbose)
def __str__(self):
r = []
@ -1198,26 +1179,7 @@ class Package:
todo.append(n.get('name'))
return todo
def validate(self, validators_dir, verbose_validation=False):
import subprocess
import stat
if validators_dir is None or self.name.startswith('_'):
return
for validator in sorted(os.listdir(validators_dir)):
if validator.startswith('.'):
continue
fn = os.path.join(validators_dir, validator)
mode = os.stat(fn).st_mode
if stat.S_ISREG(mode):
if verbose_validation:
print 'osc runs source validator: %s' % fn
p = subprocess.Popen([fn, '--verbose'], close_fds=True)
else:
p = subprocess.Popen([fn], close_fds=True)
if p.wait() != 0:
raise oscerr.ExtRuntimeError('ERROR: source_validator failed:\n%s' % p.stdout, validator)
def commit(self, msg='', validators_dir=None, verbose=False, skip_local_service_run=False):
def commit(self, msg='', verbose=False, skip_local_service_run=False):
# commit only if the upstream revision is the same as the working copy's
upstream_rev = self.latest_rev()
if self.rev != upstream_rev:
@ -1228,9 +1190,6 @@ class Package:
if r is not 0:
raise oscerr.ServiceRuntimeError(r)
if not validators_dir is None:
self.validate(validators_dir, verbose)
if not self.todo:
self.todo = [i for i in self.to_be_added if not i in self.filenamelist] + self.filenamelist