diff --git a/NEWS b/NEWS index a17be863..bcc94576 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +jw: +- add --debuginfo to osc build. + since 0.99: - build: diff --git a/osc/build.py b/osc/build.py index a2780d9c..1d1bdd90 100644 --- a/osc/build.py +++ b/osc/build.py @@ -8,6 +8,7 @@ import os +import re import sys from tempfile import NamedTemporaryFile from osc.fetch import * @@ -243,6 +244,22 @@ def main(opts, argv): print >>sys.stderr, 'Error: specfile \'%s\' does not exist.' % spec return 1 + if opts.debuginfo: + # make sure %debug_package is in the spec-file. + spec_text = open(spec).read() + if not re.search(r'(?m)^%debug_package', spec_text): + spec_text = re.sub(r'(?m)^(%prep)', + r'# added by osc build -d\n%debug_package\n\n\1', + spec_text, 1) + tmp_spec = NamedTemporaryFile(prefix = spec + '_', dir = '.', suffix = '.spec') + tmp_spec.write(spec_text) + tmp_spec.flush() + spec = tmp_spec.name + os.chmod(spec, 0644) + + + # make it possible to override configuration of the rc file + for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'BUILD_ROOT', 'OSC_BUILD_ROOT']: # make it possible to override configuration of the rc file for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'BUILD_ROOT', 'OSC_BUILD_ROOT']: diff --git a/osc/commandline.py b/osc/commandline.py index 9e9f70f7..40648088 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1482,6 +1482,8 @@ class Osc(cmdln.Cmdln): help='build a package which does not exist on the server') @cmdln.option('', '--alternative-project', metavar='PROJECT', help='specify the build target project') + @cmdln.option('-d', '--debuginfo', action='store_true', + help='also build debuginfo sub-packages') def do_build(self, subcmd, opts, *args): """${cmd_name}: Build a package on your local machine