From a7c92eb18f64ee4832529e7211ee16442332744b Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Wed, 1 Oct 2014 14:45:48 +0200 Subject: [PATCH] - do not hardcode path to the build scripts and removed legacy check --- osc/commandline.py | 19 ++++++++----------- osc/conf.py | 2 ++ osc/core.py | 13 +++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index bd79958e..607b4942 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -5595,10 +5595,9 @@ Please submit there instead, or use --nodevelproject to force direct submission. import osc.build - if not os.path.exists('/usr/lib/build/debtransform') \ - and not os.path.exists('/usr/lib/lbuild/debtransform'): - sys.stderr.write('Error: you need build.rpm with version 2007.3.12 or newer.\n') - sys.stderr.write('See http://download.opensuse.org/repositories/openSUSE:/Tools/\n') + if which(conf.config['build-cmd']) is None: + print('Error: build (\'%s\') command not found' % conf.config['build-cmd'], file=sys.stderr) + print('Install the build package from http://download.opensuse.org/repositories/openSUSE:/Tools/', file=sys.stderr) return 1 if opts.debuginfo and opts.disable_debuginfo: @@ -7894,18 +7893,16 @@ Please submit there instead, or use --nodevelproject to force direct submission. except IndexError: pass + cmd_list = [conf.config['vc-cmd']] if meego_style: if not os.path.exists('/usr/bin/vc'): print('Error: you need meego-packaging-tools for /usr/bin/vc command', file=sys.stderr) return 1 cmd_list = ['/usr/bin/vc'] - else: - if not os.path.exists('/usr/lib/build/vc'): - print('Error: you need build.rpm with version 2009.04.17 or newer', file=sys.stderr) - print('See http://download.opensuse.org/repositories/openSUSE:/Tools/', file=sys.stderr) - return 1 - - cmd_list = ['/usr/lib/build/vc'] + elif which(cmd_list[0]) is None: + print('Error: vc (\'%s\') command not found' % cmd_list[0], file=sys.stderr) + print('Install the build package from http://download.opensuse.org/repositories/openSUSE:/Tools/', file=sys.stderr) + return 1 # set user's email if no mailaddr exists if 'mailaddr' not in os.environ: diff --git a/osc/conf.py b/osc/conf.py index dfc25dc7..c4376781 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -172,6 +172,8 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org', 'maintenance_attribute': 'OBS:MaintenanceProject', 'maintained_update_project_attribute': 'OBS:UpdateProject', 'show_download_progress': '0', + # path to the vc script + 'vc-cmd': '/usr/lib/build/vc' } # being global to this module, this dict can be accessed from outside diff --git a/osc/core.py b/osc/core.py index 3b5c27e4..b80e1244 100644 --- a/osc/core.py +++ b/osc/core.py @@ -7032,4 +7032,17 @@ def utime(filename, arg, ignore_einval=True): return raise +def which(name): + """Searches "name" in PATH.""" + name = os.path.expanduser(name) + if os.path.isabs(name): + if os.path.exists(name): + return name + return None + for directory in os.environ.get('PATH', '').split(':'): + path = os.path.join(directory, name) + if os.path.exists(path): + return path + return None + # vim: sw=4 et