From: Zhang Qiang Date: Fri, 27 Jul 2012 21:11:09 +0000 (+0800) Subject: add new option --source-rpm to export source rpm, #89 X-Git-Tag: 0.9~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13e988e528e4a787566cd60c4ee412ade975f5bf;p=tools%2Fgbs.git add new option --source-rpm to export source rpm, #89 --- diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index 8a33f4d..b12efd3 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -24,6 +24,7 @@ import shutil import errno import msger +import runner import utils import errors @@ -140,4 +141,20 @@ def do(opts, args): shutil.rmtree(outdir, ignore_errors=True) shutil.move(export_dir, outdir) + if opts.source_rpm: + cmd = ['rpmbuild', + '--short-circuit', '-bs', + '--define "_topdir %s"' % outdir, + '--define "_builddir %_topdir"', + '--define "_buildrootdir %_topdir"', + '--define "_rpmdir %_topdir"', + '--define "_sourcedir %_topdir"', + '--define "_specdir %_topdir"', + '--define "_srcrpmdir %_topdir"', + specfile + ] + runner.quiet(' '.join(cmd)) + msger.info('source rpm generated to:\n %s/%s.src.rpm' % \ + (outdir, os.path.basename(outdir))) + msger.info('package files have been exported to:\n %s' % outdir) diff --git a/tools/gbs b/tools/gbs index f272ee5..3b1c9f5 100755 --- a/tools/gbs +++ b/tools/gbs @@ -134,6 +134,11 @@ class Gbs(cmdln.Cmdln): dest='include_all', help='Uncommitted changes and untracked files would be '\ 'included while generating tar ball') + @cmdln.option('--source-rpm', + action='store_true', + default=False, + dest='source_rpm', + help='generate source rpm') def do_export(self, _subcmd, opts, *args): """${cmd_name}: export files and prepare for build