From d7d6e8c72cea5f1626e71415b2eab19d6d6eef56 Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Fri, 3 Aug 2012 14:35:34 +0800 Subject: [PATCH] Implemented --out commandline option. Fixes #200. --out specifies existing directory for the RPMs. gbs copies result RPMs to it when build is finished successfully. As build is run with root privileges we can't move RPMs because of possible access restrictions, so we're copying them. --- gitbuildsys/cmd_build.py | 19 +++++++++++++++++-- tools/gbs | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gitbuildsys/cmd_build.py b/gitbuildsys/cmd_build.py index 7a85728..66488de 100644 --- a/gitbuildsys/cmd_build.py +++ b/gitbuildsys/cmd_build.py @@ -24,6 +24,8 @@ import re import subprocess import tempfile import urllib2 +import glob +import shutil from urlparse import urlsplit, urlunsplit import msger @@ -245,6 +247,12 @@ def do(opts, args): raise errors.Usage('--commit can\'t be specified together with '\ '--include-all') + if opts.out: + if not os.path.exists(opts.out): + msger.error('Output directory %s doesn\'t exist' % opts.out) + if not os.path.isdir(opts.out): + msger.error('%s is not a directory' % opts.out) + try: repo = RpmGitRepository(workdir) except GitRepositoryError, err: @@ -404,9 +412,16 @@ def do(opts, args): if subprocess.call(cmd): msger.error('rpmbuild fails') else: + out_dir = os.path.join(build_root, 'home/abuild/rpmbuild/RPMS/') + if opts.out: + for fpath in glob.glob(out_dir + '/*/*.rpm'): + shutil.copy(fpath, opts.out) + msger.info('RPMs have been copied from %s to %s' \ + % (out_dir, opts.out)) + out_dir = os.path.abspath(opts.out) msger.info('The buildroot was: %s' % build_root) - msger.info('Binaries RPM packages can be found here:\n %s/%s' % \ - (build_root, 'home/abuild/rpmbuild/RPMS/')) + msger.info('Binaries RPM packages can be found here:'\ + '\n %s' % out_dir) msger.info('Done') except KeyboardInterrupt: msger.info('keyboard interrupt, killing build ...') diff --git a/tools/gbs b/tools/gbs index 3b1c9f5..8199f53 100755 --- a/tools/gbs +++ b/tools/gbs @@ -222,6 +222,10 @@ class Gbs(cmdln.Cmdln): dest='include_all', help='Uncommitted changes and untracked files would be '\ 'included while generating tar ball') + @cmdln.option('--out', + default=None, + dest='out', + help='Output directory for RPMs') @cmdln.option('--debuginfo', action='store_true', default=False, -- 2.7.4