From 9c3e0e1683a39752a86f34166aacec5a103bd662 Mon Sep 17 00:00:00 2001 From: Huang Hao Date: Tue, 16 Oct 2012 16:24:18 +0800 Subject: [PATCH] Implement build --spec. Fix #386 Pass the spec file to depanneur, it will only build that file. Change-Id: I9dd3aabe719d2f022e1650493bc44a27ca3b5b67 --- gitbuildsys/cmd_build.py | 9 +++++++++ tools/gbs | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gitbuildsys/cmd_build.py b/gitbuildsys/cmd_build.py index 47531e1..ae32307 100644 --- a/gitbuildsys/cmd_build.py +++ b/gitbuildsys/cmd_build.py @@ -231,6 +231,12 @@ def main(args): except GitRepositoryError: pass + if args.spec: + try: + RpmGitRepository(os.path.dirname(args.spec)) + except GitRepositoryError: + msger.error('spec file should reside in git directory') + hostarch = get_hostarch() if args.arch: buildarch = args.arch @@ -300,6 +306,9 @@ def main(args): if args.squash_patches_until: cmd += ['--squash-patches-until=%s' % args.squash_patches_until] + if args.spec: + cmd += [args.spec] + msger.debug("running command: %s" % ' '.join(cmd)) retcode = os.system(' '.join(cmd)) if retcode != 0: diff --git a/tools/gbs b/tools/gbs index a79670a..1f9edfa 100755 --- a/tools/gbs +++ b/tools/gbs @@ -21,12 +21,21 @@ import sys import os -from argparse import ArgumentParser +from argparse import ArgumentParser, ArgumentTypeError from gitbuildsys import __version__ from gitbuildsys import msger, errors from gitbuildsys.parsing import subparser, GbsHelpFormatter + +def abspath_arg(arg): + '''validate path argument and convert to absolute format''' + path = os.path.abspath(arg) + if not os.path.exists(path): + raise ArgumentTypeError('no such %s' % path) + return path + + @subparser def import_parser(parser): """import spec file/source rpm/tar ball to git repository @@ -127,7 +136,8 @@ def build_parser(parser): parser.add_argument('--skip-conf-repos', action="store_true", help='skip repositories mentioned in config file') parser.add_argument('-c', '--commit', help='specify a commit ID to build') - parser.add_argument('--spec', help='specify a spec file to use') + parser.add_argument('--spec', type=abspath_arg, + help='specify a spec file to use') parser.add_argument('--extra-packs', help='specify extra packages to install to build root ' 'multiple packages can be separated by comma') -- 2.34.1