Revert "Revert "Implement build --spec. Fix #386""
authorZhang Qiang <qiang.z.zhang@intel.com>
Tue, 23 Oct 2012 08:05:38 +0000 (16:05 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Tue, 23 Oct 2012 08:34:04 +0000 (16:34 +0800)
This reverts commit e72f7f2c49239e09d98b6cea96ce9a0d84be45eb.

After more discussion, we'd prefer to keep the current implementation
just like gbs 0.9. Fix all --commit / --include-all issue in next
gbs release.

Change-Id: I0717d663975cbbc6cac3f5993c4ebda4a742946f

gitbuildsys/cmd_build.py
tools/gbs

index 47531e1350a3889ceacc349bf8fa1d629830c4b4..ae32307084f1c3fece011a39cc82130c59e9dc5c 100644 (file)
@@ -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:
index a79670a998886a83a1b05a6213ab9ed3e4df93fa..1f9edfaaf32a20d9d788c1f4b1bf29147e73036c 100755 (executable)
--- a/tools/gbs
+++ b/tools/gbs
 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')