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
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:
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
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')